Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
X2Paddle
提交
32e91854
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看板
提交
32e91854
编写于
8月 10, 2020
作者:
C
Channingss
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
update
上级
8f9bd9b6
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
16 addition
and
30 deletion
+16
-30
x2paddle/op_mapper/onnx2paddle/onnx_op_mapper.py
x2paddle/op_mapper/onnx2paddle/onnx_op_mapper.py
+0
-7
x2paddle/op_mapper/onnx2paddle/opset9/opset.py
x2paddle/op_mapper/onnx2paddle/opset9/opset.py
+16
-23
未找到文件。
x2paddle/op_mapper/onnx2paddle/onnx_op_mapper.py
浏览文件 @
32e91854
...
...
@@ -53,21 +53,14 @@ class ONNXOpMapper(OpMapper):
def
op_checker
(
self
):
unsupported_ops
=
set
()
contain_ops
=
set
()
for
node_name
in
self
.
graph
.
topo_sort
:
node
=
self
.
graph
.
get_node
(
node_name
)
op
=
node
.
layer_type
contain_ops
.
add
(
op
)
if
not
hasattr
(
self
.
opset
,
op
)
and
\
op
not
in
self
.
opset
.
default_op_mapping
and
\
op
not
in
custom_layers
and
\
op
not
in
self
.
opset
.
elementwise_ops
:
unsupported_ops
.
add
(
op
)
print
(
"There are {} ops need converted , list as below"
.
format
(
len
(
contain_ops
)))
for
op
in
contain_ops
:
print
(
op
)
if
len
(
unsupported_ops
)
==
0
:
return
True
else
:
...
...
x2paddle/op_mapper/onnx2paddle/opset9/opset.py
浏览文件 @
32e91854
...
...
@@ -46,7 +46,7 @@ def _is_static_shape(shape):
for
dim
in
shape
:
if
dim
<
0
:
negtive_dims
+=
1
if
dim
!=
-
1
:
if
dim
<
-
1
:
error_dims
+=
1
if
negtive_dims
>
1
:
return
False
...
...
@@ -512,6 +512,19 @@ class OpSet9():
inputs
=
val_x
,
output
=
node
,
param_attr
=
{
'shape'
:
[
1
]})
else
:
if
str
(
val_x
.
dtype
)
==
'bool'
:
val_x_cast
=
val_x
.
layer_name
+
'_cast'
node
.
fluid_code
.
add_layer
(
'cast'
,
inputs
=
val_x
,
output
=
val_x_cast
,
param_attr
=
{
'dtype'
:
string
(
'int64'
)})
node
.
fluid_code
.
add_layer
(
'unsqueeze'
,
inputs
=
val_x_cast
,
output
=
node
,
param_attr
=
attr
)
else
:
node
.
fluid_code
.
add_layer
(
'unsqueeze'
,
inputs
=
val_x
,
output
=
node
,
param_attr
=
attr
)
...
...
@@ -783,9 +796,6 @@ class OpSet9():
param_attr
=
None
)
else
:
input_inner_indices
=
node
.
layer_name
+
'_input_inner_indices'
print
(
'val_x shape:'
,
val_x
.
out_shapes
[
0
])
print
(
'indices shape:'
,
indices
.
out_shapes
[
0
])
print
(
'updates shape:'
,
updates
.
out_shapes
[
0
])
node
.
fluid_code
.
add_layer
(
'scatter_nd'
,
inputs
=
{
...
...
@@ -1037,28 +1047,11 @@ class OpSet9():
node
.
fluid_code
.
add_layer
(
'cast'
,
inputs
=
val_input
,
output
=
node
,
param_attr
=
attr
)
@
print_mapping_info
def
Cast
(
self
,
node
):
val_input
=
self
.
graph
.
get_input_node
(
node
,
idx
=
0
,
copy
=
True
)
val_output
=
self
.
graph
.
get_node
(
node
.
layer
.
output
[
0
],
copy
=
True
)
dtype
=
node
.
get_attr
(
'to'
)
if
not
isinstance
(
dtype
,
np
.
dtype
):
dtype
=
TENSOR_TYPE_TO_NP_TYPE
[
dtype
]
output_dtype
=
val_output
.
dtype
if
output_dtype
:
assert
dtype
==
output_dtype
,
'dtype of to unmatches output'
attr
=
{
'dtype'
:
string
(
dtype
)}
node
.
fluid_code
.
add_layer
(
'cast'
,
inputs
=
val_input
,
output
=
node
,
param_attr
=
attr
)
@
print_mapping_info
def
Not
(
self
,
node
):
val_input
=
self
.
graph
.
get_input_node
(
node
,
idx
=
0
,
copy
=
True
)
node
.
fluid_code
.
add_layer
(
'logical_not'
,
inputs
=
val_input
,
output
=
node
)
val_output
=
self
.
graph
.
get_node
(
node
.
layer
.
output
[
0
],
copy
=
True
)
node
.
fluid_code
.
add_layer
(
'cast'
,
inputs
=
node
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录