From 768048b56d9d0b7c731e0df244a5aa0f4f9062f8 Mon Sep 17 00:00:00 2001 From: longranger2 <836253168@qq.com> Date: Sun, 10 Sep 2023 03:14:50 +0000 Subject: [PATCH 1/2] add test for torch.copysign --- tests/test_Tensor_copysign.py | 69 +++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 tests/test_Tensor_copysign.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", + ) From 3933f7d2c16a418f43ac127dd8fe4035fd5ef068 Mon Sep 17 00:00:00 2001 From: longranger2 <836253168@qq.com> Date: Sun, 10 Sep 2023 03:23:21 +0000 Subject: [PATCH 2/2] add test for torch.dequantize --- tests/test_Tensor_dequantize.py | 83 +++++++++++++++++++++++++++++++++ 1 file changed, 83 insertions(+) create mode 100644 tests/test_Tensor_dequantize.py 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", + )