Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
X2Paddle
提交
0bd1269e
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看板
提交
0bd1269e
编写于
6月 01, 2022
作者:
W
wjj19950828
浏览文件
操作
浏览文件
下载
差异文件
Merge remote-tracking branch 'upstream/develop' into fixed_topk
上级
907c1f58
ea254a8d
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
41 addition
and
46 deletion
+41
-46
x2paddle/op_mapper/onnx2paddle/opset9/opset.py
x2paddle/op_mapper/onnx2paddle/opset9/opset.py
+41
-46
未找到文件。
x2paddle/op_mapper/onnx2paddle/opset9/opset.py
浏览文件 @
0bd1269e
...
...
@@ -262,6 +262,8 @@ class OpSet9():
shape
=
node
.
out_shapes
[
0
]
if
hasattr
(
node
.
weight
,
"shape"
)
and
len
(
node
.
weight
.
shape
)
==
0
:
if
node
.
weight
==
float
(
'inf'
)
or
node
.
weight
==
float
(
'-inf'
):
node
.
weight
=
string
(
node
.
weight
)
self
.
paddle_graph
.
add_layer
(
"paddle.full"
,
inputs
=
{},
...
...
@@ -792,6 +794,8 @@ class OpSet9():
if
len
(
value
)
==
1
:
value
=
value
.
tolist
()
value
=
value
[
0
]
if
value
==
float
(
'inf'
)
or
value
==
float
(
'-inf'
):
value
=
string
(
value
)
self
.
paddle_graph
.
add_layer
(
"paddle.full"
,
inputs
=
{},
...
...
@@ -1195,7 +1199,6 @@ class OpSet9():
@
print_mapping_info
def
ConstantOfShape
(
self
,
node
):
val_shape
=
self
.
graph
.
get_input_node
(
node
,
idx
=
0
,
copy
=
True
)
val_y
=
self
.
graph
.
get_node
(
node
.
layer
.
output
[
0
],
copy
=
True
)
value
=
node
.
get_attr
(
'value'
)
dtype
=
value
.
dtype
...
...
@@ -1204,6 +1207,8 @@ class OpSet9():
'this is not supported'
)
if
len
(
value
)
==
1
:
value
=
value
[
0
]
if
value
==
float
(
'inf'
)
or
value
==
float
(
'-inf'
):
value
=
string
(
value
)
layer_attrs
=
{
'dtype'
:
string
(
dtype
),
'fill_value'
:
value
}
self
.
paddle_graph
.
add_layer
(
"paddle.full"
,
...
...
@@ -1563,11 +1568,15 @@ class OpSet9():
val_x
=
self
.
graph
.
get_input_node
(
node
,
idx
=
0
,
copy
=
True
)
output_shape
=
val_x
.
out_shapes
[
0
]
axis
=
node
.
get_attr
(
'axis'
,
1
)
shape_list
=
[
1
,
1
]
if
axis
==
0
:
for
s
in
output_shape
:
shape_list
[
1
]
*=
s
self
.
paddle_graph
.
add_layer
(
'paddle.reshape'
,
inputs
=
{
"x"
:
val_x
.
name
},
outputs
=
[
node
.
name
],
shape
=
[
1
,
-
1
])
else
:
if
len
(
output_shape
)
!=
0
:
shape_list
=
[
1
,
1
]
for
s
in
output_shape
[:
axis
]:
shape_list
[
0
]
*=
s
for
s
in
output_shape
[
axis
:]:
...
...
@@ -1577,6 +1586,19 @@ class OpSet9():
inputs
=
{
"x"
:
val_x
.
name
},
outputs
=
[
node
.
name
],
shape
=
shape_list
)
else
:
# flatten + reshape
self
.
paddle_graph
.
add_layer
(
"paddle.flatten"
,
inputs
=
{
"input"
:
val_x
.
name
},
outputs
=
[
val_x
.
name
+
"_flatten"
],
start_axis
=
[
0
],
stop_axis
=
[
axis
])
self
.
paddle_graph
.
add_layer
(
'paddle.reshape'
,
inputs
=
{
'x'
:
val_x
.
name
+
"_flatten"
},
outputs
=
[
node
.
name
],
shape
=
[
0
,
-
1
])
@
print_mapping_info
def
Gemm
(
self
,
node
):
...
...
@@ -1846,40 +1868,13 @@ class OpSet9():
val_x
=
self
.
graph
.
get_input_node
(
node
,
idx
=
1
,
copy
=
True
)
val_y
=
self
.
graph
.
get_input_node
(
node
,
idx
=
2
,
copy
=
True
)
not_condition
=
condition
.
name
+
'_not'
self
.
paddle_graph
.
add_layer
(
"paddle.logical_not"
,
inputs
=
{
"x"
:
condition
.
name
},
outputs
=
[
not_condition
])
cast_not_condition
=
not_condition
+
'_cast'
self
.
paddle_graph
.
add_layer
(
"paddle.cast"
,
inputs
=
{
"x"
:
not_condition
},
outputs
=
[
cast_not_condition
],
dtype
=
string
(
val_x
.
dtype
))
cast_condition
=
condition
.
name
+
'_cast'
self
.
paddle_graph
.
add_layer
(
"paddle.cast"
,
inputs
=
{
"x"
:
condition
.
name
},
outputs
=
[
cast_condition
],
dtype
=
string
(
val_x
.
dtype
))
mul_val_x
=
val_x
.
name
+
'_mul'
self
.
paddle_graph
.
add_layer
(
"paddle.multiply"
,
inputs
=
{
'x'
:
val_x
.
name
,
'y'
:
cast_condition
},
outputs
=
[
mul_val_x
])
mul_val_y
=
val_y
.
name
+
'_mul'
self
.
paddle_graph
.
add_layer
(
"paddle.multiply"
,
inputs
=
{
'x'
:
val_y
.
name
,
'y'
:
cast_not_condition
},
outputs
=
[
mul_val_y
])
self
.
paddle_graph
.
add_layer
(
"paddle.add"
,
inputs
=
{
'x'
:
mul_val_x
,
'y'
:
mul_val_y
},
"paddle.where"
,
inputs
=
{
'condition'
:
condition
.
name
,
'x'
:
val_x
.
name
,
'y'
:
val_y
.
name
},
outputs
=
[
node
.
name
])
@
print_mapping_info
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录