diff --git a/tools/mace_tools.py b/tools/mace_tools.py index 7f2ef056f2be757bc35d38549a0081cf7de16a39..ca418472377dd8753e19f81bdcbca039fabea737 100644 --- a/tools/mace_tools.py +++ b/tools/mace_tools.py @@ -162,7 +162,8 @@ def tuning_run(model_name, running_round, tuning, restart_round, - option_args=''): + option_args='', + out_of_range_check=False): # TODO(yejianwu) refactoring the hackish code stdout_buff = [] process_output = sh_commands.make_output_processor(stdout_buff) @@ -174,6 +175,7 @@ def tuning_run(model_name, int(tuning), restart_round, option_args, + int(out_of_range_check), _out=process_output, _bg=True, _err_to_out=True) @@ -209,10 +211,11 @@ def benchmark_model(target_soc, model_output_dir, option_args=''): def run_model(model_name, target_runtime, target_abi, target_soc, - model_output_dir, running_round, restart_round, option_args): + model_output_dir, running_round, restart_round, option_args, + out_of_range_check): tuning_run(model_name, target_runtime, target_abi, target_soc, model_output_dir, running_round, False, restart_round, - option_args) + option_args, out_of_range_check) def generate_production_code(target_soc, model_output_dirs, pull_or_not): @@ -235,6 +238,18 @@ def build_mace_run_prod(model_name, target_runtime, target_abi, target_soc, generate_code(target_soc, [], False) production_or_not = False build_mace_run(production_or_not, model_output_dir, hexagon_mode) + + tuning_run( + model_name, + target_runtime, + target_abi, + target_soc, + model_output_dir, + running_round=0, + tuning=False, + restart_round=1, + out_of_range_check=True) + tuning_run( model_name, target_runtime, @@ -345,6 +360,11 @@ def parse_args(): type=str, default="all", help="SoCs to build, comma seperated list (getprop ro.board.platform)") + parser.add_argument( + "--out_of_range_check", + type="bool", + default="false", + help="Enable out of range check for opencl.") return parser.parse_known_args() @@ -454,7 +474,8 @@ def main(unused_args): FLAGS.mode == "all": run_model(model_name, global_runtime, target_abi, target_soc, model_output_dir, FLAGS.round, - FLAGS.restart_round, option_args) + FLAGS.restart_round, option_args, + FLAGS.out_of_range_check) if FLAGS.mode == "benchmark": benchmark_model(target_soc, model_output_dir, option_args) diff --git a/tools/tuning_run.sh b/tools/tuning_run.sh index 98fc9e092b88b55ec573bc688c95e14ec3242149..9499d792ba217d1415d7bcaff238825949b3fc73 100644 --- a/tools/tuning_run.sh +++ b/tools/tuning_run.sh @@ -1,10 +1,10 @@ #!/bin/bash Usage() { - echo "Usage: bash tools/tuning_run.sh target_soc model_output_dir round tuning " + echo "Usage: bash tools/tuning_run.sh target_soc model_output_dir round tuning restart_round opt_args out_of_range_check" } -if [ $# -lt 6 ]; then +if [ $# -lt 7 ]; then Usage exit 1 fi @@ -18,6 +18,7 @@ ROUND=$3 TUNING_OR_NOT=$4 RESTART_ROUND=$5 OPTION_ARGS=$6 +OUT_OF_RANGE_CHECK_OR_NOT=$7 echo $OPTION_ARGS @@ -49,6 +50,12 @@ else else tuning_flag=0 fi + + if [[ "${OUT_OF_RANGE_CHECK_OR_NOT}" != "0" ]]; then + out_of_range_check_flag=1 + else + out_of_range_check_flag=0 + fi adb -s $DEVICE_ID shell "mkdir -p ${PHONE_DATA_DIR}" || exit 1 adb -s $DEVICE_ID shell "mkdir -p ${COMPILED_PROGRAM_DIR}" || exit 1 @@ -67,6 +74,7 @@ else ADB_CMD_STR="LD_LIBRARY_PATH=${PHONE_DATA_DIR} \ MACE_TUNING=${tuning_flag} \ + MACE_OUT_OF_RANGE_CHECK=${out_of_range_check_flag} \ MACE_CPP_MIN_VLOG_LEVEL=$VLOG_LEVEL \ MACE_RUN_PARAMETER_PATH=${PHONE_DATA_DIR}/mace_run.config \ MACE_CL_PROGRAM_PATH=$COMPILED_PROGRAM_DIR \