Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
X2Paddle
提交
c6a79644
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看板
提交
c6a79644
编写于
7月 22, 2022
作者:
W
wjj19950828
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
support 7-15 opset version
上级
ab0cdacc
变更
12
显示空白变更内容
内联
并排
Showing
12 changed file
with
263 addition
and
76 deletion
+263
-76
x2paddle/op_mapper/onnx2paddle/onnx_op_mapper.py
x2paddle/op_mapper/onnx2paddle/onnx_op_mapper.py
+14
-7
x2paddle/op_mapper/onnx2paddle/opset10.py
x2paddle/op_mapper/onnx2paddle/opset10.py
+20
-0
x2paddle/op_mapper/onnx2paddle/opset11.py
x2paddle/op_mapper/onnx2paddle/opset11.py
+20
-0
x2paddle/op_mapper/onnx2paddle/opset12.py
x2paddle/op_mapper/onnx2paddle/opset12.py
+20
-0
x2paddle/op_mapper/onnx2paddle/opset13.py
x2paddle/op_mapper/onnx2paddle/opset13.py
+20
-0
x2paddle/op_mapper/onnx2paddle/opset14.py
x2paddle/op_mapper/onnx2paddle/opset14.py
+20
-0
x2paddle/op_mapper/onnx2paddle/opset15.py
x2paddle/op_mapper/onnx2paddle/opset15.py
+20
-0
x2paddle/op_mapper/onnx2paddle/opset7.py
x2paddle/op_mapper/onnx2paddle/opset7.py
+20
-0
x2paddle/op_mapper/onnx2paddle/opset8.py
x2paddle/op_mapper/onnx2paddle/opset8.py
+20
-0
x2paddle/op_mapper/onnx2paddle/opset9.py
x2paddle/op_mapper/onnx2paddle/opset9.py
+20
-0
x2paddle/op_mapper/onnx2paddle/opset9/__init__.py
x2paddle/op_mapper/onnx2paddle/opset9/__init__.py
+0
-1
x2paddle/op_mapper/onnx2paddle/opset_legacy.py
x2paddle/op_mapper/onnx2paddle/opset_legacy.py
+69
-68
未找到文件。
x2paddle/op_mapper/onnx2paddle/onnx_op_mapper.py
浏览文件 @
c6a79644
# Copyright (c) 20
19
PaddlePaddle Authors. All Rights Reserved.
# Copyright (c) 20
22
PaddlePaddle Authors. All Rights Reserved.
#
#
# Licensed under the Apache License, Version 2.0 (the "License"
# Licensed under the Apache License, Version 2.0 (the "License"
# you may not use this file except in compliance with the License.
# you may not use this file except in compliance with the License.
...
@@ -13,14 +13,22 @@
...
@@ -13,14 +13,22 @@
# limitations under the License.
# limitations under the License.
import
sys
import
sys
from
x2paddle.op_mapper.onnx2paddle.opset9
import
OpSet9
from
.opset7
import
OpSet7
from
.opset8
import
OpSet8
from
.opset9
import
OpSet9
from
.opset10
import
OpSet10
from
.opset11
import
OpSet11
from
.opset12
import
OpSet12
from
.opset13
import
OpSet13
from
.opset14
import
OpSet14
from
.opset15
import
OpSet15
from
x2paddle.decoder.onnx_decoder
import
ONNXGraphNode
from
x2paddle.decoder.onnx_decoder
import
ONNXGraphNode
from
x2paddle.core.program
import
PaddleGraph
from
x2paddle.core.program
import
PaddleGraph
class
ONNXOpMapper
():
class
ONNXOpMapper
():
def
__init__
(
self
,
decoder
):
def
__init__
(
self
,
decoder
):
self
.
support_op_sets
=
[
9
,
]
self
.
support_op_sets
=
[
7
,
8
,
9
,
10
,
11
,
12
,
13
,
14
,
15
]
self
.
default_op_set
=
9
self
.
default_op_set
=
9
self
.
graph
=
decoder
.
graph
self
.
graph
=
decoder
.
graph
self
.
paddle_graph
=
PaddleGraph
(
parent_layer
=
None
,
source_type
=
"onnx"
)
self
.
paddle_graph
=
PaddleGraph
(
parent_layer
=
None
,
source_type
=
"onnx"
)
...
@@ -84,8 +92,7 @@ class ONNXOpMapper():
...
@@ -84,8 +92,7 @@ class ONNXOpMapper():
else
:
else
:
break
break
opset
=
'OpSet'
+
str
(
run_op_set
)
opset
=
'OpSet'
+
str
(
run_op_set
)
print
(
print
(
'Now, onnx2paddle support convert onnx model opset_verison {}, '
'Now, onnx2paddle support convert onnx model opset_verison {},'
'opset_verison of your onnx model is {}.'
'opset_verison of your onnx model is {}, automatically treated as op_set: {}.'
.
format
(
self
.
support_op_sets
,
decoder
.
op_set
))
.
format
(
self
.
support_op_sets
,
decoder
.
op_set
,
run_op_set
))
return
eval
(
opset
)(
decoder
,
self
.
paddle_graph
)
return
eval
(
opset
)(
decoder
,
self
.
paddle_graph
)
x2paddle/op_mapper/onnx2paddle/opset10.py
0 → 100644
浏览文件 @
c6a79644
# Copyright (c) 2022 PaddlePaddle Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from
.opset_legacy
import
OpSet
class
OpSet10
(
OpSet
):
def
__init__
(
self
,
decoder
,
paddle_graph
):
super
(
OpSet10
,
self
).
__init__
(
decoder
,
paddle_graph
)
x2paddle/op_mapper/onnx2paddle/opset11.py
0 → 100644
浏览文件 @
c6a79644
# Copyright (c) 2022 PaddlePaddle Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from
.opset_legacy
import
OpSet
class
OpSet11
(
OpSet
):
def
__init__
(
self
,
decoder
,
paddle_graph
):
super
(
OpSet11
,
self
).
__init__
(
decoder
,
paddle_graph
)
x2paddle/op_mapper/onnx2paddle/opset12.py
0 → 100644
浏览文件 @
c6a79644
# Copyright (c) 2022 PaddlePaddle Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from
.opset_legacy
import
OpSet
class
OpSet12
(
OpSet
):
def
__init__
(
self
,
decoder
,
paddle_graph
):
super
(
OpSet12
,
self
).
__init__
(
decoder
,
paddle_graph
)
x2paddle/op_mapper/onnx2paddle/opset13.py
0 → 100644
浏览文件 @
c6a79644
# Copyright (c) 2022 PaddlePaddle Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from
.opset_legacy
import
OpSet
class
OpSet13
(
OpSet
):
def
__init__
(
self
,
decoder
,
paddle_graph
):
super
(
OpSet13
,
self
).
__init__
(
decoder
,
paddle_graph
)
x2paddle/op_mapper/onnx2paddle/opset14.py
0 → 100644
浏览文件 @
c6a79644
# Copyright (c) 2022 PaddlePaddle Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from
.opset_legacy
import
OpSet
class
OpSet14
(
OpSet
):
def
__init__
(
self
,
decoder
,
paddle_graph
):
super
(
OpSet14
,
self
).
__init__
(
decoder
,
paddle_graph
)
x2paddle/op_mapper/onnx2paddle/opset15.py
0 → 100644
浏览文件 @
c6a79644
# Copyright (c) 2022 PaddlePaddle Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from
.opset_legacy
import
OpSet
class
OpSet15
(
OpSet
):
def
__init__
(
self
,
decoder
,
paddle_graph
):
super
(
OpSet15
,
self
).
__init__
(
decoder
,
paddle_graph
)
x2paddle/op_mapper/onnx2paddle/opset7.py
0 → 100644
浏览文件 @
c6a79644
# Copyright (c) 2022 PaddlePaddle Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from
.opset_legacy
import
OpSet
class
OpSet7
(
OpSet
):
def
__init__
(
self
,
decoder
,
paddle_graph
):
super
(
OpSet7
,
self
).
__init__
(
decoder
,
paddle_graph
)
x2paddle/op_mapper/onnx2paddle/opset8.py
0 → 100644
浏览文件 @
c6a79644
# Copyright (c) 2022 PaddlePaddle Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from
.opset_legacy
import
OpSet
class
OpSet8
(
OpSet
):
def
__init__
(
self
,
decoder
,
paddle_graph
):
super
(
OpSet8
,
self
).
__init__
(
decoder
,
paddle_graph
)
x2paddle/op_mapper/onnx2paddle/opset9.py
0 → 100644
浏览文件 @
c6a79644
# Copyright (c) 2022 PaddlePaddle Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from
.opset_legacy
import
OpSet
class
OpSet9
(
OpSet
):
def
__init__
(
self
,
decoder
,
paddle_graph
):
super
(
OpSet9
,
self
).
__init__
(
decoder
,
paddle_graph
)
x2paddle/op_mapper/onnx2paddle/opset9/__init__.py
已删除
100644 → 0
浏览文件 @
ab0cdacc
from
.opset
import
OpSet9
x2paddle/op_mapper/onnx2paddle/opset
9/opset
.py
→
x2paddle/op_mapper/onnx2paddle/opset
_legacy
.py
100755 → 100644
浏览文件 @
c6a79644
# Copyright (c) 20
19
PaddlePaddle Authors. All Rights Reserved.
# Copyright (c) 20
22
PaddlePaddle Authors. All Rights Reserved.
#
#
# Licensed under the Apache License, Version 2.0 (the "License"
# Licensed under the Apache License, Version 2.0 (the "License"
# you may not use this file except in compliance with the License.
# you may not use this file except in compliance with the License.
...
@@ -114,8 +114,19 @@ def print_mapping_info(func):
...
@@ -114,8 +114,19 @@ def print_mapping_info(func):
return
run_mapping
return
run_mapping
class
OpSet9
():
class
OpSet
():
elementwise_ops
=
{
def
__init__
(
self
,
decoder
,
paddle_graph
):
super
(
OpSet
,
self
).
__init__
()
self
.
graph
=
decoder
.
graph
self
.
paddle_graph
=
paddle_graph
self
.
inputs_info
=
dict
()
self
.
weights
=
dict
()
self
.
nn_name2id
=
dict
()
self
.
done_weight_list
=
list
()
# solve for same data is used as an argument to multiple OPs.
# PR link(wangjunjie06): https://github.com/PaddlePaddle/X2Paddle/pull/728
self
.
rename_mapper
=
dict
()
self
.
elementwise_ops
=
{
'Add'
:
'paddle.add'
,
'Add'
:
'paddle.add'
,
'Div'
:
'paddle.divide'
,
'Div'
:
'paddle.divide'
,
'Sub'
:
'paddle.subtract'
,
'Sub'
:
'paddle.subtract'
,
...
@@ -125,7 +136,7 @@ class OpSet9():
...
@@ -125,7 +136,7 @@ class OpSet9():
'LessOrEqual'
:
'paddle.less_equal'
,
'LessOrEqual'
:
'paddle.less_equal'
,
}
}
directly_map_ops
=
{
self
.
directly_map_ops
=
{
'Ceil'
:
[
'paddle.ceil'
],
'Ceil'
:
[
'paddle.ceil'
],
# reduce function
# reduce function
'ReduceMean'
:
[
'ReduceMean'
:
[
...
@@ -157,8 +168,8 @@ class OpSet9():
...
@@ -157,8 +168,8 @@ class OpSet9():
'Elu'
:
'Elu'
:
[
'paddle.nn.functional.elu'
,
dict
(
alpha
=
'alpha'
),
dict
(
alpha
=
1.
)],
[
'paddle.nn.functional.elu'
,
dict
(
alpha
=
'alpha'
),
dict
(
alpha
=
1.
)],
'ThresholdedRelu'
:
[
'ThresholdedRelu'
:
[
'paddle.nn.functional.thresholded_relu'
,
dict
(
alpha
=
'threshold'
)
,
'paddle.nn.functional.thresholded_relu'
,
dict
(
alpha
=
1.
)
dict
(
alpha
=
'threshold'
),
dict
(
alpha
=
1.
)
],
],
'Tanh'
:
[
'paddle.nn.Tanh'
],
'Tanh'
:
[
'paddle.nn.Tanh'
],
'Sigmoid'
:
[
'paddle.nn.Sigmoid'
],
'Sigmoid'
:
[
'paddle.nn.Sigmoid'
],
...
@@ -169,8 +180,10 @@ class OpSet9():
...
@@ -169,8 +180,10 @@ class OpSet9():
],
],
'Exp'
:
[
'paddle.exp'
],
'Exp'
:
[
'paddle.exp'
],
'Log'
:
[
'paddle.log'
],
'Log'
:
[
'paddle.log'
],
'LogSoftmax'
:
'LogSoftmax'
:
[
[
'paddle.nn.functional.log_softmax'
,
dict
(
axis
=
'axis'
),
dict
(
axis
=
1
)],
'paddle.nn.functional.log_softmax'
,
dict
(
axis
=
'axis'
),
dict
(
axis
=
1
)
],
'Softmax'
:
[
'paddle.nn.Softmax'
,
dict
(
axis
=
'axis'
),
dict
(
axis
=
1
)],
'Softmax'
:
[
'paddle.nn.Softmax'
,
dict
(
axis
=
'axis'
),
dict
(
axis
=
1
)],
'Sqrt'
:
[
'paddle.sqrt'
],
'Sqrt'
:
[
'paddle.sqrt'
],
'Floor'
:
[
'paddle.floor'
],
'Floor'
:
[
'paddle.floor'
],
...
@@ -180,18 +193,6 @@ class OpSet9():
...
@@ -180,18 +193,6 @@ class OpSet9():
'Cos'
:
[
'paddle.cos'
],
'Cos'
:
[
'paddle.cos'
],
}
}
def
__init__
(
self
,
decoder
,
paddle_graph
):
super
(
OpSet9
,
self
).
__init__
()
self
.
graph
=
decoder
.
graph
self
.
paddle_graph
=
paddle_graph
self
.
inputs_info
=
dict
()
self
.
weights
=
dict
()
self
.
nn_name2id
=
dict
()
self
.
done_weight_list
=
list
()
# solve for same data is used as an argument to multiple OPs.
# PR link(wangjunjie06): https://github.com/PaddlePaddle/X2Paddle/pull/728
self
.
rename_mapper
=
dict
()
@
print_mapping_info
@
print_mapping_info
def
directly_map
(
self
,
node
,
*
args
,
**
kwargs
):
def
directly_map
(
self
,
node
,
*
args
,
**
kwargs
):
inputs
=
node
.
layer
.
input
inputs
=
node
.
layer
.
input
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录