From 734b5ca5a90cbc5b71ccacbccde909ced1e1d054 Mon Sep 17 00:00:00 2001 From: yejianwu Date: Sat, 28 Apr 2018 15:54:49 +0800 Subject: [PATCH] update benchmark and build mace_run flow --- tools/mace_tools.py | 17 ++++++++++++----- tools/sh_commands.py | 14 +++++++++----- 2 files changed, 21 insertions(+), 10 deletions(-) diff --git a/tools/mace_tools.py b/tools/mace_tools.py index b063c023..851b6be1 100644 --- a/tools/mace_tools.py +++ b/tools/mace_tools.py @@ -217,15 +217,15 @@ def build_mace_run_prod(hexagon_mode, runtime, target_abi, tuning_run(runtime, target_abi, serialno, vlog_level, embed_model_data, model_output_dir, input_nodes, output_nodes, input_shapes, output_shapes, model_name, device_type, running_round=0, - restart_round=1, out_of_range_check=True, - phone_data_dir=phone_data_dir, tuning=False) + restart_round=1, out_of_range_check=False, + phone_data_dir=phone_data_dir, tuning=tuning, + limit_opencl_kernel_time=limit_opencl_kernel_time) tuning_run(runtime, target_abi, serialno, vlog_level, embed_model_data, model_output_dir, input_nodes, output_nodes, input_shapes, output_shapes, model_name, device_type, running_round=0, - restart_round=1, out_of_range_check=False, - phone_data_dir=phone_data_dir, tuning=tuning, - limit_opencl_kernel_time=limit_opencl_kernel_time) + restart_round=1, out_of_range_check=True, + phone_data_dir=phone_data_dir, tuning=False) gen_opencl_and_tuning_code(target_abi, serialno, [model_output_dir], True) @@ -394,6 +394,9 @@ def process_models(project_name, configs, embed_model_data, vlog_level, if os.path.exists(model_output_dir): sh.rm("-rf", model_output_dir) os.makedirs(model_output_dir) + + if FLAGS.mode == "build" or FLAGS.mode == "benchmark" or \ + FLAGS.mode == "all": sh_commands.clear_mace_run_data( target_abi, serialno, phone_data_dir) @@ -428,6 +431,8 @@ def process_models(project_name, configs, embed_model_data, vlog_level, embed_model_data, model_config["fast_conv"], model_config["obfuscate"]) + + if FLAGS.mode == "build" or FLAGS.mode == "all": build_mace_run_prod(hexagon_mode, model_config["runtime"], target_abi, @@ -467,6 +472,8 @@ def process_models(project_name, configs, embed_model_data, vlog_level, phone_data_dir) if FLAGS.mode == "benchmark": + gen_opencl_and_tuning_code( + target_abi, serialno, [model_output_dir], False) sh_commands.benchmark_model(target_abi, serialno, vlog_level, diff --git a/tools/sh_commands.py b/tools/sh_commands.py index 0a2a4f0b..92fc6e4e 100644 --- a/tools/sh_commands.py +++ b/tools/sh_commands.py @@ -528,8 +528,10 @@ def tuning_run(abi, option_args="", input_file_name="model_input", output_file_name="model_out"): - print("* Run '%s' with round=%s, restart_round=%s, tuning=%s" % - (model_tag, running_round, restart_round, str(tuning))) + print("* Run '%s' with round=%s, restart_round=%s, tuning=%s, " + "out_of_range_check=%s" % + (model_tag, running_round, restart_round, str(tuning), + str(out_of_range_check))) if abi == "host": p = subprocess.Popen([ "env", @@ -750,10 +752,9 @@ def merge_libs(target_soc, sh.cp("-f", hexagon_lib_file, model_bin_dir) mri_stream = "" - mri_stream += "create %s/libmace_%s.%s.a\n" % \ - (model_bin_dir, project_name, target_soc) - if abi == "host": + mri_stream += "create %s/libmace_%s.a\n" % \ + (model_bin_dir, project_name) mri_stream += ( "addlib " "bazel-bin/mace/codegen/libgenerated_opencl.pic.a\n") @@ -761,6 +762,8 @@ def merge_libs(target_soc, "addlib " "bazel-bin/mace/codegen/libgenerated_tuning_params.pic.a\n") else: + mri_stream += "create %s/libmace_%s.%s.a\n" % \ + (model_bin_dir, project_name, target_soc) mri_stream += ( "addlib " "bazel-bin/mace/codegen/libgenerated_opencl.a\n") @@ -861,6 +864,7 @@ def benchmark_model(abi, bazel_build(benchmark_target, abi=abi, model_tag=model_tag, + production_mode=True, hexagon_mode=hexagon_mode) target_bin = "/".join(bazel_target_to_bin(benchmark_target)) -- GitLab