Skip to content

Commit 67992d4

Browse files
committed
Merge branch 'develop' of https://github.com/PaddlePaddle/docs into my_docs_change
2 parents 36ba79c + b5e7623 commit 67992d4

26 files changed

+399
-27
lines changed

docs/api/paddle/Overview_cn.rst

+5
Original file line numberDiff line numberDiff line change
@@ -197,13 +197,18 @@ tensor 数学操作原位(inplace)版本
197197
" :ref:`paddle.ceil_ <cn_api_paddle_ceil_>` ", "Inplace 版本的 ceil API,对输入 x 采用 Inplace 策略"
198198
" :ref:`paddle.clip_ <cn_api_paddle_clip_>` ", "Inplace 版本的 clip API,对输入 x 采用 Inplace 策略"
199199
" :ref:`paddle.copysign_ <cn_api_paddle_copysign_>` ", "Inplace 版本的 copysign API,对输入 x 采用 Inplace 策略"
200+
" :ref:`paddle.divide_ <cn_api_paddle_divide_>` ", "Inplace 版本的 divide API,对输入 x 采用 Inplace 策略"
201+
" :ref:`paddle.equal_ <cn_api_paddle_equal_>` ", "Inplace 版本的 equal API,对输入 x 采用 Inplace 策略"
200202
" :ref:`paddle.exp_ <cn_api_paddle_exp_>` ", "Inplace 版本的 exp API,对输入 x 采用 Inplace 策略"
201203
" :ref:`paddle.expm1_ <cn_api_paddle_expm1_>` ", "Inplace 版本的 expm1 API,对输入 x 采用 Inplace 策略"
202204
" :ref:`paddle.flatten_ <cn_api_paddle_flatten_>` ", "Inplace 版本的 flatten API,对输入 x 采用 Inplace 策略"
203205
" :ref:`paddle.floor_ <cn_api_paddle_floor_>` ", "Inplace 版本的 floor API,对输入 x 采用 Inplace 策略"
206+
" :ref:`paddle.floor_divide_ <cn_api_paddle_floor_divide_>` ", "Inplace 版本的 floor_divide API,对输入 x 采用 Inplace 策略"
207+
" :ref:`paddle.frac_ <cn_api_paddle_frac_>` ", "Inplace 版本的 frac API,对输入 x 采用 Inplace 策略"
204208
" :ref:`paddle.gammaincc_ <cn_api_paddle_gammaincc_>` ", "Inplace 版本的 gammaincc API,对输入 x 采用 Inplace 策略"
205209
" :ref:`paddle.gammainc_ <cn_api_paddle_gammainc_>` ", "Inplace 版本的 gammainc API,对输入 x 采用 Inplace 策略"
206210
" :ref:`paddle.gammaln_ <cn_api_paddle_gammaln_>` ", "Inplace 版本的 gammaln API,对输入 x 采用 Inplace 策略"
211+
" :ref:`paddle.gcd_ <cn_api_paddle_gcd_>` ", "Inplace 版本的 gcd API,对输入 x 采用 Inplace 策略"
207212
" :ref:`paddle.reciprocal_ <cn_api_paddle_reciprocal_>` ", "Inplace 版本的 reciprocal API,对输入 x 采用 Inplace 策略"
208213
" :ref:`paddle.round_ <cn_api_paddle_round_>` ", "Inplace 版本的 round API,对输入 x 采用 Inplace 策略"
209214
" :ref:`paddle.rsqrt_ <cn_api_paddle_rsqrt_>` ", "Inplace 版本的 rsqrt API,对输入 x 采用 Inplace 策略"

docs/api/paddle/addmm__cn.rst

-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ addmm\_
44
-------------------------------
55

66
.. py:function:: paddle.addmm_(input, x, y, alpha=1.0, beta=1.0, name=None)
7-
87
Inplace 版本的 :ref:`cn_api_paddle_addmm` API,对输入 `input` 采用 Inplace 策略。
98

109
更多关于 inplace 操作的介绍请参考 `3.1.3 原位(Inplace)操作和非原位操作的区别`_ 了解详情。

docs/api/paddle/broadcast_tensors_cn.rst

