diff --git a/mace_tools.py b/mace_tools.py index 0d420cd0ea3aa2041a1f133c471b1ba3c582f87e..452d8fbdf28c71184f515fa2a633de05207b3602 100644 --- a/mace_tools.py +++ b/mace_tools.py @@ -80,9 +80,9 @@ def build_mace_run(production_mode, model_output_dir, hexagon_mode): run_command(command) -def tuning_run(model_output_dir, running_round, tuning, production_mode): - command = "bash tools/tuning_run.sh {} {} {} {}".format( - model_output_dir, running_round, int(tuning), int(production_mode)) +def tuning_run(model_output_dir, running_round, tuning, production_mode, restart_round): + command = "bash tools/tuning_run.sh {} {} {} {} {}".format( + model_output_dir, running_round, int(tuning), int(production_mode), restart_round) run_command(command) @@ -91,8 +91,8 @@ def benchmark_model(model_output_dir): run_command(command) -def run_model(model_output_dir, running_round): - tuning_run(model_output_dir, running_round, False, False) +def run_model(model_output_dir, running_round, restart_round): + tuning_run(model_output_dir, running_round, False, False, restart_round) def generate_production_code(model_output_dirs, pull_or_not): @@ -117,7 +117,8 @@ def build_mace_run_prod(model_output_dir, tuning, libmace_name): model_output_dir, running_round=0, tuning=tuning, - production_mode=production_or_not) + production_mode=production_or_not, + restart_round=1) production_or_not = True pull_or_not = True @@ -175,6 +176,8 @@ def parse_args(): "--round", type=int, default=1, help="The model running round.") parser.add_argument("--run_seconds", type=int, default=10, help="The model throughput test running seconds.") + parser.add_argument( + "--restart_round", type=int, default=1, help="The model restart round.") parser.add_argument( "--tuning", type="bool", default="true", help="Tune opencl params.") parser.add_argument("--mode", type=str, default="all", @@ -194,6 +197,7 @@ def main(unused_args): if FLAGS.mode == "validate": FLAGS.round = 1 + FLAGS.restart_round = 1 # target_abi = configs["target_abi"] # libmace_name = get_libs(target_abi, configs) @@ -252,7 +256,7 @@ def main(unused_args): build_mace_run_prod(model_output_dir, FLAGS.tuning, libmace_name) if FLAGS.mode == "run" or FLAGS.mode == "validate" or FLAGS.mode == "all": - run_model(model_output_dir, FLAGS.round) + run_model(model_output_dir, FLAGS.round, FLAGS.restart_round) if FLAGS.mode == "benchmark": benchmark_model(model_output_dir) diff --git a/tuning_run.sh b/tuning_run.sh index 1e0e5d94564df4057d9bc407e17b2a61081650cc..ae2bf1141486370626a06de31c179caf4151e1c7 100644 --- a/tuning_run.sh +++ b/tuning_run.sh @@ -16,6 +16,7 @@ MODEL_OUTPUT_DIR=$1 ROUND=$2 TUNING_OR_NOT=$3 PRODUCTION_MODE=$4 +RESTART_ROUND=$5 if [ x"$TARGET_ABI" = x"host" ]; then MACE_CPP_MIN_VLOG_LEVEL=$VLOG_LEVEL \ @@ -28,7 +29,8 @@ if [ x"$TARGET_ABI" = x"host" ]; then --output_file=${MODEL_OUTPUT_DIR}/${OUTPUT_FILE_NAME} \ --model_data_file=${MODEL_OUTPUT_DIR}/${MODEL_TAG}.data \ --device=${DEVICE_TYPE} \ - --round=1 || exit 1 + --round=1 \ + --restart_round=1 || exit 1 else if [[ "${TUNING_OR_NOT}" != "0" && "$PRODUCTION_MODE" != 1 ]];then tuning_flag=1 @@ -69,7 +71,8 @@ else --output_file=${PHONE_DATA_DIR}/${OUTPUT_FILE_NAME} \ --model_data_file=${PHONE_DATA_DIR}/${MODEL_TAG}.data \ --device=${DEVICE_TYPE} \ - --round=$ROUND; echo \\$?"` || exit 1 + --round=$ROUND \ + --restart_round=$RESTART_ROUND; echo \\$?"` || exit 1 echo "$mace_adb_output" | head -n -1 mace_adb_return_code=`echo "$mace_adb_output" | tail -1`