diff --git a/tests/test_nn_Module_bfloat16.py b/tests/test_nn_Module_bfloat16.py new file mode 100644 index 000000000..ebdfd21da --- /dev/null +++ b/tests/test_nn_Module_bfloat16.py @@ -0,0 +1,38 @@ +# 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.Module.bfloat16") + + +def _test_case_1(): + pytorch_code = textwrap.dedent( + """ + import torch + x = torch.tensor([1., 2., 3.]) + module1 = torch.nn.Module() + module1.register_buffer('buffer', x) + module1.bfloat16() + result = module1.buffer + """ + ) + obj.run( + pytorch_code, + ["result"], + unsupport=True, + reason="paddle does not support this function temporarily", + ) diff --git a/tests/test_nn_Module_double.py b/tests/test_nn_Module_double.py new file mode 100644 index 000000000..c8bc02ab8 --- /dev/null +++ b/tests/test_nn_Module_double.py @@ -0,0 +1,38 @@ +# 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.Module.double") + + +def _test_case_1(): + pytorch_code = textwrap.dedent( + """ + import torch + x = torch.tensor([1., 2., 3.]) + module1 = torch.nn.Module() + module1.register_buffer('buffer', x) + module1.double() + result = module1.buffer + """ + ) + obj.run( + pytorch_code, + ["result"], + unsupport=True, + reason="paddle does not support this function temporarily", + ) diff --git a/tests/test_nn_Module_float.py b/tests/test_nn_Module_float.py new file mode 100644 index 000000000..38e4d7db5 --- /dev/null +++ b/tests/test_nn_Module_float.py @@ -0,0 +1,38 @@ +# 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.Module.float") + + +def _test_case_1(): + pytorch_code = textwrap.dedent( + """ + import torch + x = torch.tensor([1., 2., 3.]) + module1 = torch.nn.Module() + module1.register_buffer('buffer', x) + module1.float() + result = module1.buffer + """ + ) + obj.run( + pytorch_code, + ["result"], + unsupport=True, + reason="paddle does not support this function temporarily", + ) diff --git a/tests/test_nn_Module_half.py b/tests/test_nn_Module_half.py new file mode 100644 index 000000000..3c021f07a --- /dev/null +++ b/tests/test_nn_Module_half.py @@ -0,0 +1,38 @@ +# 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.Module.half") + + +def _test_case_1(): + pytorch_code = textwrap.dedent( + """ + import torch + x = torch.tensor([1., 2., 3.]) + module1 = torch.nn.Module() + module1.register_buffer('buffer', x) + module1.half() + result = module1.buffer + """ + ) + obj.run( + pytorch_code, + ["result"], + unsupport=True, + reason="paddle does not support this function temporarily", + ) diff --git a/tests/test_nn_Module_register_full_backward_hook.py b/tests/test_nn_Module_register_full_backward_hook.py new file mode 100644 index 000000000..9de9b6cef --- /dev/null +++ b/tests/test_nn_Module_register_full_backward_hook.py @@ -0,0 +1,53 @@ +# 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.Module.register_full_backward_hook") + + +def test_case_1(): + pytorch_code = textwrap.dedent( + """ + import torch + import torch.nn as nn + import torch.nn.functional as F + + def backward_after_hook(module, data_input, data_output): + print("I am function after forward function.") + + class MyModule(nn.Module): + def __init__(self): + super().__init__() + self.conv1 = nn.Conv2d(1, 3, 3) + self.conv2 = nn.Conv2d(3, 3, 3) + + def forward(self, x): + x = F.relu(self.conv1(x)) + x = F.relu(self.conv2(x)) + return x + + my_module = MyModule() + my_module.register_full_backward_hook(backward_after_hook) + result = None + """ + ) + obj.run( + pytorch_code, + ["result"], + unsupport=True, + reason="paddle does not support this function temporarily", + ) diff --git a/tests/test_nn_Module_register_full_backward_pre_hook.py b/tests/test_nn_Module_register_full_backward_pre_hook.py new file mode 100644 index 000000000..d6df7e320 --- /dev/null +++ b/tests/test_nn_Module_register_full_backward_pre_hook.py @@ -0,0 +1,53 @@ +# 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.Module.register_full_backward_pre_hook") + + +def test_case_1(): + pytorch_code = textwrap.dedent( + """ + import torch + import torch.nn as nn + import torch.nn.functional as F + + def backward_pre_hook(module, data_input): + print("I am function before forward function.") + + class MyModule(nn.Module): + def __init__(self): + super().__init__() + self.conv1 = nn.Conv2d(1, 3, 3) + self.conv2 = nn.Conv2d(3, 3, 3) + + def forward(self, x): + x = F.relu(self.conv1(x)) + x = F.relu(self.conv2(x)) + return x + + my_module = MyModule() + my_module.register_full_backward_pre_hook(backward_pre_hook) + result = None + """ + ) + obj.run( + pytorch_code, + ["result"], + unsupport=True, + reason="paddle does not support this function temporarily", + ) diff --git a/tests/test_nn_Module_requires_grad_.py b/tests/test_nn_Module_requires_grad_.py new file mode 100644 index 000000000..252093653 --- /dev/null +++ b/tests/test_nn_Module_requires_grad_.py @@ -0,0 +1,57 @@ +# 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.Module.requires_grad_") + + +def _test_case_1(): + pytorch_code = textwrap.dedent( + """ + import torch + x = torch.tensor([1., 2., 3.]) + module1 = torch.nn.Module() + module1.register_buffer('buffer', x) + module1.requires_grad_(True) + result = None + """ + ) + 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 + x = torch.tensor([1., 2., 3.]) + module1 = torch.nn.Module() + module1.register_buffer('buffer', x) + module1.requires_grad_(requires_grad=True) + result = None + """ + ) + obj.run( + pytorch_code, + ["result"], + unsupport=True, + reason="paddle does not support this function temporarily", + ) diff --git a/tests/test_nn_Module_to.py b/tests/test_nn_Module_to.py new file mode 100644 index 000000000..a8220a80f --- /dev/null +++ b/tests/test_nn_Module_to.py @@ -0,0 +1,76 @@ +# 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.Module.to") + + +def _test_case_1(): + pytorch_code = textwrap.dedent( + """ + import torch + x = torch.tensor([1., 2., 3.]) + module1 = torch.nn.Module() + module1.register_buffer('buffer', x) + module1.to(dtype=torch.float32) + result = module1.buffer + """ + ) + 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 + x = torch.tensor([1., 2., 3.]) + module1 = torch.nn.Module() + module1.register_buffer('buffer', x) + module1.to(device="cpu") + result = module1.buffer + """ + ) + 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.]) + module1 = torch.nn.Module() + module1.register_buffer('buffer', x) + module1.to(device="cpu", non_blocking=False) + result = module1.buffer + """ + ) + obj.run( + pytorch_code, + ["result"], + unsupport=True, + reason="paddle does not support this function temporarily", + ) diff --git a/tests/test_nn_Module_to_empty.py b/tests/test_nn_Module_to_empty.py new file mode 100644 index 000000000..7baea6668 --- /dev/null +++ b/tests/test_nn_Module_to_empty.py @@ -0,0 +1,57 @@ +# 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.Module.to_empty") + + +def test_case_1(): + pytorch_code = textwrap.dedent( + """ + import torch + x = torch.tensor([1., 2., 3.]) + module1 = torch.nn.Module() + module1.register_buffer('buffer', x) + module1.to_empty(device="cpu") + result = module1.buffer + """ + ) + 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 + x = torch.tensor([1., 2., 3.]) + module1 = torch.nn.Module() + module1.register_buffer('buffer', x) + module1.to_empty(device=torch.device("cpu")) + result = module1.buffer + """ + ) + obj.run( + pytorch_code, + ["result"], + unsupport=True, + reason="paddle does not support this function temporarily", + ) diff --git a/tests/test_nn_Module_type.py b/tests/test_nn_Module_type.py new file mode 100644 index 000000000..58bb375ed --- /dev/null +++ b/tests/test_nn_Module_type.py @@ -0,0 +1,57 @@ +# 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.Module.type") + + +def _test_case_1(): + pytorch_code = textwrap.dedent( + """ + import torch + x = torch.tensor([1., 2., 3.]) + module1 = torch.nn.Module() + module1.register_buffer('buffer', x) + module1.type_unsupport(torch.float32) + result = module1.buffer + """ + ) + 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 + x = torch.tensor([1., 2., 3.]) + module1 = torch.nn.Module() + module1.register_buffer('buffer', x) + module1.type_unsupport(dst_type=torch.float32) + result = module1.buffer + """ + ) + obj.run( + pytorch_code, + ["result"], + unsupport=True, + reason="paddle does not support this function temporarily", + ) diff --git a/tests/test_nn_Module_zero_grad.py b/tests/test_nn_Module_zero_grad.py new file mode 100644 index 000000000..cecccb0a5 --- /dev/null +++ b/tests/test_nn_Module_zero_grad.py @@ -0,0 +1,59 @@ +# 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.Module.zero_grad") + + +def test_case_1(): + pytorch_code = textwrap.dedent( + """ + import torch + x = torch.tensor([1., 2., 3.]) + module1 = torch.nn.Module() + module1.register_buffer('buffer', x) + module1.zero_grad() + module1.buffer.pow(2).sum().backward() + result = module1.buffer.grad + """ + ) + 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 + x = torch.tensor([1., 2., 3.]) + module1 = torch.nn.Module() + module1.register_buffer('buffer', x) + module1.zero_grad(set_to_none=True) + module1.buffer.pow(2).sum().backward() + result = module1.buffer.grad + """ + ) + obj.run( + pytorch_code, + ["result"], + unsupport=True, + reason="paddle does not support this function temporarily", + ) diff --git a/tests/test_onnx_disable_log.py b/tests/test_onnx_disable_log.py new file mode 100644 index 000000000..da68c0cf8 --- /dev/null +++ b/tests/test_onnx_disable_log.py @@ -0,0 +1,34 @@ +# 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.onnx.disable_log") + + +def test_case_1(): + pytorch_code = textwrap.dedent( + """ + import torch + result = torch.onnx.disable_log() + """ + ) + obj.run( + pytorch_code, + ["result"], + unsupport=True, + reason="paddle does not support this function temporarily", + ) diff --git a/tests/test_onnx_enable_log.py b/tests/test_onnx_enable_log.py new file mode 100644 index 000000000..b72697372 --- /dev/null +++ b/tests/test_onnx_enable_log.py @@ -0,0 +1,34 @@ +# 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.onnx.enable_log") + + +def test_case_1(): + pytorch_code = textwrap.dedent( + """ + import torch + result = torch.onnx.enable_log() + """ + ) + obj.run( + pytorch_code, + ["result"], + unsupport=True, + reason="paddle does not support this function temporarily", + )