|
| 1 | +# Copyright (c) 2021 PaddlePaddle Authors. All Rights Reserved. |
| 2 | +# |
| 3 | +# Licensed under the Apache License, Version 2.0 (the "License" |
| 4 | +# you may not use this file except in compliance with the License. |
| 5 | +# You may obtain a copy of the License at |
| 6 | +# |
| 7 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +# |
| 9 | +# Unless required by applicable law or agreed to in writing, software |
| 10 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | +# See the License for the specific language governing permissions and |
| 13 | +# limitations under the License. |
| 14 | + |
| 15 | +import paddle |
| 16 | +from onnxbase import APIOnnx |
| 17 | +from onnxbase import randtool |
| 18 | + |
| 19 | + |
| 20 | +class Net(paddle.nn.Layer): |
| 21 | + """ |
| 22 | + simplr Net |
| 23 | + """ |
| 24 | + |
| 25 | + def __init__(self): |
| 26 | + super(Net, self).__init__() |
| 27 | + |
| 28 | + def forward(self, inputs, inputs_): |
| 29 | + """ |
| 30 | + forward |
| 31 | + """ |
| 32 | + x = paddle.mod(inputs, inputs_) |
| 33 | + return x |
| 34 | + |
| 35 | + |
| 36 | +def test_mod_10(): |
| 37 | + """ |
| 38 | + api: paddle.mod |
| 39 | + op version: 10 |
| 40 | + """ |
| 41 | + op = Net() |
| 42 | + op.eval() |
| 43 | + # net, name, ver_list, delta=1e-6, rtol=1e-5 |
| 44 | + obj = APIOnnx(op, 'mod', [10]) |
| 45 | + obj.set_input_data("input_data", |
| 46 | + paddle.to_tensor([2, 3, 8, 7]), |
| 47 | + paddle.to_tensor([1, 5, 3, 3])) |
| 48 | + obj.run() |
| 49 | + |
| 50 | + |
| 51 | +def test_mod_11(): |
| 52 | + """ |
| 53 | + api: paddle.mod |
| 54 | + op version: 11 |
| 55 | + """ |
| 56 | + op = Net() |
| 57 | + op.eval() |
| 58 | + # net, name, ver_list, delta=1e-6, rtol=1e-5 |
| 59 | + obj = APIOnnx(op, 'mod', [11]) |
| 60 | + obj.set_input_data("input_data", |
| 61 | + paddle.to_tensor([2, 3, 8, 7]), |
| 62 | + paddle.to_tensor([1, 5, 3, 3])) |
| 63 | + obj.run() |
| 64 | + |
| 65 | + |
| 66 | +def test_mod_12(): |
| 67 | + """ |
| 68 | + api: paddle.mod |
| 69 | + op version: 12 |
| 70 | + """ |
| 71 | + op = Net() |
| 72 | + op.eval() |
| 73 | + # net, name, ver_list, delta=1e-6, rtol=1e-5 |
| 74 | + obj = APIOnnx(op, 'mod', [12]) |
| 75 | + obj.set_input_data("input_data", |
| 76 | + paddle.to_tensor([2, 3, 8, 7]), |
| 77 | + paddle.to_tensor([1, 5, 3, 3])) |
| 78 | + obj.run() |
0 commit comments