Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Xiaomi
Mace
提交
f3f3a58f
Mace
项目概览
Xiaomi
/
Mace
通知
106
Star
40
Fork
27
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
Mace
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
f3f3a58f
编写于
3月 16, 2018
作者:
Y
yejianwu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
support multi soc in throughput_test and benchmark
上级
f7fe515b
变更
4
显示空白变更内容
内联
并排
Showing
4 changed file
with
56 addition
and
50 deletion
+56
-50
tools/benchmark.sh
tools/benchmark.sh
+11
-8
tools/build_run_throughput_test.sh
tools/build_run_throughput_test.sh
+29
-27
tools/generate_production_code.sh
tools/generate_production_code.sh
+2
-2
tools/mace_tools.py
tools/mace_tools.py
+14
-13
未找到文件。
tools/benchmark.sh
浏览文件 @
f3f3a58f
#!/bin/bash
Usage
()
{
echo
"Usage: bash tools/benchmark.sh
model_output_dir
"
echo
"Usage: bash tools/benchmark.sh
target_soc model_output_dir option_args
"
}
if
[
$#
-lt
1
]
;
then
...
...
@@ -12,11 +12,14 @@ fi
CURRENT_DIR
=
`
dirname
$0
`
source
${
CURRENT_DIR
}
/env.sh
MODEL_OUTPUT_DIR
=
$1
OPTION_ARGS
=
$2
TARGET_SOC
=
$1
MODEL_OUTPUT_DIR
=
$2
OPTION_ARGS
=
$3
echo
$OPTION_ARGS
DEVICE_ID
=
`
echo_device_id_by_soc
$TARGET_SOC
`
if
[
-f
"
$MODEL_OUTPUT_DIR
/benchmark_model"
]
;
then
rm
-rf
$MODEL_OUTPUT_DIR
/benchmark_model
fi
...
...
@@ -63,18 +66,18 @@ else
cp
bazel-bin/mace/benchmark/benchmark_model
$MODEL_OUTPUT_DIR
adb shell
"mkdir -p
${
PHONE_DATA_DIR
}
"
||
exit
1
adb
-s
$DEVICE_ID
shell
"mkdir -p
${
PHONE_DATA_DIR
}
"
||
exit
1
IFS
=
','
read
-r
-a
INPUT_NAMES
<<<
"
${
INPUT_NODES
}
"
for
NAME
in
"
${
INPUT_NAMES
[@]
}
"
;
do
FORMATTED_NAME
=
$(
sed
s/[^[:alnum:]]/_/g
<<<
${
NAME
}
)
adb push
${
MODEL_OUTPUT_DIR
}
/
${
INPUT_FILE_NAME
}
_
${
FORMATTED_NAME
}
${
PHONE_DATA_DIR
}
||
exit
1
adb
-s
$DEVICE_ID
push
${
MODEL_OUTPUT_DIR
}
/
${
INPUT_FILE_NAME
}
_
${
FORMATTED_NAME
}
${
PHONE_DATA_DIR
}
||
exit
1
done
adb push
${
MODEL_OUTPUT_DIR
}
/benchmark_model
${
PHONE_DATA_DIR
}
||
exit
1
adb
-s
$DEVICE_ID
push
${
MODEL_OUTPUT_DIR
}
/benchmark_model
${
PHONE_DATA_DIR
}
||
exit
1
if
[
"
$EMBED_MODEL_DATA
"
=
0
]
;
then
adb push
${
MODEL_OUTPUT_DIR
}
/
${
MODEL_TAG
}
.data
${
PHONE_DATA_DIR
}
||
exit
1
adb
-s
$DEVICE_ID
push
${
MODEL_OUTPUT_DIR
}
/
${
MODEL_TAG
}
.data
${
PHONE_DATA_DIR
}
||
exit
1
fi
adb </dev/null shell
\
adb
-s
$DEVICE_ID
</dev/null shell
\
LD_LIBRARY_PATH
=
${
PHONE_DATA_DIR
}
\
MACE_CPP_MIN_VLOG_LEVEL
=
$VLOG_LEVEL
\
MACE_RUN_PARAMETER_PATH
=
${
PHONE_DATA_DIR
}
/mace_run.config
\
...
...
tools/build_run_throughput_test.sh
浏览文件 @
f3f3a58f
#!/bin/bash
Usage
()
{
echo
"Usage: bash tools/build_run_throughput_test.sh run_seconds merged_lib_file model_input_dir"
echo
"Usage: bash tools/build_run_throughput_test.sh
target_soc
run_seconds merged_lib_file model_input_dir"
}
if
[
$#
-lt
1
]
;
then
if
[
$#
-lt
4
]
;
then
Usage
exit
1
fi
RUN_SECONDS
=
$1
MERGED_LIB_FILE
=
$2
MODEL_INPUT_DIR
=
$3
CURRENT_DIR
=
`
dirname
$0
`
source
${
CURRENT_DIR
}
/env.sh
TARGET_SOC
=
$1
RUN_SECONDS
=
$2
MERGED_LIB_FILE
=
$3
MODEL_INPUT_DIR
=
$4
DEVICE_ID
=
`
echo_device_id_by_soc
$TARGET_SOC
`
if
[
"
$CPU_MODEL_TAG
"
!=
''
]
;
then
CPU_MODEL_TAG_BUILD_FLAGS
=
"--copt=-DMACE_CPU_MODEL_TAG=
${
CPU_MODEL_TAG
}
"
...
...
@@ -46,28 +48,28 @@ bazel build --verbose_failures -c opt --strip always //mace/benchmark:model_thro
rm
mace/benchmark/libmace_merged.a
adb shell
"mkdir -p
${
PHONE_DATA_DIR
}
"
||
exit
1
adb
-s
$DEVICE_ID
shell
"mkdir -p
${
PHONE_DATA_DIR
}
"
||
exit
1
adb push
${
MODEL_INPUT_DIR
}
/
${
INPUT_FILE_NAME
}
_
${
INPUT_NODES
}
${
PHONE_DATA_DIR
}
||
exit
1
adb push bazel-bin/mace/benchmark/model_throughput_test
${
PHONE_DATA_DIR
}
||
exit
1
adb
-s
$DEVICE_ID
push
${
MODEL_INPUT_DIR
}
/
${
INPUT_FILE_NAME
}
_
${
INPUT_NODES
}
${
PHONE_DATA_DIR
}
||
exit
1
adb
-s
$DEVICE_ID
push bazel-bin/mace/benchmark/model_throughput_test
${
PHONE_DATA_DIR
}
||
exit
1
if
[
"
$EMBED_MODEL_DATA
"
=
0
]
;
then
adb push codegen/models/
${
CPU_MODEL_TAG
}
/
${
CPU_MODEL_TAG
}
.data
${
PHONE_DATA_DIR
}
||
exit
1
adb push codegen/models/
${
GPU_MODEL_TAG
}
/
${
GPU_MODEL_TAG
}
.data
${
PHONE_DATA_DIR
}
||
exit
1
adb push codegen/models/
${
DSP_MODEL_TAG
}
/
${
DSP_MODEL_TAG
}
.data
${
PHONE_DATA_DIR
}
||
exit
1
adb
-s
$DEVICE_ID
push codegen/models/
${
CPU_MODEL_TAG
}
/
${
CPU_MODEL_TAG
}
.data
${
PHONE_DATA_DIR
}
||
exit
1
adb
-s
$DEVICE_ID
push codegen/models/
${
GPU_MODEL_TAG
}
/
${
GPU_MODEL_TAG
}
.data
${
PHONE_DATA_DIR
}
||
exit
1
adb
-s
$DEVICE_ID
push codegen/models/
${
DSP_MODEL_TAG
}
/
${
DSP_MODEL_TAG
}
.data
${
PHONE_DATA_DIR
}
||
exit
1
fi
adb push mace/core/runtime/hexagon/libhexagon_controller.so
${
PHONE_DATA_DIR
}
||
exit
1
adb
-s
$DEVICE_ID
push mace/core/runtime/hexagon/libhexagon_controller.so
${
PHONE_DATA_DIR
}
||
exit
1
adb </dev/null shell
\
LD_LIBRARY_PATH
=
${
PHONE_DATA_DIR
}
\
MACE_CPP_MIN_VLOG_LEVEL
=
$VLOG_LEVEL
\
MACE_RUN_PARAMETER_PATH
=
${
PHONE_DATA_DIR
}
/mace_run.config
\
MACE_KERNEL_PATH
=
$KERNEL_DIR
\
MACE_LIMIT_OPENCL_KERNEL_TIME
=
${
LIMIT_OPENCL_KERNEL_TIME
}
\
${
PHONE_DATA_DIR
}
/model_throughput_test
\
--input_shape
=
"
${
INPUT_SHAPES
}
"
\
--output_shape
=
"
${
OUTPUT_SHAPES
}
"
\
--input_file
=
${
PHONE_DATA_DIR
}
/
${
INPUT_FILE_NAME
}
_
${
INPUT_NODES
}
\
--cpu_model_data_file
=
${
PHONE_DATA_DIR
}
/
${
CPU_MODEL_TAG
}
.data
\
--gpu_model_data_file
=
${
PHONE_DATA_DIR
}
/
${
GPU_MODEL_TAG
}
.data
\
--dsp_model_data_file
=
${
PHONE_DATA_DIR
}
/
${
DSP_MODEL_TAG
}
.data
\
--run_seconds
=
$RUN_SECONDS
||
exit
1
\ No newline at end of file
adb
-s
$DEVICE_ID
</dev/null shell
\
LD_LIBRARY_PATH
=
${
PHONE_DATA_DIR
}
\
MACE_CPP_MIN_VLOG_LEVEL
=
$VLOG_LEVEL
\
MACE_RUN_PARAMETER_PATH
=
${
PHONE_DATA_DIR
}
/mace_run.config
\
MACE_KERNEL_PATH
=
$KERNEL_DIR
\
MACE_LIMIT_OPENCL_KERNEL_TIME
=
${
LIMIT_OPENCL_KERNEL_TIME
}
\
${
PHONE_DATA_DIR
}
/model_throughput_test
\
--input_shape
=
"
${
INPUT_SHAPES
}
"
\
--output_shape
=
"
${
OUTPUT_SHAPES
}
"
\
--input_file
=
${
PHONE_DATA_DIR
}
/
${
INPUT_FILE_NAME
}
_
${
INPUT_NODES
}
\
--cpu_model_data_file
=
${
PHONE_DATA_DIR
}
/
${
CPU_MODEL_TAG
}
.data
\
--gpu_model_data_file
=
${
PHONE_DATA_DIR
}
/
${
GPU_MODEL_TAG
}
.data
\
--dsp_model_data_file
=
${
PHONE_DATA_DIR
}
/
${
DSP_MODEL_TAG
}
.data
\
--run_seconds
=
$RUN_SECONDS
||
exit
1
tools/generate_production_code.sh
浏览文件 @
f3f3a58f
...
...
@@ -23,8 +23,8 @@ if [ "$PULL_OR_NOT" = 1 ]; then
rm
-rf
${
CL_BIN_DIR
}
mkdir
-p
${
CL_BIN_DIR
}
if
[
x
"
$TARGET_ABI
"
!=
x
"host"
]
;
then
adb
-s
$DEVICE_ID
pull
${
KERNEL_DIR
}
/.
${
CL_BIN_DIR
}
>
/dev/null
||
exit
1
adb
-s
$DEVICE_ID
pull
${
PHONE_DATA_DIR
}
/mace_run.config
${
CL_BIN_DIR
}
>
/dev/null
||
exit
1
adb
-s
$DEVICE_ID
pull
${
KERNEL_DIR
}
/.
${
CL_BIN_DIR
}
>
/dev/null
adb
-s
$DEVICE_ID
pull
${
PHONE_DATA_DIR
}
/mace_run.config
${
CL_BIN_DIR
}
>
/dev/null
fi
fi
...
...
tools/mace_tools.py
浏览文件 @
f3f3a58f
...
...
@@ -94,9 +94,9 @@ def tuning_run(target_soc,
run_command
(
command
)
def
benchmark_model
(
model_output_dir
,
option_args
=
''
):
command
=
"bash tools/benchmark.sh {}
\"
{}
\"
"
.
format
(
model_output_dir
,
option_args
)
def
benchmark_model
(
target_soc
,
model_output_dir
,
option_args
=
''
):
command
=
"bash tools/benchmark.sh {}
{}
\"
{}
\"
"
.
format
(
target_soc
,
model_output_dir
,
option_args
)
run_command
(
command
)
...
...
@@ -138,9 +138,10 @@ def build_mace_run_prod(target_soc, model_output_dir, tuning, global_runtime):
build_mace_run
(
production_or_not
,
model_output_dir
,
hexagon_mode
)
def
build_run_throughput_test
(
run_seconds
,
merged_lib_file
,
model_input_dir
):
command
=
"bash tools/build_run_throughput_test.sh {} {} {}"
.
format
(
run_seconds
,
merged_lib_file
,
model_input_dir
)
def
build_run_throughput_test
(
target_soc
,
run_seconds
,
merged_lib_file
,
model_input_dir
):
command
=
"bash tools/build_run_throughput_test.sh {} {} {} {}"
.
format
(
target_soc
,
run_seconds
,
merged_lib_file
,
model_input_dir
)
run_command
(
command
)
...
...
@@ -226,8 +227,8 @@ def main(unused_args):
generate_opencl_and_version_code
()
option_args
=
' '
.
join
([
arg
for
arg
in
unused_args
if
arg
.
startswith
(
'--'
)])
for
target_abi
in
configs
[
"target_abis"
]:
for
target_soc
in
configs
[
"target_socs"
]:
for
target_abi
in
configs
[
"target_abis"
]:
global_runtime
=
get_global_runtime
(
configs
)
# Transfer params by environment
os
.
environ
[
"TARGET_ABI"
]
=
target_abi
...
...
@@ -291,7 +292,7 @@ def main(unused_args):
FLAGS
.
restart_round
,
option_args
)
if
FLAGS
.
mode
==
"benchmark"
:
benchmark_model
(
model_output_dir
,
option_args
)
benchmark_model
(
target_soc
,
model_output_dir
,
option_args
)
if
FLAGS
.
mode
==
"validate"
or
FLAGS
.
mode
==
"all"
:
validate_model
(
target_soc
,
model_output_dir
)
...
...
@@ -302,14 +303,14 @@ def main(unused_args):
model_output_dirs
)
if
FLAGS
.
mode
==
"throughput_test"
:
merged_lib_file
=
FLAGS
.
output_dir
+
"/%s/
libmace/lib/libmace_
%s.a"
%
\
(
configs
[
"target_abis"
][
0
],
os
.
environ
[
"PROJECT_NAME"
]
)
merged_lib_file
=
FLAGS
.
output_dir
+
"/%s/
%s/libmace_%s.
%s.a"
%
\
(
os
.
environ
[
"PROJECT_NAME"
],
target_abi
,
os
.
environ
[
"PROJECT_NAME"
],
target_soc
)
generate_random_input
(
target_soc
,
FLAGS
.
output_dir
)
for
model_name
in
configs
[
"models"
]:
runtime
=
configs
[
"models"
][
model_name
][
"runtime"
]
os
.
environ
[
"%s_MODEL_TAG"
%
runtime
.
upper
()]
=
model_name
build_run_throughput_test
(
FLAGS
.
run_seconds
,
merged_lib_file
,
FLAGS
.
output_dir
)
build_run_throughput_test
(
target_soc
,
FLAGS
.
run_seconds
,
merged_lib_file
,
FLAGS
.
output_dir
)
if
__name__
==
"__main__"
:
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录