From 37520ba42ae29cc10989bff7f22e15d8bf0092aa Mon Sep 17 00:00:00 2001 From: Bin Li Date: Wed, 11 Jul 2018 19:40:25 +0800 Subject: [PATCH] conform to latest mace --- third_party/mace/BUILD | 4 ++-- tools/build_mace.sh | 25 ++++++++++++------------- tools/model_and_input.yml | 2 +- tools/sh_commands.py | 3 +-- 4 files changed, 16 insertions(+), 18 deletions(-) diff --git a/third_party/mace/BUILD b/third_party/mace/BUILD index 6a1fcec..1b87a65 100644 --- a/third_party/mace/BUILD +++ b/third_party/mace/BUILD @@ -13,7 +13,7 @@ cc_library( cc_library( name = "mace_armeabi-v7a", srcs = glob([ - "lib/armeabi-v7a/libmace*.a", + "lib/armeabi-v7a/libmace.a", ]), visibility = ["//visibility:public"], deps = ["mace_headers"], @@ -22,7 +22,7 @@ cc_library( cc_library( name = "mace_arm64-v8a", srcs = glob([ - "lib/arm64-v8a/libmace*.a", + "lib/arm64-v8a/libmace.a", ]), visibility = ["//visibility:public"], deps = ["mace_headers"], diff --git a/tools/build_mace.sh b/tools/build_mace.sh index a2f0a02..b0b6b92 100755 --- a/tools/build_mace.sh +++ b/tools/build_mace.sh @@ -4,17 +4,17 @@ set -e -u -o pipefail trap "exit" INT -# get all model yamls +# get mace-models rm -rf mace-models -GIT_SSH_COMMAND="ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no" git clone git@v9.git.n.xiaomi.com:deep-computing/mace-models.git +GIT_SSH_COMMAND="ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no" git clone git@github.com:XiaoMi/mace-models.git cd mace-models/ MODEL_ROOT_PATH=`pwd` CONF_FILES=`find $MODEL_ROOT_PATH -name *.yml | { grep -v ".gitlab-ci.yml" || true; }` -# build all model yamls +# get mace cd .. rm -rf mace -GIT_SSH_COMMAND="ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no" git clone git@v9.git.n.xiaomi.com:deep-computing/mace.git +GIT_SSH_COMMAND="ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no" git clone git@github.com:XiaoMi/mace.git cd mace/ MODELS=( @@ -27,24 +27,23 @@ MODELS=( "vgg16-tensorflow-cpu" ) +# convert models to pb and data for CONF_FILE in $CONF_FILES; do for MODEL in "${MODELS[@]}"; do if [ "$(basename $CONF_FILE .yml)" == "$MODEL" ]; then set +e - python tools/converter.py build --config=$CONF_FILE --build_type=proto --target_abi=$1 + python tools/converter.py convert --config=$CONF_FILE RESULT=$? set -e if [ $RESULT == 0 ]; then - cp build/$(basename $CONF_FILE .yml)/model/*.pb $2 - cp build/$(basename $CONF_FILE .yml)/model/*.data $2 - if [ "$(basename $CONF_FILE .yml)" == "inception-v3-dsp" ]; then - COPIED_FILE=$CONF_FILE - fi + cp builds/$(basename $CONF_FILE .yml)/model/*.pb $2 + cp builds/$(basename $CONF_FILE .yml)/model/*.data $2 fi fi done done -# copy headers and library to aibench -cp -r build/$(basename $COPIED_FILE .yml)/include ../third_party/mace/ -cp -r build/$(basename $COPIED_FILE .yml)/lib ../third_party/mace/ +# build and copy includes and libs to aibench +bash tools/build-standalone-lib.sh +cp -r builds/include ../third_party/mace/ +cp -r builds/lib ../third_party/mace/ diff --git a/tools/model_and_input.yml b/tools/model_and_input.yml index 222ac4e..1c5c463 100644 --- a/tools/model_and_input.yml +++ b/tools/model_and_input.yml @@ -64,4 +64,4 @@ models_and_inputs: tensorflow-1.9.0-rc1.zip: https://cnbj1.fds.api.xiaomi.com/aibench/third_party/tensorflow-1.9.0-rc1.zip tensorflow-1.9.0-rc1.zip_md5_checksum: ef248c5c6cc463e9fb28cea43dc3b840 libmace.zip: https://cnbj1.fds.api.xiaomi.com/aibench/third_party/libmace.zip -libmace.zip_md5_checksum: e84fba9ebc177fd4068a588af59fd8ad +libmace.zip_md5_checksum: 31972695b8fb9ea82564cb999c14d3cd diff --git a/tools/sh_commands.py b/tools/sh_commands.py index 8016f47..237257f 100644 --- a/tools/sh_commands.py +++ b/tools/sh_commands.py @@ -157,7 +157,6 @@ def download_file(configs, file_name, output_dir): def get_mace(configs, abis, output_dir, build_mace): if build_mace: - print("get build mace") sh.bash("tools/build_mace.sh", abis, os.path.abspath(output_dir), _fg=True) else: @@ -223,7 +222,7 @@ def prepare_device_env(serialno, abi, device_bin_path, frameworks): adb_push(libgnustl_path, device_bin_path, serialno) # for mace - if "MACE" in frameworks: + if "MACE" in frameworks and abi == "armeabi-v7a": adb_push("third_party/nnlib/libhexagon_controller.so", device_bin_path, serialno)