Esempio n. 1
0
    def test_tflite_engine(self):
        from core.global_config import create_config

        framework_name = "tflite"
        config_dict = create_config(framework_name)
        config_dict["work_dir"] = os.getcwd() + "/../tflite"

        tflite = Engine(config_dict)
        tflite.set_config("benchmark_platform", ["android-armv7"])  # noqa
        tflite.set_config(
            "support_backend",
            ["ARM", "ARM_XNNPACK", "GPU_CL_GL", "DSP_HEXAGON"],  # noqa
        )  # ARM,ARM_XNNPACK, GPU_CL_GL, DSP_HEXAGON
        tflite.set_config("cpu_thread_num", [1, 2, 4])  # [1, 2, 4]
        model_dict = tflite.prepare_models()
        device_dict = tflite.prepare_devices()
        if len(device_dict) == 0:
            logger.error("no device found")
            return 0
        config_dict = tflite.set_config("model_dict", model_dict)
        config_dict = tflite.set_config("device_dict", device_dict)

        tflite.prepare_models_for_devices()
        tflite.prepare_benchmark_assets_for_devices()

        bench_dict = tflite.run_bench()
        summary_list = tflite.generate_benchmark_summary(bench_dict)
        summary_str = "\n".join(summary_list)
        logger.info("summary_str:\n{}".format(summary_str))
        tflite.write_list_to_file(summary_list)
        return 0
Esempio n. 2
0
    def test_mnn_engine(self):
        from core.global_config import create_config

        framework_name = "mnn"
        config_dict = create_config(framework_name)
        config_dict["work_dir"] = os.getcwd() + "/../mnn"

        mnn = Engine(config_dict)
        mnn.set_config("benchmark_platform",
                       ["android-armv8", "android-armv7"])  # noqa

        mnn.set_config(
            "support_backend",
            ["3", "6", "7"])  # 0->CPU,1->Metal,3->OpenCL,6->OpenGL,7->Vulkan
        mnn.set_config("cpu_thread_num", [1, 2, 4])  # [1, 2, 4]
        mnn.config["warmup"] = 2
        model_dict = mnn.prepare_models()
        device_dict = mnn.prepare_devices()
        if len(device_dict) == 0:
            logger.error("no device found")
            return 0
        config_dict = mnn.set_config("model_dict", model_dict)
        config_dict = mnn.set_config("device_dict", device_dict)

        mnn.prepare_models_for_devices()
        mnn.prepare_benchmark_assets_for_devices()

        bench_dict = mnn.run_bench()
        summary_list = mnn.generate_benchmark_summary(bench_dict)
        summary_str = "\n".join(summary_list)
        logger.info("summary_str:\n{}".format(summary_str))
        mnn.write_list_to_file(summary_list)
        return 0
Esempio n. 3
0
def main():
    config_dict = create_config("tnn")
    tnn = Engine(config_dict)
    model_dict = tnn.prepare_models()
    device_dict = tnn.prepare_devices()
    tnn.set_config("model_dict", model_dict)
    tnn.set_config("device_dict", device_dict)

    tnn.prepare_models_for_devices()
    tnn.prepare_benchmark_assets_for_devices()
    bench_dict = tnn.run_bench()
    bench_str_list = tnn.generate_benchmark_summary(bench_dict)
    tnn.write_list_to_file(bench_str_list)
Esempio n. 4
0
def bench(name):
    if name is None:
        return
    config_dict = create_config(name)
    engine = Engine(config_dict)

    model_dict = engine.prepare_models()
    device_dict = engine.prepare_devices()
    engine.set_config("model_dict", model_dict)
    engine.set_config("device_dict", device_dict)

    engine.prepare_models_for_devices()
    engine.prepare_benchmark_assets_for_devices()

    bench_dict = engine.run_bench()

    bench_str_list = engine.generate_benchmark_summary(bench_dict)
    engine.write_list_to_file(bench_str_list)
Esempio n. 5
0
    def test_ncnn_engine(self):
        from core.global_config import create_config

        framework_name = "ncnn"
        config_dict = create_config(framework_name)
        config_dict["work_dir"] = os.getcwd() + "/../ncnn"

        ncnn = Engine(config_dict)
        ncnn.set_config(
            "benchmark_platform", ["android-armv8", "android-armv7"]  # noqa
        )
        ncnn.set_config("support_backend", ["0"])  # -1: cpu, 0: gpu # noqa
        ncnn.set_config("cpu_thread_num", [1, 2, 4])
        ncnn.config["repeats"] = (
            lambda backend: 100 if backend == "VULKAN" else 1000
        )  # noqa
        ncnn.config["warmup"] = 2
        model_dict = ncnn.prepare_models()

        device_dict = ncnn.prepare_devices()
        if len(device_dict) == 0:
            logger.error("no device found")
            return 0
        config_dict = ncnn.set_config("model_dict", model_dict)
        config_dict = ncnn.set_config("device_dict", device_dict)

        ncnn.prepare_models_for_devices()
        ncnn.prepare_benchmark_assets_for_devices()

        bench_dict = ncnn.run_bench()
        summary_list = ncnn.generate_benchmark_summary(bench_dict)
        ncnn.write_list_to_file(summary_list)

        summary_str = "\n".join(summary_list)
        logger.info("summary_str:\n{}".format(summary_str))
        return 0