+9-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,15 @@ broadcast_tensors
1313

1414
.. _Tensor 介绍: ../../guides/beginner/tensor_cn.html#id7
1515

16-
下图展示将三个 Tensor 广播到同一维度的过程。三个 Tensor 的尺寸分别为 [4, 1, 3]、[2, 3]、[4, 2, 1],在广播时,会从最后一个维度开始对齐,对于每一个维度,任意两个 Tensor 的在该维度大小相等;或者其中一个 Tensor 的维度等于 1;或者其中一个 Tensor 的维度不存在。在下图中,最后一个维度中,Tenser3 取值为 1,Tensor1 和 Tensor2 取值为 3,所有 Tensor 的该维度被扩张为 3;倒数第二个维度中,Tenser1 取值为 2,Tensor2 和 Tensor3 取值为 2,所有 Tensor 的该维度被扩张为 2;倒数第三个维度中,Tenser2 为空,Tensor1 和 Tensor3 取值为 4,所有 Tensor 的该维度被扩张为 4。最终,所有 Tensor 都被扩张到 [4, 2, 3]。
16+
下图展示将三个 Tensor 广播到同一维度的过程。三个 Tensor 的尺寸分别为 [4, 1, 3]、[2, 3]、[4, 2, 1],在广播时,会从最后一个维度开始对齐,对于每一个维度,任意两个 Tensor 的在该维度大小相等;或者其中一个 Tensor 的维度等于 1;或者其中一个 Tensor 的维度不存在。
17+
18+
在下图中,
19+
20+
- 最后一个维度中,Tenser3 取值为 1,Tensor1 和 Tensor2 取值为 3,所有 Tensor 的该维度被扩张为 3;
21+
- 倒数第二个维度中,Tenser1 取值为 1,Tensor2 和 Tensor3 取值为 2,所有 Tensor 的该维度被扩张为 2;
22+
- 倒数第三个维度中,Tenser2 为空,Tensor1 和 Tensor3 取值为 4,所有 Tensor 的该维度被扩张为 4。
23+
24+
最终,所有 Tensor 都被扩张到 [4, 2, 3]。
1725

1826
.. figure:: ../../images/api_legend/broadcast.png
1927
:width: 800

docs/api/paddle/divide__cn.rst

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
.. _cn_api_paddle_divide_:
2+
3+
divide\_
4+
-------------------------------
5+
6+
.. py:function:: paddle.divide_(x, y, name=None)
7+
Inplace 版本的 :ref:`cn_api_paddle_divide` API,对输入 x 采用 Inplace 策略。
8+
9+
更多关于 inplace 操作的介绍请参考 `3.1.3 原位(Inplace)操作和非原位操作的区别`_ 了解详情。
10+
11+
.. _3.1.3 原位(Inplace)操作和非原位操作的区别: https://www.paddlepaddle.org.cn/documentation/docs/zh/develop/guides/beginner/tensor_cn.html#id3

docs/api/paddle/equal__cn.rst

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
.. _cn_api_paddle_equal_:
2+
3+
equal\_
4+
-------------------------------
5+
6+
.. py:function:: paddle.equal_(x, y, name=None)
7+
Inplace 版本的 :ref:`cn_api_paddle_equal` API,对输入 x 采用 Inplace 策略。
8+
9+
更多关于 inplace 操作的介绍请参考 `3.1.3 原位(Inplace)操作和非原位操作的区别`_ 了解详情。
10+
11+
.. _3.1.3 原位(Inplace)操作和非原位操作的区别: https://www.paddlepaddle.org.cn/documentation/docs/zh/develop/guides/beginner/tensor_cn.html#id3

docs/api/paddle/floor_divide__cn.rst

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
.. _cn_api_paddle_floor_divide_:
2+
3+
floor_divide\_
4+
-------------------------------
5+
6+
.. py:function:: paddle.floor_divide_(x, y, name=None)
7+
Inplace 版本的 :ref:`cn_api_paddle_floor_divide` API,对输入 x 采用 Inplace 策略。
8+
9+
更多关于 inplace 操作的介绍请参考 `3.1.3 原位(Inplace)操作和非原位操作的区别`_ 了解详情。
10+
11+
.. _3.1.3 原位(Inplace)操作和非原位操作的区别: https://www.paddlepaddle.org.cn/documentation/docs/zh/develop/guides/beginner/tensor_cn.html#id3

