Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
X2Paddle
提交
57786e37
X
X2Paddle
项目概览
PaddlePaddle
/
X2Paddle
大约 1 年 前同步成功
通知
328
Star
698
Fork
167
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
26
列表
看板
标记
里程碑
合并请求
4
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
X
X2Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
26
Issue
26
列表
看板
标记
里程碑
合并请求
4
合并请求
4
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
57786e37
编写于
10月 09, 2021
作者:
Y
yeliang2258
提交者:
GitHub
10月 09, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add 5 operators and fix 2 operators (#682)
* support movenet * update * update * update reducesum * update max and min
上级
f909d314
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
148 addition
and
16 deletion
+148
-16
x2paddle/op_mapper/onnx2paddle/opset9/opset.py
x2paddle/op_mapper/onnx2paddle/opset9/opset.py
+148
-16
未找到文件。
x2paddle/op_mapper/onnx2paddle/opset9/opset.py
浏览文件 @
57786e37
...
@@ -124,27 +124,22 @@ class OpSet9():
...
@@ -124,27 +124,22 @@ class OpSet9():
'ReduceMean'
:
[
'ReduceMean'
:
[
'paddle.mean'
,
dict
(
'paddle.mean'
,
dict
(
axes
=
'axis'
,
keepdims
=
'keepdim'
),
dict
(
axes
=
'axis'
,
keepdims
=
'keepdim'
),
dict
(
axes
=
None
,
keepdims
=
1
)
axes
=
None
,
keepdims
=
True
)
],
'ReduceSum'
:
[
'paddle.sum'
,
dict
(
axes
=
'axis'
,
keepdims
=
'keepdim'
),
dict
(
axes
=
None
,
keepdims
=
1
)
],
],
'ReduceMin'
:
[
'ReduceMin'
:
[
'paddle.min'
,
dict
(
'paddle.min'
,
dict
(
axes
=
'axis'
,
keepdims
=
'keepdim'
),
dict
(
axes
=
'axis'
,
keepdims
=
'keepdim'
),
dict
(
axes
=
None
,
keepdim
=
1
)
axes
=
None
,
keepdim
=
True
)
],
],
'ReduceMax'
:
[
'ReduceMax'
:
[
'paddle.max'
,
dict
(
'paddle.max'
,
dict
(
axes
=
'axis'
,
keepdims
=
'keepdim'
),
dict
(
axes
=
'axis'
,
keepdims
=
'keepdim'
),
dict
(
axes
=
None
,
keepdim
=
1
)
axes
=
None
,
keepdim
=
True
)
],
],
'ReduceProd'
:
[
'ReduceProd'
:
[
'paddle.prod'
,
dict
(
'paddle.prod'
,
dict
(
axes
=
'axis'
,
keepdims
=
'keepdim'
),
dict
(
axes
=
'axis'
,
keepdims
=
'keepdim'
),
dict
(
axes
=
None
,
keepdim
=
1
)
axes
=
None
,
keepdim
=
True
)
],
],
# active function
# active function
'Relu'
:
[
'paddle.nn.ReLU'
],
'Relu'
:
[
'paddle.nn.ReLU'
],
...
@@ -663,7 +658,9 @@ class OpSet9():
...
@@ -663,7 +658,9 @@ class OpSet9():
def
Unsqueeze
(
self
,
node
):
def
Unsqueeze
(
self
,
node
):
val_x
=
self
.
graph
.
get_input_node
(
node
,
idx
=
0
,
copy
=
True
)
val_x
=
self
.
graph
.
get_input_node
(
node
,
idx
=
0
,
copy
=
True
)
axes
=
node
.
get_attr
(
'axes'
)
axes
=
node
.
get_attr
(
'axes'
)
layer_attrs
=
{
'axis'
:
axes
}
if
axes
is
None
:
axes
=
self
.
graph
.
get_input_node
(
node
,
idx
=
1
,
copy
=
True
)
if
len
(
val_x
.
out_shapes
[
0
])
==
0
:
if
len
(
val_x
.
out_shapes
[
0
])
==
0
:
if
node
.
name
:
if
node
.
name
:
self
.
paddle_graph
.
add_layer
(
self
.
paddle_graph
.
add_layer
(
...
@@ -672,11 +669,18 @@ class OpSet9():
...
@@ -672,11 +669,18 @@ class OpSet9():
outputs
=
[
node
.
name
],
outputs
=
[
node
.
name
],
shape
=
[
1
])
shape
=
[
1
])
else
:
else
:
self
.
paddle_graph
.
add_layer
(
if
isinstance
(
axes
,
list
)
or
isinstance
(
axes
,
tuple
):
'paddle.unsqueeze'
,
self
.
paddle_graph
.
add_layer
(
inputs
=
{
"x"
:
val_x
.
name
},
'paddle.unsqueeze'
,
outputs
=
[
node
.
name
],
inputs
=
{
"x"
:
val_x
.
name
},
**
layer_attrs
)
axis
=
axes
,
outputs
=
[
node
.
name
])
else
:
self
.
paddle_graph
.
add_layer
(
'paddle.unsqueeze'
,
inputs
=
{
"x"
:
val_x
.
name
,
"axis"
:
axes
.
name
},
outputs
=
[
node
.
name
])
@
print_mapping_info
@
print_mapping_info
def
Shrink
(
self
,
node
):
def
Shrink
(
self
,
node
):
...
@@ -1183,11 +1187,135 @@ class OpSet9():
...
@@ -1183,11 +1187,135 @@ class OpSet9():
else
:
else
:
raise
Exception
(
"max_value or min_value can't be None"
)
raise
Exception
(
"max_value or min_value can't be None"
)
@
print_mapping_info
def
ReduceSum
(
self
,
node
):
val_x
=
self
.
graph
.
get_input_node
(
node
,
idx
=
0
,
copy
=
True
)
if
len
(
node
.
inputs
)
==
1
:
keepdims
=
node
.
get_attr
(
'keepdims'
)
if
keepdims
is
None
:
keepdims
=
True
axes_value
=
node
.
get_attr
(
'axes'
)
layer_attrs
=
{
'axis'
:
axes_value
,
'keepdim'
:
keepdims
}
self
.
paddle_graph
.
add_layer
(
'paddle.sum'
,
inputs
=
{
"x"
:
val_x
.
name
},
outputs
=
[
node
.
name
],
**
layer_attrs
)
else
:
axes
=
self
.
graph
.
get_input_node
(
node
,
idx
=
1
,
copy
=
True
)
axes_value
=
_const_weight_or_none
(
axes
)
if
axes_value
.
shape
==
(
1
,
):
axes_value
=
axes_value
[
0
]
keepdims
=
node
.
get_attr
(
'keepdims'
)
if
keepdims
is
None
:
layer_attrs
=
{
'axis'
:
axes_value
}
else
:
layer_attrs
=
{
'axis'
:
axes_value
,
'keepdim'
:
keepdims
}
self
.
paddle_graph
.
add_layer
(
'paddle.sum'
,
inputs
=
{
"x"
:
val_x
.
name
},
outputs
=
[
node
.
name
],
**
layer_attrs
)
@
print_mapping_info
def
Max
(
self
,
node
):
if
len
(
node
.
inputs
)
==
2
:
val_x
=
self
.
graph
.
get_input_node
(
node
,
idx
=
0
,
copy
=
True
)
val_y
=
self
.
graph
.
get_input_node
(
node
,
idx
=
1
,
copy
=
True
)
self
.
paddle_graph
.
add_layer
(
"paddle.maximum"
,
inputs
=
{
"x"
:
val_x
.
name
,
"y"
:
val_y
.
name
},
outputs
=
[
node
.
name
])
else
:
val_x
=
self
.
graph
.
get_input_node
(
node
,
idx
=
0
,
copy
=
True
)
temp_name
=
"max_"
for
i
in
range
(
1
,
len
(
node
.
inputs
)):
val_y
=
self
.
graph
.
get_input_node
(
node
,
idx
=
i
,
copy
=
True
)
temp_name
=
temp_name
+
str
(
i
)
if
i
==
len
(
node
.
inputs
)
-
1
:
self
.
paddle_graph
.
add_layer
(
"paddle.maximum"
,
inputs
=
{
"x"
:
val_x
.
name
,
"y"
:
val_y
.
name
},
outputs
=
[
node
.
name
])
else
:
self
.
paddle_graph
.
add_layer
(
"paddle.maximum"
,
inputs
=
{
"x"
:
val_x
.
name
,
"y"
:
val_y
.
name
},
outputs
=
[
temp_name
])
val_x
.
name
=
temp_name
@
print_mapping_info
def
Min
(
self
,
node
):
if
len
(
node
.
inputs
)
==
2
:
val_x
=
self
.
graph
.
get_input_node
(
node
,
idx
=
0
,
copy
=
True
)
val_y
=
self
.
graph
.
get_input_node
(
node
,
idx
=
1
,
copy
=
True
)
self
.
paddle_graph
.
add_layer
(
"paddle.minimum"
,
inputs
=
{
"x"
:
val_x
.
name
,
"y"
:
val_y
.
name
},
outputs
=
[
node
.
name
])
else
:
val_x
=
self
.
graph
.
get_input_node
(
node
,
idx
=
0
,
copy
=
True
)
temp_name
=
"min_"
for
i
in
range
(
1
,
len
(
node
.
inputs
)):
val_y
=
self
.
graph
.
get_input_node
(
node
,
idx
=
i
,
copy
=
True
)
temp_name
=
temp_name
+
str
(
i
)
if
i
==
len
(
node
.
inputs
)
-
1
:
self
.
paddle_graph
.
add_layer
(
"paddle.minimum"
,
inputs
=
{
"x"
:
val_x
.
name
,
"y"
:
val_y
.
name
},
outputs
=
[
node
.
name
])
else
:
self
.
paddle_graph
.
add_layer
(
"paddle.minimum"
,
inputs
=
{
"x"
:
val_x
.
name
,
"y"
:
val_y
.
name
},
outputs
=
[
temp_name
])
val_x
.
name
=
temp_name
@
print_mapping_info
def
GreaterOrEqual
(
self
,
node
):
val_x
=
self
.
graph
.
get_input_node
(
node
,
idx
=
0
,
copy
=
True
)
val_y
=
self
.
graph
.
get_input_node
(
node
,
idx
=
1
,
copy
=
True
)
self
.
paddle_graph
.
add_layer
(
"paddle.greater_equal"
,
inputs
=
{
"x"
:
val_x
.
name
,
"y"
:
val_y
.
name
},
outputs
=
[
node
.
name
])
@
print_mapping_info
def
GatherND
(
self
,
node
):
print
(
len
(
node
.
inputs
),
node
.
inputs
)
val_x
=
self
.
graph
.
get_input_node
(
node
,
idx
=
0
,
copy
=
True
)
val_y
=
self
.
graph
.
get_input_node
(
node
,
idx
=
1
,
copy
=
True
)
self
.
paddle_graph
.
add_layer
(
"paddle.gather_nd"
,
inputs
=
{
"x"
:
val_x
.
name
,
"index"
:
val_y
.
name
},
outputs
=
[
node
.
name
])
@
print_mapping_info
def
And
(
self
,
node
):
val_x
=
self
.
graph
.
get_input_node
(
node
,
idx
=
0
,
copy
=
True
)
val_y
=
self
.
graph
.
get_input_node
(
node
,
idx
=
1
,
copy
=
True
)
self
.
paddle_graph
.
add_layer
(
"paddle.logical_and"
,
inputs
=
{
"x"
:
val_x
.
name
,
"y"
:
val_y
.
name
},
outputs
=
[
node
.
name
])
@
print_mapping_info
@
print_mapping_info
def
Split
(
self
,
node
):
def
Split
(
self
,
node
):
val_x
=
self
.
graph
.
get_input_node
(
node
,
idx
=
0
,
copy
=
True
)
val_x
=
self
.
graph
.
get_input_node
(
node
,
idx
=
0
,
copy
=
True
)
paddle_op
=
'split'
paddle_op
=
'split'
split
=
node
.
get_attr
(
'split'
)
split
=
node
.
get_attr
(
'split'
)
if
split
is
None
:
split
=
len
(
node
.
outputs
)
axis
=
node
.
get_attr
(
'axis'
,
0
)
axis
=
node
.
get_attr
(
'axis'
,
0
)
layer_attrs
=
{
layer_attrs
=
{
'num_or_sections'
:
split
,
'num_or_sections'
:
split
,
...
@@ -1201,7 +1329,11 @@ class OpSet9():
...
@@ -1201,7 +1329,11 @@ class OpSet9():
for
i
in
range
(
len
(
split
)):
for
i
in
range
(
len
(
split
)):
outputs_list
.
append
(
"{}_p{}"
.
format
(
node
.
layer_name
,
i
))
outputs_list
.
append
(
"{}_p{}"
.
format
(
node
.
layer_name
,
i
))
else
:
else
:
outputs_list
.
append
(
node
.
name
)
if
len
(
node
.
outputs
)
==
1
:
outputs_list
.
append
(
node
.
name
)
else
:
for
i
in
range
(
len
(
node
.
outputs
)):
outputs_list
.
append
(
"{}_p{}"
.
format
(
node
.
layer_name
,
i
))
self
.
paddle_graph
.
add_layer
(
self
.
paddle_graph
.
add_layer
(
'paddle.split'
,
'paddle.split'
,
inputs
=
{
"x"
:
val_x
.
name
},
inputs
=
{
"x"
:
val_x
.
name
},
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录