diff --git a/build_mace_run.sh b/build_mace_run.sh index a24057d27cb6fdf972de888834aa2bcefd1535c1..a62788da41f7de37c6eb5e559cbeeb6b9e9cdf2c 100644 --- a/build_mace_run.sh +++ b/build_mace_run.sh @@ -1,10 +1,10 @@ #!/bin/bash Usage() { - echo "Usage: bash tools/build_mace_run.sh production_mode model_output_dir" + echo "Usage: bash tools/build_mace_run.sh production_mode model_output_dir hexagon_mode" } -if [ $# -lt 2 ]; then +if [ $# -lt 3 ]; then Usage exit 1 fi @@ -14,6 +14,7 @@ source ${CURRENT_DIR}/env.sh PRODUCTION_MODE=$1 MODEL_OUTPUT_DIR=$2 +HEXAGON_MODE=$3 if [ "$PRODUCTION_MODE" = 1 ]; then PRODUCTION_MODE_BUILD_FLAGS="--define production=true" @@ -36,7 +37,7 @@ if [ x"$RUNTIME" = x"local" ]; then --define openmp=true \ $PRODUCTION_MODE_BUILD_FLAGS || exit 1 else - if [ x"$RUNTIME" = x"dsp" ]; then + if [ "$HEXAGON_MODE" = 1 ]; then HEXAGON_MODE_BUILD_FLAG="--define hexagon=true" fi diff --git a/mace_tools.py b/mace_tools.py index 9ca311a46132ce052905d8a3a1273a22e9aec1e8..05c4afcb4178c95747e727340a31c2761c97a521 100644 --- a/mace_tools.py +++ b/mace_tools.py @@ -54,6 +54,8 @@ def get_libs(configs): command = "bash tools/download_and_link_lib.sh " + libmace_name run_command(command) + return libmace_name + def clear_env(): command = "bash tools/clear_env.sh" @@ -72,9 +74,9 @@ def generate_model_code(): run_command(command) -def build_mace_run(production_mode, model_output_dir): - command = "bash tools/build_mace_run.sh {} {}".format( - int(production_mode), model_output_dir) +def build_mace_run(production_mode, model_output_dir, hexagon_mode): + command = "bash tools/build_mace_run.sh {} {} {}".format( + int(production_mode), model_output_dir, int(hexagon_mode)) run_command(command) @@ -98,9 +100,14 @@ def generate_production_code(model_output_dirs, pull_or_not): run_command(command) -def build_mace_run_prod(model_output_dir, tuning): +def build_mace_run_prod(model_output_dir, tuning, libmace_name): + if "dsp" in libmace_name: + hexagon_mode = True + else: + hexagon_mode = False + production_or_not = False - build_mace_run(production_or_not, model_output_dir) + build_mace_run(production_or_not, model_output_dir, hexagon_mode) tuning_run( model_output_dir, running_round=0, @@ -110,7 +117,7 @@ def build_mace_run_prod(model_output_dir, tuning): production_or_not = True pull_or_not = True generate_production_code([model_output_dir], pull_or_not) - build_mace_run(production_or_not, model_output_dir) + build_mace_run(production_or_not, model_output_dir, hexagon_mode) def validate_model(model_output_dir): @@ -242,7 +249,7 @@ def main(unused_args): elif os.path.exists(os.path.join(FLAGS.output_dir, "libmace")): shutil.rmtree(os.path.join(FLAGS.output_dir, "libmace")) - get_libs(configs) + libmace_name = get_libs(configs) if FLAGS.mode == "run" and len(configs) > 1: raise Exception("Mode 'run' only can execute one model config, which have been built lastest") @@ -266,7 +273,7 @@ def main(unused_args): if FLAGS.mode == "build" or FLAGS.mode == "all": generate_model_code() - build_mace_run_prod(model_output_dir, FLAGS.tuning) + build_mace_run_prod(model_output_dir, FLAGS.tuning, libmace_name) if FLAGS.mode == "run" or FLAGS.mode == "all": run_model(model_output_dir, FLAGS.round)