docs/api/paddle/frac__cn.rst

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
.. _cn_api_paddle_frac_:
2+
3+
frac\_
4+
-------------------------------
5+
6+
.. py:function:: paddle.frac_(x, name=None)
7+
Inplace 版本的 :ref:`cn_api_paddle_frac` API,对输入 x 采用 Inplace 策略。
8+
9+
更多关于 inplace 操作的介绍请参考 `3.1.3 原位(Inplace)操作和非原位操作的区别`_ 了解详情。
10+
11+
.. _3.1.3 原位(Inplace)操作和非原位操作的区别: https://www.paddlepaddle.org.cn/documentation/docs/zh/develop/guides/beginner/tensor_cn.html#id3

docs/api/paddle/gcd__cn.rst

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
.. _cn_api_paddle_gcd_:
2+
3+
gcd\_
4+
-------------------------------
5+
6+
.. py:function:: paddle.gcd_(x, y, name=None)
7+
Inplace 版本的 :ref:`cn_api_paddle_gcd` API,对输入 x 采用 Inplace 策略。
8+
9+
更多关于 inplace 操作的介绍请参考 `3.1.3 原位(Inplace)操作和非原位操作的区别`_ 了解详情。
10+
11+
.. _3.1.3 原位(Inplace)操作和非原位操作的区别: https://www.paddlepaddle.org.cn/documentation/docs/zh/develop/guides/beginner/tensor_cn.html#id3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
## [ torch 参数更多 ]torch.nn.modules.module.register_module_forward_hook
1+
## [ 组合替代实现 ]torch.nn.modules.module.register_module_forward_hook
22
### [torch.nn.modules.module.register_module_forward_hook](https://pytorch.org/docs/stable/generated/torch.nn.modules.module.register_module_forward_hook.html)
33

44
```python
5-
torch.nn.modules.module.register_module_forward_hook(hook, *, prepend=False, with_kwargs=False, always_call=False)
5+
torch.nn.modules.module.register_module_forward_hook(hook, *, always_call=False)
66
```
77

