Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
项目经理老王
Mace
提交
afc440b6
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,发现更多精彩内容 >>
提交
afc440b6
编写于
4月 16, 2019
作者:
L
liutuo
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
update onnx converter
add support splite with num_splits=1
上级
7d3849a5
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
39 addition
and
14 deletion
+39
-14
mace/python/tools/converter_tool/onnx_converter.py
mace/python/tools/converter_tool/onnx_converter.py
+25
-3
mace/python/tools/converter_tool/tensorflow_converter.py
mace/python/tools/converter_tool/tensorflow_converter.py
+14
-11
未找到文件。
mace/python/tools/converter_tool/onnx_converter.py
浏览文件 @
afc440b6
...
...
@@ -120,9 +120,8 @@ OnnxSupportedOps = [
# 'OneHot',
# 'Or',
'PRelu'
,
#
'Pad',
'Pad'
,
'PadContext'
,
'Padding'
,
'PNorm'
,
'Pow'
,
# 'RNN',
...
...
@@ -346,8 +345,8 @@ class OnnxConverter(base_converter.ConverterInterface):
OnnxOpType
.
Neg
.
name
:
self
.
convert_eltwise
,
OnnxOpType
.
Normalize
:
self
.
convert_normalize
,
OnnxOpType
.
Offset
.
name
:
self
.
convert_identity
,
OnnxOpType
.
Pad
.
name
:
self
.
convert_pad
,
OnnxOpType
.
PadContext
.
name
:
self
.
convert_pad_context
,
OnnxOpType
.
Padding
.
name
:
self
.
convert_identity
,
OnnxOpType
.
PNorm
.
name
:
self
.
convert_pnorm
,
OnnxOpType
.
Pow
.
name
:
self
.
convert_eltwise
,
OnnxOpType
.
PRelu
.
name
:
self
.
convert_activation
,
...
...
@@ -982,6 +981,29 @@ class OnnxConverter(base_converter.ConverterInterface):
op
=
self
.
convert_general_op
(
node
)
op
.
type
=
MaceOp
.
BatchNorm
.
name
def
convert_pad
(
self
,
node
):
op
=
self
.
convert_general_op
(
node
)
op
.
type
=
MaceOp
.
Pad
.
name
if
'mode'
in
node
.
attrs
:
mode
=
node
.
attrs
[
'mode'
]
padding_type_arg
=
op
.
arg
.
add
()
padding_type_arg
.
name
=
MaceKeyword
.
mace_padding_type_str
if
mode
==
'reflect'
:
padding_type_arg
.
i
=
PadType
.
REFLECT
elif
mode
==
'edge'
:
padding_type_arg
.
i
=
PadType
.
SYMMETRIC
else
:
padding_type_arg
.
i
=
PadType
.
CONSTANT
if
'pads'
in
node
.
attrs
:
paddings_arg
=
op
.
arg
.
add
()
paddings_arg
.
name
=
MaceKeyword
.
mace_paddings_str
paddings_value
=
node
.
attrs
[
'pads'
]
paddings_arg
.
ints
.
extend
(
paddings_value
)
if
'value'
in
node
.
attrs
:
constant_value_arg
=
op
.
arg
.
add
()
constant_value_arg
.
name
=
MaceKeyword
.
mace_constant_value_str
constant_value_arg
.
f
=
node
.
attrs
[
'value'
]
def
convert_pad_context
(
self
,
node
):
op
=
self
.
convert_general_op
(
node
)
op
.
type
=
MaceOp
.
PadContext
.
name
...
...
mace/python/tools/converter_tool/tensorflow_converter.py
浏览文件 @
afc440b6
...
...
@@ -1004,19 +1004,22 @@ class TensorflowConverter(base_converter.ConverterInterface):
def
convert_split
(
self
,
tf_op
):
op
=
self
.
convert_general_op
(
tf_op
)
op
.
type
=
MaceOp
.
Split
.
name
axis
=
tf_op
.
inputs
[
0
].
eval
().
astype
(
np
.
int32
)
axis
=
len
(
op
.
output_shape
[
0
].
dims
)
+
axis
if
axis
<
0
else
axis
del
op
.
input
[
0
]
axis_arg
=
op
.
arg
.
add
()
axis_arg
.
name
=
MaceKeyword
.
mace_axis_str
axis_arg
.
i
=
axis
num_or_size_splits
=
tf_op
.
get_attr
(
'num_split'
)
if
num_or_size_splits
==
1
:
op
.
type
=
MaceOp
.
Identity
.
name
else
:
op
.
type
=
MaceOp
.
Split
.
name
axis
=
tf_op
.
inputs
[
0
].
eval
().
astype
(
np
.
int32
)
axis
=
len
(
op
.
output_shape
[
0
].
dims
)
+
axis
if
axis
<
0
else
axis
num_split
_arg
=
op
.
arg
.
add
()
num_split_arg
.
name
=
MaceKeyword
.
mace_num_split
_str
num_split_arg
.
i
=
tf_op
.
get_attr
(
'num_split'
)
axis
_arg
=
op
.
arg
.
add
()
axis_arg
.
name
=
MaceKeyword
.
mace_axis
_str
axis_arg
.
i
=
axis
num_split_arg
=
op
.
arg
.
add
()
num_split_arg
.
name
=
MaceKeyword
.
mace_num_split_str
num_split_arg
.
i
=
num_or_size_splits
del
op
.
input
[
0
]
self
.
_skip_tensor
.
add
(
tf_op
.
inputs
[
0
].
name
)
def
convert_fake_quantize
(
self
,
tf_op
):
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录