-
Notifications
You must be signed in to change notification settings - Fork 189
【PaddlePaddle Hackathon】在Paddle2ONNX 新增11个 Paddle 2.0 API 支持 #358
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 11 commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
5ba09a9
add nine OP support and add floor_moe unit testing
c0f5ed6
fix version error
48f9212
Merge branch 'develop' of into Paddle_develop
033b2eb
resolve the conflict
433406f
Merge branch 'PaddlePaddle-develop' into add_OP
a79a868
fix spelling mistakes
4a114d1
Merge branch 'PaddlePaddle:develop' into add_OP
1b5397c
Merge branch 'develop' into add_OP
yeliang2258 dd9a908
fix naming problem
39a5bb7
Merge branch 'add_OP' of github.com:AndPuQing/Paddle2ONNX into add_OP
025dc5d
fix logical_not support range
7bd534f
Merge branch 'develop' into add_OP
0c03144
conflict resolution
e7a1080
update op_list
9503d6c
update op_list
e107f59
Make log10 and log2 is a constant
8d6ec17
Merge branch 'develop' of https://github.com/PaddlePaddle/Paddle2ONNX…
a8d8bb3
Merge branch 'PaddlePaddle-develop' into add_OP
c88fc71
Merge branch 'develop' into add_OP
jiangjiajun 353f164
fix wrong spelling
9346d9f
Merge branch 'develop' into add_OP
jiangjiajun 7a4e0e5
empty commit
e4dbfb7
Merge branch 'add_OP' of github.com:AndPuQing/Paddle2ONNX into add_OP
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,93 @@ | ||
| # Copyright (c) 2021 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. | ||
|
|
||
| import paddle | ||
| from onnxbase import APIOnnx | ||
| from onnxbase import randtool | ||
|
|
||
|
|
||
| class Net(paddle.nn.Layer): | ||
| """ | ||
| simplr Net | ||
AndPuQing marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| """ | ||
|
|
||
| def __init__(self): | ||
| super(Net, self).__init__() | ||
|
|
||
| def forward(self, inputs): | ||
| """ | ||
| forward | ||
| """ | ||
| x = paddle.erf(inputs) | ||
| return x | ||
|
|
||
|
|
||
| def test_erf_9(): | ||
| """ | ||
| api: paddle.erf | ||
| op version: 9 | ||
| """ | ||
| op = Net() | ||
| op.eval() | ||
| # net, name, ver_list, delta=1e-6, rtol=1e-5 | ||
| obj = APIOnnx(op, 'erf', [9]) | ||
| obj.set_input_data( | ||
| "input_data", | ||
| paddle.to_tensor(randtool("float", -1, 1, [3, 3]).astype('float32'))) | ||
| obj.run() | ||
|
|
||
|
|
||
| def test_erf_10(): | ||
| """ | ||
| api: paddle.erf | ||
| op version: 10 | ||
| """ | ||
| op = Net() | ||
| op.eval() | ||
| # net, name, ver_list, delta=1e-6, rtol=1e-5 | ||
| obj = APIOnnx(op, 'erf', [10]) | ||
| obj.set_input_data( | ||
| "input_data", | ||
| paddle.to_tensor(randtool("float", -1, 1, [3, 3]).astype('float32'))) | ||
| obj.run() | ||
|
|
||
|
|
||
| def test_erf_11(): | ||
| """ | ||
| api: paddle.erf | ||
| op version: 11 | ||
| """ | ||
| op = Net() | ||
| op.eval() | ||
| # net, name, ver_list, delta=1e-6, rtol=1e-5 | ||
| obj = APIOnnx(op, 'erf', [11]) | ||
| obj.set_input_data( | ||
| "input_data", | ||
| paddle.to_tensor(randtool("float", -1, 1, [3, 3]).astype('float32'))) | ||
| obj.run() | ||
|
|
||
|
|
||
| def test_erf_12(): | ||
| """ | ||
| api: paddle.erf | ||
| op version: 12 | ||
| """ | ||
| op = Net() | ||
| op.eval() | ||
| # net, name, ver_list, delta=1e-6, rtol=1e-5 | ||
| obj = APIOnnx(op, 'erf', [12]) | ||
| obj.set_input_data( | ||
| "input_data", | ||
| paddle.to_tensor(randtool("float", -1, 1, [3, 3]).astype('float32'))) | ||
| obj.run() | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,75 @@ | ||
| # Copyright (c) 2021 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. | ||
|
|
||
| import paddle | ||
| from onnxbase import APIOnnx | ||
| from onnxbase import randtool | ||
|
|
||
|
|
||
| class Net(paddle.nn.Layer): | ||
| """ | ||
| simplr Net | ||
| """ | ||
|
|
||
| def __init__(self): | ||
| super(Net, self).__init__() | ||
|
|
||
| def forward(self, inputs, _inputs): | ||
| """ | ||
| forward | ||
| """ | ||
| x = paddle.floor_mod(inputs, _inputs) | ||
| return x | ||
|
|
||
|
|
||
| def test_floor_mod_10(): | ||
| """ | ||
| api: paddle.floor_mod | ||
| op version: 10 | ||
| """ | ||
| op = Net() | ||
| op.eval() | ||
| # net, name, ver_list, delta=1e-6, rtol=1e-5 | ||
| obj = APIOnnx(op, 'floor_mod', [10]) | ||
| obj.set_input_data("input_data", paddle.to_tensor([2, 3, 8, 7]), | ||
| paddle.to_tensor([1, 5, 3, 3])) | ||
| obj.run() | ||
|
|
||
|
|
||
| def test_floor_mod_12(): | ||
| """ | ||
| api: paddle.floor_mod | ||
| op version: 12 | ||
| """ | ||
| op = Net() | ||
| op.eval() | ||
| # net, name, ver_list, delta=1e-6, rtol=1e-5 | ||
| obj = APIOnnx(op, 'floor_mod', [12]) | ||
| obj.set_input_data("input_data", paddle.to_tensor([2, 3, 8, 7]), | ||
| paddle.to_tensor([1, 5, 3, 3])) | ||
| obj.run() | ||
|
|
||
|
|
||
| def test_floor_mod_broadcasting(): | ||
| """ | ||
| api: paddle.floor_mod | ||
| op version: 12 | ||
| """ | ||
| op = Net() | ||
| op.eval() | ||
| # net, name, ver_list, delta=1e-6, rtol=1e-5 | ||
| obj = APIOnnx(op, 'floor_mod', [12]) | ||
| obj.set_input_data("input_data", paddle.to_tensor([2, 3, 8, 7]), | ||
| paddle.to_tensor([3])) | ||
| obj.run() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| # Copyright (c) 2021 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. | ||
|
|
||
| import paddle | ||
| from onnxbase import APIOnnx | ||
| from onnxbase import randtool | ||
|
|
||
|
|
||
| class Net(paddle.nn.Layer): | ||
| """ | ||
| simplr Net | ||
| """ | ||
|
|
||
| def __init__(self): | ||
| super(Net, self).__init__() | ||
|
|
||
| def forward(self, inputs): | ||
| """ | ||
| forward | ||
| """ | ||
| x = paddle.fluid.layers.has_nan(inputs) | ||
| return x.astype('float32') | ||
|
|
||
|
|
||
| def test_has_nan_base(): | ||
| """ | ||
| api: paddle.fluid.layers.has_nan | ||
| op version: 9, 10, 12 | ||
| """ | ||
| op = Net() | ||
| op.eval() | ||
| # net, name, ver_list, delta=1e-6, rtol=1e-5 | ||
| obj = APIOnnx(op, 'has_nan', [9, 10, 12]) | ||
| obj.set_input_data( | ||
| "input_data", | ||
| paddle.to_tensor(([ | ||
| float('-inf'), -2, 3.6, | ||
| float('inf'), 0, | ||
| float('-nan'), | ||
| float('nan') | ||
| ]))) | ||
| obj.run() |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.