Skip to content

Commit

Permalink
转换规则 No.77-78 (#278)
Browse files Browse the repository at this point in the history
* add test for torch.copysign

* add test for torch.dequantize
  • Loading branch information
longranger2 authored Sep 12, 2023
1 parent 99c43a0 commit 6b3cb96
Show file tree
Hide file tree
Showing 2 changed files with 152 additions and 0 deletions.
69 changes: 69 additions & 0 deletions tests/test_Tensor_copysign.py
Original file line number Diff line number Diff line change
@@ -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",
)
83 changes: 83 additions & 0 deletions tests/test_Tensor_dequantize.py
Original file line number Diff line number Diff line change
@@ -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",
)

0 comments on commit 6b3cb96

Please sign in to comment.