Skip to content

Commit acfd52e

Browse files
authored
文档与Matcher对齐 (#7339)
* update docs * rerun CI
1 parent f58c515 commit acfd52e

13 files changed

+80
-56
lines changed

docs/guides/model_convert/convert_from_pytorch/api_difference/Tensor/torch.Tensor.swapaxes.md

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,10 @@
66
torch.Tensor.swapaxes(axis0, axis1)
77
```
88

9-
### [paddle.transpose](https://www.paddlepaddle.org.cn/documentation/docs/zh/develop/api/paddle/transpose_cn.html#transpose)
9+
### [paddle.Tensor.transpose](https://www.paddlepaddle.org.cn/documentation/docs/zh/develop/api/paddle/Tensor_cn.html#transpose-perm-name-none)
1010

1111
```python
12-
paddle.transpose(x,
13-
perm,
12+
paddle.Tensor.transpose(perm,
1413
name=None)
1514
```
1615

@@ -20,21 +19,20 @@ paddle.transpose(x,
2019

2120
| PyTorch | PaddlePaddle | 备注 |
2221
| ------------- | ------------ | ------------------------------------------------------ |
23-
| - | <font color='red'>x</font> | 输入 Tensor。 |
24-
| <font color='red'>axis0</font> | - | PyTorch 转置的第一个维度,Paddle 无此参数,需要转写。 |
25-
| <font color='red'>axis1</font> | - | PyTorch 转置的第二个维度,Paddle 无此参数,需要转写。 |
26-
| - | <font color='red'>perm</font> | PyTorch 无此参数。 Paddle 可通过 perm 参数,等价的实现 torch 的 axis0、axis1 的功能。|
27-
22+
| axis0 | - | PyTorch 转置的第一个维度,Paddle 无此参数,需要转写。 |
23+
| axis1 | - | PyTorch 转置的第二个维度,Paddle 无此参数,需要转写。 |
24+
| - | perm | PyTorch 无此参数。 Paddle 可通过 perm 参数,等价的实现 torch 的 axis0、axis1 的功能。|
2825

2926
### 转写示例
3027

3128
#### axis0、axis1 参数: 转置的维度设置
29+
3230
``` python
3331
# PyTorch 写法:
3432
x.swapaxes(axis0=0, axis1=1)
3533

3634
# Paddle 写法:
37-
paddle.transpose(x, perm=[1, 0, 2])
35+
x.transpose(perm=[1, 0, 2])
3836

3937
# 注:x 为 3D Tensor
4038
```

docs/guides/model_convert/convert_from_pytorch/api_difference/Tensor/torch.Tensor.swapdims.md

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,10 @@
66
torch.Tensor.swapdims(dim0, dim1)
77
```
88

9-
### [paddle.transpose](https://www.paddlepaddle.org.cn/documentation/docs/zh/develop/api/paddle/transpose_cn.html#transpose)
9+
### [paddle.Tensor.transpose](https://www.paddlepaddle.org.cn/documentation/docs/zh/develop/api/paddle/Tensor_cn.html#transpose-perm-name-none)
1010

1111
```python
12-
paddle.transpose(x,
13-
perm,
12+
paddle.Tensor.transpose(perm,
1413
name=None)
1514
```
1615

@@ -20,10 +19,9 @@ paddle.transpose(x,
2019

2120
| PyTorch | PaddlePaddle | 备注 |
2221
| ------------- | ------------ | ------------------------------------------------------ |
23-
| - | <font color='red'>x</font> | 输入 Tensor。 |
24-
| <font color='red'>dim0</font> | - | PyTorch 转置的第一个维度,Paddle 无此参数,需要转写。 |
25-
| <font color='red'>dim1</font> | - | PyTorch 转置的第二个维度,Paddle 无此参数,需要转写。 |
26-
| - | <font color='red'>perm</font> | Paddle 无此参数。 Paddle 可通过 perm 参数,等价的实现 torch 的 dim0、dim1 的功能。|
22+
| dim0 | - | PyTorch 转置的第一个维度,Paddle 无此参数,需要转写。 |
23+
| dim1 | - | PyTorch 转置的第二个维度,Paddle 无此参数,需要转写。 |
24+
| - | perm | Paddle 无此参数。 Paddle 可通过 perm 参数,等价的实现 torch 的 dim0、dim1 的功能。|
2725

2826

2927
### 转写示例
@@ -34,7 +32,7 @@ paddle.transpose(x,
3432
x.swapaxes(dim0=0, dim1=1)
3533

3634
# Paddle 写法:
37-
paddle.transpose(x, perm=[1, 0, 2])
35+
x.transpose(perm=[1, 0, 2])
3836

3937
# 注:x 为 3D Tensor
4038
```

docs/guides/model_convert/convert_from_pytorch/api_difference/cuda/torch.cuda.synchronize.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@
66
torch.cuda.synchronize(device)
77
```
88

9-
### [paddle.device.cuda.synchronize](https://www.paddlepaddle.org.cn/documentation/docs/zh/develop/api/paddle/device/cuda/synchronize_cn.html)
9+
### [paddle.device.synchronize](https://www.paddlepaddle.org.cn/documentation/docs/zh/develop/api/paddle/device/cuda/synchronize_cn.html)
1010

1111
```python
12-
paddle.device.cuda.synchronize(device)
12+
paddle.device.synchronize(device)
1313
```
1414

1515
两者功能一致但参数类型不一致,具体如下:
@@ -28,11 +28,11 @@ paddle.device.cuda.synchronize(device)
2828
torch.cuda.synchronize('cuda:0')
2929

3030
# Paddle 写法
31-
paddle.device.cuda.synchronize('gpu:0')
31+
paddle.device.synchronize('gpu:0')
3232

3333
# PyTorch 写法
3434
torch.cuda.synchronize(2)
3535

3636
# Paddle 写法
37-
paddle.device.cuda.synchronize('gpu:2')
37+
paddle.device.synchronize('gpu:2')
3838
```

docs/guides/model_convert/convert_from_pytorch/api_difference/distributions/torch.distributions.Distribution.log_prob.md

Lines changed: 0 additions & 22 deletions
This file was deleted.
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
## [ 参数完全一致 ]torch.distributions.distribution.Distribution.log_prob
2+
3+
### [torch.distributions.distribution.Distribution.log\_prob](https://pytorch.org/docs/stable/distributions.html#torch.distributions.distribution.Distribution.log_prob)
4+
5+
```python
6+
torch.distributions.distribution.Distribution.log_prob(value)
7+
```
8+
9+
### [paddle.distribution.Distribution.log\_prob](https://www.paddlepaddle.org.cn/documentation/docs/zh/develop/api/paddle/distribution/Distribution_cn.html#log-prob-value)
10+
11+
```python
12+
paddle.distribution.Distribution.log_prob(value)
13+
```
14+
15+
16+
功能一致,参数完全一致,具体如下:
17+
18+
### 参数映射
19+
20+
| PyTorch | PaddlePaddle | 备注 |
21+
| ------- | ------------ | ------------ |
22+
| value | value | 输入 Tensor。 |
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
## [ 仅参数名不一致 ]torch.distributions.Distribution.rsample
1+
## [ 仅参数名不一致 ]torch.distributions.distribution.Distribution.rsample
22

3-
### [torch.distributions.Distribution.rsample](https://pytorch.org/docs/stable/distributions.html#torch.distributions.distribution.Distribution.rsample)
3+
### [torch.distributions.distribution.Distribution.rsample](https://pytorch.org/docs/stable/distributions.html#torch.distributions.distribution.Distribution.rsample)
44

55
```python
6-
torch.distributions.Distribution.rsample(sample_shape=torch.Size([]))
6+
torch.distributions.distribution.Distribution.rsample(sample_shape=torch.Size([]))
77
```
88

99
### [paddle.distribution.Distribution.rsample](https://github.com/PaddlePaddle/Paddle/blob/2bbd6f84c1db3e7401732869ee50aef2d9c97bdc/python/paddle/distribution/distribution.py#L96)
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
## [ 仅参数名不一致 ]torch.distributions.Distribution.sample
1+
## [ 仅参数名不一致 ]torch.distributions.distribution.Distribution.sample
22

3-
### [torch.distributions.Distribution.sample](https://pytorch.org/docs/stable/distributions.html#torch.distributions.distribution.Distribution.sample)
3+
### [torch.distributions.distribution.Distribution.sample](https://pytorch.org/docs/stable/distributions.html#torch.distributions.distribution.Distribution.sample)
44

55
```python
6-
torch.distributions.Distribution.sample(sample_shape=torch.Size([]))
6+
torch.distributions.distribution.Distribution.sample(sample_shape=torch.Size([]))
77
```
88

99
### [paddle.distribution.Distribution.sample](https://www.paddlepaddle.org.cn/documentation/docs/zh/develop/api/paddle/distribution/Distribution_cn.html#sample)

docs/guides/model_convert/convert_from_pytorch/api_difference/functional/torch.nn.functional.scaled_dot_product_attention.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
### [torch.nn.functional.scaled_dot_product_attention](https://pytorch.org/docs/stable/generated/torch.nn.functional.scaled_dot_product_attention.html#torch-nn-functional-scaled-dot-product-attention)
44

55
```python
6-
torch.nn.functional.scaled_dot_product_attention(query, key, value, attn_mask=None, dropout_p=0.0, is_causal=False, scale=None)
6+
torch.nn.functional.scaled_dot_product_attention(query, key, value, attn_mask=None, dropout_p=0.0, is_causal=False, scale=None, enable_gqa=False)
77
```
88

99
### [paddle.nn.functional.scaled_dot_product_attention](https://www.paddlepaddle.org.cn/documentation/docs/zh/develop/api/paddle/nn/functional/scaled_dot_product_attention_cn.html#scaled-dot-product-attention)
@@ -25,4 +25,5 @@ paddle.nn.functional.scaled_dot_product_attention(query, key, value, attn_mask=N
2525
| dropout_p | dropout_p | `dropout` 的比例, 默认值为 0.00 即不进行正则化。 |
2626
| is_causal | is_causal | 是否启用因果关系, 默认值为 `False` 即不启用。 |
2727
| scale | - | 在 softmax 之前应用的缩放因子。默认与 Paddle 行为一致。Paddle 无此参数,暂无转写方式。 |
28+
| enable_gqa | - | 是否启用 GQA 优化支持。Paddle 无此参数,暂无转写方式。 |
2829
| - | training | 是否处于训练阶段, 默认值为 `True` 即处于训练阶段。Pytorch 无此参数,默认行为等同与 `training=True`,Paddle 保持默认即可。|

docs/guides/model_convert/convert_from_pytorch/api_difference/torch/torch.cpu.current_device.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@
66
torch.cpu.current_device()
77
```
88

9-
### [paddle.device.get_device](https://www.paddlepaddle.org.cn/documentation/docs/zh/develop/api/paddle/device/get_device_cn.html#get-device)
9+
### [paddle.get_device](https://www.paddlepaddle.org.cn/documentation/docs/zh/develop/api/paddle/device/get_device_cn.html#get-device)
1010

1111
```python
12-
paddle.device.get_device()
12+
paddle.get_device()
1313
```
1414

1515
功能一致,无参数。

docs/guides/model_convert/convert_from_pytorch/api_difference/torch/torch.randint_like.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ torch.randint_like(input,
77
low=0,
88
high,
99
*,
10-
memory_format=torch.preserve_format
10+
memory_format=torch.preserve_format,
1111
dtype=None,
1212
layout=torch.strided,
1313
device=None,

0 commit comments

Comments
 (0)