diff --git a/tools/mace_tools.py b/tools/mace_tools.py index f06ec24a014742d5acfe15c0a7dfafb73b9bc067..879cd72c7d0bcb22b8b4019ea44c9d59bae54aa7 100644 --- a/tools/mace_tools.py +++ b/tools/mace_tools.py @@ -121,21 +121,24 @@ def model_benchmark_stdout_processor(stdout, metrics[4] = str(float(parts[5])) break - props = sh_commands.adb_getprop_by_serialno(serialno) - device_type = props.get("ro.product.model", "") - target_soc = props.get("ro.board.platform", "") + device_name = "" + target_soc = "" + if abi != "host": + props = sh_commands.adb_getprop_by_serialno(serialno) + device_name = props.get("ro.product.model", "") + target_soc = props.get("ro.board.platform", "") report_filename = FLAGS.output_dir + "/report.csv" if not os.path.exists(report_filename): with open(report_filename, 'w') as f: - f.write("model_name,device_type,soc,abi,runtime,create_net," + f.write("model_name,device_name,soc,abi,runtime,create_net," "engine_ctor,init,warmup,run_avg\n") - data_str = "{model_name},{device_type},{soc},{abi},{runtime}," \ + data_str = "{model_name},{device_name},{soc},{abi},{runtime}," \ "{create_net},{engine_ctor},{init},{warmup},{run_avg}\n" \ .format( model_name=model_name, - device_type=device_type, + device_name=device_name, soc=target_soc, abi=abi, runtime=runtime, diff --git a/tools/sh_commands.py b/tools/sh_commands.py index 61f49b52b255a656a1e01b998179afd5da3e61de..0a2a4f0b3af30142a81fd82b79ec61ba00bd7307 100644 --- a/tools/sh_commands.py +++ b/tools/sh_commands.py @@ -530,8 +530,6 @@ def tuning_run(abi, output_file_name="model_out"): print("* Run '%s' with round=%s, restart_round=%s, tuning=%s" % (model_tag, running_round, restart_round, str(tuning))) - stdout_buff = [] - process_output = make_output_processor(stdout_buff) if abi == "host": p = subprocess.Popen([ "env", @@ -547,8 +545,14 @@ def tuning_run(abi, "--device=%s" % device_type, "--round=%s" % running_round, "--restart_round=%s" % restart_round, - "%s" % option_args]) - p.wait() + "%s" % option_args], + stderr=subprocess.PIPE, + stdout=subprocess.PIPE) + out, err = p.communicate() + stdout = err + out + print stdout + print("Running finished!\n") + return stdout else: sh.adb("-s", serialno, "shell", "mkdir", "-p", phone_data_dir) compiled_opencl_dir = "/data/local/tmp/mace_run/cl_program/" @@ -567,6 +571,8 @@ def tuning_run(abi, adb_push("mace/core/runtime/hexagon/libhexagon_controller.so", phone_data_dir, serialno) + stdout_buff = [] + process_output = make_output_processor(stdout_buff) p = sh.adb( "-s", serialno, @@ -596,9 +602,8 @@ def tuning_run(abi, _bg=True, _err_to_out=True) p.wait() - - print("Running finished!\n") - return "".join(stdout_buff) + print("Running finished!\n") + return "".join(stdout_buff) def validate_model(abi,