Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
孤小逸
Mace
提交
4b08a22c
Mace
项目概览
孤小逸
/
Mace
与 Fork 源项目一致
Fork自
Xiaomi / Mace
通知
1
Star
1
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,发现更多精彩内容 >>
提交
4b08a22c
编写于
5月 04, 2018
作者:
Y
yejianwu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
check model configs
上级
4fa3cd08
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
72 addition
and
13 deletion
+72
-13
tools/mace_tools.py
tools/mace_tools.py
+72
-13
未找到文件。
tools/mace_tools.py
浏览文件 @
4b08a22c
...
...
@@ -336,8 +336,74 @@ def str_to_caffe_env_type(v):
def
parse_model_configs
():
print
(
"============== Load and Parse configs =============="
)
with
open
(
FLAGS
.
config
)
as
f
:
configs
=
yaml
.
load
(
f
)
target_abis
=
configs
.
get
(
"target_abis"
,
[])
if
not
isinstance
(
target_abis
,
list
)
or
not
target_abis
:
print
(
"CONFIG ERROR:"
)
print
(
"target_abis list is needed!"
)
print
(
"For example: 'target_abis: [armeabi-v7a, arm64-v8a]'"
)
exit
(
1
)
embed_model_data
=
configs
.
get
(
"embed_model_data"
,
""
)
if
embed_model_data
==
""
or
not
isinstance
(
embed_model_data
,
int
)
or
\
embed_model_data
<
0
or
embed_model_data
>
1
:
print
(
"CONFIG ERROR:"
)
print
(
"embed_model_data must be integer in range [0, 1]"
)
exit
(
1
)
model_names
=
configs
.
get
(
"models"
,
""
)
if
not
model_names
:
print
(
"CONFIG ERROR:"
)
print
(
"models attribute not found in config file"
)
exit
(
1
)
for
model_name
in
model_names
:
model_config
=
configs
[
"models"
][
model_name
]
platform
=
model_config
.
get
(
"platform"
,
""
)
if
platform
==
""
or
platform
not
in
[
"tensorflow"
,
"caffe"
]:
print
(
"CONFIG ERROR:"
)
print
(
"'platform' must be 'tensorflow' or 'caffe'"
)
exit
(
1
)
for
key
in
[
"model_file_path"
,
"model_sha256_checksum"
,
"runtime"
]:
value
=
model_config
.
get
(
key
,
""
)
if
value
==
""
:
print
(
"CONFIG ERROR:"
)
print
(
"'%s' is necessary"
%
key
)
exit
(
1
)
for
key
in
[
"input_nodes"
,
"input_shapes"
,
"output_nodes"
,
"output_shapes"
]:
value
=
model_config
.
get
(
key
,
""
)
if
value
==
""
:
print
(
"CONFIG ERROR:"
)
print
(
"'%s' is necessary"
%
key
)
exit
(
1
)
if
not
isinstance
(
value
,
list
):
model_config
[
key
]
=
[
value
]
for
key
in
[
"limit_opencl_kernel_time"
,
"dsp_mode"
,
"obfuscate"
,
"fast_conv"
]:
value
=
model_config
.
get
(
key
,
""
)
if
value
==
""
:
model_config
[
key
]
=
0
print
(
"'%s' for %s is set to default value: 0"
%
(
key
,
model_name
))
validation_inputs_data
=
model_config
.
get
(
"validation_inputs_data"
,
[])
model_config
[
"validation_inputs_data"
]
=
validation_inputs_data
if
not
isinstance
(
validation_inputs_data
,
list
):
model_config
[
"validation_inputs_data"
]
=
[
validation_inputs_data
]
weight_file_path
=
model_config
.
get
(
"weight_file_path"
,
""
)
model_config
[
"weight_file_path"
]
=
weight_file_path
print
(
"Parse model configs successfully!
\n
"
)
return
configs
...
...
@@ -386,8 +452,8 @@ def parse_args():
help
=
"Enable out of range check for opencl."
)
parser
.
add_argument
(
"--enable_openmp"
,
type
=
"bool"
,
default
=
"true"
,
type
=
str2bool
,
default
=
True
,
help
=
"Enable openmp."
)
parser
.
add_argument
(
"--omp_num_threads"
,
...
...
@@ -434,16 +500,10 @@ def process_models(project_name, configs, embed_model_data, vlog_level,
for
model_name
in
configs
[
"models"
]:
print
'==================='
,
model_name
,
'==================='
model_config
=
configs
[
"models"
][
model_name
]
input_file_list
=
model_config
.
get
(
"validation_inputs_data"
,
[])
input_file_list
=
model_config
[
"validation_inputs_data"
]
data_type
,
device_type
=
get_data_and_device_type
(
model_config
[
"runtime"
])
for
key
in
[
"input_nodes"
,
"output_nodes"
,
"input_shapes"
,
"output_shapes"
]:
if
not
isinstance
(
model_config
[
key
],
list
):
model_config
[
key
]
=
[
model_config
[
key
]]
# Create model build directory
model_path_digest
=
md5sum
(
model_config
[
"model_file_path"
])
...
...
@@ -472,7 +532,7 @@ def process_models(project_name, configs, embed_model_data, vlog_level,
model_file_path
,
weight_file_path
=
get_model_files
(
model_config
[
"model_file_path"
],
model_output_dir
,
model_config
.
get
(
"weight_file_path"
,
""
)
)
model_config
[
"weight_file_path"
]
)
if
FLAGS
.
mode
==
"build"
or
FLAGS
.
mode
==
"run"
or
\
FLAGS
.
mode
==
"validate"
or
\
...
...
@@ -604,8 +664,7 @@ def process_models(project_name, configs, embed_model_data, vlog_level,
if
os
.
path
.
exists
(
throughput_test_output_dir
):
sh
.
rm
(
"-rf"
,
throughput_test_output_dir
)
os
.
makedirs
(
throughput_test_output_dir
)
input_file_list
=
model_config
.
get
(
"validation_inputs_data"
,
[])
input_file_list
=
model_config
[
"validation_inputs_data"
]
sh_commands
.
gen_random_input
(
throughput_test_output_dir
,
first_model
[
"input_nodes"
],
first_model
[
"input_shapes"
],
...
...
@@ -654,7 +713,7 @@ def main(unused_args):
target_socs
=
get_target_socs
(
configs
)
embed_model_data
=
configs
.
get
(
"embed_model_data"
,
1
)
embed_model_data
=
configs
[
"embed_model_data"
]
vlog_level
=
FLAGS
.
vlog_level
phone_data_dir
=
"/data/local/tmp/mace_run/"
for
target_abi
in
configs
[
"target_abis"
]:
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录