Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
毕竟曾有刹那
Mace
提交
1e24c9ad
Mace
项目概览
毕竟曾有刹那
/
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
1e24c9ad
编写于
5月 31, 2018
作者:
L
liuqi
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Support target_soc == 'all' for building all SOCs plugged in.
上级
a86482d8
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
36 addition
and
12 deletion
+36
-12
tools/converter.py
tools/converter.py
+24
-9
tools/sh_commands.py
tools/sh_commands.py
+12
-3
未找到文件。
tools/converter.py
浏览文件 @
1e24c9ad
...
...
@@ -47,6 +47,7 @@ CL_PLATFORM_INFO_FILE_NAME = "mace_cl_platform_info.txt"
CODEGEN_BASE_DIR
=
'mace/codegen'
MODEL_CODEGEN_DIR
=
CODEGEN_BASE_DIR
+
'/models'
MACE_RUN_TARGET
=
"//mace/tools/validation:mace_run"
ALL_SOC_TAG
=
'all'
ABITypeStrs
=
[
'armeabi-v7a'
,
...
...
@@ -233,11 +234,19 @@ def format_model_config(config_file_path):
elif
not
isinstance
(
target_socs
,
list
):
configs
[
YAMLKeyword
.
target_socs
]
=
[
target_socs
]
configs
[
YAMLKeyword
.
target_socs
]
=
\
[
soc
.
lower
()
for
soc
in
configs
[
YAMLKeyword
.
target_socs
]]
if
ABIType
.
armeabi_v7a
in
target_abis
\
or
ABIType
.
arm64_v8a
in
target_abis
:
available_socs
=
sh_commands
.
adb_get_all_socs
()
if
YAMLKeyword
.
target_socs
in
configs
:
target_socs
=
set
(
configs
[
YAMLKeyword
.
target_socs
])
target_socs
=
configs
[
YAMLKeyword
.
target_socs
]
if
ALL_SOC_TAG
in
target_socs
:
mace_check
(
available_socs
,
ModuleName
.
YAML_CONFIG
,
"Build for all SOCs plugged in computer, "
"you at least plug in one phone"
)
else
:
for
soc
in
target_socs
:
mace_check
(
soc
in
available_socs
,
ModuleName
.
YAML_CONFIG
,
...
...
@@ -670,6 +679,7 @@ def build_specific_lib(target_abi, target_soc, serial_num,
pull_opencl_binary_and_tuning_param
(
target_abi
,
serial_num
,
[
model_output_dir
])
sh_commands
.
touch_tuned_file_flag
(
build_tmp_binary_dir
)
binary_changed
=
True
if
binary_changed
:
...
...
@@ -732,6 +742,8 @@ def generate_library(configs, tuning, enable_openmp, address_sanitizer):
build_specific_lib
(
target_abi
,
None
,
None
,
configs
,
tuning
,
enable_openmp
,
address_sanitizer
)
else
:
if
ALL_SOC_TAG
in
target_socs
:
target_socs
=
sh_commands
.
adb_get_all_socs
()
for
target_soc
in
target_socs
:
serial_nums
=
\
sh_commands
.
get_target_socs_serialnos
([
target_soc
])
...
...
@@ -778,7 +790,8 @@ def report_run_statistics(stdout,
serialno
,
model_name
,
device_type
,
output_dir
):
output_dir
,
tuned
):
metrics
=
[
0
]
*
3
for
line
in
stdout
.
split
(
'
\n
'
):
line
=
line
.
strip
()
...
...
@@ -800,10 +813,10 @@ def report_run_statistics(stdout,
if
not
os
.
path
.
exists
(
report_filename
):
with
open
(
report_filename
,
'w'
)
as
f
:
f
.
write
(
"model_name,device_name,soc,abi,runtime,"
"init,warmup,run_avg
\n
"
)
"init,warmup,run_avg
,tuned
\n
"
)
data_str
=
"{model_name},{device_name},{soc},{abi},{device_type},"
\
"{init},{warmup},{run_avg}
\n
"
\
"{init},{warmup},{run_avg}
,{tuned}
\n
"
\
.
format
(
model_name
=
model_name
,
device_name
=
device_name
,
soc
=
target_soc
,
...
...
@@ -811,7 +824,8 @@ def report_run_statistics(stdout,
device_type
=
device_type
,
init
=
metrics
[
0
],
warmup
=
metrics
[
1
],
run_avg
=
metrics
[
2
]
run_avg
=
metrics
[
2
],
tuned
=
tuned
,
)
with
open
(
report_filename
,
'a'
)
as
f
:
f
.
write
(
data_str
)
...
...
@@ -929,14 +943,15 @@ def run_specific_target(flags, configs, target_abi,
if
flags
.
report
and
flags
.
round
>
0
:
report_run_statistics
(
run_output
,
target_abi
,
serial_num
,
model_name
,
device_type
,
flags
.
report_dir
)
model_name
,
device_type
,
flags
.
report_dir
,
sh_commands
.
is_binary_tuned
(
build_tmp_binary_dir
))
def
run_mace
(
flags
):
configs
=
format_model_config
(
flags
.
config
)
target_socs
=
configs
[
YAMLKeyword
.
target_socs
]
if
not
target_socs
:
if
not
target_socs
or
ALL_SOC_TAG
in
target_socs
:
target_socs
=
sh_commands
.
adb_get_all_socs
()
for
target_abi
in
configs
[
YAMLKeyword
.
target_abis
]:
...
...
@@ -1043,7 +1058,7 @@ def benchmark_model(flags):
configs
=
format_model_config
(
flags
.
config
)
target_socs
=
configs
[
YAMLKeyword
.
target_socs
]
if
not
target_socs
:
if
not
target_socs
or
ALL_SOC_TAG
in
target_socs
:
target_socs
=
sh_commands
.
adb_get_all_socs
()
for
target_abi
in
configs
[
YAMLKeyword
.
target_abis
]:
...
...
tools/sh_commands.py
浏览文件 @
1e24c9ad
...
...
@@ -520,11 +520,20 @@ def gen_random_input(model_output_dir,
sh
.
cp
(
"-f"
,
input_file_list
[
i
],
dst_input_file
)
def
update_mace_run_lib
(
model_output
_dir
):
mace_run_filepath
=
model_output
_dir
+
"/mace_run"
def
update_mace_run_lib
(
build_tmp_binary
_dir
):
mace_run_filepath
=
build_tmp_binary
_dir
+
"/mace_run"
if
os
.
path
.
exists
(
mace_run_filepath
):
sh
.
rm
(
"-rf"
,
mace_run_filepath
)
sh
.
cp
(
"-f"
,
"bazel-bin/mace/tools/validation/mace_run"
,
model_output_dir
)
sh
.
cp
(
"-f"
,
"bazel-bin/mace/tools/validation/mace_run"
,
build_tmp_binary_dir
)
def
touch_tuned_file_flag
(
build_tmp_binary_dir
):
sh
.
touch
(
build_tmp_binary_dir
+
'/tuned'
)
def
is_binary_tuned
(
build_tmp_binary_dir
):
return
os
.
path
.
exists
(
build_tmp_binary_dir
+
'/tuned'
)
def
mv_model_file_to_output_dir
(
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录