Skip to content

Commit e782cac

Browse files
authored
映射文档 No. 49 (#5849)
* '新增四个api映射文档' * fix some errors * fix some errors * add some examples
1 parent 3572a48 commit e782cac

File tree

6 files changed

+158
-2
lines changed

6 files changed

+158
-2
lines changed

docs/guides/model_convert/convert_from_pytorch/api_difference/ops/torch.mm.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
## [torch 参数更多 ]torch.mm
2-
### [torch.mm](https://pytorch.org/docs/stable/generated/torch.mm.html?highlight=mm#torch.mm)
2+
### [torch.mm](https://pytorch.org/docs/1.13/generated/torch.mm.html?highlight=torch+mm#torch.mm)
33

44
```python
55
torch.mm(input,

docs/guides/model_convert/convert_from_pytorch/api_difference/ops/torch.mv.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
## [ torch 参数更多 ]torch.mv
2-
### [torch.mv](https://pytorch.org/docs/stable/generated/torch.mv.html?highlight=mv#torch.mv)
2+
### [torch.mv](https://pytorch.org/docs/1.13/generated/torch.mv.html?highlight=torch+mv#torch.mv)
33
```python
44
torch.mv(input, vec, out=None)
55
```
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
## [ torch 参数更多 ] torch.qr
2+
3+
### [torch.qr](https://pytorch.org/docs/1.13/generated/torch.qr.html#torch.qr)
4+
5+
```python
6+
torch.qr(input, some=True, *, out=None)
7+
```
8+
9+
### [paddle.linalg.qr](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/linalg/qr_cn.html#qr)
10+
11+
```python
12+
paddle.linalg.qr(x, mode='reduced', name=None)
13+
```
14+
15+
其中 PyTorch 相比 Paddle 支持更多其他参数,具体如下:
16+
17+
### 参数映射
18+
| PyTorch | PaddlePaddle | 备注 |
19+
| ------------- | ------------ | ------------------------------------------------------ |
20+
| input | x | 表示输入 Tensor,仅参数名不一致。 |
21+
| some | mode | 表示 QR 分解的行为。 需进行转写。 |
22+
| out | - | 表示输出的 Tensor 元组。 Paddle 无此参数,需要进行转写。 |
23+
24+
### 转写示例
25+
### some:控制 QR 分解的行为
26+
```python
27+
# 当进行完整的 QR 分解时
28+
# Pytorch 写法
29+
q, r = torch.qr(x, some=False)
30+
31+
# Paddle 写法
32+
q, r = paddle.linalg.qr(x, mode='complete')
33+
34+
#当进行减少的 QR 分解时
35+
# Pytorch 写法
36+
q, r = torch.qr(x, some=True)
37+
38+
# Paddle 写法
39+
q, r = paddle.linalg.qr(x, mode='reduced')
40+
```
41+
42+
#### out:指定输出
43+
```python
44+
# Pytorch 写法
45+
torch.qr(x, out = (q, r) )
46+
47+
# Paddle 写法
48+
q, r = paddle.linalg.qr(x)
49+
```
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
## [ torch 参数更多 ] torch.svd
2+
3+
### [torch.svd](https://pytorch.org/docs/1.13/generated/torch.svd.html?highlight=torch+svd#torch.svd)
4+
5+
```python
6+
torch.svd(input, some=True, compute_uv=True, *, out=None)
7+
```
8+
9+
### [paddle.linalg.svd](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/linalg/svd_cn.html#svd)
10+
11+
```python
12+
paddle.linalg.svd(x, full_matrics=False, name=None)
13+
```
14+
15+
其中 PyTorch 相比 Paddle 支持更多其他参数,具体如下:
16+
17+
### 参数映射
18+
| PyTorch | PaddlePaddle | 备注 |
19+
| ------------- | ------------ | ------------------------------------------------------ |
20+
| input | x | 输入 Tensor ,仅参数名不一致。 |
21+
| some | full_matrics | 表示需计算的奇异值数目。 与 Pytorch 默认值不同,需要转写。 |
22+
| compute_uv | - | 表示是否计算 U 和 V 。 Paddle 暂无转写方式。 |
23+
| out | - | 表示输出的 Tensor 元组。 Paddle 无此参数,需要进行转写。 |
24+
25+
### 转写示例
26+
#### some:表示需计算的奇异值数目
27+
```python
28+
# Pytorch 写法
29+
u, s, v = torch.svd(x, some = True )
30+
31+
# Paddle 写法
32+
u, s, v = paddle.linalg.svd(x, full_matrics = False)
33+
```
34+
#### out:指定输出
35+
```python
36+
# Pytorch 写法
37+
torch.svd(x, out=(u, s, v) )
38+
39+
# Paddle 写法
40+
u, s, v = paddle.linalg.svd(x)
41+
```
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
## [ torch 参数更多 ] torch.svd_lowrank
2+
3+
### [torch.svd_lowrank](https://pytorch.org/docs/1.13/generated/torch.svd_lowrank.html?highlight=torch+svd_lowrank#torch.svd_lowrank)
4+
5+
```python
6+
torch.svd_lowrank(A, q=6, niter=2, M=None)
7+
```
8+
9+
### [paddle.linalg.svd](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/linalg/svd_cn.html#svd)
10+
11+
```python
12+
paddle.linalg.svd(x, full_matrics=False, name=None)
13+
```
14+
15+
其中 PyTorch 相比 Paddle 支持更多其他参数,具体如下:
16+
17+
### 参数映射
18+
| PyTorch | PaddlePaddle | 备注 |
19+
| ------------- | ------------ | ------------------------------------------------------ |
20+
| A | x | 表示输入 Tensor,仅参数名不一致。 |
21+
| q | - | 表示输入 Tensor 略高估计秩。 Paddle 暂无转写方式。 |
22+
| niter | - | 表示子空间进行迭代的数量。 Paddle 暂无转写方式。 |
23+
| M | - | 表示输入 Tensor 的平均 size。 Paddle 暂无转写方式。 |
24+
| - | full_matrics | 表示是否计算完整的 U 和 V 矩阵。 PyTorch 无此参数,Paddle 保持默认即可。 |
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
## [ torch 参数更多 ] torch.symeig
2+
3+
### [torch.symeig](https://pytorch.org/docs/1.13/generated/torch.symeig.html?highlight=torch+symeig#torch.symeig)
4+
5+
```python
6+
torch.symeig(input, eigenvectors=False, upper=True, *, out=None)
7+
```
8+
9+
### [paddle.linalg.eigh](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/linalg/eigh_cn.html#eigh)
10+
11+
```python
12+
paddle.linalg.eigh(x, UPLO='L', name=None)
13+
```
14+
15+
其中 PyTorch 相比 Paddle 支持更多其他参数,具体如下:
16+
17+
### 参数映射
18+
| PyTorch | PaddlePaddle | 备注 |
19+
| ------------- | ------------ | ------------------------------------------------------ |
20+
| input | x | 输入的对称 Tensor,仅参数名不一致。 |
21+
| eigenvectors | - | 表示是否计算特征向量。Paddle 暂无转写方式。 |
22+
| upper | UPLO | 表示计算上三角或者下三角矩阵。 需进行转写。 |
23+
| out | - | 表示输出的 Tensor 元组, Paddle 无此参数,需要进行转写。 |
24+
25+
### 转写示例
26+
#### upper:表示计算上三角或者下三角矩阵
27+
```python
28+
# Pytorch 写法
29+
e, v = torch.symeig(x, upper = False)
30+
31+
# Paddle 写法
32+
e, v = paddle.linalg.eigh(x, UPLO = 'L')
33+
```
34+
35+
#### out:指定输出
36+
```python
37+
# Pytorch 写法
38+
torch.symeig(x, out=(e, v) )
39+
40+
# Paddle 写法
41+
e, v = paddle.linalg.eigh(x)
42+
```

0 commit comments

Comments
 (0)