-
Notifications
You must be signed in to change notification settings - Fork 756
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 组)-part #6884
Changes from 1 commit
614e281
46ac3dc
a9c013c
67a3eed
d5980ae
35226d4
810e997
05498ff
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 |
---|---|---|
@@ -0,0 +1,29 @@ | ||
## [ 仅参数名不一致 ]torch.Tensor.igamma | ||
|
||
### [torch.Tensor.igamma](https://pytorch.org/docs/stable/generated/torch.Tensor.igamma.html#torch.Tensor.igamma) | ||
|
||
```python | ||
torch.Tensor.igamma(other) | ||
``` | ||
|
||
### [paddle.Tensor.gammainc](https://www.paddlepaddle.org.cn/documentation/docs/zh/develop/api/paddle/gammainc_cn.html#gammainc) | ||
|
||
```python | ||
paddle.Tensor.gammainc(y, name=None) | ||
``` | ||
|
||
### 参数映射 | ||
|
||
| PyTorch | PaddlePaddle | 备注 | | ||
| ------- | ------------ | ------------- | | ||
| other | y | 正参数 Tensor | | ||
|
||
### 转写示例 | ||
|
||
```python | ||
# PyTorch 写法 | ||
out = x.igamma(y) | ||
|
||
# Paddle 写法 | ||
out = .gammainc(y) | ||
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. x掉了 |
||
``` |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
## [ 仅参数名不一致 ]torch.Tensor.igamma_ | ||
|
||
### [torch.Tensor.igamma_](https://pytorch.org/docs/stable/generated/torch.Tensor.igamma_.html#torch.Tensor.igamma_) | ||
|
||
```python | ||
torch.Tensor.igamma_(other) | ||
``` | ||
|
||
### [paddle.Tensor.gammainc_](https://www.paddlepaddle.org.cn/documentation/docs/zh/develop/api/paddle/gammainc__cn.html#gammainc) | ||
|
||
```python | ||
paddle.Tensor.gammainc_(y, name=None) | ||
``` | ||
|
||
### 参数映射 | ||
|
||
| PyTorch | PaddlePaddle | 备注 | | ||
| ------- | ------------ | ------------- | | ||
| other | y | 正参数 Tensor | | ||
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. 加一个 仅参数名不同,一比一对照模板 |
||
|
||
### 转写示例 | ||
|
||
```python | ||
# PyTorch 写法 | ||
out = x.igamma_(y) | ||
|
||
# Paddle 写法 | ||
out = x.gammainc_(y) | ||
``` |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
## [ 仅参数名不一致 ]torch.Tensor.igammac | ||
|
||
### [torch.Tensor.igammac](https://pytorch.org/docs/stable/generated/torch.Tensor.igammac.html#torch.Tensor.igammac) | ||
|
||
```python | ||
torch.Tensor.igammac(other) | ||
``` | ||
|
||
### [paddle.Tensor.gammaincc](https://www.paddlepaddle.org.cn/documentation/docs/zh/develop/api/paddle/gammaincc_cn.html#gammaincc) | ||
|
||
```python | ||
paddle.Tensor.gammaincc(y, name=None) | ||
``` | ||
|
||
### 参数映射 | ||
|
||
| PyTorch | PaddlePaddle | 备注 | | ||
| ------- | ------------ | ------------- | | ||
| other | y | 正参数 Tensor | | ||
|
||
### 转写示例 | ||
|
||
```python | ||
# PyTorch 写法 | ||
out = x.igammac(y) | ||
|
||
# Paddle 写法 | ||
out = x.gammaincc(y) | ||
``` |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
## [ 仅参数名不一致 ]torch.Tensor.igammac\_ | ||
|
||
### [torch.Tensor.igammac_](https://pytorch.org/docs/stable/generated/torch.Tensor.igammac_.html#torch.Tensor.igammac_) | ||
|
||
```python | ||
torch.Tensor.igammac_(other) | ||
``` | ||
|
||
### [paddle.Tensor.gammaincc_](https://www.paddlepaddle.org.cn/documentation/docs/zh/develop/api/paddle/gammaincc__cn.html#gammaincc) | ||
|
||
```python | ||
paddle.Tensor.gammaincc_(y, name=None) | ||
``` | ||
|
||
### 参数映射 | ||
|
||
| PyTorch | PaddlePaddle | 备注 | | ||
| ------- | ------------ | ------------- | | ||
| other | y | 正参数 Tensor | | ||
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. 一比一对照模板写 |
||
|
||
### 转写示例 | ||
|
||
```python | ||
# PyTorch 写法 | ||
out = x.igammac_(y) | ||
|
||
# Paddle 写法 | ||
out = x.gammaincc_(y) | ||
``` |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
## [ 无参数 ]torch.Tensor.matrix_exp | ||
|
||
### [torch.Tensor.matrix_exp](https://pytorch.org/docs/stable/generated/torch.Tensor.matrix_exp.html#torch-tensor-matrix-exp) | ||
|
||
```python | ||
torch.Tensor.matrix_exp() | ||
``` | ||
|
||
### [paddle.linalg.matrix_exp](https://www.paddlepaddle.org.cn/documentation/docs/zh/develop/api/paddle/linalg/matrix_exp_cn.html) | ||
|
||
```python | ||
paddle.linalg.matrix_exp(x, name=None) | ||
``` | ||
|
||
两者功能一致,无参数。 | ||
|
||
### 转写示例 | ||
|
||
```python | ||
# PyTorch 写法 | ||
out = x.matrix_exp() | ||
|
||
# Paddle 写法 | ||
out = paddle.linalg.matrix_exp(x) | ||
``` |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
## [ 参数完全一致 ]torch.Tensor.mvlgamma | ||
|
||
### [torch.Tensor.mvlgamma](https://pytorch.org/docs/stable/generated/torch.Tensor.mvlgamma.html#torch-tensor-mvlgamma) | ||
|
||
```python | ||
torch.Tensor.mvlgamma(p) | ||
``` | ||
|
||
### [paddle.Tensor.multigammaln](https://github.com/PaddlePaddle/Paddle/blob/be090bd0bc9ac7a8595296c316b3a6ed3dc60ba6/python/paddle/tensor/math.py#L5099) | ||
|
||
```python | ||
paddle.Tensor.multigammaln(p, name=None) | ||
``` | ||
|
||
### 转写示例 | ||
|
||
```python | ||
# PyTorch 写法 | ||
y = x.mvlgamma(p) | ||
|
||
# Paddle 写法 | ||
y = x.multigammaln(p) | ||
``` |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<!-- | ||
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. 这些删掉 |
||
* @Description: | ||
* @Author: Xiao | ||
* @Date: 2024-09-21 16:03:47 | ||
* @LastEditTime: 2024-09-23 19:33:10 | ||
* @LastEditors: Xiao | ||
--> | ||
## [ 参数完全一致 ]torch.Tensor.mvlgamma_ | ||
|
||
### [torch.Tensor.mvlgamma_](https://pytorch.org/docs/stable/generated/torch.Tensor.mvlgamma_.html#torch-tensor-mvlgamma) | ||
|
||
```python | ||
torch.Tensor.mvlgamma_(p) | ||
``` | ||
|
||
### [paddle.Tensor.multigammaln_](https://www.paddlepaddle.org.cn/documentation/docs/zh/develop/api/paddle/multigammaln__cn.html#multigammaln) | ||
|
||
```python | ||
paddle.Tensor.multigammaln_(p, name=None) | ||
``` | ||
|
||
### 转写示例 | ||
|
||
```python | ||
# PyTorch 写法 | ||
y = x.mvlgamma_(p) | ||
|
||
# Paddle 写法 | ||
y = x.multigammaln_(p) | ||
``` |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
## [ 仅参数名不一致 ]torch.Tensor.orgqr | ||
|
||
### [torch.Tensor.orgqr](https://pytorch.org/docs/stable/generated/torch.Tensor.orgqr.html#torch.Tensor.orgqr) | ||
|
||
```python | ||
torch.Tensor.orgqr(input2) | ||
``` | ||
|
||
### [paddle.Tensor.householder_product](https://www.paddlepaddle.org.cn/documentation/docs/zh/2.6/api/paddle/linalg/householder_product_cn.html#householder-product) | ||
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. 这些2.6统一都换成develop版本的 |
||
|
||
```python | ||
paddle.Tensor.householder_product(tau, name=None) | ||
``` | ||
|
||
### 参数映射 | ||
|
||
| PyTorch | PaddlePaddle | 备注 | | ||
| ------- | ------------ | ---------------- | | ||
| input2 | tau | 仅参数名字不一致 | | ||
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. 仅参数名不一致 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
## [ 仅参数名不一致 ]torch.Tensor.ormqr | ||
|
||
### [torch.Tensor.ormqr](https://pytorch.org/docs/stable/generated/torch.Tensor.orgqr.html#torch.Tensor.orgqr) | ||
|
||
```python | ||
torch.Tensor.ormqr(input2, input3, left=True, transpose=False) | ||
``` | ||
|
||
### [paddle.Tensor.ormqr](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/Tensor_cn.html#tensor) | ||
|
||
```python | ||
paddle.Tensor.ormqr(tau, other, left=True, transpose=False) | ||
``` | ||
|
||
### 参数映射 | ||
|
||
| PyTorch | PaddlePaddle | 备注 | | ||
| ------------- | ------------ | ------------------------------------------------------ | | ||
| input2 | tau | 仅参数名字不一致 | | ||
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. 先简述下功能,再表明差异 一比一对照模板写 |
||
| input3 | other | 仅参数名字不一致 | | ||
| left | left | 一致 | | ||
| transpose | transpose | 一致 | |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
## [ torch 参数更多 ]torch.linalg.cholesky_ex | ||
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. 根据分类的优先级排序,这个不能算做 torch参数更多,因为返回参数不同 |
||
|
||
### [torch.linalg.cholesky_ex](https://pytorch.org/docs/stable/generated/torch.linalg.cholesky_ex.html) | ||
|
||
```python | ||
torch.linalg.cholesky_ex(input, *, upper=False, check_errors=False, out=None) | ||
``` | ||
|
||
### [paddle.linalg.cholesky](https://www.paddlepaddle.org.cn/documentation/docs/zh/develop/api/paddle/linalg/cholesky_cn.html) | ||
|
||
```python | ||
paddle.linalg.cholesky(x, upper=False, name=None) | ||
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. cholesky_ex与cholesky是不是返回值不同,cholesky_ex会多返回一种info类型的 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. 对的,他会多返回一个info |
||
``` | ||
|
||
PyTorch 相比 Paddle 支持更多其他参数,具体如下: | ||
|
||
### 参数映射 | ||
|
||
| PyTorch | PaddlePaddle | 备注 | | ||
| ------------ | ------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------- | | ||
| input | x | 表示输入参数为多维 Tensor,它的维度应该为 [*, M, N],其中*为零或更大的批次尺寸,并且最里面的两个维度上的矩阵都应为对称的正定矩阵,仅参数名不一致。 | | ||
| upper | upper | 表示是否返回上三角矩阵或下三角矩阵。 | | ||
| check_errors | - | 是否检查错误,paddle 暂不支持。 | | ||
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. 能否转写 要备注清楚 |
||
| out | - | 表示输出的 Tensor ,Paddle 无此参数,需要转写。 | | ||
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. |
||
| 返回值 | 返回值 | Pytorch 返回两个 out 与 info,Paddle 仅返回一个 Tensor:out,需转写。 | | ||
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. 返回值这个还是需要转写的,我的意思是 你不用再注释强调仅支持 check_errors=False 这句话 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. 懂了,那个强调不需要,我都觉得返回值不转写太奇怪了 |
||
|
||
### 转写示例 | ||
|
||
#### out: 输出的 Tensor | ||
|
||
#### 返回值 | ||
|
||
```python | ||
# PyTorch 写法: | ||
torch.linalg.cholesky_ex(x, upper=False) | ||
|
||
# Paddle 写法: | ||
## 注: 仅支持check_errors=False时的情况 | ||
(paddle.linalg.cholesky(x, upper=False), paddle.zeros(x.shape[:-2], dtype='int64')) | ||
``` | ||
|
||
```python | ||
# PyTorch 写法 | ||
torch.linalg.cholesky_ex(x, upper=False, out=output) | ||
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. |
||
|
||
|
||
# Paddle 写法 | ||
paddle.assign(paddle.linalg.cholesky(x, upper=False),output) | ||
``` |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
## [torch 参数更多]torch.linalg.inv_ex | ||
|
||
### [torch.linalg.inv_ex](https://pytorch.org/docs/stable/generated/torch.linalg.inv_ex.html) | ||
|
||
```python | ||
torch.linalg.inv_ex(A, *, check_errors=False, out=None) | ||
``` | ||
|
||
### [paddle.linalg.inv](https://www.paddlepaddle.org.cn/documentation/docs/zh/develop/api/paddle/linalg/inv_cn.html) | ||
|
||
```python | ||
paddle.linalg.inv(x, name=None) | ||
monster1015 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
``` | ||
|
||
PyTorch 相比 Paddle 支持更多其他参数,具体如下: | ||
|
||
### 参数映射 | ||
|
||
| PyTorch | PaddlePaddle | 备注 | | ||
| ------------ | ------------ | --------------------------------------------------------------------- | | ||
| A | x | 输入 Tensor,仅参数名不一致。 | | ||
| check_errors | - | paddle 暂不支持检查错误 | | ||
| out | - | 表示输出的 Tensor , Paddle 无此参数,需要转写。 | | ||
| 返回值 | 返回值 | Pytorch 返回两个 out 与 info,Paddle 仅返回一个 Tensor:out,需转写。 | | ||
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. 返回值这个还是需要转写的,我的意思是 你不用再注释强调仅支持 check_errors=False 这句话 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. 已经好了的 |
||
|
||
### 转写示例 | ||
|
||
#### 返回值 | ||
|
||
```python | ||
# PyTorch 写法: | ||
torch.linalg.inv_ex(x) | ||
|
||
# Paddle 写法: | ||
## 注: 仅支持check_errors=False时的情况 | ||
(paddle.linalg.inv(x), paddle.zeros(x.shape[:-2], dtype='int64')) | ||
``` | ||
|
||
#### out 参数:输出的 Tensor | ||
|
||
```python | ||
# PyTorch 写法: | ||
torch.linalg.inv_ex(x, out=y) | ||
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. 同上 |
||
|
||
# Paddle 写法: | ||
paddle.assign(paddle.linalg.inv(x), y) | ||
``` |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
## [ 组合替代实现 ]torch.special.ndtr | ||
|
||
### [torch.special.ndtr](https://pytorch.org/docs/stable/special.html#torch.special.ndtr) | ||
|
||
```python | ||
torch.special.ndtr(input, *, out=None) | ||
``` | ||
|
||
Paddle 无此 API,需要组合实现。 | ||
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. 公式已经加了 |
||
|
||
### 转写示例 | ||
|
||
```python | ||
# PyTorch 写法 | ||
y = torch.special.ndtr(a) | ||
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. 不需要加个y= 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. 这个是删掉了的 |
||
|
||
# Paddle 写法 | ||
y = (paddle.erf(a/paddle.sqrt(paddle.to_tensor(2)))-paddle.erf(paddle.to_tensor(-float('inf'))))/2 | ||
``` |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
## [ 组合替代实现 ]torch.testing.make_tensor | ||
|
||
### [torch.testing.make_tensor](https://pytorch.org/docs/stable/testing.html#torch.testing.make_tensor) | ||
|
||
```python | ||
torch.testing.make_tensor(*shape, dtype, device, low=None, high=None, requires_grad=False, noncontiguous=False, exclude_zero=False, memory_format=None) | ||
``` | ||
|
||
Paddle 无此 API,需要组合实现。 | ||
|
||
### 转写示例 | ||
|
||
```python | ||
# PyTorch 写法 | ||
x = torch.testing.make_tensor(shape, dtype, device, low=low, high=high, requires_grad=True) | ||
|
||
# Paddle 写法 | ||
x = paddle.uniform(shape, dtype=dtype, min=low, max=high).to(device) | ||
x.stop_gradient = False | ||
``` |
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.
加一个 仅参数名不同