提交 0d467313 编写于 作者: Y yejianwu

update ANDROID_ABI to TARGET_ABI include 'host' stand for x86. update RUNTIME...

update ANDROID_ABI to TARGET_ABI include 'host' stand for x86. update RUNTIME content, with options cpu, gpu, dsp only
上级 d94265f2
......@@ -20,7 +20,7 @@ if [ "$PRODUCTION_MODE" = 1 ]; then
PRODUCTION_MODE_BUILD_FLAGS="--define production=true"
fi
if [ x"$RUNTIME" = x"local" ]; then
if [ x"$TARGET_ABI" = x"host" ]; then
bazel build --verbose_failures -c opt --strip always codegen:generated_models \
--copt="-std=c++11" \
--copt="-D_GLIBCXX_USE_C99_MATH_TR1" \
......@@ -44,11 +44,12 @@ else
bazel build --verbose_failures -c opt --strip always examples:mace_run \
--crosstool_top=//external:android/crosstool \
--host_crosstool_top=@bazel_tools//tools/cpp:toolchain \
--cpu=${ANDROID_ABI} \
--cpu=${TARGET_ABI} \
--copt="-std=c++11" \
--copt="-D_GLIBCXX_USE_C99_MATH_TR1" \
--copt="-Werror=return-type" \
--copt="-DMACE_MODEL_TAG=${MODEL_TAG}" \
--define openmp=true \
$PRODUCTION_MODE_BUILD_FLAGS \
$HEXAGON_MODE_BUILD_FLAG || exit 1
fi
......
......@@ -7,7 +7,7 @@ Usage() {
CURRENT_DIR=`dirname $0`
source ${CURRENT_DIR}/env.sh
build_local_target()
build_host_target()
{
BAZEL_TARGET=$1
bazel build --verbose_failures -c opt --strip always $BAZEL_TARGET \
......@@ -24,16 +24,16 @@ build_target()
bazel build --verbose_failures -c opt --strip always $BAZEL_TARGET \
--crosstool_top=//external:android/crosstool \
--host_crosstool_top=@bazel_tools//tools/cpp:toolchain \
--cpu=$ANDROID_ABI \
--cpu=$TARGET_ABI \
--copt="-std=c++11" \
--copt="-D_GLIBCXX_USE_C99_MATH_TR1" \
--copt="-Werror=return-type" \
--copt="-DMACE_OBFUSCATE_LITERALS" || exit 1
}
if [ x"$RUNTIME" = x"local" ]; then
build_local_target //codegen:generated_opencl_prod
build_local_target //codegen:generated_tuning_params
if [ x"$TARGET_ABI" = x"host" ]; then
build_host_target //codegen:generated_opencl_prod
build_host_target //codegen:generated_tuning_params
else
build_target //codegen:generated_opencl_prod
build_target //codegen:generated_tuning_params
......
CURRENT_DIR=`dirname $0`
source ${CURRENT_DIR}/env.sh
if [ x"$RUNTIME" != x"local" ]; then
if [ x"$TARGET_ABI" != x"host" ]; then
adb shell rm -rf $PHONE_DATA_DIR
rm -rf codegen/models codegen/opencl codegen/tuning
fi
rm -rf codegen/models codegen/opencl codegen/tuning
......@@ -10,6 +10,6 @@ MODEL_TAG=mobile_net
INPUT_SHAPE=1,64,64,3
OUTPUT_SHAPE=1,64,64,2
RUNTIME=gpu
ANDROID_ABI=armeabi-v7a ; Or 'arm64-v8a'
TARGET_ABI=armeabi-v7a ; Or 'arm64-v8a', 'host' etc.
LIMIT_OPENCL_KERNEL_TIME=0
DSP_MODE=0 ; used only for dsp
......@@ -14,25 +14,21 @@ MODEL_CODEGEN_DIR=${CODEGEN_DIR}/models/${MODEL_TAG}
CL_CODEGEN_DIR=${CODEGEN_DIR}/opencl
TUNING_CODEGEN_DIR=${CODEGEN_DIR}/tuning
VERSION_SOURCE_PATH=${CODEGEN_DIR}/version
GENERATED_MODEL_LIB_NAME="libgenerated_models.a"
MACE_RUNTIME=cpu
if [ x"$RUNTIME" = x"dsp" ]; then
DATA_TYPE="DT_UINT8"
DEVICE_TYPE="HEXAGON"
LIB_FOLDER_NAME="${LIB_FOLDER_NAME}_dsp"
MACE_RUNTIME=$RUNTIME
elif [ x"$RUNTIME" = x"gpu" ]; then
DATA_TYPE="DT_HALF"
DEVICE_TYPE="OPENCL"
MACE_RUNTIME=$RUNTIME
elif [ x"$RUNTIME" = x"cpu" ]; then
DATA_TYPE="DT_FLOAT"
DEVICE_TYPE="CPU"
elif [ x"$RUNTIME" = x"local" ];then
DATA_TYPE="DT_FLOAT"
DEVICE_TYPE="CPU"
GENERATED_MODEL_LIB_NAME="libgenerated_models.pic.a"
fi
GENERATED_MODEL_LIB_NAME="libgenerated_models.a"
if [ x"$TARGET_ABI" = x"host" ]; then
GENERATED_MODEL_LIB_NAME="libgenerated_models.pic.a"
fi
GENERATED_MODEL_LIB_PATH="bazel-bin/codegen/${GENERATED_MODEL_LIB_NAME}"
......@@ -14,7 +14,7 @@ bazel-bin/lib/python/tools/tf_converter --input=${TF_MODEL_FILE_PATH} \
--input_node=${TF_INPUT_NODE} \
--output_node=${TF_OUTPUT_NODE} \
--data_type=${DATA_TYPE} \
--runtime=${MACE_RUNTIME} \
--runtime=${RUNTIME} \
--output_type=source \
--template=${LIBMACE_SOURCE_DIR}/lib/python/tools/model.template \
--model_tag=${MODEL_TAG} \
......
......@@ -19,7 +19,7 @@ if [ "$PULL_OR_NOT" = 1 ]; then
CL_BIN_DIR=${CL_BIN_DIRS}
rm -rf ${CL_BIN_DIR}
mkdir -p ${CL_BIN_DIR}
if [ x"$RUNTIME" != x"local" ]; then
if [ x"$TARGET_ABI" != x"host" ]; then
adb pull ${KERNEL_DIR}/. ${CL_BIN_DIR}
adb pull ${PHONE_DATA_DIR}/mace_run.config ${CL_BIN_DIR}
fi
......
......@@ -34,22 +34,26 @@ def run_command(command):
def get_libs(configs):
libmace_name = "libmace"
global_target_abi = ""
global_runtime = ""
runtime_list = []
for config in configs:
if config["ANDROID_ABI"] == "armeabi-v7a":
libmace_name += "_v7"
break
elif config["ANDROID_ABI"] == "arm64-v8a":
libmace_name += "_v8"
break
if global_target_abi == "":
global_target_abi = config["TARGET_ABI"]
elif global_target_abi != config["TARGET_ABI"]:
raise Exception("Multiple TARGET_ABI found in config files!")
runtime_list.append(config["RUNTIME"])
if "dsp" in runtime_list:
global_runtime = "dsp"
elif "gpu" in runtime_list:
global_runtime = "gpu"
elif "cpu" in runtime_list:
global_runtime = "cpu"
else:
raise Exception("Not found available RUNTIME in config files!")
for config in configs:
if config["RUNTIME"] == "dsp":
libmace_name += "_dsp"
break
if config["RUNTIME"] == "local":
libmace_name += "_local"
break
libmace_name = "libmace-{}-{}".format(global_target_abi, global_runtime)
command = "bash tools/download_and_link_lib.sh " + libmace_name
run_command(command)
......
......@@ -38,7 +38,7 @@ $ANDROID_NDK_HOME/toolchains/aarch64-linux-android-4.9/prebuilt/linux-x86_64/bin
# Merge opencl bin and tuning result
echo "create ${LIBMACE_BUILD_DIR}/libmace/lib/libmace_opencl.a" > ${LIBMACE_TEMP_DIR}/libmace_opencl.mri
if [ x"RUNTIME" = x"local" ]; then
if [ x"TARGET_ABI" = x"host" ]; then
echo "addlib bazel-bin/codegen/libgenerated_opencl_prod.pic.a" >> ${LIBMACE_TEMP_DIR}/libmace_opencl.mri
echo "addlib bazel-bin/codegen/libgenerated_tuning_params.pic.a" >> ${LIBMACE_TEMP_DIR}/libmace_opencl.mri
else
......
......@@ -17,7 +17,7 @@ ROUND=$2
TUNING_OR_NOT=$3
PRODUCTION_MODE=$4
if [ x"$RUNTIME" = x"local" ]; then
if [ x"$TARGET_ABI" = x"host" ]; then
MACE_CPP_MIN_VLOG_LEVEL=$VLOG_LEVEL \
${MODEL_OUTPUT_DIR}/mace_run \
--input_shape="${INPUT_SHAPE}"\
......
......@@ -26,7 +26,7 @@ else
python tools/validate.py --model_file ${TF_MODEL_FILE_PATH} \
--input_file ${MODEL_OUTPUT_DIR}/${INPUT_FILE_NAME} \
--mace_out_file ${MODEL_OUTPUT_DIR}/${OUTPUT_FILE_NAME} \
--mace_runtime ${MACE_RUNTIME} \
--mace_runtime ${RUNTIME} \
--input_node ${TF_INPUT_NODE} \
--output_node ${TF_OUTPUT_NODE} \
--input_shape ${INPUT_SHAPE} \
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册