提交 d0c87868 编写于 作者: L Liangliang He

Merge branch 'valgrind' into 'master'

Enable valgrind memory leak check in mace_run

See merge request !452
......@@ -91,7 +91,7 @@ def parse_args():
parser.add_argument(
"--valgrind_path",
type=str,
default="/data/local/valgrind",
default="/data/local/tmp/valgrind",
help="Valgrind install path.")
parser.add_argument(
"--valgrind_args",
......
......@@ -197,7 +197,10 @@ def tuning_run(runtime,
omp_num_threads,
cpu_affinity_policy,
gpu_perf_hint,
gpu_priority_hint
gpu_priority_hint,
valgrind=FLAGS.valgrind,
valgrind_path=FLAGS.valgrind_path,
valgrind_args=FLAGS.valgrind_args
)
if running_round > 0 and FLAGS.collect_report:
......@@ -213,6 +216,12 @@ def build_mace_run_prod(hexagon_mode, runtime, target_abi,
limit_opencl_kernel_time, phone_data_dir,
enable_openmp):
mace_run_target = "//mace/tools/validation:mace_run"
strip = "always"
debug = False
if FLAGS.valgrind:
strip = "never"
debug = True
if runtime == "gpu":
gen_opencl_and_tuning_code(target_abi, serialno, [], False)
sh_commands.bazel_build(
......@@ -243,10 +252,12 @@ def build_mace_run_prod(hexagon_mode, runtime, target_abi,
True)
sh_commands.bazel_build(
mace_run_target,
strip,
abi=target_abi,
model_tag=model_name,
production_mode=True,
hexagon_mode=hexagon_mode,
debug=debug,
enable_openmp=enable_openmp
)
sh_commands.update_mace_run_lib(model_output_dir, target_abi,
......@@ -255,10 +266,12 @@ def build_mace_run_prod(hexagon_mode, runtime, target_abi,
gen_opencl_and_tuning_code(target_abi, serialno, [], False)
sh_commands.bazel_build(
mace_run_target,
strip,
abi=target_abi,
model_tag=model_name,
production_mode=True,
hexagon_mode=hexagon_mode,
debug=debug,
enable_openmp=enable_openmp
)
sh_commands.update_mace_run_lib(model_output_dir, target_abi,
......@@ -490,6 +503,21 @@ def parse_args():
type=str_to_caffe_env_type,
default='docker',
help="[docker | local] caffe environment.")
parser.add_argument(
"--valgrind",
type=bool,
default=False,
help="Whether to use valgrind to check memory error.")
parser.add_argument(
"--valgrind_path",
type=str,
default="/data/local/tmp/valgrind",
help="Valgrind install path.")
parser.add_argument(
"--valgrind_args",
type=str,
default="",
help="Valgrind command args.")
return parser.parse_known_args()
......
......@@ -216,7 +216,7 @@ def adb_run(serialno,
def adb_run_valgrind(serialno,
host_bin_path,
bin_name,
valgrind_path="/data/local/valgrind",
valgrind_path="/data/local/tmp/valgrind",
valgrind_args="",
args="",
opencl_profiling=1,
......@@ -581,6 +581,9 @@ def tuning_run(abi,
cpu_affinity_policy=1,
gpu_perf_hint=3,
gpu_priority_hint=3,
valgrind=False,
valgrind_path="/data/local/tmp/valgrind",
valgrind_args="",
input_file_name="model_input",
output_file_name="model_out"):
print("* Run '%s' with round=%s, restart_round=%s, tuning=%s, "
......@@ -637,19 +640,22 @@ def tuning_run(abi,
stdout_buff = []
process_output = make_output_processor(stdout_buff)
p = sh.adb(
"-s",
serialno,
"shell",
adb_cmd = [
"LD_LIBRARY_PATH=%s" % phone_data_dir,
"MACE_TUNING=%s" % int(tuning),
"MACE_OUT_OF_RANGE_CHECK=%s" % int(out_of_range_check),
"MACE_CPP_MIN_VLOG_LEVEL=%s" % vlog_level,
"MACE_RUN_PARAMETER_PATH=%s/mace_run.config" %
phone_data_dir,
"MACE_RUN_PARAMETER_PATH=%s/mace_run.config" % phone_data_dir,
"MACE_CL_PROGRAM_PATH=%s/cl_program" % phone_data_dir,
"MACE_LIMIT_OPENCL_KERNEL_TIME=%s" %
limit_opencl_kernel_time,
"MACE_LIMIT_OPENCL_KERNEL_TIME=%s" % limit_opencl_kernel_time,
]
if valgrind:
adb_cmd.extend([
"VALGRIND_LIB=%s" % valgrind_path + "/lib/valgrind",
valgrind_path + "/bin/valgrind",
valgrind_args
])
adb_cmd.extend([
"%s/mace_run" % phone_data_dir,
"--input_node=%s" % ",".join(input_nodes),
"--output_node=%s" % ",".join(output_nodes),
......@@ -665,6 +671,13 @@ def tuning_run(abi,
"--cpu_affinity_policy=%s" % cpu_affinity_policy,
"--gpu_perf_hint=%s" % gpu_perf_hint,
"--gpu_priority_hint=%s" % gpu_priority_hint,
])
adb_cmd = ' '.join(adb_cmd)
p = sh.adb(
"-s",
serialno,
"shell",
adb_cmd,
_out=process_output,
_bg=True,
_err_to_out=True)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册