Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
X2Paddle
提交
14889935
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看板
提交
14889935
编写于
1月 07, 2021
作者:
S
SunAhong1993
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add prelu
上级
ba5a3314
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
60 addition
and
24 deletion
+60
-24
x2paddle/op_mapper/dygraph/onnx2paddle/opset9/opset.py
x2paddle/op_mapper/dygraph/onnx2paddle/opset9/opset.py
+41
-13
x2paddle/op_mapper/static/onnx2paddle/opset9/opset.py
x2paddle/op_mapper/static/onnx2paddle/opset9/opset.py
+19
-11
未找到文件。
x2paddle/op_mapper/dygraph/onnx2paddle/opset9/opset.py
浏览文件 @
14889935
...
@@ -1359,21 +1359,49 @@ class OpSet9():
...
@@ -1359,21 +1359,49 @@ class OpSet9():
elif
len
(
shape_slope
)
>
2
:
elif
len
(
shape_slope
)
>
2
:
raise
Exception
(
"The 'element' mode is not supported yet!"
)
raise
Exception
(
"The 'element' mode is not supported yet!"
)
if
mode
==
'channel'
and
len
(
shape_slope
)
==
1
:
if
mode
==
"element"
:
# paddle params shape need be [1, channel]
self
.
paddle_graph
.
add_layer
(
slope_data
=
_const_weight_or_none
(
val_slope
)
"paddle.zeros"
,
slope_data
=
np
.
reshape
(
slope_data
,
[
1
]
+
shape_slope
)
inputs
=
{},
self
.
weights
[
val_slope
.
name
]
=
slope_data
outputs
=
[
output_name
+
"__zeros"
],
num_parameters
=
val_x
.
out_shapes
[
0
][
1
]
shape
=
shape_slope
,
dtype
=
string
(
node
.
dtype
))
self
.
paddle_graph
.
add_layer
(
"paddle.maximum"
,
inputs
=
{
"x"
:
val_x
.
name
,
"y"
:
output_name
+
"__zeros"
},
outputs
=
[
output_name
+
"__max"
])
self
.
paddle_graph
.
add_layer
(
"paddle.minimum"
,
inputs
=
{
"x"
:
val_x
.
name
,
"y"
:
output_name
+
"__zeros"
},
outputs
=
[
output_name
+
"__max"
])
self
.
paddle_graph
.
add_layer
(
"paddle.multiply"
,
inputs
=
{
"x"
:
val_slope
.
name
,
"y"
:
output_name
+
"__min"
},
outputs
=
[
output_name
+
"__mul"
])
self
.
paddle_graph
.
add_layer
(
"paddle.add"
,
inputs
=
{
"x"
:
output_name
+
"__max"
,
"y"
:
output_name
+
"__mul"
},
outputs
=
[
output_name
])
else
:
else
:
num_parameters
=
1
if
mode
==
'channel'
and
len
(
shape_slope
)
==
1
:
# paddle params shape need be [1, channel]
slope_data
=
_const_weight_or_none
(
val_slope
)
slope_data
=
np
.
reshape
(
slope_data
,
[
1
]
+
shape_slope
)
self
.
weights
[
val_slope
.
name
]
=
slope_data
num_parameters
=
val_x
.
out_shapes
[
0
][
1
]
else
:
num_parameters
=
1
self
.
paddle_graph
.
add_layer
(
self
.
paddle_graph
.
add_layer
(
"paddle.nn.PReLU"
,
"paddle.nn.PReLU"
,
inputs
=
{
"x"
:
val_x
.
name
},
inputs
=
{
"x"
:
val_x
.
name
},
outputs
=
layer_outputs
,
outputs
=
layer_outputs
,
num_parameters
=
num_parameters
,
num_parameters
=
num_parameters
,
weight_attr
=
string
(
val_slope
.
name
))
weight_attr
=
string
(
val_slope
.
name
))
@
print_mapping_info
@
print_mapping_info
def
Squeeze
(
self
,
node
):
def
Squeeze
(
self
,
node
):
...
...
x2paddle/op_mapper/static/onnx2paddle/opset9/opset.py
浏览文件 @
14889935
...
@@ -1336,17 +1336,25 @@ class OpSet9():
...
@@ -1336,17 +1336,25 @@ class OpSet9():
elif
len
(
shape_slope
)
>
2
:
elif
len
(
shape_slope
)
>
2
:
raise
Exception
(
"The 'element' mode is not supported yet!"
)
raise
Exception
(
"The 'element' mode is not supported yet!"
)
if
mode
==
'channel'
and
len
(
shape_slope
)
==
1
:
if
mode
==
"element"
:
# paddle params shape need be [1, channel]
self
.
paddle_graph
.
add_layer
(
slope_data
=
_const_weight_or_none
(
val_slope
)
"paddle.static.nn.prelu"
,
slope_data
=
np
.
reshape
(
slope_data
,
[
1
]
+
shape_slope
)
inputs
=
{
"x"
:
val_x
.
name
,
self
.
params
[
val_slope
.
name
]
=
slope_data
"param_attr"
:
val_slope
.
name
},
outputs
=
[
node
.
name
],
self
.
paddle_graph
.
add_layer
(
mode
=
"element"
)
"paddle.nn.functional.prelu"
,
else
:
inputs
=
{
"x"
:
val_x
.
name
,
if
mode
==
'channel'
and
len
(
shape_slope
)
==
1
:
"weight"
:
val_slope
.
name
},
# paddle params shape need be [1, channel]
outputs
=
[
node
.
name
])
slope_data
=
_const_weight_or_none
(
val_slope
)
slope_data
=
np
.
reshape
(
slope_data
,
[
1
]
+
shape_slope
)
self
.
params
[
val_slope
.
name
]
=
slope_data
self
.
paddle_graph
.
add_layer
(
"paddle.nn.functional.prelu"
,
inputs
=
{
"x"
:
val_x
.
name
,
"weight"
:
val_slope
.
name
},
outputs
=
[
node
.
name
])
@
print_mapping_info
@
print_mapping_info
def
Squeeze
(
self
,
node
):
def
Squeeze
(
self
,
node
):
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录