From 6b3cb9685a23d4acc4ebdbf56e57adc38baee0b9 Mon Sep 17 00:00:00 2001 From: LoneRanger <836253168@qq.com> Date: Tue, 12 Sep 2023 21:45:37 +0800 Subject: [PATCH] =?UTF-8?q?=E8=BD=AC=E6=8D=A2=E8=A7=84=E5=88=99=20No.77-78?= =?UTF-8?q?=20(#278)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * add test for torch.copysign * add test for torch.dequantize --- tests/test_Tensor_copysign.py | 69 +++++++++++++++++++++++++++ tests/test_Tensor_dequantize.py | 83 +++++++++++++++++++++++++++++++++ 2 files changed, 152 insertions(+) create mode 100644 tests/test_Tensor_copysign.py create mode 100644 tests/test_Tensor_dequantize.py diff --git a/tests/test_Tensor_copysign.py b/tests/test_Tensor_copysign.py new file mode 100644 index 000000000..022107168 --- /dev/null +++ b/tests/test_Tensor_copysign.py @@ -0,0 +1,69 @@ +# Copyright (c) 2023 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 textwrap + +from apibase import APIBase + +obj = APIBase("torch.Tensor.copysign") + + +def test_case_1(): + pytorch_code = textwrap.dedent( + """ + import torch + a = torch.randn(5) + result = torch.copysign(a, 1) + """ + ) + obj.run( + pytorch_code, + ["result"], + unsupport=True, + reason="paddle has no corresponding api tentatively", + ) + + +def test_case_2(): + pytorch_code = textwrap.dedent( + """ + import torch + a = torch.randn(4, 4) + b = torch.randn(4) + result = torch.copysign(a, b) + """ + ) + obj.run( + pytorch_code, + ["result"], + unsupport=True, + reason="paddle has no corresponding api tentatively", + ) + + +def test_case_3(): + pytorch_code = textwrap.dedent( + """ + import torch + a = torch.tensor([1.]) + b = torch.tensor([-0.]) + result = torch.copysign(a, b) + """ + ) + obj.run( + pytorch_code, + ["result"], + unsupport=True, + reason="paddle has no corresponding api tentatively", + ) diff --git a/tests/test_Tensor_dequantize.py b/tests/test_Tensor_dequantize.py new file mode 100644 index 000000000..e412e5140 --- /dev/null +++ b/tests/test_Tensor_dequantize.py @@ -0,0 +1,83 @@ +# Copyright (c) 2023 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 textwrap + +from apibase import APIBase + +obj = APIBase("torch.Tensor.dequantize") + + +def test_case_1(): + pytorch_code = textwrap.dedent( + """ + import torch + x = torch.tensor([[1, 2, 3], [4, 5, 6]]) + result = torch.dequantize(x) + """ + ) + obj.run( + pytorch_code, + ["result"], + unsupport=True, + reason="paddle has no corresponding api tentatively", + ) + + +def test_case_2(): + pytorch_code = textwrap.dedent( + """ + import torch + x = torch.tensor([[1., 2., 3.], [4., 5., 6.]]) + result = torch.dequantize(x) + """ + ) + obj.run( + pytorch_code, + ["result"], + unsupport=True, + reason="paddle has no corresponding api tentatively", + ) + + +def test_case_3(): + pytorch_code = textwrap.dedent( + """ + import torch + x = torch.randn(10, 20) + result = torch.dequantize(x) + """ + ) + obj.run( + pytorch_code, + ["result"], + unsupport=True, + reason="paddle has no corresponding api tentatively", + ) + + +def test_case_4(): + pytorch_code = textwrap.dedent( + """ + import torch + x = torch.randn(10, 20, 5) + result = torch.dequantize(x) + """ + ) + obj.run( + pytorch_code, + ["result"], + unsupport=True, + reason="paddle has no corresponding api tentatively", + )