88
### [paddle.nn.Layer.register_forward_post_hook](https://www.paddlepaddle.org.cn/documentation/docs/zh/develop/api/paddle/nn/Layer_cn.html#register-forward-post-hook-hook)
@@ -11,12 +11,28 @@ torch.nn.modules.module.register_module_forward_hook(hook, *, prepend=False, wit
1111
paddle.nn.Layer.register_forward_post_hook(hook)
1212
```
1313

14-
PyTorch 相比 Paddle 支持更多其他参数,具体如下:
14+
其中,PyTorch 为给全局所有 module 注册 hook,而 Paddle 为给单个 Layer 注册 hook。PyTorch 相比 Paddle 支持更多其他参数,具体如下:
1515
### 参数映射
1616

1717
| PyTorch | PaddlePaddle | 备注 |
1818
| ------------- | ------------ | ------------------------------------------------------ |
19-
| hook | hook | 被注册为 forward pre-hook 的函数。 |
20-
| prepend | - | 钩子执行顺序控制,Paddle 无此参数,暂无转写方式。 |
21-
| with_kwargs | - | 是否传递关键字参数,Paddle 无此参数,暂无转写方式。 |
22-
| always_call | - | 是否强制调用钩子,Paddle 无此参数,暂无转写方式。 |
19+
| hook | hook | 被注册为 forward post-hook 的函数。 |
20+
| always_call | - | 是否强制调用钩子,Paddle 无此参数,一般对训练结果影响不大,可直接删除。 |
21+
22+
### 转写示例
23+
24+
```python
25+
# PyTorch 写法
26+
Linear = torch.nn.Linear(2, 4)
27+
Conv2d = torch.nn.Conv2d(3, 16, 3)
28+
Batch2d = torch.nn.BatchNorm2d(10)
29+
torch.nn.modules.module.register_module_forward_hook(hook)
30+
31+
# Paddle 写法
32+
Linear = paddle.nn.Linear(2, 4)
33+
Conv2d = paddle.nn.Conv2d(3, 16, 3)
34+
Batch2d = paddle.nn.BatchNorm2D(10)
35+
Linear.register_forward_post_hook(hook)
36+
Conv2d.register_forward_post_hook(hook)
37+
Batch2d.register_forward_post_hook(hook)
38+
```

docs/guides/model_convert/convert_from_pytorch/api_difference/nn/torch.nn.modules.module.register_module_forward_pre_hook.md

+20-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
## [ 参数完全一致 ]torch.nn.modules.module.register_module_forward_pre_hook
1+
## [ 组合替代实现 ]torch.nn.modules.module.register_module_forward_pre_hook
22

33
### [torch.nn.modules.module.register_module_forward_pre_hook](https://pytorch.org/docs/stable/generated/torch.nn.modules.module.register_module_forward_pre_hook.html)
44

@@ -12,10 +12,28 @@ torch.nn.modules.module.register_module_forward_pre_hook(hook)
1212
paddle.nn.Layer.register_forward_pre_hook(hook)
1313
```
1414

15-
功能一致,参数完全一致,具体如下:
15+
其中,PyTorch 为给全局所有 module 注册 hook,而 Paddle 为给单个 Layer 注册 hook, 具体如下:
1616

1717
### 参数映射
1818

1919
| PyTorch | PaddlePaddle | 备注 |
2020
|---------|--------------|-----------------------------------------------------------------------------------------------|
2121
| hook | hook | 被注册为 forward pre-hook 的函数。 |
22+
23+
### 转写示例
24+
25+
```python
26+
# PyTorch 写法
27+
Linear = torch.nn.Linear(2, 4)
28+
Conv2d = torch.nn.Conv2d(3, 16, 3)
29+
Batch2d = torch.nn.BatchNorm2d(10)
30+
torch.nn.modules.module.register_module_forward_pre_hook(hook)
31+
32+
# Paddle 写法
33+
Linear = paddle.nn.Linear(2, 4)
34+
Conv2d = paddle.nn.Conv2d(3, 16, 3)
35+
Batch2d = paddle.nn.BatchNorm2D(10)
36+
Linear.register_forward_pre_hook(hook)
37+
Conv2d.register_forward_pre_hook(hook)
38+
Batch2d.register_forward_pre_hook(hook)
39+
```
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
## [组合替代实现]torch.\_foreach_abs
2+
3+
### [torch.\_foreach_abs](https://pytorch.org/docs/stable/generated/torch._foreach_abs.html#torch-foreach-abs)
4+
5+
```python
6+
torch._foreach_abs(self)
7+
```
8+
9+
Paddle 无此 API,需要组合实现。
10+
11+
### 转写示例
12+
13+
```python
14+
# PyTorch 写法
15+
torch._foreach_abs(tensors)
16+
17+
# Paddle 写法
18+
[paddle.abs(x) for x in tensors]
19+
```
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
## [组合替代实现]torch.\_foreach_abs_
2+
3+
### [torch.\_foreach_abs_](https://pytorch.org/docs/stable/generated/torch._foreach_abs_.html#torch-foreach-abs)
4+
5+
```python
6+
torch._foreach_abs_(self)
7+
```
8+
9+
Paddle 无此 API,需要组合实现。
10+
11+
### 转写示例
12+
13+
```python
14+
# PyTorch 写法
15+
torch._foreach_abs_(tensors)
16+
17+
# Paddle 写法
18+
[paddle.abs_(x) for x in tensors]
19+
```
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
## [组合替代实现]torch.\_foreach_acos
2+
3+
### [torch.\_foreach_acos](https://pytorch.org/docs/stable/generated/torch._foreach_acos.html#torch-foreach-acos)
4+
5+
```python
6+
torch._foreach_acos(self)
7+
```
8+
9+
Paddle 无此 API,需要组合实现。
10+
11+
### 转写示例
12+
13+
```python
14+
# PyTorch 写法
15+
torch._foreach_acos(tensors)
16+
17+
# Paddle 写法
18+
[paddle.acos(x) for x in tensors]
19+
```
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
## [组合替代实现]torch.\_foreach_acos_
2+
3+
### [torch.\_foreach_acos_](https://pytorch.org/docs/stable/generated/torch._foreach_acos_.html#torch-foreach-acos)
4+
5+
```python
6+
torch._foreach_acos_(self)
7+
```
8+
9+
Paddle 无此 API,需要组合实现。
10+
11+
### 转写示例
12+
13+
```python
14+
# PyTorch 写法
15+
torch._foreach_acos_(tensors)
16+
17+
# Paddle 写法
18+
[paddle.acos_(x) for x in tensors]
19+
```
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
## [组合替代实现]torch.\_foreach_asin
2+
3+
### [torch.\_foreach_asin](https://pytorch.org/docs/stable/generated/torch._foreach_asin.html#torch-foreach-asin)
4+
5+
```python
6+
torch._foreach_asin(self)
7+
```
8+
9+
Paddle 无此 API,需要组合实现。
10+
11+
### 转写示例
12+
13+
```python
14+
# PyTorch 写法
15+
torch._foreach_asin(tensors)
16+
17+
# Paddle 写法
18+
[paddle.asin(x) for x in tensors]
19+
```
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
## [组合替代实现]torch.\_foreach_asin_
2+
3+
### [torch.\_foreach_asin_](https://pytorch.org/docs/stable/generated/torch._foreach_asin_.html#torch-foreach-asin)
4+
5+
```python
6+
torch._foreach_asin_(self)
7+
```
8+
9+
Paddle 无此 API,需要组合实现。
10+
11+
### 转写示例
12+
13+
```python
14+
# PyTorch 写法
15+
torch._foreach_asin_(tensors)
16+
17+
# Paddle 写法
18+
[paddle.asin_(x) for x in tensors]
19+
```
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
## [组合替代实现]torch.\_foreach_atan
2+
3+
### [torch.\_foreach_atan](https://pytorch.org/docs/stable/generated/torch._foreach_atan.html#torch-foreach-atan)
4+
5+
```python
6+
torch._foreach_atan(self)
7+
```
8+
9+
Paddle 无此 API,需要组合实现。
10+
11+
### 转写示例
12+
13+
```python
14+
# PyTorch 写法
15+
torch._foreach_atan(tensors)
16+
17+
# Paddle 写法
18+
[paddle.atan(x) for x in tensors]
19+
```
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
## [组合替代实现]torch.\_foreach_atan_
2+
3+
### [torch.\_foreach_atan_](https://pytorch.org/docs/stable/generated/torch._foreach_atan_.html#torch-foreach-atan)
4+
5+
```python
6+
torch._foreach_atan_(self)
7+
```
8+
9+
Paddle 无此 API,需要组合实现。
10+
11+
### 转写示例
12+
13+
```python
14+
# PyTorch 写法
15+
torch._foreach_atan_(tensors)
16+
17+
# Paddle 写法
18+
[paddle.atan_(x) for x in tensors]
19+
```
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
## [组合替代实现]torch.\_foreach_ceil
2+
3+
### [torch.\_foreach_ceil](https://pytorch.org/docs/stable/generated/torch._foreach_ceil.html#torch-foreach-ceil)
4+
5+
```python
6+
torch._foreach_ceil(self)
7+
```
8+
9+
Paddle 无此 API,需要组合实现。
10+
11+
### 转写示例
12+
13+
```python
14+
# PyTorch 写法
15+
torch._foreach_ceil(tensors)
16+
17+
# Paddle 写法
18+
[paddle.ceil(x) for x in tensors]
19+
```
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
## [组合替代实现]torch.\_foreach_cos
2+
3+
### [torch.\_foreach_cos](https://pytorch.org/docs/stable/generated/torch._foreach_cos.html#torch-foreach-cos)
4+
5+
```python
6+
torch._foreach_cos(self)
7+
```
8+
9+
Paddle 无此 API,需要组合实现。
10+
11+
### 转写示例
12+
13+
```python
14+
# PyTorch 写法
15+
torch._foreach_cos(tensors)
16+
17+
# Paddle 写法
18+
[paddle.cos(x) for x in tensors]
19+
```

0 commit comments

Comments
 (0)