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

【Hackathon 7th No.37】为 Paddle 代码转换工具新增 API 转换规则(第 4 组) #481

Merged
merged 23 commits into from
Oct 12, 2024
Merged
Show file tree
Hide file tree
Changes from 12 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
188 changes: 176 additions & 12 deletions paconvert/api_mapping.json
Original file line number Diff line number Diff line change
Expand Up @@ -1796,10 +1796,50 @@
"paddle_api": "paddle.Tensor.i0_",
"min_input_args": 0
},
"torch.Tensor.igamma": {},
"torch.Tensor.igamma_": {},
"torch.Tensor.igammac": {},
"torch.Tensor.igammac_": {},
"torch.Tensor.igamma": {
"Matcher": "GenericMatcher",
"paddle_api": "paddle.Tensor.gammainc",
"min_input_args": 1,
"args_list": [
"other"
],
"kwargs_change": {
"other": "y"
}
},
"torch.Tensor.igamma_": {
"Matcher": "GenericMatcher",
"paddle_api": "paddle.Tensor.gammainc_",
"min_input_args": 1,
"args_list": [
"other"
],
"kwargs_change": {
"other": "y"
}
},
"torch.Tensor.igammac": {
"Matcher": "GenericMatcher",
"paddle_api": "paddle.Tensor.gammaincc",
"min_input_args": 1,
"args_list": [
"other"
],
"kwargs_change": {
"other": "y"
}
},
"torch.Tensor.igammac_": {
"Matcher": "GenericMatcher",
"paddle_api": "paddle.Tensor.gammaincc_",
"min_input_args": 1,
"args_list": [
"other"
],
"kwargs_change": {
"other": "y"
}
},
"torch.Tensor.index_add": {
"Matcher": "IndexAddMatcher",
"paddle_api": "paddle.Tensor.index_add",
Expand Down Expand Up @@ -2398,7 +2438,11 @@
"other": "y"
}
},
"torch.Tensor.matrix_exp": {},
"torch.Tensor.matrix_exp": {
"Matcher": "TensorMatrixExpMatcher",
"paddle_api": "paddle.linalg.matrix_exp",
"min_input_args": 0
},
"torch.Tensor.matrix_power": {
"Matcher": "GenericMatcher",
"paddle_api": "paddle.Tensor.matrix_power",
Expand Down Expand Up @@ -2567,8 +2611,22 @@
"vec"
]
},
"torch.Tensor.mvlgamma": {},
"torch.Tensor.mvlgamma_": {},
"torch.Tensor.mvlgamma": {
"Matcher": "GenericMatcher",
"paddle_api": "paddle.Tensor.multigammaln",
"min_input_args": 1,
"args_list": [
"p"
]
},
"torch.Tensor.mvlgamma_": {
"Matcher": "GenericMatcher",
"paddle_api": "paddle.Tensor.multigammaln_",
"min_input_args": 1,
"args_list": [
"p"
]
},
"torch.Tensor.nan_to_num": {
"Matcher": "GenericMatcher",
"paddle_api": "paddle.Tensor.nan_to_num",
Expand Down Expand Up @@ -2873,8 +2931,25 @@
"force": ""
}
},
"torch.Tensor.orgqr": {},
"torch.Tensor.ormqr": {},
"torch.Tensor.orgqr": {
"Matcher": "OrgqrMatcher",
Copy link
Collaborator

Choose a reason for hiding this comment

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

命名TensorOrgqrMatcher

"paddle_api": "paddle.Tensor.householder_product",
"min_input_args": 1,
"args_list": [
"input2"
]
},
"torch.Tensor.ormqr": {
"Matcher": "OrmqrMatcher",
Copy link
Collaborator

Choose a reason for hiding this comment

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

这个配置TensorFunc2PaddleFunc就可以吧

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_api": "paddle.linalg.ormqr",
"min_input_args": 2,
"args_list": [
"input2",
"input3",
"left",
"transpose"
]
},
"torch.Tensor.outer": {
"Matcher": "GenericMatcher",
"paddle_api": "paddle.Tensor.outer",
Expand Down Expand Up @@ -4007,6 +4082,14 @@
"maxsplit"
]
},
"torch._assert": {
"Matcher": "AssertMatcher",
"min_input_args": 2,
"args_list": [
"condition",
"message"
]
},
"torch.abs": {
"Matcher": "GenericMatcher",
"paddle_api": "paddle.abs",
Expand Down Expand Up @@ -8106,7 +8189,21 @@
"input": "x"
}
},
"torch.linalg.cholesky_ex": {},
"torch.linalg.cholesky_ex": {
"Matcher": "LinalgCholeskyExMatcher",
"paddle_api": "paddle.linalg.cholesky",
"min_input_args": 1,
"args_list": [
"input",
"*",
"upper",
"check_errors",
"out"
],
"unsupport_args": [
"check_errors"
Copy link
Collaborator

Choose a reason for hiding this comment

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

文档改了这里不改?

]
},
"torch.linalg.cond": {
"Matcher": "GenericMatcher",
"paddle_api": "paddle.linalg.cond",
Expand Down Expand Up @@ -8256,7 +8353,20 @@
"A": "x"
}
},
"torch.linalg.inv_ex": {},
"torch.linalg.inv_ex": {
"Matcher": "LinalgInvExMatcher",
"paddle_api": "paddle.linalg.inv",
"min_input_args": 1,
"args_list": [
"A",
"check_errors",
Copy link
Collaborator

Choose a reason for hiding this comment

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

这个不对吧,放在*的前后意义是不同的,是 位置参数 还是 指定关键字参数

Copy link
Contributor Author

Choose a reason for hiding this comment

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

他是指定关键字参数

"*",
"out"
],
"unsupport_args": [
"check_errors"
Copy link
Collaborator

Choose a reason for hiding this comment

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

文档改了这里不改?

]
},
"torch.linalg.ldl_factor": {},
"torch.linalg.ldl_factor_ex": {},
"torch.linalg.ldl_solve": {},
Expand Down Expand Up @@ -9170,6 +9280,20 @@
"input": "x"
}
},
"torch.mvlgamma": {
"Matcher": "GenericMatcher",
"paddle_api": "paddle.multigammaln",
"min_input_args": 2,
"args_list": [
"input",
"p",
"*",
"out"
],
"kwargs_change": {
"input": "x"
}
},
"torch.nan_to_num": {
"Matcher": "GenericMatcher",
"paddle_api": "paddle.nan_to_num",
Expand Down Expand Up @@ -13937,6 +14061,18 @@
"verbose"
]
},
"torch.ormqr": {
"Matcher": "OrmqrMatcher",
Copy link
Collaborator

Choose a reason for hiding this comment

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

这个配置GenericMatcher就可以吧

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_api": "paddle.linalg.ormqr",
"min_input_args": 3,
"args_list": [
"input",
"input2",
"input3",
"left",
"transpose"
]
},
"torch.outer": {
"Matcher": "GenericMatcher",
"paddle_api": "paddle.outer",
Expand Down Expand Up @@ -15170,7 +15306,15 @@
"input": "x"
}
},
"torch.special.ndtr": {},
"torch.special.ndtr": {
"Matcher": "SpecialNdtrMatcher",
"min_input_args": 1,
"args_list": [
"input",
"*",
"out"
]
},
"torch.special.ndtri": {
"Matcher": "SpecialNdtriMatcher",
"min_input_args": 1,
Expand Down Expand Up @@ -15650,6 +15794,26 @@
"check_stride": ""
}
},
"torch.testing.make_tensor": {
"Matcher": "MakeTMatcher",
"min_input_args": 3,
"args_list": [
"shape",
Copy link
Collaborator

Choose a reason for hiding this comment

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

这个看起来shape是 可变参数位置参数

其他的应该是 指定关键字参数

所以应该这么写:

"args_list": [
    "*shape",
    "*",
    "device",
    "dtype",
    "low",
    "high",
    "requires_grad",
    "noncontiguous",
    "exclude_zero",
    "memory_format"
]

只看torch文档可能不精确

"device",
"dtype",
"low",
"high",
"requires_grad",
"noncontiguous",
"exclude_zero",
"memory_format"
],
"unsupport_args": [
"noncontiguous",
"exclude_zero",
"memory_format"
Copy link
Collaborator

Choose a reason for hiding this comment

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

这些其实没必要全部算作 无法支持,只有影响到网络计算的才算。

]
},
"torch.tile": {
"Matcher": "GenericMatcher",
"paddle_api": "paddle.tile",
Expand Down
Loading