Skip to content

Commit 614e281

Browse files
committed
【Hackathon 7th No.37】为 Paddle 代码转换工具新增 API 转换规则(第 4 组)
1 parent 22404df commit 614e281

16 files changed

+460
-0
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
## [ 仅参数名不一致 ]torch.Tensor.igamma
2+
3+
### [torch.Tensor.igamma](https://pytorch.org/docs/stable/generated/torch.Tensor.igamma.html#torch.Tensor.igamma)
4+
5+
```python
6+
torch.Tensor.igamma(other)
7+
```
8+
9+
### [paddle.Tensor.gammainc](https://www.paddlepaddle.org.cn/documentation/docs/zh/develop/api/paddle/gammainc_cn.html#gammainc)
10+
11+
```python
12+
paddle.Tensor.gammainc(y, name=None)
13+
```
14+
15+
### 参数映射
16+
17+
| PyTorch | PaddlePaddle | 备注 |
18+
| ------- | ------------ | ------------- |
19+
| other | y | 正参数 Tensor |
20+
21+
### 转写示例
22+
23+
```python
24+
# PyTorch 写法
25+
out = x.igamma(y)
26+
27+
# Paddle 写法
28+
out = .gammainc(y)
29+
```
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
## [ 仅参数名不一致 ]torch.Tensor.igamma_
2+
3+
### [torch.Tensor.igamma_](https://pytorch.org/docs/stable/generated/torch.Tensor.igamma_.html#torch.Tensor.igamma_)
4+
5+
```python
6+
torch.Tensor.igamma_(other)
7+
```
8+
9+
### [paddle.Tensor.gammainc_](https://www.paddlepaddle.org.cn/documentation/docs/zh/develop/api/paddle/gammainc__cn.html#gammainc)
10+
11+
```python
12+
paddle.Tensor.gammainc_(y, name=None)
13+
```
14+
15+
### 参数映射
16+
17+
| PyTorch | PaddlePaddle | 备注 |
18+
| ------- | ------------ | ------------- |
19+
| other | y | 正参数 Tensor |
20+
21+
### 转写示例
22+
23+
```python
24+
# PyTorch 写法
25+
out = x.igamma_(y)
26+
27+
# Paddle 写法
28+
out = x.gammainc_(y)
29+
```
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
## [ 仅参数名不一致 ]torch.Tensor.igammac
2+
3+
### [torch.Tensor.igammac](https://pytorch.org/docs/stable/generated/torch.Tensor.igammac.html#torch.Tensor.igammac)
4+
5+
```python
6+
torch.Tensor.igammac(other)
7+
```
8+
9+
### [paddle.Tensor.gammaincc](https://www.paddlepaddle.org.cn/documentation/docs/zh/develop/api/paddle/gammaincc_cn.html#gammaincc)
10+
11+
```python
12+
paddle.Tensor.gammaincc(y, name=None)
13+
```
14+
15+
### 参数映射
16+
17+
| PyTorch | PaddlePaddle | 备注 |
18+
| ------- | ------------ | ------------- |
19+
| other | y | 正参数 Tensor |
20+
21+
### 转写示例
22+
23+
```python
24+
# PyTorch 写法
25+
out = x.igammac(y)
26+
27+
# Paddle 写法
28+
out = x.gammaincc(y)
29+
```
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
## [ 仅参数名不一致 ]torch.Tensor.igammac\_
2+
3+
### [torch.Tensor.igammac_](https://pytorch.org/docs/stable/generated/torch.Tensor.igammac_.html#torch.Tensor.igammac_)
4+
5+
```python
6+
torch.Tensor.igammac_(other)
7+
```
8+
9+
### [paddle.Tensor.gammaincc_](https://www.paddlepaddle.org.cn/documentation/docs/zh/develop/api/paddle/gammaincc__cn.html#gammaincc)
10+
11+
```python
12+
paddle.Tensor.gammaincc_(y, name=None)
13+
```
14+
15+
### 参数映射
16+
17+
| PyTorch | PaddlePaddle | 备注 |
18+
| ------- | ------------ | ------------- |
19+
| other | y | 正参数 Tensor |
20+
21+
### 转写示例
22+
23+
```python
24+
# PyTorch 写法
25+
out = x.igammac_(y)
26+
27+
# Paddle 写法
28+
out = x.gammaincc_(y)
29+
```
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
## [ 无参数 ]torch.Tensor.matrix_exp
2+
3+
### [torch.Tensor.matrix_exp](https://pytorch.org/docs/stable/generated/torch.Tensor.matrix_exp.html#torch-tensor-matrix-exp)
4+
5+
```python
6+
torch.Tensor.matrix_exp()
7+
```
8+
9+
### [paddle.linalg.matrix_exp](https://www.paddlepaddle.org.cn/documentation/docs/zh/develop/api/paddle/linalg/matrix_exp_cn.html)
10+
11+
```python
12+
paddle.linalg.matrix_exp(x, name=None)
13+
```
14+
15+
两者功能一致,无参数。
16+
17+
### 转写示例
18+
19+
```python
20+
# PyTorch 写法
21+
out = x.matrix_exp()
22+
23+
# Paddle 写法
24+
out = paddle.linalg.matrix_exp(x)
25+
```
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
## [ 参数完全一致 ]torch.Tensor.mvlgamma
2+
3+
### [torch.Tensor.mvlgamma](https://pytorch.org/docs/stable/generated/torch.Tensor.mvlgamma.html#torch-tensor-mvlgamma)
4+
5+
```python
6+
torch.Tensor.mvlgamma(p)
7+
```
8+
9+
### [paddle.Tensor.multigammaln](https://github.com/PaddlePaddle/Paddle/blob/be090bd0bc9ac7a8595296c316b3a6ed3dc60ba6/python/paddle/tensor/math.py#L5099)
10+
11+
```python
12+
paddle.Tensor.multigammaln(p, name=None)
13+
```
14+
15+
### 转写示例
16+
17+
```python
18+
# PyTorch 写法
19+
y = x.mvlgamma(p)
20+
21+
# Paddle 写法
22+
y = x.multigammaln(p)
23+
```
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<!--
2+
* @Description:
3+
* @Author: Xiao
4+
* @Date: 2024-09-21 16:03:47
5+
* @LastEditTime: 2024-09-23 19:33:10
6+
* @LastEditors: Xiao
7+
-->
8+
## [ 参数完全一致 ]torch.Tensor.mvlgamma_
9+
10+
### [torch.Tensor.mvlgamma_](https://pytorch.org/docs/stable/generated/torch.Tensor.mvlgamma_.html#torch-tensor-mvlgamma)
11+
12+
```python
13+
torch.Tensor.mvlgamma_(p)
14+
```
15+
16+
### [paddle.Tensor.multigammaln_](https://www.paddlepaddle.org.cn/documentation/docs/zh/develop/api/paddle/multigammaln__cn.html#multigammaln)
17+
18+
```python
19+
paddle.Tensor.multigammaln_(p, name=None)
20+
```
21+
22+
### 转写示例
23+
24+
```python
25+
# PyTorch 写法
26+
y = x.mvlgamma_(p)
27+
28+
# Paddle 写法
29+
y = x.multigammaln_(p)
30+
```
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
## [ 仅参数名不一致 ]torch.Tensor.orgqr
2+
3+
### [torch.Tensor.orgqr](https://pytorch.org/docs/stable/generated/torch.Tensor.orgqr.html#torch.Tensor.orgqr)
4+
5+
```python
6+
torch.Tensor.orgqr(input2)
7+
```
8+
9+
### [paddle.Tensor.householder_product](https://www.paddlepaddle.org.cn/documentation/docs/zh/2.6/api/paddle/linalg/householder_product_cn.html#householder-product)
10+
11+
```python
12+
paddle.Tensor.householder_product(tau, name=None)
13+
```
14+
15+
### 参数映射
16+
17+
| PyTorch | PaddlePaddle | 备注 |
18+
| ------- | ------------ | ---------------- |
19+
| input2 | tau | 仅参数名字不一致 |
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
## [ 仅参数名不一致 ]torch.Tensor.ormqr
2+
3+
### [torch.Tensor.ormqr](https://pytorch.org/docs/stable/generated/torch.Tensor.orgqr.html#torch.Tensor.orgqr)
4+
5+
```python
6+
torch.Tensor.ormqr(input2, input3, left=True, transpose=False)
7+
```
8+
9+
### [paddle.Tensor.ormqr](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/Tensor_cn.html#tensor)
10+
11+
```python
12+
paddle.Tensor.ormqr(tau, other, left=True, transpose=False)
13+
```
14+
15+
### 参数映射
16+
17+
| PyTorch | PaddlePaddle | 备注 |
18+
| ------------- | ------------ | ------------------------------------------------------ |
19+
| input2 | tau | 仅参数名字不一致 |
20+
| input3 | other | 仅参数名字不一致 |
21+
| left | left | 一致 |
22+
| transpose | transpose | 一致 |
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
## [ torch 参数更多 ]torch.linalg.cholesky_ex
2+
3+
### [torch.linalg.cholesky_ex](https://pytorch.org/docs/stable/generated/torch.linalg.cholesky_ex.html)
4+
5+
```python
6+
torch.linalg.cholesky_ex(input, *, upper=False, check_errors=False, out=None)
7+
```
8+
9+
### [paddle.linalg.cholesky](https://www.paddlepaddle.org.cn/documentation/docs/zh/develop/api/paddle/linalg/cholesky_cn.html)
10+
11+
```python
12+
paddle.linalg.cholesky(x, upper=False, name=None)
13+
```
14+
15+
PyTorch 相比 Paddle 支持更多其他参数,具体如下:
16+
17+
### 参数映射
18+
19+
| PyTorch | PaddlePaddle | 备注 |
20+
| ------------ | ------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------- |
21+
| input | x | 表示输入参数为多维 Tensor,它的维度应该为 [*, M, N],其中*为零或更大的批次尺寸,并且最里面的两个维度上的矩阵都应为对称的正定矩阵,仅参数名不一致。 |
22+
| upper | upper | 表示是否返回上三角矩阵或下三角矩阵。 |
23+
| check_errors | - | 是否检查错误,paddle 暂不支持。 |
24+
| out | - | 表示输出的 Tensor ,Paddle 无此参数,需要转写。 |
25+
| 返回值 | 返回值 | Pytorch 返回两个 out 与 info,Paddle 仅返回一个 Tensor:out,需转写。 |
26+
27+
### 转写示例
28+
29+
#### out: 输出的 Tensor
30+
31+
#### 返回值
32+
33+
```python
34+
# PyTorch 写法:
35+
torch.linalg.cholesky_ex(x, upper=False)
36+
37+
# Paddle 写法:
38+
## 注: 仅支持check_errors=False时的情况
39+
(paddle.linalg.cholesky(x, upper=False), paddle.zeros(x.shape[:-2], dtype='int64'))
40+
```
41+
42+
```python
43+
# PyTorch 写法
44+
torch.linalg.cholesky_ex(x, upper=False, out=output)
45+
46+
47+
# Paddle 写法
48+
paddle.assign(paddle.linalg.cholesky(x, upper=False),output)
49+
```

0 commit comments

Comments
 (0)