Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
项目经理老王
Mace
提交
89d36182
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,发现更多精彩内容 >>
提交
89d36182
编写于
8月 22, 2019
作者:
李
李寅
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'fix-converter-bugs' into 'master'
fix converter bugs See merge request !1182
上级
3ff07fc8
97032b47
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
31 addition
and
6 deletion
+31
-6
tools/python/convert.py
tools/python/convert.py
+30
-5
tools/python/utils/config_parser.py
tools/python/utils/config_parser.py
+1
-1
未找到文件。
tools/python/convert.py
浏览文件 @
89d36182
...
...
@@ -176,13 +176,28 @@ def convert_model(conf):
input_count
=
len
(
input_tensors
)
input_data_types
=
[
data_type_map
[
dt
]
for
dt
in
to_list
(
conf
.
get
(
"input_data_types"
,
[
"float32"
]
*
input_count
))]
[
"float32"
]))]
if
len
(
input_data_types
)
==
1
and
input_count
>
1
:
input_data_types
=
[
input_data_types
[
0
]]
*
input_count
mace_check
(
len
(
input_data_types
)
==
input_count
,
"the number of input_data_types should be "
"the same as input tensors"
)
input_data_formats
=
[
data_format_map
[
df
]
for
df
in
to_list
(
conf
.
get
(
"input_data_formats"
,
[
"NHWC"
]
*
input_count
))]
[
"NHWC"
]))]
if
len
(
input_data_formats
)
==
1
and
input_count
>
1
:
input_data_formats
=
[
input_data_formats
[
0
]]
*
input_count
mace_check
(
len
(
input_data_formats
)
==
input_count
,
"the number of input_data_formats should be "
"the same as input tensors"
)
input_ranges
=
[
parse_float_array_from_str
(
r
)
for
r
in
to_list
(
conf
.
get
(
"input_ranges"
,
[
"-1.0,1.0"
]
*
input_count
))]
[
"-1.0,1.0"
]))]
if
len
(
input_ranges
)
==
1
and
input_count
>
1
:
input_ranges
=
[
input_ranges
[
0
]]
*
input_count
mace_check
(
len
(
input_ranges
)
==
input_count
,
"the number of input_ranges should be "
"the same as input tensors"
)
for
i
in
range
(
len
(
input_tensors
)):
input_node
=
cvt
.
NodeInfo
()
input_node
.
name
=
input_tensors
[
i
]
...
...
@@ -204,10 +219,20 @@ def convert_model(conf):
output_count
=
len
(
output_tensors
)
output_data_types
=
[
data_type_map
[
dt
]
for
dt
in
to_list
(
conf
.
get
(
"output_data_types"
,
[
"float32"
]
*
output_count
))]
[
"float32"
]))]
if
len
(
output_data_types
)
==
1
and
output_count
>
1
:
output_data_types
=
[
output_data_types
[
0
]]
*
output_count
mace_check
(
len
(
output_data_types
)
==
output_count
,
"the number of output_data_types should be "
"the same as output tensors"
)
output_data_formats
=
[
data_format_map
[
df
]
for
df
in
to_list
(
conf
.
get
(
"output_data_formats"
,
[
"NHWC"
]
*
output_count
))]
[
"NHWC"
]))]
if
len
(
output_data_formats
)
==
1
and
output_count
>
1
:
output_data_formats
=
[
output_data_formats
[
0
]]
*
output_count
mace_check
(
len
(
output_data_formats
)
==
output_count
,
"the number of output_data_formats should be "
"the same as output tensors"
)
for
i
in
range
(
len
(
output_tensors
)):
output_node
=
cvt
.
NodeInfo
()
output_node
.
name
=
output_tensors
[
i
]
...
...
tools/python/utils/config_parser.py
浏览文件 @
89d36182
...
...
@@ -46,7 +46,7 @@ CPP_KEYWORDS = [
def
sanitize_load
(
s
):
# do not let yaml parse ON/OFF to boolean
for
w
in
[
"ON"
,
"OFF"
,
"on"
,
"off"
]:
s
=
re
.
sub
(
r
":\s+"
+
w
,
r
": '"
+
w
+
"'"
,
s
)
s
=
re
.
sub
(
r
":\s+"
+
w
+
"$"
,
r
": '"
+
w
+
"'"
,
s
)
# sub ${} to env value
s
=
re
.
sub
(
r
"\${(\w+)}"
,
lambda
x
:
os
.
environ
[
x
.
group
(
1
)],
s
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录