-
Notifications
You must be signed in to change notification settings - Fork 826
新增映射文档 #7104
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
新增映射文档 #7104
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
## [ torch 参数更多 ]torch.nn.modules.module.register_module_forward_hook | ||
## [ 组合替代实现 ]torch.nn.modules.module.register_module_forward_hook | ||
### [torch.nn.modules.module.register_module_forward_hook](https://pytorch.org/docs/stable/generated/torch.nn.modules.module.register_module_forward_hook.html) | ||
|
||
```python | ||
torch.nn.modules.module.register_module_forward_hook(hook, *, prepend=False, with_kwargs=False, always_call=False) | ||
torch.nn.modules.module.register_module_forward_hook(hook, *, always_call=False) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 这个PyTorch官方文档上面有,但我实际使用应该没有 |
||
``` | ||
|
||
### [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 | |
paddle.nn.Layer.register_forward_post_hook(hook) | ||
``` | ||
|
||
PyTorch 相比 Paddle 支持更多其他参数,具体如下: | ||
其中,PyTorch 为给全局所有 module 注册 hook,而 Paddle 为给单个 Layer 注册 hook。PyTorch 相比 Paddle 支持更多其他参数,具体如下: | ||
### 参数映射 | ||
|
||
| PyTorch | PaddlePaddle | 备注 | | ||
| ------------- | ------------ | ------------------------------------------------------ | | ||
| hook | hook | 被注册为 forward pre-hook 的函数。 | | ||
| prepend | - | 钩子执行顺序控制,Paddle 无此参数,暂无转写方式。 | | ||
| with_kwargs | - | 是否传递关键字参数,Paddle 无此参数,暂无转写方式。 | | ||
| always_call | - | 是否强制调用钩子,Paddle 无此参数,暂无转写方式。 | | ||
| hook | hook | 被注册为 forward post-hook 的函数。 | | ||
| always_call | - | 是否强制调用钩子,Paddle 无此参数,一般对训练结果影响不大,可直接删除。 | | ||
|
||
### 转写示例 | ||
|
||
```python | ||
# PyTorch 写法 | ||
Linear = torch.nn.Linear(2, 4) | ||
Conv2d = torch.nn.Conv2d(3, 16, 3) | ||
Batch2d = torch.nn.BatchNorm2d(10) | ||
torch.nn.modules.module.register_module_forward_hook(hook) | ||
|
||
# Paddle 写法 | ||
Linear = paddle.nn.Linear(2, 4) | ||
Conv2d = paddle.nn.Conv2d(3, 16, 3) | ||
Batch2d = paddle.nn.BatchNorm2D(10) | ||
Linear.register_forward_post_hook(hook) | ||
Conv2d.register_forward_post_hook(hook) | ||
Batch2d.register_forward_post_hook(hook) | ||
``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
...s/model_convert/convert_from_pytorch/api_difference/torch/torch._foreach_abs.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
## [组合替代实现]torch.\_foreach_abs | ||
|
||
### [torch.\_foreach_abs](https://pytorch.org/docs/stable/generated/torch._foreach_abs.html#torch-foreach-abs) | ||
|
||
```python | ||
torch._foreach_abs(self) | ||
``` | ||
|
||
Paddle 无此 API,需要组合实现。 | ||
|
||
### 转写示例 | ||
|
||
```python | ||
# PyTorch 写法 | ||
torch._foreach_abs(tensors) | ||
|
||
# Paddle 写法 | ||
[paddle.abs(x) for x in tensors] | ||
``` |
19 changes: 19 additions & 0 deletions
19
.../model_convert/convert_from_pytorch/api_difference/torch/torch._foreach_abs_.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
## [组合替代实现]torch.\_foreach_abs_ | ||
|
||
### [torch.\_foreach_abs_](https://pytorch.org/docs/stable/generated/torch._foreach_abs_.html#torch-foreach-abs) | ||
|
||
```python | ||
torch._foreach_abs_(self) | ||
``` | ||
|
||
Paddle 无此 API,需要组合实现。 | ||
|
||
### 转写示例 | ||
|
||
```python | ||
# PyTorch 写法 | ||
torch._foreach_abs_(tensors) | ||
|
||
# Paddle 写法 | ||
[paddle.abs_(x) for x in tensors] | ||
``` |
19 changes: 19 additions & 0 deletions
19
.../model_convert/convert_from_pytorch/api_difference/torch/torch._foreach_acos.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
## [组合替代实现]torch.\_foreach_acos | ||
|
||
### [torch.\_foreach_acos](https://pytorch.org/docs/stable/generated/torch._foreach_acos.html#torch-foreach-acos) | ||
|
||
```python | ||
torch._foreach_acos(self) | ||
``` | ||
|
||
Paddle 无此 API,需要组合实现。 | ||
|
||
### 转写示例 | ||
|
||
```python | ||
# PyTorch 写法 | ||
torch._foreach_acos(tensors) | ||
|
||
# Paddle 写法 | ||
[paddle.acos(x) for x in tensors] | ||
``` |
19 changes: 19 additions & 0 deletions
19
...model_convert/convert_from_pytorch/api_difference/torch/torch._foreach_acos_.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
## [组合替代实现]torch.\_foreach_acos_ | ||
|
||
### [torch.\_foreach_acos_](https://pytorch.org/docs/stable/generated/torch._foreach_acos_.html#torch-foreach-acos) | ||
|
||
```python | ||
torch._foreach_acos_(self) | ||
``` | ||
|
||
Paddle 无此 API,需要组合实现。 | ||
|
||
### 转写示例 | ||
|
||
```python | ||
# PyTorch 写法 | ||
torch._foreach_acos_(tensors) | ||
|
||
# Paddle 写法 | ||
[paddle.acos_(x) for x in tensors] | ||
``` |
19 changes: 19 additions & 0 deletions
19
.../model_convert/convert_from_pytorch/api_difference/torch/torch._foreach_asin.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
## [组合替代实现]torch.\_foreach_asin | ||
|
||
### [torch.\_foreach_asin](https://pytorch.org/docs/stable/generated/torch._foreach_asin.html#torch-foreach-asin) | ||
|
||
```python | ||
torch._foreach_asin(self) | ||
``` | ||
|
||
Paddle 无此 API,需要组合实现。 | ||
|
||
### 转写示例 | ||
|
||
```python | ||
# PyTorch 写法 | ||
torch._foreach_asin(tensors) | ||
|
||
# Paddle 写法 | ||
[paddle.asin(x) for x in tensors] | ||
``` |
19 changes: 19 additions & 0 deletions
19
...model_convert/convert_from_pytorch/api_difference/torch/torch._foreach_asin_.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
## [组合替代实现]torch.\_foreach_asin_ | ||
|
||
### [torch.\_foreach_asin_](https://pytorch.org/docs/stable/generated/torch._foreach_asin_.html#torch-foreach-asin) | ||
|
||
```python | ||
torch._foreach_asin_(self) | ||
``` | ||
|
||
Paddle 无此 API,需要组合实现。 | ||
|
||
### 转写示例 | ||
|
||
```python | ||
# PyTorch 写法 | ||
torch._foreach_asin_(tensors) | ||
|
||
# Paddle 写法 | ||
[paddle.asin_(x) for x in tensors] | ||
``` |
19 changes: 19 additions & 0 deletions
19
.../model_convert/convert_from_pytorch/api_difference/torch/torch._foreach_atan.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
## [组合替代实现]torch.\_foreach_atan | ||
|
||
### [torch.\_foreach_atan](https://pytorch.org/docs/stable/generated/torch._foreach_atan.html#torch-foreach-atan) | ||
|
||
```python | ||
torch._foreach_atan(self) | ||
``` | ||
|
||
Paddle 无此 API,需要组合实现。 | ||
|
||
### 转写示例 | ||
|
||
```python | ||
# PyTorch 写法 | ||
torch._foreach_atan(tensors) | ||
|
||
# Paddle 写法 | ||
[paddle.atan(x) for x in tensors] | ||
``` |
19 changes: 19 additions & 0 deletions
19
...model_convert/convert_from_pytorch/api_difference/torch/torch._foreach_atan_.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
## [组合替代实现]torch.\_foreach_atan_ | ||
|
||
### [torch.\_foreach_atan_](https://pytorch.org/docs/stable/generated/torch._foreach_atan_.html#torch-foreach-atan) | ||
|
||
```python | ||
torch._foreach_atan_(self) | ||
``` | ||
|
||
Paddle 无此 API,需要组合实现。 | ||
|
||
### 转写示例 | ||
|
||
```python | ||
# PyTorch 写法 | ||
torch._foreach_atan_(tensors) | ||
|
||
# Paddle 写法 | ||
[paddle.atan_(x) for x in tensors] | ||
``` |
19 changes: 19 additions & 0 deletions
19
.../model_convert/convert_from_pytorch/api_difference/torch/torch._foreach_ceil.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
## [组合替代实现]torch.\_foreach_ceil | ||
|
||
### [torch.\_foreach_ceil](https://pytorch.org/docs/stable/generated/torch._foreach_ceil.html#torch-foreach-ceil) | ||
|
||
```python | ||
torch._foreach_ceil(self) | ||
``` | ||
|
||
Paddle 无此 API,需要组合实现。 | ||
|
||
### 转写示例 | ||
|
||
```python | ||
# PyTorch 写法 | ||
torch._foreach_ceil(tensors) | ||
|
||
# Paddle 写法 | ||
[paddle.ceil(x) for x in tensors] | ||
``` |
19 changes: 19 additions & 0 deletions
19
...s/model_convert/convert_from_pytorch/api_difference/torch/torch._foreach_cos.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
## [组合替代实现]torch.\_foreach_cos | ||
|
||
### [torch.\_foreach_cos](https://pytorch.org/docs/stable/generated/torch._foreach_cos.html#torch-foreach-cos) | ||
|
||
```python | ||
torch._foreach_cos(self) | ||
``` | ||
|
||
Paddle 无此 API,需要组合实现。 | ||
|
||
### 转写示例 | ||
|
||
```python | ||
# PyTorch 写法 | ||
torch._foreach_cos(tensors) | ||
|
||
# Paddle 写法 | ||
[paddle.cos(x) for x in tensors] | ||
``` |
19 changes: 19 additions & 0 deletions
19
.../model_convert/convert_from_pytorch/api_difference/torch/torch._foreach_cos_.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
## [组合替代实现]torch.\_foreach_cos_ | ||
|
||
### [torch.\_foreach_cos_](https://pytorch.org/docs/stable/generated/torch._foreach_cos_.html#torch-foreach-cos) | ||
|
||
```python | ||
torch._foreach_cos_(self) | ||
``` | ||
|
||
Paddle 无此 API,需要组合实现。 | ||
|
||
### 转写示例 | ||
|
||
```python | ||
# PyTorch 写法 | ||
torch._foreach_cos_(tensors) | ||
|
||
# Paddle 写法 | ||
[paddle.cos_(x) for x in tensors] | ||
``` |
19 changes: 19 additions & 0 deletions
19
.../model_convert/convert_from_pytorch/api_difference/torch/torch._foreach_cosh.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
## [组合替代实现]torch.\_foreach_cosh | ||
|
||
### [torch.\_foreach_cosh](https://pytorch.org/docs/stable/generated/torch._foreach_cosh.html#torch-foreach-cosh) | ||
|
||
```python | ||
torch._foreach_cosh(self) | ||
``` | ||
|
||
Paddle 无此 API,需要组合实现。 | ||
|
||
### 转写示例 | ||
|
||
```python | ||
# PyTorch 写法 | ||
torch._foreach_cosh(tensors) | ||
|
||
# Paddle 写法 | ||
[paddle.cosh(x) for x in tensors] | ||
``` |
19 changes: 19 additions & 0 deletions
19
...model_convert/convert_from_pytorch/api_difference/torch/torch._foreach_cosh_.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
## [组合替代实现]torch.\_foreach_cosh_ | ||
|
||
### [torch.\_foreach_cosh_](https://pytorch.org/docs/stable/generated/torch._foreach_cosh_.html#torch-foreach-cosh) | ||
|
||
```python | ||
torch._foreach_cosh_(self) | ||
``` | ||
|
||
Paddle 无此 API,需要组合实现。 | ||
|
||
### 转写示例 | ||
|
||
```python | ||
# PyTorch 写法 | ||
torch._foreach_cosh_(tensors) | ||
|
||
# Paddle 写法 | ||
[paddle.cosh_(x) for x in tensors] | ||
``` |
19 changes: 19 additions & 0 deletions
19
...s/model_convert/convert_from_pytorch/api_difference/torch/torch._foreach_erf.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
## [组合替代实现]torch.\_foreach_erf | ||
|
||
### [torch.\_foreach_erf](https://pytorch.org/docs/stable/generated/torch._foreach_erf.html#torch-foreach-erf) | ||
|
||
```python | ||
torch._foreach_erf(self) | ||
``` | ||
|
||
Paddle 无此 API,需要组合实现。 | ||
|
||
### 转写示例 | ||
|
||
```python | ||
# PyTorch 写法 | ||
torch._foreach_erf(tensors) | ||
|
||
# Paddle 写法 | ||
[paddle.erf(x) for x in tensors] | ||
``` |
19 changes: 19 additions & 0 deletions
19
.../model_convert/convert_from_pytorch/api_difference/torch/torch._foreach_erf_.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
## [组合替代实现]torch.\_foreach_erf_ | ||
|
||
### [torch.\_foreach_erf_](https://pytorch.org/docs/stable/generated/torch._foreach_erf_.html#torch-foreach-erf) | ||
|
||
```python | ||
torch._foreach_erf_(self) | ||
``` | ||
|
||
Paddle 无此 API,需要组合实现。 | ||
|
||
### 转写示例 | ||
|
||
```python | ||
# PyTorch 写法 | ||
torch._foreach_erf_(tensors) | ||
|
||
# Paddle 写法 | ||
[paddle.erf_(x) for x in tensors] | ||
``` |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.