From cb53bb7097b78a59560c7ef02229fdce5288b4b2 Mon Sep 17 00:00:00 2001 From: co63oc Date: Tue, 22 Aug 2023 17:42:04 +0800 Subject: [PATCH 1/2] Add tests --- tests/test_Tensor_bitwise_left_shift_.py | 71 +++++++++++ tests/test_Tensor_bitwise_right_shift_.py | 71 +++++++++++ tests/test_Tensor_retains_grad.py | 35 ++++++ tests/test_autograd_Function_jvp.py | 51 ++++++++ tests/test_distributed_monitored_barrier.py | 51 ++++++++ tests/test_layout.py | 35 ++++++ ...test_nn_utils_stateless_functional_call.py | 55 +++++++++ tests/test_resolve_conj.py | 67 ++++++++++ tests/test_sparse_sampled_addmm.py | 115 ++++++++++++++++++ tests/test_special_multigammaln.py | 68 +++++++++++ tests/test_testing_make_tensor.py | 97 +++++++++++++++ tests/test_utils_data_default_convert.py | 98 +++++++++++++++ 12 files changed, 814 insertions(+) create mode 100644 tests/test_Tensor_bitwise_left_shift_.py create mode 100644 tests/test_Tensor_bitwise_right_shift_.py create mode 100644 tests/test_Tensor_retains_grad.py create mode 100644 tests/test_autograd_Function_jvp.py create mode 100644 tests/test_distributed_monitored_barrier.py create mode 100644 tests/test_layout.py create mode 100644 tests/test_nn_utils_stateless_functional_call.py create mode 100644 tests/test_resolve_conj.py create mode 100644 tests/test_sparse_sampled_addmm.py create mode 100644 tests/test_special_multigammaln.py create mode 100644 tests/test_testing_make_tensor.py create mode 100644 tests/test_utils_data_default_convert.py diff --git a/tests/test_Tensor_bitwise_left_shift_.py b/tests/test_Tensor_bitwise_left_shift_.py new file mode 100644 index 000000000..86f2fe88d --- /dev/null +++ b/tests/test_Tensor_bitwise_left_shift_.py @@ -0,0 +1,71 @@ +# 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.bitwise_left_shift_") + + +def test_case_1(): + pytorch_code = textwrap.dedent( + """ + import torch + input = torch.tensor([-2, -7, 31], dtype=torch.int8) + other = torch.tensor([1, 0, 3], dtype=torch.int8) + result = input.bitwise_left_shift_(other) + """ + ) + obj.run( + pytorch_code, + ["result"], + unsupport=True, + reason="paddle does not support this function temporarily", + ) + + +def test_case_2(): + pytorch_code = textwrap.dedent( + """ + import torch + input = torch.tensor([-2, -7, 31], dtype=torch.int8) + other = torch.tensor([1, 0, 3], dtype=torch.int8) + result = input.bitwise_left_shift_(other=other) + """ + ) + obj.run( + pytorch_code, + ["result"], + unsupport=True, + reason="paddle does not support this function temporarily", + ) + + +def test_case_3(): + pytorch_code = textwrap.dedent( + """ + import torch + input = torch.tensor([-2, -7, 31], dtype=torch.int32) + other = torch.tensor([1, 0, 3], dtype=torch.int32) + result = input.bitwise_left_shift_(other=other) + """ + ) + obj.run( + pytorch_code, + ["result"], + unsupport=True, + reason="paddle does not support this function temporarily", + ) diff --git a/tests/test_Tensor_bitwise_right_shift_.py b/tests/test_Tensor_bitwise_right_shift_.py new file mode 100644 index 000000000..09b54b489 --- /dev/null +++ b/tests/test_Tensor_bitwise_right_shift_.py @@ -0,0 +1,71 @@ +# 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.bitwise_right_shift_") + + +def test_case_1(): + pytorch_code = textwrap.dedent( + """ + import torch + input = torch.tensor([-2, -7, 31], dtype=torch.int8) + other = torch.tensor([1, 0, 3], dtype=torch.int8) + result = input.bitwise_right_shift_(other) + """ + ) + obj.run( + pytorch_code, + ["result"], + unsupport=True, + reason="paddle does not support this function temporarily", + ) + + +def test_case_2(): + pytorch_code = textwrap.dedent( + """ + import torch + input = torch.tensor([-2, -7, 31], dtype=torch.int8) + other = torch.tensor([1, 0, 3], dtype=torch.int8) + result = input.bitwise_right_shift_(other=other) + """ + ) + obj.run( + pytorch_code, + ["result"], + unsupport=True, + reason="paddle does not support this function temporarily", + ) + + +def test_case_3(): + pytorch_code = textwrap.dedent( + """ + import torch + input = torch.tensor([-2, -7, 31], dtype=torch.int32) + other = torch.tensor([1, 0, 3], dtype=torch.int32) + result = input.bitwise_right_shift_(other=other) + """ + ) + obj.run( + pytorch_code, + ["result"], + unsupport=True, + reason="paddle does not support this function temporarily", + ) diff --git a/tests/test_Tensor_retains_grad.py b/tests/test_Tensor_retains_grad.py new file mode 100644 index 000000000..09f88e0b9 --- /dev/null +++ b/tests/test_Tensor_retains_grad.py @@ -0,0 +1,35 @@ +# 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.retains_grad") + + +def test_case_1(): + pytorch_code = textwrap.dedent( + """ + import torch + y = torch.Tensor([[1.,2.], [3.,4.]]) + result = y.retains_grad + """ + ) + obj.run( + pytorch_code, + ["result"], + unsupport=True, + reason="paddle does not support this function temporarily", + ) diff --git a/tests/test_autograd_Function_jvp.py b/tests/test_autograd_Function_jvp.py new file mode 100644 index 000000000..9a7271209 --- /dev/null +++ b/tests/test_autograd_Function_jvp.py @@ -0,0 +1,51 @@ +# 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.autograd.Function.jvp") + + +def test_case_1(): + pytorch_code = textwrap.dedent( + """ + import torch + from torch.autograd import Function + + # Inherit from Function + class cus_tanh(Function): + @staticmethod + def forward(ctx, x): + y = torch.autograd.Function.jvp(ctx, x) + return y + + @staticmethod + def backward(ctx, dy): + grad = dy + 1 + return grad + + data = torch.ones([2, 3], dtype=torch.float64) + data.requires_grad = True + result = cus_tanh.apply(data) + """ + ) + obj.run( + pytorch_code, + ["result"], + unsupport=True, + reason="paddle does not support this function temporarily", + ) diff --git a/tests/test_distributed_monitored_barrier.py b/tests/test_distributed_monitored_barrier.py new file mode 100644 index 000000000..08dc50ebb --- /dev/null +++ b/tests/test_distributed_monitored_barrier.py @@ -0,0 +1,51 @@ +# 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.distributed.monitored_barrier") + + +def test_case_1(): + pytorch_code = textwrap.dedent( + """ + import torch + torch.distributed.monitored_barrier() + result=True + """ + ) + obj.run( + pytorch_code, + ["result"], + unsupport=True, + reason="paddle does not support this function temporarily", + ) + + +def test_case_2(): + pytorch_code = textwrap.dedent( + """ + import torch + torch.distributed.monitored_barrier(group=None, timeout=None, wait_all_ranks=False) + result=True + """ + ) + obj.run( + pytorch_code, + ["result"], + unsupport=True, + reason="paddle does not support this function temporarily", + ) diff --git a/tests/test_layout.py b/tests/test_layout.py new file mode 100644 index 000000000..67de5c818 --- /dev/null +++ b/tests/test_layout.py @@ -0,0 +1,35 @@ +# 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.layout") + + +def test_case_1(): + pytorch_code = textwrap.dedent( + """ + import torch + a = torch.tensor([[4, 9], [23, 2]]) + result = torch.layout(a) + """ + ) + obj.run( + pytorch_code, + ["result"], + unsupport=True, + reason="paddle does not support this function temporarily", + ) diff --git a/tests/test_nn_utils_stateless_functional_call.py b/tests/test_nn_utils_stateless_functional_call.py new file mode 100644 index 000000000..43c4d0f41 --- /dev/null +++ b/tests/test_nn_utils_stateless_functional_call.py @@ -0,0 +1,55 @@ +# 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.nn.utils.stateless.functional_call") + + +def test_case_1(): + pytorch_code = textwrap.dedent( + """ + import torch + a = {'foo': torch.zeros(())} + mod = torch.nn.Module() + m = torch.nn.utils.stateless.functional_call(mod, a, torch.ones(())) + result = a['foo'] + """ + ) + obj.run( + pytorch_code, + ["result"], + unsupport=True, + reason="paddle does not support this function temporarily", + ) + + +def test_case_2(): + pytorch_code = textwrap.dedent( + """ + import torch + a = {'foo': torch.zeros(())} + mod = torch.nn.Module() + m = torch.nn.utils.stateless.functional_call(mod, a, torch.ones(()), tie_weights=True, strict=False) + result = a['foo'] + """ + ) + obj.run( + pytorch_code, + ["result"], + unsupport=True, + reason="paddle does not support this function temporarily", + ) diff --git a/tests/test_resolve_conj.py b/tests/test_resolve_conj.py new file mode 100644 index 000000000..c518c5ffb --- /dev/null +++ b/tests/test_resolve_conj.py @@ -0,0 +1,67 @@ +# 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.resolve_conj") + + +def test_case_1(): + pytorch_code = textwrap.dedent( + """ + import torch + x = torch.tensor([-1 + 1j, -2 + 2j, 3 - 3j]) + result = torch.resolve_conj(x) + """ + ) + obj.run( + pytorch_code, + ["result"], + unsupport=True, + reason="paddle does not support this function temporarily", + ) + + +def test_case_2(): + pytorch_code = textwrap.dedent( + """ + import torch + result = torch.resolve_conj(input=torch.tensor([-1 + 1j, -2 + 2j, 3 - 3j])) + """ + ) + obj.run( + pytorch_code, + ["result"], + unsupport=True, + reason="paddle does not support this function temporarily", + ) + + +def test_case_3(): + pytorch_code = textwrap.dedent( + """ + import torch + x = torch.tensor([-1, 2, 3]) + result = torch.resolve_conj(x) + """ + ) + obj.run( + pytorch_code, + ["result"], + unsupport=True, + reason="paddle does not support this function temporarily", + ) diff --git a/tests/test_sparse_sampled_addmm.py b/tests/test_sparse_sampled_addmm.py new file mode 100644 index 000000000..c321d8d36 --- /dev/null +++ b/tests/test_sparse_sampled_addmm.py @@ -0,0 +1,115 @@ +# 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.sparse.sampled_addmm") + + +def test_case_1(): + pytorch_code = textwrap.dedent( + """ + import torch + input = torch.eye(3, device='cuda').to_sparse_csr() + mat1 = torch.randn(3, 5, device='cuda') + mat2 = torch.randn(5, 3, device='cuda') + result = torch.sparse.sampled_addmm(input, mat1, mat2) + result = result.to_dense() + """ + ) + obj.run( + pytorch_code, + ["result"], + unsupport=True, + reason="paddle does not support this function temporarily", + ) + + +def test_case_2(): + pytorch_code = textwrap.dedent( + """ + import torch + input = torch.eye(3, device='cuda').to_sparse_csr() + mat1 = torch.randn(3, 5, device='cuda') + mat2 = torch.randn(5, 3, device='cuda') + result = torch.sparse.sampled_addmm(input=input, mat1=mat1, mat2=mat2) + result = result.to_dense() + """ + ) + obj.run( + pytorch_code, + ["result"], + unsupport=True, + reason="paddle does not support this function temporarily", + ) + + +def test_case_3(): + pytorch_code = textwrap.dedent( + """ + import torch + input = torch.eye(3, device='cuda').to_sparse_csr() + mat1 = torch.randn(3, 5, device='cuda') + mat2 = torch.randn(5, 3, device='cuda') + result = torch.sparse.sampled_addmm(mat1=mat1, mat2=mat2, input=input) + result = result.to_dense() + """ + ) + obj.run( + pytorch_code, + ["result"], + unsupport=True, + reason="paddle does not support this function temporarily", + ) + + +def test_case_4(): + pytorch_code = textwrap.dedent( + """ + import torch + input = torch.eye(3, device='cuda').to_sparse_csr() + mat1 = torch.randn(3, 5, device='cuda') + mat2 = torch.randn(5, 3, device='cuda') + result = torch.sparse.sampled_addmm(input=input, mat1=mat1, mat2=mat2, beta=0.5, alpha=0.5) + result = result.to_dense() + """ + ) + obj.run( + pytorch_code, + ["result"], + unsupport=True, + reason="paddle does not support this function temporarily", + ) + + +def test_case_5(): + pytorch_code = textwrap.dedent( + """ + import torch + input = torch.eye(3, device='cuda').to_sparse_csr() + mat1 = torch.randn(3, 5, device='cuda') + mat2 = torch.randn(5, 3, device='cuda') + out = torch.tensor([]) + result = torch.sparse.sampled_addmm(input=input, mat1=mat1, mat2=mat2, beta=0.5, alpha=0.5, out=out) + result = result.to_dense() + """ + ) + obj.run( + pytorch_code, + ["result"], + unsupport=True, + reason="paddle does not support this function temporarily", + ) diff --git a/tests/test_special_multigammaln.py b/tests/test_special_multigammaln.py new file mode 100644 index 000000000..935133c0e --- /dev/null +++ b/tests/test_special_multigammaln.py @@ -0,0 +1,68 @@ +# 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.special.multigammaln") + + +def test_case_1(): + pytorch_code = textwrap.dedent( + """ + import torch + result = torch.special.multigammaln(torch.tensor([0.34, 1.5, 0.73]), 2) + """ + ) + obj.run( + pytorch_code, + ["result"], + unsupport=True, + reason="paddle does not support this function temporarily", + ) + + +def test_case_2(): + pytorch_code = textwrap.dedent( + """ + import torch + input = torch.tensor([0.34, 1.5, 0.73]) + result = torch.special.multigammaln(input=input, p=2) + """ + ) + obj.run( + pytorch_code, + ["result"], + unsupport=True, + reason="paddle does not support this function temporarily", + ) + + +def test_case_3(): + pytorch_code = textwrap.dedent( + """ + import torch + input = torch.tensor([0.34, 1.5, 0.73]) + out = torch.tensor([0.34, 1.5, 0.73]) + result = torch.special.multigammaln(input, 2, out=out) + """ + ) + obj.run( + pytorch_code, + ["result", "out"], + unsupport=True, + reason="paddle does not support this function temporarily", + ) diff --git a/tests/test_testing_make_tensor.py b/tests/test_testing_make_tensor.py new file mode 100644 index 000000000..a0d2403fd --- /dev/null +++ b/tests/test_testing_make_tensor.py @@ -0,0 +1,97 @@ +# 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.testing.make_tensor") + + +def test_case_1(): + pytorch_code = textwrap.dedent( + """ + import torch + result = torch.testing.make_tensor((3,), device='cpu', dtype=torch.float32) + """ + ) + obj.run( + pytorch_code, + ["result"], + unsupport=True, + reason="paddle does not support this function temporarily", + ) + + +def test_case_2(): + pytorch_code = textwrap.dedent( + """ + import torch + result = torch.testing.make_tensor((3,), dtype=torch.float32, device='cpu') + """ + ) + obj.run( + pytorch_code, + ["result"], + unsupport=True, + reason="paddle does not support this function temporarily", + ) + + +def test_case_3(): + pytorch_code = textwrap.dedent( + """ + import torch + result = torch.testing.make_tensor((2, 2), device='cuda', dtype=torch.bool) + """ + ) + obj.run( + pytorch_code, + ["result"], + unsupport=True, + reason="paddle does not support this function temporarily", + ) + + +def test_case_4(): + pytorch_code = textwrap.dedent( + """ + import torch + result = torch.testing.make_tensor((3,), dtype=torch.float32, device='cpu', + low=None, high=None, requires_grad=False, noncontiguous=False, exclude_zero=False, + memory_format=None) + """ + ) + obj.run( + pytorch_code, + ["result"], + unsupport=True, + reason="paddle does not support this function temporarily", + ) + + +def test_case_5(): + pytorch_code = textwrap.dedent( + """ + import torch + result = torch.testing.make_tensor((3,), dtype=torch.float32, device='cpu', + low=-1, high=1, requires_grad=False, noncontiguous=False, exclude_zero=False, + memory_format=None) + """ + ) + obj.run( + pytorch_code, + ["result"], + unsupport=True, + reason="paddle does not support this function temporarily", + ) diff --git a/tests/test_utils_data_default_convert.py b/tests/test_utils_data_default_convert.py new file mode 100644 index 000000000..f4d13f1bc --- /dev/null +++ b/tests/test_utils_data_default_convert.py @@ -0,0 +1,98 @@ +# 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.utils.data.default_convert") + + +def test_case_1(): + pytorch_code = textwrap.dedent( + """ + import torch + from torch.utils.data import default_convert + result = torch.tensor(default_convert([0, 1, 2, 3])) + """ + ) + obj.run( + pytorch_code, + ["result"], + unsupport=True, + reason="paddle does not support this function temporarily", + ) + + +def test_case_2(): + pytorch_code = textwrap.dedent( + """ + from torch.utils.data import default_convert + result = default_convert(['a', 'b', 'c']) + """ + ) + obj.run( + pytorch_code, + ["result"], + unsupport=True, + reason="paddle does not support this function temporarily", + ) + + +def test_case_3(): + pytorch_code = textwrap.dedent( + """ + import torch + from torch.utils.data import default_convert + result = default_convert([torch.tensor([0, 1, 2, 3])]) + """ + ) + obj.run( + pytorch_code, + ["result"], + unsupport=True, + reason="paddle does not support this function temporarily", + ) + + +def test_case_4(): + pytorch_code = textwrap.dedent( + """ + import torch + from torch.utils.data import default_convert + result = default_convert((torch.tensor([1, 3, 3]), torch.tensor([3, 1, 1]))) + """ + ) + obj.run( + pytorch_code, + ["result"], + unsupport=True, + reason="paddle does not support this function temporarily", + ) + + +def test_case_5(): + pytorch_code = textwrap.dedent( + """ + import torch + from torch.utils.data import default_convert + result = default_convert(batch=(torch.tensor([1, 3, 3]), torch.tensor([3, 1, 1]))) + """ + ) + obj.run( + pytorch_code, + ["result"], + unsupport=True, + reason="paddle does not support this function temporarily", + ) From b85f872270b3547520a42fea641fec05a046759b Mon Sep 17 00:00:00 2001 From: co63oc Date: Tue, 22 Aug 2023 18:16:48 +0800 Subject: [PATCH 2/2] Fix --- tests/test_Tensor_retains_grad.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_Tensor_retains_grad.py b/tests/test_Tensor_retains_grad.py index 09f88e0b9..3c46e0d23 100644 --- a/tests/test_Tensor_retains_grad.py +++ b/tests/test_Tensor_retains_grad.py @@ -24,7 +24,7 @@ def test_case_1(): """ import torch y = torch.Tensor([[1.,2.], [3.,4.]]) - result = y.retains_grad + result = y.retains_grad() """ ) obj.run(