Skip to content

Commit 1ca6211

Browse files
committed
fix Difference document
1 parent 80b8768 commit 1ca6211

File tree

6 files changed

+97
-27
lines changed

6 files changed

+97
-27
lines changed

docs/guides/model_convert/convert_from_pytorch/pytorch_api_mapping_cn.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
| [torch.nn.XX](#id2) | 主要为`torch.nn.XX`类 API |
1010
| [torch.nn.functional.XX](#id3) | 主要为`torch.nn.functional.XX`类 API |
1111
| [torch.nn.init.XX](#id4) | 主要为`torch.nn.init.XX`类 API |
12-
| [torch.nn.utils.XX](#id5) | 主要为`torch.nn.init.XX`类 API |
12+
| [torch.nn.utils.XX](#id5) | 主要为`torch.nn.utils.XX`类 API |
1313
| [torch.Tensor.XX](#id6) | 主要为`torch.Tensor.XX`类 API |
1414
| [torch.cuda.XX](#id7) | 主要为`torch.cuda.XX`类 API |
1515
| [torch.distributed.XX](#id8) | 主要为`torch.distributed.XX`类 API |
@@ -85,7 +85,7 @@
8585
| 60 | [torch.is\_grad\_enabled](https://pytorch.org/docs/stable/generated/torch.is_grad_enabled.html?highlight=is_grad_enabled#torch.is_grad_enabled) | [paddle.is\_grad\_enabled](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/is_grad_enabled_cn.html#is-grad-enabled) | 功能一致,无参数 |
8686
| 61 | [torch.cov](https://pytorch.org/docs/stable/generated/torch.cov.html?highlight=cov#torch.cov) | [paddle.linalg.cov](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/linalg/cov_cn.html#cov) | 功能一致,仅参数命名不一致,[差异对比](https://github.com/PaddlePaddle/docs/tree/develop/docs/guides/model_convert/ops/torch.cov.md) |
8787
| 62 | [torch.moveaxis](https://pytorch.org/docs/stable/generated/torch.moveaxis.html?highlight=moveaxis#torch.moveaxis) | [paddle.moveaxis](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/moveaxis_cn.html#moveaxis) |功能一致,仅参数命名不一致,[差异对比](https://github.com/PaddlePaddle/docs/tree/develop/docs/guides/model_convert/ops/torch.moveaxis.md) |
88-
| 63 | [torch.sqrt](https://pytorch.org/docs/stable/generated/torch.sqrt.html?highlight=sqrt#torch.sqrt) | [paddle.sqrt](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/sqrt_cn.html#sqrt) | 功能一致,torch 参数更多,torch`out` 参数代表输出 |
88+
| 63 | [torch.sqrt](https://pytorch.org/docs/stable/generated/torch.sqrt.html?highlight=sqrt#torch.sqrt) | [paddle.sqrt](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/sqrt_cn.html#sqrt) | 功能一致,torch 参数更多,[差异对比](https://github.com/PaddlePaddle/docs/tree/develop/docs/guides/model_convert/ops/torch.sqrt.md) |
8989
| 64 | [torch.tensor](https://pytorch.org/docs/stable/generated/torch.tensor.html?highlight=tensor#torch.tensor) | [paddle.to\_tensor](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/to_tensor_cn.html#to-tensor) | 功能一致,torch 参数更多,[差异对比](https://github.com/PaddlePaddle/docs/tree/develop/docs/guides/model_convert/ops/torch.tensor.md) |
9090
| 65 | [torch.zeros\_like](https://pytorch.org/docs/stable/generated/torch.zeros_like.html?highlight=zeros_like#torch.zeros_like) | [paddle.zeros\_like](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/zeros_like_cn.html#zeros-like) | 功能一致,torch 参数更多,[差异对比](https://github.com/PaddlePaddle/docs/tree/develop/docs/guides/model_convert/ops/torch.zeros_like.md) |
9191
| 66 | [torch.ones](https://pytorch.org/docs/stable/generated/torch.ones.html?highlight=ones#torch.ones) | [paddle.ones](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/ones_cn.html#ones) | 功能一致,参数不一致,[差异对比](https://github.com/PaddlePaddle/docs/tree/develop/docs/guides/model_convert/ops/torch.ones.md) |

docs/guides/model_convert/ops/torch.ones.md

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ paddle.ones(shape,
2424
| ------------- | ------------ | ------------------------------------------------------ |
2525
| *size | shape | 表示输出形状大小。 |
2626
| out | - | 表示输出的 Tensor,PaddlePaddle 无此参数。 |
27-
| layout | - | 表示布局方式,PaddlePaddle 无此参数。 |
28-
| device | - | 表示 Tensor 存放位置,PaddlePaddle 无此参数。 |
27+
| layout | - | 表示布局方式,PaddlePaddle 无此参数,一般对网络训练结果影响不大,可直接删除|
28+
| device | - | 表示 Tensor 存放位置,PaddlePaddle 无此参数,一般对网络训练结果影响不大,可直接删除|
2929
| requires_grad | - | 表示是否不阻断梯度传导,PaddlePaddle 无此参数。 |
3030

3131

@@ -35,20 +35,24 @@ paddle.ones(shape,
3535
***PyTorch***:生成 Tensor 的形状大小以可变参数、list 或 tuple 的方式传入。
3636
***PaddlePaddle***:生成 Tensor 的形状大小以 list 或 tuple 的方式传入。
3737

38-
### 代码示例
39-
``` python
40-
# PyTorch 示例:
41-
torch.ones(2, 3)
42-
# 输出
43-
# tensor([[ 1., 1., 1.],
44-
# [ 1., 1., 1.]])
38+
39+
### 转写示例
40+
#### out:指定输出
41+
```python
42+
# Pytorch 写法
43+
torch.full([3, 5], 1., out=y)
44+
45+
# Paddle 写法
46+
y = paddle.full([3, 5], 1.)
4547
```
4648

47-
``` python
48-
# PaddlePaddle 示例:
49-
paddle.ones([2, 3])
50-
# 输出
51-
# Tensor(shape=[2, 3], dtype=float32, place=CPUPlace, stop_gradient=True,
52-
# [[1., 1., 1.],
53-
# [1., 1., 1.]])
49+
50+
#### requires_grad:是否需要求反向梯度,需要修改该 Tensor 的 stop_gradient 属性
51+
```python
52+
# Pytorch 写法
53+
x = torch.full([3, 5], 1., requires_grad=True)
54+
55+
# Paddle 写法
56+
x = paddle.full([3, 5], 1.)
57+
x.stop_gradient = False
5458
```

docs/guides/model_convert/ops/torch.ones_like.md

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,20 @@ paddle.ones_like(x, dtype=None, name=None)
1919
### 参数差异
2020
| PyTorch | PaddlePaddle | 备注 |
2121
| ------------- | ------------ | ------------------------------------------------------ |
22-
| input | x | 表示输入 Tensor。 |
23-
| layout | - | 表示布局方式,PaddlePaddle 无此参数。 |
24-
| device | - | 表示 Tensor 存放位置,PaddlePaddle 无此参数。 |
22+
| input | x | 表示输入 Tensor。 |
23+
| layout | - | 表示布局方式,PaddlePaddle 无此参数,一般对网络训练结果影响不大,可直接删除|
24+
| device | - | 表示 Tensor 存放位置,PaddlePaddle 无此参数,一般对网络训练结果影响不大,可直接删除|
2525
| requires_grad | - | 表示是否不阻断梯度传导,PaddlePaddle 无此参数。 |
26-
| memory_format | - | 表示内存格式,PaddlePaddle 无此参数。 |
26+
| memory_format | - | 表示内存格式,PaddlePaddle 无此参数,一般对网络训练结果影响不大,可直接删除。 |
27+
28+
29+
### 转写示例
30+
#### requires_grad:是否需要求反向梯度,需要修改该 Tensor 的 stop_gradient 属性
31+
```python
32+
# Pytorch 写法
33+
x = torch.full([3, 5], 1., requires_grad=True)
34+
35+
# Paddle 写法
36+
x = paddle.full([3, 5], 1.)
37+
x.stop_gradient = False
38+
```
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
## torch.sqrt
2+
### [torch.sqrt](https://pytorch.org/docs/stable/generated/torch.sqrt.html?highlight=sqrt#torch.sqrt)
3+
4+
```python
5+
torch.sqrt(input,
6+
*,
7+
out=None)
8+
```
9+
10+
### [paddle.sqrt](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/sqrt_cn.html#sqrt)
11+
12+
```python
13+
paddle.sqrt(x,
14+
name=None)
15+
```
16+
### 参数差异
17+
| PyTorch | PaddlePaddle | 备注 |
18+
| ------------- | ------------ | ------------------------------------------------------ |
19+
| input | x | 输入的 Tensor。 |
20+
| out | - | 表示输出的 Tensor,PaddlePaddle 无此参数。 |
21+
22+
23+
### 转写示例
24+
#### out:指定输出
25+
```python
26+
# Pytorch 写法
27+
torch.full([3, 5], 1., out=y)
28+
29+
# Paddle 写法
30+
y = paddle.full([3, 5], 1.)
31+
```

docs/guides/model_convert/ops/torch.tensor.md

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,17 @@ paddle.to_tensor(data,
2020
### 参数差异
2121
| PyTorch | PaddlePaddle | 备注 |
2222
| ------------- | ------------ | ------------------------------------------------------ |
23-
| device | place | 表示 Tensor 存放位置。 |
24-
| requires_grad | stop_gradient | PyTorch 表示是否不阻断梯度传导,PaddlePaddle 表示是否阻断梯度传导。 |
23+
| device | place | 表示 Tensor 存放位置。 |
24+
| requires_grad | stop_gradient| PyTorch 表示是否不阻断梯度传导,PaddlePaddle 表示是否阻断梯度传导。 |
2525
| pin_memeory | - | 表示是否使用锁页内存,PaddlePaddle 无此参数。 |
26+
27+
28+
### 转写示例
29+
#### pin_memory:是否分配到固定内存上
30+
```python
31+
# Pytorch 写法
32+
x = torch.eye(3, pin_memory=True)
33+
34+
# Paddle 写法
35+
x = paddle.eye(3).pin_memory()
36+
```

docs/guides/model_convert/ops/torch.zeros_like.md

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,19 @@ paddle.zeros_like(x, dtype=None, name=None)
2121
| PyTorch | PaddlePaddle | 备注 |
2222
| ------------- | ------------ | ------------------------------------------------------ |
2323
| input | x | 表示输入 Tensor。 |
24-
| layout | - | 表示布局方式,PaddlePaddle 无此参数。 |
25-
| device | - | 表示 Tensor 存放位置,PaddlePaddle 无此参数。 |
24+
| layout | - | 表示布局方式,PaddlePaddle 无此参数,一般对网络训练结果影响不大,可直接删除|
25+
| device | - | 表示 Tensor 存放位置,PaddlePaddle 无此参数,一般对网络训练结果影响不大,可直接删除|
2626
| requires_grad | - | 表示是否不阻断梯度传导,PaddlePaddle 无此参数。 |
27-
| memory_format | - | 表示内存格式,PaddlePaddle 无此参数。 |
27+
| memory_format | - | 表示内存格式,PaddlePaddle 无此参数,一般对网络训练结果影响不大,可直接删除。 |
28+
29+
30+
### 转写示例
31+
#### requires_grad:是否需要求反向梯度,需要修改该 Tensor 的 stop_gradient 属性
32+
```python
33+
# Pytorch 写法
34+
x = torch.full([3, 5], 1., requires_grad=True)
35+
36+
# Paddle 写法
37+
x = paddle.full([3, 5], 1.)
38+
x.stop_gradient = False
39+
```

0 commit comments

Comments
 (0)