Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Mr.Vain
Mace
提交
a41a3f77
Mace
项目概览
Mr.Vain
/
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,体验更适合开发者的 AI 搜索 >>
提交
a41a3f77
编写于
4月 29, 2019
作者:
L
liuqi
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add arguments checking for mace_run tool.
上级
279947d1
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
28 addition
and
8 deletion
+28
-8
mace/tools/validation/mace_run.cc
mace/tools/validation/mace_run.cc
+28
-8
未找到文件。
mace/tools/validation/mace_run.cc
浏览文件 @
a41a3f77
...
...
@@ -99,16 +99,16 @@ DEFINE_string(model_name,
""
,
"model name in yaml"
);
DEFINE_string
(
input_node
,
"
input_node0,input_node1
"
,
""
,
"input nodes, separated by comma"
);
DEFINE_string
(
input_shape
,
"
1,224,224,3:1,1,1,10
"
,
""
,
"input shapes, separated by colon and comma"
);
DEFINE_string
(
output_node
,
"
output_node0,output_node1
"
,
""
,
"output nodes, separated by comma"
);
DEFINE_string
(
output_shape
,
"
1,224,224,2:1,1,1,10
"
,
""
,
"output shapes, separated by colon and comma"
);
DEFINE_string
(
input_data_format
,
"NHWC"
,
...
...
@@ -222,6 +222,10 @@ bool RunModel(const std::string &model_name,
// Create Engine
int64_t
t0
=
NowMicros
();
#ifdef MODEL_GRAPH_FORMAT_CODE
if
(
model_name
.
empty
())
{
LOG
(
INFO
)
<<
"Please specify model name you want to run"
;
return
false
;
}
create_engine_status
=
CreateMaceEngineFromCode
(
model_name
,
reinterpret_cast
<
const
unsigned
char
*>
(
...
...
@@ -233,6 +237,10 @@ bool RunModel(const std::string &model_name,
&
engine
);
#else
(
void
)(
model_name
);
if
(
model_graph_data
==
nullptr
||
model_weights_data
==
nullptr
)
{
LOG
(
INFO
)
<<
"Please specify model graph file and model data file"
;
return
false
;
}
create_engine_status
=
CreateMaceEngineFromProto
(
reinterpret_cast
<
const
unsigned
char
*>
(
model_graph_data
->
data
()),
...
...
@@ -425,11 +433,19 @@ bool RunModel(const std::string &model_name,
}
int
Main
(
int
argc
,
char
**
argv
)
{
std
::
string
usage
=
"mace run model
\n
usage: "
+
std
::
string
(
argv
[
0
])
+
" [flags]"
;
std
::
string
usage
=
"MACE run model tool, please specify proper arguments.
\n
"
"usage: "
+
std
::
string
(
argv
[
0
])
+
" --help"
;
gflags
::
SetUsageMessage
(
usage
);
gflags
::
ParseCommandLineFlags
(
&
argc
,
&
argv
,
true
);
std
::
vector
<
std
::
string
>
input_names
=
Split
(
FLAGS_input_node
,
','
);
std
::
vector
<
std
::
string
>
output_names
=
Split
(
FLAGS_output_node
,
','
);
if
(
input_names
.
empty
()
||
output_names
.
empty
())
{
LOG
(
INFO
)
<<
gflags
::
ProgramUsage
();
return
0
;
}
LOG
(
INFO
)
<<
"model name: "
<<
FLAGS_model_name
;
LOG
(
INFO
)
<<
"mace version: "
<<
MaceVersion
();
LOG
(
INFO
)
<<
"input node: "
<<
FLAGS_input_node
;
...
...
@@ -448,8 +464,6 @@ int Main(int argc, char **argv) {
LOG
(
INFO
)
<<
"omp_num_threads: "
<<
FLAGS_omp_num_threads
;
LOG
(
INFO
)
<<
"cpu_affinity_policy: "
<<
FLAGS_cpu_affinity_policy
;
std
::
vector
<
std
::
string
>
input_names
=
Split
(
FLAGS_input_node
,
','
);
std
::
vector
<
std
::
string
>
output_names
=
Split
(
FLAGS_output_node
,
','
);
std
::
vector
<
std
::
string
>
input_shapes
=
Split
(
FLAGS_input_shape
,
':'
);
std
::
vector
<
std
::
string
>
output_shapes
=
Split
(
FLAGS_output_shape
,
':'
);
...
...
@@ -463,6 +477,12 @@ int Main(int argc, char **argv) {
for
(
size_t
i
=
0
;
i
<
output_count
;
++
i
)
{
ParseShape
(
output_shapes
[
i
],
&
output_shape_vec
[
i
]);
}
if
(
input_names
.
size
()
!=
input_shape_vec
.
size
()
||
output_names
.
size
()
!=
output_shape_vec
.
size
())
{
LOG
(
INFO
)
<<
"inputs' names do not match inputs' shapes "
"or outputs' names do not match outputs' shapes"
;
return
0
;
}
std
::
vector
<
std
::
string
>
raw_input_data_formats
=
Split
(
FLAGS_input_data_format
,
','
);
std
::
vector
<
std
::
string
>
raw_output_data_formats
=
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录