Skip to content

Commit 8f1cd27

Browse files
committed
[API Compatibility] Fix some API Edit By AI
1 parent cd54c40 commit 8f1cd27

7 files changed

Lines changed: 162 additions & 217 deletions

paconvert/api_mapping.json

Lines changed: 13 additions & 143 deletions
Original file line numberDiff line numberDiff line change
@@ -806,15 +806,7 @@
806806
}
807807
},
808808
"torch.Tensor.copysign_": {
809-
"Matcher": "Num2TensorBinaryMatcher",
810-
"paddle_api": "paddle.Tensor.copysign_",
811-
"min_input_args": 1,
812-
"args_list": [
813-
"other"
814-
],
815-
"kwargs_change": {
816-
"other": "y"
817-
}
809+
"Matcher": "ChangePrefixMatcher"
818810
},
819811
"torch.Tensor.corrcoef": {
820812
"Matcher": "ChangePrefixMatcher"
@@ -1305,18 +1297,7 @@
13051297
}
13061298
},
13071299
"torch.Tensor.geometric_": {
1308-
"Matcher": "GenericMatcher",
1309-
"paddle_api": "paddle.Tensor.geometric_",
1310-
"min_input_args": 1,
1311-
"args_list": [
1312-
"p",
1313-
"*",
1314-
"generator"
1315-
],
1316-
"kwargs_change": {
1317-
"p": "probs",
1318-
"generator": ""
1319-
}
1300+
"Matcher": "ChangePrefixMatcher"
13201301
},
13211302
"torch.Tensor.geqrf": {},
13221303
"torch.Tensor.ger": {
@@ -1436,15 +1417,7 @@
14361417
}
14371418
},
14381419
"torch.Tensor.hypot_": {
1439-
"Matcher": "GenericMatcher",
1440-
"paddle_api": "paddle.Tensor.hypot_",
1441-
"min_input_args": 1,
1442-
"args_list": [
1443-
"other"
1444-
],
1445-
"kwargs_change": {
1446-
"other": "y"
1447-
}
1420+
"Matcher": "ChangePrefixMatcher"
14481421
},
14491422
"torch.Tensor.i0": {
14501423
"Matcher": "ChangePrefixMatcher"
@@ -1513,30 +1486,10 @@
15131486
]
15141487
},
15151488
"torch.Tensor.index_fill": {
1516-
"Matcher": "GenericMatcher",
1517-
"paddle_api": "paddle.Tensor.index_fill",
1518-
"min_input_args": 3,
1519-
"args_list": [
1520-
"dim",
1521-
"index",
1522-
"value"
1523-
],
1524-
"kwargs_change": {
1525-
"dim": "axis"
1526-
}
1489+
"Matcher": "ChangePrefixMatcher"
15271490
},
15281491
"torch.Tensor.index_fill_": {
1529-
"Matcher": "GenericMatcher",
1530-
"paddle_api": "paddle.Tensor.index_fill_",
1531-
"min_input_args": 3,
1532-
"args_list": [
1533-
"dim",
1534-
"index",
1535-
"value"
1536-
],
1537-
"kwargs_change": {
1538-
"dim": "axis"
1539-
}
1492+
"Matcher": "ChangePrefixMatcher"
15401493
},
15411494
"torch.Tensor.index_put": {
15421495
"Matcher": "ChangePrefixMatcher"
@@ -3895,15 +3848,7 @@
38953848
"Matcher": "ChangePrefixMatcher"
38963849
},
38973850
"torch.block_diag": {
3898-
"Matcher": "SimpleScalableVarMatcher",
3899-
"paddle_api": "paddle.block_diag",
3900-
"min_input_args": 1,
3901-
"args_list": [
3902-
"*tensors"
3903-
],
3904-
"kwargs_change": {
3905-
"tensors": "inputs"
3906-
}
3851+
"Matcher": "ChangePrefixMatcher"
39073852
},
39083853
"torch.bmm": {
39093854
"Matcher": "ChangePrefixMatcher"
@@ -3912,15 +3857,7 @@
39123857
"Matcher": "ChangePrefixMatcher"
39133858
},
39143859
"torch.broadcast_tensors": {
3915-
"Matcher": "ScalableVarMatcher",
3916-
"paddle_api": "paddle.broadcast_tensors",
3917-
"min_input_args": 1,
3918-
"args_list": [
3919-
"*tensors"
3920-
],
3921-
"kwargs_change": {
3922-
"tensors": "input"
3923-
}
3860+
"Matcher": "ChangePrefixMatcher"
39243861
},
39253862
"torch.broadcast_to": {
39263863
"Matcher": "ChangePrefixMatcher"
@@ -3936,15 +3873,7 @@
39363873
]
39373874
},
39383875
"torch.cartesian_prod": {
3939-
"Matcher": "SimpleScalableVarMatcher",
3940-
"paddle_api": "paddle.cartesian_prod",
3941-
"min_input_args": 1,
3942-
"args_list": [
3943-
"*tensors"
3944-
],
3945-
"kwargs_change": {
3946-
"tensors": "x"
3947-
}
3876+
"Matcher": "ChangePrefixMatcher"
39483877
},
39493878
"torch.cat": {
39503879
"Matcher": "ChangePrefixMatcher"
@@ -4130,19 +4059,7 @@
41304059
"Matcher": "ChangePrefixMatcher"
41314060
},
41324061
"torch.copysign": {
4133-
"Matcher": "GenericMatcher",
4134-
"paddle_api": "paddle.copysign",
4135-
"min_input_args": 2,
4136-
"args_list": [
4137-
"input",
4138-
"other",
4139-
"*",
4140-
"out"
4141-
],
4142-
"kwargs_change": {
4143-
"input": "x",
4144-
"other": "y"
4145-
}
4062+
"Matcher": "ChangePrefixMatcher"
41464063
},
41474064
"torch.corrcoef": {
41484065
"Matcher": "GenericMatcher",
@@ -4226,21 +4143,7 @@
42264143
}
42274144
},
42284145
"torch.cross": {
4229-
"Matcher": "GenericMatcher",
4230-
"paddle_api": "paddle.cross",
4231-
"min_input_args": 2,
4232-
"args_list": [
4233-
"input",
4234-
"other",
4235-
"dim",
4236-
"*",
4237-
"out"
4238-
],
4239-
"kwargs_change": {
4240-
"input": "x",
4241-
"other": "y",
4242-
"dim": "axis"
4243-
}
4146+
"Matcher": "ChangePrefixMatcher"
42444147
},
42454148
"torch.ctc_loss": {},
42464149
"torch.cuda.BFloat16Tensor": {
@@ -4577,18 +4480,7 @@
45774480
"Matcher": "ChangePrefixMatcher"
45784481
},
45794482
"torch.dist": {
4580-
"Matcher": "GenericMatcher",
4581-
"paddle_api": "paddle.dist",
4582-
"min_input_args": 2,
4583-
"args_list": [
4584-
"input",
4585-
"other",
4586-
"p"
4587-
],
4588-
"kwargs_change": {
4589-
"input": "x",
4590-
"other": "y"
4591-
}
4483+
"Matcher": "ChangePrefixMatcher"
45924484
},
45934485
"torch.distributed.Backend": {
45944486
"Matcher": "DistributedBackendMatcher",
@@ -5838,17 +5730,7 @@
58385730
"Matcher": "ChangePrefixMatcher"
58395731
},
58405732
"torch.flip": {
5841-
"Matcher": "GenericMatcher",
5842-
"paddle_api": "paddle.flip",
5843-
"min_input_args": 2,
5844-
"args_list": [
5845-
"input",
5846-
"dims"
5847-
],
5848-
"kwargs_change": {
5849-
"input": "x",
5850-
"dims": "axis"
5851-
}
5733+
"Matcher": "ChangePrefixMatcher"
58525734
},
58535735
"torch.fliplr": {
58545736
"Matcher": "GenericMatcher",
@@ -6286,19 +6168,7 @@
62866168
]
62876169
},
62886170
"torch.index_fill": {
6289-
"Matcher": "GenericMatcher",
6290-
"paddle_api": "paddle.index_fill",
6291-
"min_input_args": 4,
6292-
"args_list": [
6293-
"input",
6294-
"dim",
6295-
"index",
6296-
"value"
6297-
],
6298-
"kwargs_change": {
6299-
"input": "x",
6300-
"dim": "axis"
6301-
}
6171+
"Matcher": "ChangePrefixMatcher"
63026172
},
63036173
"torch.index_put": {
63046174
"Matcher": "ChangePrefixMatcher"

tests/test_Tensor_floor_divide_.py

Lines changed: 18 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
14-
#
1514

1615
import textwrap
1716

@@ -24,65 +23,55 @@ def test_case_1():
2423
pytorch_code = textwrap.dedent(
2524
"""
2625
import torch
27-
a = torch.tensor([4.0, 3.0])
28-
b = torch.tensor([2.0, 2.0])
29-
a.floor_divide_(b)
26+
a = torch.tensor([4.0, 3.0, 8.0])
27+
result = a.floor_divide_(2.0)
3028
"""
3129
)
32-
obj.run(pytorch_code, ["a"])
30+
obj.run(pytorch_code, ["result"])
3331

3432

3533
def test_case_2():
3634
pytorch_code = textwrap.dedent(
3735
"""
3836
import torch
39-
a = torch.tensor([4.0, 3.0])
40-
b = torch.tensor([2.0, 2.0])
41-
a.floor_divide_(other=b)
37+
a = torch.tensor([4.0, 3.0, 8.0])
38+
b = torch.tensor([2.0, 2.0, 3.0])
39+
result = a.floor_divide_(b)
4240
"""
4341
)
44-
obj.run(pytorch_code, ["a"])
42+
obj.run(pytorch_code, ["result"])
4543

4644

4745
def test_case_3():
4846
pytorch_code = textwrap.dedent(
4947
"""
5048
import torch
51-
a = torch.tensor([4.0, 3.0])
52-
a.floor_divide_(torch.tensor([2.0, 2.0]))
49+
a = torch.tensor([4.0, 3.0, 8.0])
50+
b = torch.tensor([2.0, 2.0, 3.0])
51+
result = a.floor_divide_(other=b)
5352
"""
5453
)
55-
obj.run(pytorch_code, ["a"])
54+
obj.run(pytorch_code, ["result"])
5655

5756

5857
def test_case_4():
5958
pytorch_code = textwrap.dedent(
6059
"""
6160
import torch
62-
a = torch.tensor([4.0, 3.0])
63-
a.floor_divide_(other=torch.tensor([2.0, 2.0]))
61+
a = torch.tensor([[4.0, 3.0], [8.0, 9.0]])
62+
result = a.floor_divide_(2)
6463
"""
6564
)
66-
obj.run(pytorch_code, ["a"])
65+
obj.run(pytorch_code, ["result"])
6766

6867

6968
def test_case_5():
7069
pytorch_code = textwrap.dedent(
7170
"""
7271
import torch
73-
a = torch.tensor([4.0, 3.0])
74-
a.floor_divide_(2.)
75-
"""
76-
)
77-
obj.run(pytorch_code, ["a"])
78-
79-
80-
def test_case_6():
81-
pytorch_code = textwrap.dedent(
82-
"""
83-
import torch
84-
a = torch.tensor([4.0, 3.0])
85-
a.floor_divide_(other=2.)
72+
a = torch.tensor([10.0, 15.0, 20.0])
73+
b = torch.tensor([3.0, 4.0, 6.0])
74+
result = a.floor_divide_(other=b)
8675
"""
8776
)
88-
obj.run(pytorch_code, ["a"])
77+
obj.run(pytorch_code, ["result"])

tests/test_Tensor_pow_.py

Lines changed: 41 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,19 +23,54 @@ def test_case_1():
2323
pytorch_code = textwrap.dedent(
2424
"""
2525
import torch
26-
a = torch.tensor([0.4331, 1.2475, 0.6834, -0.2791])
27-
a.pow_(2)
26+
a = torch.tensor([1.0, 2.0, 3.0])
27+
result = a.pow_(2.0)
2828
"""
2929
)
30-
obj.run(pytorch_code, ["a"])
30+
obj.run(pytorch_code, ["result"])
3131

3232

3333
def test_case_2():
3434
pytorch_code = textwrap.dedent(
3535
"""
3636
import torch
37-
a = torch.tensor([0.4331, 1.2475, 0.6834, -0.2791])
38-
a.pow_(exponent=3.)
37+
a = torch.tensor([1.0, 2.0, 3.0])
38+
b = torch.tensor([2.0, 3.0, 2.0])
39+
result = a.pow_(b)
3940
"""
4041
)
41-
obj.run(pytorch_code, ["a"])
42+
obj.run(pytorch_code, ["result"])
43+
44+
45+
def test_case_3():
46+
pytorch_code = textwrap.dedent(
47+
"""
48+
import torch
49+
a = torch.tensor([1.0, 2.0, 3.0])
50+
result = a.pow_(exponent=3.0)
51+
"""
52+
)
53+
obj.run(pytorch_code, ["result"])
54+
55+
56+
def test_case_4():
57+
pytorch_code = textwrap.dedent(
58+
"""
59+
import torch
60+
a = torch.tensor([[2.0, 3.0], [4.0, 5.0]])
61+
result = a.pow_(2)
62+
"""
63+
)
64+
obj.run(pytorch_code, ["result"])
65+
66+
67+
def test_case_5():
68+
pytorch_code = textwrap.dedent(
69+
"""
70+
import torch
71+
a = torch.tensor([2.0, 3.0, 4.0])
72+
b = torch.tensor([1.0, 2.0, 3.0])
73+
result = a.pow_(exponent=b)
74+
"""
75+
)
76+
obj.run(pytorch_code, ["result"])

0 commit comments

Comments
 (0)