Skip to content

Commit

Permalink
Merge branch 'mace' into 'master'
Browse files Browse the repository at this point in the history
conform to latest mace

See merge request !31
  • Loading branch information
lydoc committed Jul 12, 2018
2 parents 32d45fa + 37520ba commit 12b1e97
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 18 deletions.
4 changes: 2 additions & 2 deletions third_party/mace/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -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"],
Expand All @@ -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"],
Expand Down
25 changes: 12 additions & 13 deletions tools/build_mace.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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=(
Expand All @@ -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/
2 changes: 1 addition & 1 deletion tools/model_and_input.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
3 changes: 1 addition & 2 deletions tools/sh_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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)

Expand Down

0 comments on commit 12b1e97

Please sign in to comment.