Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

转换规则 No. 271/273/280/283/297/298/301/325/337/343-344 #185

Merged
merged 4 commits into from
Jul 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 71 additions & 0 deletions tests/test_Tensor_bitwise_right_shift.py
Original file line number Diff line number Diff line change
@@ -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",
)
68 changes: 68 additions & 0 deletions tests/test_Tensor_dsplit.py
Original file line number Diff line number Diff line change
@@ -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.Tensor.dsplit")


def test_case_1():
pytorch_code = textwrap.dedent(
"""
import torch
t = torch.arange(16.0).reshape(2, 2, 4)
result = t.dsplit(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
t = torch.arange(16.0).reshape(2, 2, 4)
result = t.dsplit([2, 3])
"""
)
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
t = torch.arange(12).reshape(3, 2, 2)
result = t.dsplit(indices=[1, 1])
"""
)
obj.run(
pytorch_code,
["result"],
unsupport=True,
reason="paddle does not support this function temporarily",
)
68 changes: 68 additions & 0 deletions tests/test_Tensor_hsplit.py
Original file line number Diff line number Diff line change
@@ -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.Tensor.hsplit")


def test_case_1():
pytorch_code = textwrap.dedent(
"""
import torch
t = torch.arange(16.0).reshape(4, 4)
result = t.hsplit(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
t = torch.arange(16.0).reshape(4, 4)
result = t.hsplit([3, 6])
"""
)
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
t = torch.arange(12).reshape(3, 2, 2)
result = t.hsplit(indices=[1, 2])
"""
)
obj.run(
pytorch_code,
["result"],
unsupport=True,
reason="paddle does not support this function temporarily",
)
35 changes: 35 additions & 0 deletions tests/test_Tensor_is_conj.py
Original file line number Diff line number Diff line change
@@ -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.is_conj")


def test_case_1():
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个参考下 is_contiguous

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Paddle最新代码搜索没有is_contiguous
图片

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

那就功能缺失来吧

pytorch_code = textwrap.dedent(
"""
import torch
src = torch.tensor([1., 2., 3., 4., 5., 6.])
result = src.is_conj()
"""
)
obj.run(
pytorch_code,
["result"],
unsupport=True,
reason="paddle does not support this function temporarily",
)
68 changes: 68 additions & 0 deletions tests/test_Tensor_vsplit.py
Original file line number Diff line number Diff line change
@@ -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.Tensor.vsplit")


def test_case_1():
pytorch_code = textwrap.dedent(
"""
import torch
t = torch.arange(16.0).reshape(2, 2, 4)
result = t.vsplit(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
t = torch.arange(16.0).reshape(2, 2, 4)
result = t.vsplit([2, 3])
"""
)
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
t = torch.arange(12).reshape(3, 2, 2)
result = t.vsplit(indices=[1, 2])
"""
)
obj.run(
pytorch_code,
["result"],
unsupport=True,
reason="paddle does not support this function temporarily",
)
71 changes: 71 additions & 0 deletions tests/test_bitwise_right_shift.py
Original file line number Diff line number Diff line change
@@ -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.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 = torch.bitwise_right_shift(input, 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 = torch.bitwise_right_shift(input=input, 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 = torch.bitwise_right_shift(input=input, other=other)
"""
)
obj.run(
pytorch_code,
["result"],
unsupport=True,
reason="paddle does not support this function temporarily",
)
Loading