Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
慢慢CG
Mace
提交
f1390833
Mace
项目概览
慢慢CG
/
Mace
与 Fork 源项目一致
Fork自
Xiaomi / Mace
通知
1
Star
0
Fork
0
代码
文件
提交
分支
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看板
提交
f1390833
编写于
7月 12, 2018
作者:
L
liuqi
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix host and report bug.
上级
1855fe15
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
64 addition
and
50 deletion
+64
-50
README.md
README.md
+4
-3
README_zh.md
README_zh.md
+4
-3
tools/converter.py
tools/converter.py
+55
-43
tools/sh_commands.py
tools/sh_commands.py
+1
-1
未找到文件。
README.md
浏览文件 @
f1390833
...
...
@@ -44,9 +44,10 @@ targets:
architectures with limited performance.
## Getting Started
*
[
Introduction
](
https://mace.readthedocs.io/en/latest/getting_started/introduction.html
)
*
[
Create a model deployment file
](
https://mace.readthedocs.io/en/latest/getting_started/create_a_model_deployment.html
)
*
[
How to build
](
https://mace.readthedocs.io/en/latest/getting_started/how_to_build.html
)
*
[
Introduction
](
https://mace.readthedocs.io/en/latest/introduction.html
)
*
[
Installation
](
https://mace.readthedocs.io/en/latest/installation/env_requirement.html
)
*
[
Basic Usage
](
https://mace.readthedocs.io/en/latest/user_guide/basic_usage.html
)
*
[
Advanced Usage
](
https://mace.readthedocs.io/en/latest/user_guide/advanced_usage.html
)
## Performance
[
MACE Model Zoo
](
https://github.com/XiaoMi/mace-models
)
contains
...
...
README_zh.md
浏览文件 @
f1390833
...
...
@@ -35,9 +35,10 @@
同时支持在具有POSIX接口的系统的CPU上运行。
## 开始使用
*
[
简介
](
https://mace.readthedocs.io/en/latest/getting_started/introduction.html
)
*
[
创建模型部署文件
](
https://mace.readthedocs.io/en/latest/getting_started/create_a_model_deployment.html
)
*
[
如何构建
](
https://mace.readthedocs.io/en/latest/getting_started/how_to_build.html
)
*
[
简介
](
https://mace.readthedocs.io/en/latest/introduction.html
)
*
[
安装
](
https://mace.readthedocs.io/en/latest/installation/env_requirement.html
)
*
[
基本用法
](
https://mace.readthedocs.io/en/latest/user_guide/basic_usage.html
)
*
[
高级用法
](
https://mace.readthedocs.io/en/latest/user_guide/advanced_usage.html
)
## 性能评测
[
MACE Model Zoo
](
https://github.com/XiaoMi/mace-models
)
...
...
tools/converter.py
浏览文件 @
f1390833
...
...
@@ -543,23 +543,24 @@ def clear_build_dirs(library_name):
def
check_model_converted
(
library_name
,
model_name
,
model_graph_format
,
model_data_format
):
model_graph_format
,
model_data_format
,
abi
):
model_output_dir
=
\
'%s/%s/%s'
%
(
BUILD_OUTPUT_DIR
,
library_name
,
MODEL_OUTPUT_DIR_NAME
)
if
model_graph_format
==
ModelFormat
.
file
:
mace_check
(
os
.
path
.
exists
(
"%s/%s.pb"
%
(
model_output_dir
,
model_name
)),
ModuleName
.
RUN
,
"You sh
uo
ld convert model first."
)
"You sh
ou
ld convert model first."
)
else
:
m
ace_check
(
os
.
path
.
exists
(
"%s/%s.a"
%
(
model_output_dir
,
library_name
)
),
m
odel_lib_path
=
get_model_lib_output_path
(
library_name
,
abi
)
mace_check
(
os
.
path
.
exists
(
model_lib_path
),
ModuleName
.
RUN
,
"You sh
uo
ld convert model first."
)
"You sh
ou
ld convert model first."
)
if
model_data_format
==
ModelFormat
.
file
:
mace_check
(
os
.
path
.
exists
(
"%s/%s.data"
%
(
model_output_dir
,
model_name
)),
ModuleName
.
RUN
,
"You sh
uo
ld convert model first."
)
"You sh
ou
ld convert model first."
)
################################
...
...
@@ -716,10 +717,10 @@ def convert_model(configs):
StringFormatter
.
block
(
"Model %s converted"
%
model_name
))
def
get_model_lib_output_path
(
library_name
):
lib
rary_out_dir
=
os
.
path
.
join
(
BUILD_OUTPUT_DIR
,
library_name
,
MODEL_OUTPUT_DIR_NAME
)
lib_output_path
=
"%s/%s.a"
%
(
library_out_dir
,
library_name
)
def
get_model_lib_output_path
(
library_name
,
abi
):
lib
_output_path
=
os
.
path
.
join
(
BUILD_OUTPUT_DIR
,
library_name
,
MODEL_OUTPUT_DIR_NAME
,
abi
,
"%s.a"
%
library_name
)
return
lib_output_path
...
...
@@ -728,13 +729,13 @@ def build_model_lib(configs, address_sanitizer):
# create model library dir
library_name
=
configs
[
YAMLKeyword
.
library_name
]
model_lib_output_path
=
get_model_lib_output_path
(
library_name
)
library_out_dir
=
os
.
path
.
dirname
(
model_lib_output_path
)
if
not
os
.
path
.
exists
(
library_out_dir
):
os
.
makedirs
(
library_out_dir
)
for
target_abi
in
configs
[
YAMLKeyword
.
target_abis
]:
hexagon_mode
=
get_hexagon_mode
(
configs
)
model_lib_output_path
=
get_model_lib_output_path
(
library_name
,
target_abi
)
library_out_dir
=
os
.
path
.
dirname
(
model_lib_output_path
)
if
not
os
.
path
.
exists
(
library_out_dir
):
os
.
makedirs
(
library_out_dir
)
sh_commands
.
bazel_build
(
MODEL_LIB_TARGET
,
...
...
@@ -841,7 +842,7 @@ def build_mace_run(configs, target_abi, enable_openmp, address_sanitizer,
if
configs
[
YAMLKeyword
.
model_graph_format
]
==
ModelFormat
.
code
:
mace_check
(
os
.
path
.
exists
(
ENGINE_CODEGEN_DIR
),
ModuleName
.
RUN
,
"You sh
uo
ld convert model first."
)
"You sh
ou
ld convert model first."
)
build_arg
=
"--per_file_copt=mace/tools/validation/mace_run.cc@-DMODEL_GRAPH_FORMAT_CODE"
# noqa
sh_commands
.
bazel_build
(
...
...
@@ -887,8 +888,9 @@ def build_example(configs, target_abi, enable_openmp, mace_lib_type):
if
configs
[
YAMLKeyword
.
model_graph_format
]
==
ModelFormat
.
code
:
mace_check
(
os
.
path
.
exists
(
ENGINE_CODEGEN_DIR
),
ModuleName
.
RUN
,
"You shuold convert model first."
)
model_lib_path
=
get_model_lib_output_path
(
library_name
)
"You should convert model first."
)
model_lib_path
=
get_model_lib_output_path
(
library_name
,
target_abi
)
sh
.
cp
(
"-f"
,
model_lib_path
,
LIB_CODEGEN_DIR
)
build_arg
=
"--per_file_copt=mace/examples/cli/example.cc@-DMODEL_GRAPH_FORMAT_CODE"
# noqa
...
...
@@ -912,12 +914,6 @@ def tuning(library_name, model_name, model_config,
mace_lib_type
):
print
(
'* Tuning, it may take some time...'
)
# clear opencl output dir
opencl_output_dir
=
os
.
path
.
join
(
BUILD_OUTPUT_DIR
,
library_name
,
OUTPUT_OPENCL_BINARY_DIR_NAME
)
if
os
.
path
.
exists
(
opencl_output_dir
):
sh
.
rm
(
'-rf'
,
opencl_output_dir
)
build_tmp_binary_dir
=
get_build_binary_dir
(
library_name
,
target_abi
)
mace_run_name
=
MACE_RUN_STATIC_NAME
link_dynamic
=
False
...
...
@@ -994,16 +990,7 @@ def run_specific_target(flags, configs, target_abi,
mace_lib_type
=
flags
.
mace_lib_type
embed_model_data
=
\
configs
[
YAMLKeyword
.
model_data_format
]
==
ModelFormat
.
code
opencl_output_bin_path
=
""
opencl_parameter_path
=
""
build_tmp_binary_dir
=
get_build_binary_dir
(
library_name
,
target_abi
)
if
configs
[
YAMLKeyword
.
target_socs
]
and
target_abi
!=
ABIType
.
host
:
opencl_output_bin_path
=
get_opencl_binary_output_path
(
library_name
,
target_abi
,
target_soc
,
serial_num
)
opencl_parameter_path
=
get_opencl_parameter_output_path
(
library_name
,
target_abi
,
target_soc
,
serial_num
)
# get target name for run
if
flags
.
example
:
...
...
@@ -1023,7 +1010,8 @@ def run_specific_target(flags, configs, target_abi,
for
model_name
in
configs
[
YAMLKeyword
.
models
]:
check_model_converted
(
library_name
,
model_name
,
configs
[
YAMLKeyword
.
model_graph_format
],
configs
[
YAMLKeyword
.
model_data_format
])
configs
[
YAMLKeyword
.
model_data_format
],
target_abi
)
if
target_abi
==
ABIType
.
host
:
device_name
=
ABIType
.
host
else
:
...
...
@@ -1049,10 +1037,14 @@ def run_specific_target(flags, configs, target_abi,
get_build_model_dirs
(
library_name
,
model_name
,
target_abi
,
target_soc
,
serial_num
,
model_config
[
YAMLKeyword
.
model_file_path
])
# clear temp model output dir
if
os
.
path
.
exists
(
model_output_dir
):
sh
.
rm
(
"-rf"
,
model_output_dir
)
os
.
makedirs
(
model_output_dir
)
is_tuned
=
False
model_opencl_output_bin_path
=
""
model_opencl_parameter_path
=
""
# tuning for specified soc
if
not
flags
.
address_sanitizer
\
and
not
flags
.
example
\
...
...
@@ -1067,6 +1059,23 @@ def run_specific_target(flags, configs, target_abi,
target_abi
,
target_soc
,
serial_num
,
mace_lib_type
)
model_output_dirs
.
append
(
model_output_dir
)
model_opencl_output_bin_path
=
\
"%s/%s/%s"
%
(
model_output_dir
,
BUILD_TMP_OPENCL_BIN_DIR
,
CL_COMPILED_BINARY_FILE_NAME
)
model_opencl_parameter_path
=
\
"%s/%s/%s"
%
(
model_output_dir
,
BUILD_TMP_OPENCL_BIN_DIR
,
CL_TUNED_PARAMETER_FILE_NAME
)
sh_commands
.
clear_phone_data_dir
(
serial_num
,
PHONE_DATA_DIR
)
is_tuned
=
True
elif
target_abi
!=
ABIType
.
host
and
target_soc
:
model_opencl_output_bin_path
=
get_opencl_binary_output_path
(
library_name
,
target_abi
,
target_soc
,
serial_num
)
model_opencl_parameter_path
=
get_opencl_parameter_output_path
(
library_name
,
target_abi
,
target_soc
,
serial_num
)
# generate input data
sh_commands
.
gen_random_input
(
...
...
@@ -1114,8 +1123,8 @@ def run_specific_target(flags, configs, target_abi,
gpu_priority_hint
=
flags
.
gpu_priority_hint
,
runtime_failure_ratio
=
flags
.
runtime_failure_ratio
,
address_sanitizer
=
flags
.
address_sanitizer
,
opencl_binary_file
=
opencl_output_bin_path
,
opencl_parameter_file
=
opencl_parameter_path
,
opencl_binary_file
=
model_
opencl_output_bin_path
,
opencl_parameter_file
=
model_
opencl_parameter_path
,
libmace_dynamic_library_path
=
LIBMACE_DYNAMIC_PATH
,
link_dynamic
=
link_dynamic
,
)
...
...
@@ -1142,11 +1151,7 @@ def run_specific_target(flags, configs, target_abi,
phone_data_dir
=
PHONE_DATA_DIR
,
caffe_env
=
flags
.
caffe_env
)
if
flags
.
report
and
flags
.
round
>
0
:
opencl_parameter_bin_path
=
get_opencl_parameter_output_path
(
library_name
,
target_abi
,
target_soc
,
serial_num
)
tuned
=
device_type
==
DeviceType
.
GPU
\
and
os
.
path
.
exists
(
opencl_parameter_bin_path
)
tuned
=
is_tuned
and
device_type
==
DeviceType
.
GPU
report_run_statistics
(
run_output
,
target_abi
,
serial_num
,
model_name
,
device_type
,
flags
.
report_dir
,
...
...
@@ -1159,6 +1164,12 @@ def run_specific_target(flags, configs, target_abi,
opencl_parameter_bin_path
=
get_opencl_parameter_output_path
(
library_name
,
target_abi
,
target_soc
,
serial_num
)
# clear opencl output dir
if
os
.
path
.
exists
(
opencl_output_bin_path
):
sh
.
rm
(
'-rf'
,
opencl_output_bin_path
)
if
os
.
path
.
exists
(
opencl_parameter_bin_path
):
sh
.
rm
(
'-rf'
,
opencl_parameter_bin_path
)
# merge all models' OpenCL binaries together
sh_commands
.
merge_opencl_binaries
(
model_output_dirs
,
CL_COMPILED_BINARY_FILE_NAME
,
...
...
@@ -1228,7 +1239,7 @@ def build_benchmark_model(configs, target_abi, enable_openmp, mace_lib_type):
if
configs
[
YAMLKeyword
.
model_graph_format
]
==
ModelFormat
.
code
:
mace_check
(
os
.
path
.
exists
(
ENGINE_CODEGEN_DIR
),
ModuleName
.
BENCHMARK
,
"You sh
uo
ld convert model first."
)
"You sh
ou
ld convert model first."
)
build_arg
=
"--per_file_copt=mace/benchmark/benchmark_model.cc@-DMODEL_GRAPH_FORMAT_CODE"
# noqa
sh_commands
.
bazel_build
(
benchmark_target
,
...
...
@@ -1271,7 +1282,8 @@ def bm_specific_target(flags, configs, target_abi, target_soc, serial_num):
for
model_name
in
configs
[
YAMLKeyword
.
models
]:
check_model_converted
(
library_name
,
model_name
,
configs
[
YAMLKeyword
.
model_graph_format
],
configs
[
YAMLKeyword
.
model_data_format
])
configs
[
YAMLKeyword
.
model_data_format
],
target_abi
)
if
target_abi
==
ABIType
.
host
:
device_name
=
ABIType
.
host
else
:
...
...
tools/sh_commands.py
浏览文件 @
f1390833
...
...
@@ -780,7 +780,7 @@ def tuning_run(abi,
print
(
"Running finished!
\n
"
)
return
stdout
return
stdout
def
validate_model
(
abi
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录