-
Notifications
You must be signed in to change notification settings - Fork 55
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
【Hackathon 5th No.42】 为Paddle代码转换工具新增API转换规则 (第1组 编号1-20) #318
Changes from 21 commits
c70c56a
278dabb
18c4fcf
c2ff651
27f95ea
2b34c7e
ac77673
d012be7
f5437e4
fd743e8
b9af256
bba66f9
f0f795a
9a13e34
bfc41d6
82fe9ed
1d49bcf
45a8bf8
4e48493
ce9228c
ab0709a
0d209d9
f5e026f
314f1ce
a2b2b09
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1473,7 +1473,9 @@ | |
}, | ||
"torch.Tensor.is_inference": {}, | ||
"torch.Tensor.is_meta": {}, | ||
"torch.Tensor.is_pinned": {}, | ||
"torch.Tensor.is_pinned": { | ||
"Matcher": "Is_PinnedMatcher" | ||
}, | ||
"torch.Tensor.is_quantized": {}, | ||
"torch.Tensor.is_set_to": {}, | ||
"torch.Tensor.is_shared": {}, | ||
|
@@ -2395,7 +2397,24 @@ | |
] | ||
}, | ||
"torch.Tensor.qscheme": {}, | ||
"torch.Tensor.quantile": {}, | ||
"torch.Tensor.quantile": { | ||
"Matcher": "GenericMatcher", | ||
"paddle_api": "paddle.Tensor.quantile", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
"args_list": [ | ||
"q", | ||
"dim", | ||
"keepdim", | ||
"*", | ||
"interpolation", | ||
"out" | ||
], | ||
"kwargs_change": { | ||
"dim": "axis" | ||
}, | ||
"unsupport_args": [ | ||
"interpolation " | ||
] | ||
}, | ||
"torch.Tensor.rad2deg": { | ||
"Matcher": "UnchangeMatcher" | ||
}, | ||
|
@@ -2937,7 +2956,10 @@ | |
"paddle_api": "paddle.Tensor.tanh_" | ||
}, | ||
"torch.Tensor.tensor_split": {}, | ||
"torch.Tensor.tile": {}, | ||
"torch.Tensor.tile": { | ||
"Matcher": "TensorTileMatcher", | ||
"paddle_api": "paddle.Tensor.tile" | ||
}, | ||
"torch.Tensor.to": { | ||
"Matcher": "TensorToMatcher" | ||
}, | ||
|
@@ -2946,7 +2968,14 @@ | |
"paddle_api": "paddle.Tensor.to_dense" | ||
}, | ||
"torch.Tensor.to_mkldnn": {}, | ||
"torch.Tensor.to_sparse": {}, | ||
"torch.Tensor.to_sparse": { | ||
"Matcher": "GenericMatcher", | ||
"min_input_args": 0, | ||
"paddle_api": "paddle.Tensor.to_sparse_coo", | ||
"args_list": [ | ||
"sparse_dim" | ||
] | ||
}, | ||
"torch.Tensor.tolist": { | ||
"Matcher": "UnchangeMatcher" | ||
}, | ||
|
@@ -7422,6 +7451,26 @@ | |
"dim" | ||
] | ||
}, | ||
"torch.nanquantile": { | ||
"Matcher": "GenericMatcher", | ||
"paddle_api": "paddle.nanquantile", | ||
"args_list": [ | ||
"input", | ||
"q", | ||
"dim", | ||
"keepdim", | ||
"*", | ||
"interpolation", | ||
"out" | ||
], | ||
"kwargs_change": { | ||
"input": "x", | ||
"dim": "axis" | ||
}, | ||
"unsupport_args": [ | ||
"interpolation " | ||
] | ||
}, | ||
"torch.nansum": { | ||
"Matcher": "GenericMatcher", | ||
"paddle_api": "paddle.nansum", | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# 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_pinned") | ||
|
||
|
||
def test_case_1(): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 加个GPU的单测,使用 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 这个comment不修改吗 |
||
pytorch_code = textwrap.dedent( | ||
""" | ||
import torch | ||
x = torch.randn(4,4) | ||
result = x.is_pinned() | ||
""" | ||
) | ||
obj.run(pytorch_code, ["result"]) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
# 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.quantile") | ||
|
||
|
||
def test_case_1(): | ||
pytorch_code = textwrap.dedent( | ||
""" | ||
import torch | ||
x = torch.tensor([0., 1., 2., 3.],dtype=torch.float64) | ||
result = x.quantile(0.6) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 第一个参数,指定下关键字吧,这四种情况的用例必须实现:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 这些comment不修改吗 |
||
""" | ||
) | ||
obj.run(pytorch_code, ["result"]) | ||
|
||
|
||
def test_case_2(): | ||
pytorch_code = textwrap.dedent( | ||
""" | ||
import torch | ||
x = torch.tensor([0., 1., 2., 3.],dtype=torch.float64) | ||
result = x.quantile(0.6, dim=None) | ||
""" | ||
) | ||
obj.run(pytorch_code, ["result"]) | ||
|
||
|
||
def test_case_3(): | ||
pytorch_code = textwrap.dedent( | ||
""" | ||
import torch | ||
x = torch.tensor([0., 1., 2., 3.],dtype=torch.float64) | ||
result = x.quantile(0.6, dim=None, keepdim=False) | ||
""" | ||
) | ||
obj.run(pytorch_code, ["result"]) | ||
|
||
|
||
def test_case_4(): | ||
pytorch_code = textwrap.dedent( | ||
""" | ||
import torch | ||
x = torch.tensor([0., 1., 2., 3.],dtype=torch.float64) | ||
result = x.quantile(0.6, dim=None, keepdim=False) | ||
""" | ||
) | ||
obj.run(pytorch_code, ["result"]) | ||
|
||
|
||
def test_case_5(): | ||
pytorch_code = textwrap.dedent( | ||
""" | ||
import torch | ||
x = torch.tensor([[ 0.0795, -1.2117, 0.9765], [ 1.1707, 0.6706, 0.4884]],dtype=torch.float64) | ||
result = x.quantile(0.6, dim=1, keepdim=True) | ||
""" | ||
) | ||
obj.run(pytorch_code, ["result"]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
torch.Tensor的API,都需要配置min_input_args