-
Notifications
You must be signed in to change notification settings - Fork 764
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
376 additions
and
3 deletions.
There are no files selected for viewing
21 changes: 21 additions & 0 deletions
21
...model_convert/convert_from_pytorch/api_difference/cuda/torch.cuda.set_stream.md
This file contains 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,21 @@ | ||
## [参数完全一致]torch.cuda.set_stream | ||
|
||
### [torch.cuda.set_stream](https://pytorch.org/docs/stable/generated/torch.cuda.set_stream.html#torch.cuda.set_stream) | ||
|
||
```python | ||
torch.cuda.set_stream(stream) | ||
``` | ||
|
||
### [paddle.device.set_stream](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/device/set_stream_cn.html#set-stream) | ||
|
||
```python | ||
paddle.device.set_stream(stream=None) | ||
``` | ||
|
||
功能一致,参数完全一致,具体如下: | ||
|
||
### 参数映射 | ||
|
||
| PyTorch | PaddlePaddle | 备注 | | ||
| ------- | ------------ | ------------------- | | ||
| stream | stream | 希望设置的 stream。 | |
47 changes: 47 additions & 0 deletions
47
...odel_convert/convert_from_pytorch/api_difference/linalg/torch.linalg.svdvals.md
This file contains 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,47 @@ | ||
## [ torch 参数更多 ] torch.linalg.svdvals | ||
|
||
### [torch.linalg.svdvals](https://pytorch.org/docs/stable/generated/torch.linalg.svdvals.html#torch.linalg.svdvals) | ||
|
||
```python | ||
torch.linalg.svdvals(A, *, driver=None, out=None) | ||
``` | ||
|
||
### [paddle.linalg.svd](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/linalg/svd_cn.html) | ||
|
||
```python | ||
paddle.linalg.svd(x, full_matrices=False, name=None) | ||
``` | ||
|
||
其中 PyTorch 相比 Paddle 支持更多其他参数,具体如下: | ||
|
||
### 参数映射 | ||
|
||
| PyTorch | PaddlePaddle | 备注 | | ||
| ------- | ------------- | ------------------------------------------------------------------------------------ | | ||
| A | x | 输入 Tensor,仅参数名不一致。 | | ||
| driver | - | cuSOLVER 方法名,Paddle 无此参数,一般对网络训练结果影响不大,可直接删除。 | | ||
| - | full_matrices | 是否计算完整的 U 和 V 矩阵,Paddle 为 False,Pytorch 无此参数,Paddle 使用默认即可。 | | ||
| out | - | 表示输出的 Tensor,Paddle 无此参数,需要转写。 | | ||
| 返回值 | 返回值 | PyTorch 返回值为 S,Paddle 返回 U、S、VH,需要转写。 | | ||
|
||
### 转写示例 | ||
|
||
#### out 参数:输出的 Tensor | ||
|
||
```python | ||
# PyTorch 写法: | ||
torch.linalg.svdvals(x, out=y) | ||
|
||
# Paddle 写法: | ||
paddle.assign(paddle.linalg.svd(x)[1], y) | ||
``` | ||
|
||
#### 返回值 | ||
|
||
```python | ||
# PyTorch 写法: | ||
y = torch.linalg.svdvals(x) | ||
|
||
# Paddle 写法: | ||
y = paddle.linalg.svd(x)[1] | ||
``` |
23 changes: 23 additions & 0 deletions
23
.../convert_from_pytorch/api_difference/others/torch.autograd.Function.backward.md
This file contains 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,23 @@ | ||
## [仅 Paddle 参数更多]torch.autograd.Function.backward | ||
|
||
### [torch.autograd.Function.backward](https://pytorch.org/docs/stable/generated/torch.autograd.Function.backward.html#torch.autograd.Function.backward) | ||
|
||
```python | ||
torch.autograd.Function.backward(ctx, *grad_outputs) | ||
``` | ||
|
||
### [paddle.autograd.PyLayer.backward](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/autograd/PyLayer_cn.html#backward-ctx-args-kwargs) | ||
|
||
```python | ||
paddle.autograd.PyLayer.backward(ctx, *args, **kwargs) | ||
``` | ||
|
||
Paddle 相比 PyTorch 支持更多其他参数,具体如下: | ||
|
||
### 参数映射 | ||
|
||
| PyTorch | PaddlePaddle | 备注 | | ||
| ------------ | ------------ | ------------------------------------------------------------------- | | ||
| ctx | ctx | 上下文对象。 | | ||
| grad_outputs | args | forward 输出 Tensor 的梯度,仅参数名不一致。 | | ||
| - | kwargs | forward 输出 Tensor 的梯度,PyTorch 无此参数,Paddle 保持默认即可。 | |
23 changes: 23 additions & 0 deletions
23
...t/convert_from_pytorch/api_difference/others/torch.autograd.Function.forward.md
This file contains 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,23 @@ | ||
## [参数完全一致]torch.autograd.Function.forward | ||
|
||
### [torch.autograd.Function.forward](https://pytorch.org/docs/stable/generated/torch.autograd.Function.forward.html#torch.autograd.Function.forward) | ||
|
||
```python | ||
torch.autograd.Function.forward(ctx, *args, **kwargs) | ||
``` | ||
|
||
### [paddle.autograd.PyLayer.forward](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/autograd/PyLayer_cn.html#forward-ctx-args-kwargs) | ||
|
||
```python | ||
paddle.autograd.PyLayer.forward(ctx, *args, **kwargs) | ||
``` | ||
|
||
两者功能一致,参数完全一致,具体如下: | ||
|
||
### 参数映射 | ||
|
||
| PyTorch | PaddlePaddle | 备注 | | ||
| ------- | ------------ | ------------------ | | ||
| ctx | ctx | 上下文对象。 | | ||
| args | args | 自定义算子的输入。 | | ||
| kwargs | kwargs | 自定义算子的输入。 | |
22 changes: 22 additions & 0 deletions
22
...l_convert/convert_from_pytorch/api_difference/others/torch.autograd.Function.md
This file contains 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,22 @@ | ||
## [torch 参数更多]torch.autograd.Function | ||
|
||
### [torch.autograd.Function](https://pytorch.org/docs/stable/autograd.html#torch.autograd.Function) | ||
|
||
```python | ||
torch.autograd.Function(*args, **kwargs) | ||
``` | ||
|
||
### [paddle.autograd.PyLayer](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/autograd/PyLayer_cn.html#paddle.autograd.PyLayer) | ||
|
||
```python | ||
paddle.autograd.PyLayer() | ||
``` | ||
|
||
其中 PyTorch 相比 Paddle 支持更多其他参数,但该类一般用于继承实现,不会调用其参数。 | ||
|
||
### 参数映射 | ||
|
||
| PyTorch | PaddlePaddle | 备注 | | ||
| ------- | ------------ | ----------------------------------------- | | ||
| args | - | 自定义参数,Paddle 无此参数,可直接删除。 | | ||
| kwargs | - | 自定义参数,Paddle 无此参数,可直接删除。 | |
21 changes: 21 additions & 0 deletions
21
...ifference/others/torch.autograd.function.FunctionCtx.mark_non_differentiable.md
This file contains 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,21 @@ | ||
## [仅参数名不一致]torch.autograd.function.FunctionCtx.mark_non_differentiable | ||
|
||
### [torch.autograd.function.FunctionCtx.mark_non_differentiable](https://pytorch.org/docs/stable/generated/torch.autograd.function.FunctionCtx.mark_non_differentiable.html#torch.autograd.function.FunctionCtx.mark_non_differentiable) | ||
|
||
```python | ||
torch.autograd.function.FunctionCtx.mark_non_differentiable(*args) | ||
``` | ||
|
||
### [paddle.autograd.PyLayerContext.mark_non_differentiable](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/autograd/PyLayerContext_cn.html#mark-non-differentiable-self-tensors) | ||
|
||
```python | ||
paddle.autograd.PyLayerContext.mark_non_differentiable(*tensors) | ||
``` | ||
|
||
两者功能一致,仅参数名不一致,具体如下: | ||
|
||
### 参数映射 | ||
|
||
| PyTorch | PaddlePaddle | 备注 | | ||
| ------- | ------------ | ----------------------------- | | ||
| args | tensors | 需要标记不需要反向的 Tensor。 | |
21 changes: 21 additions & 0 deletions
21
.../api_difference/others/torch.autograd.function.FunctionCtx.save_for_backward.md
This file contains 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,21 @@ | ||
## [参数完全一致]torch.autograd.function.FunctionCtx.save_for_backward | ||
|
||
### [torch.autograd.function.FunctionCtx.save_for_backward](https://pytorch.org/docs/stable/generated/torch.autograd.function.FunctionCtx.save_for_backward.html#torch.autograd.function.FunctionCtx.save_for_backward) | ||
|
||
```python | ||
torch.autograd.function.FunctionCtx.save_for_backward(*tensors) | ||
``` | ||
|
||
### [paddle.autograd.PyLayerContext.save_for_backward](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/autograd/PyLayerContext_cn.html#save-for-backward-tensors) | ||
|
||
```python | ||
paddle.autograd.PyLayerContext.save_for_backward(*tensors) | ||
``` | ||
|
||
两者功能一致,参数完全一致,具体如下: | ||
|
||
### 参数映射 | ||
|
||
| PyTorch | PaddlePaddle | 备注 | | ||
| ------- | ------------ | --------------------- | | ||
| tensors | tensors | 需要被暂存的 Tensor。 | |
21 changes: 21 additions & 0 deletions
21
..._difference/others/torch.autograd.function.FunctionCtx.set_materialize_grads.md
This file contains 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,21 @@ | ||
## [参数完全一致]torch.autograd.function.FunctionCtx.set_materialize_grads | ||
|
||
### [torch.autograd.function.FunctionCtx.set_materialize_grads](https://pytorch.org/docs/stable/generated/torch.autograd.function.FunctionCtx.set_materialize_grads.html#torch.autograd.function.FunctionCtx.set_materialize_grads) | ||
|
||
```python | ||
torch.autograd.function.FunctionCtx.set_materialize_grads(value) | ||
``` | ||
|
||
### [paddle.autograd.PyLayerContext.set_materialize_grads](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/autograd/PyLayerContext_cn.html#set-materialize-grads-self-value) | ||
|
||
```python | ||
paddle.autograd.PyLayerContext.set_materialize_grads(value) | ||
``` | ||
|
||
两者功能一致,参数完全一致,具体如下: | ||
|
||
### 参数映射 | ||
|
||
| PyTorch | PaddlePaddle | 备注 | | ||
| ------- | ------------ | -------------------------------------- | | ||
| value | value | 是否要框架来初始化未初始化的反向梯度。 | |
22 changes: 22 additions & 0 deletions
22
..._from_pytorch/api_difference/others/torch.autograd.graph.saved_tensors_hooks.md
This file contains 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,22 @@ | ||
## [参数完全一致]torch.autograd.graph.saved_tensors_hooks | ||
|
||
### [torch.autograd.graph.saved_tensors_hooks](https://pytorch.org/docs/stable/autograd.html?highlight=saved_tensors_hooks#torch.autograd.graph.saved_tensors_hooks) | ||
|
||
```python | ||
torch.autograd.graph.saved_tensors_hooks(pack_hook, unpack_hook) | ||
``` | ||
|
||
### [paddle.autograd.saved_tensors_hooks](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/autograd/saved_tensors_hooks_cn.html) | ||
|
||
```python | ||
paddle.autograd.saved_tensors_hooks(pack_hook, unpack_hook) | ||
``` | ||
|
||
两者功能一致,参数完全一致,具体如下: | ||
|
||
### 参数映射 | ||
|
||
| PyTorch | PaddlePaddle | 备注 | | ||
| ----------- | ------------ | ----------------------------------------------------------------------------------------- | | ||
| pack_hook | pack_hook | 当某个算子的前向执行时,存在 Tensor 需要保留给反向计算梯度使用时, pack_hook 将会被调用。 | | ||
| unpack_hook | unpack_hook | 当反向执行,需要用到前向保留的 Tensor 时, unpack_hook 会被调用。 | |
19 changes: 19 additions & 0 deletions
19
.../model_convert/convert_from_pytorch/api_difference/others/torch.special.erfc.md
This file contains 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.special.erfc | ||
|
||
### [torch.special.erfc](https://pytorch.org/docs/stable/special.html#torch.special.erfc) | ||
|
||
```python | ||
torch.special.erfc(input, *, out=None) | ||
``` | ||
|
||
Paddle 无此 API,需要组合实现。 | ||
|
||
### 转写示例 | ||
|
||
```python | ||
# Pytorch 写法 | ||
y = torch.special.erfc(x) | ||
|
||
# Paddle 写法 | ||
y = 1 - paddle.erf(x) | ||
``` |
19 changes: 19 additions & 0 deletions
19
.../model_convert/convert_from_pytorch/api_difference/others/torch.special.exp2.md
This file contains 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.special.exp2 | ||
|
||
### [torch.special.exp2](https://pytorch.org/docs/stable/special.html#torch.special.exp2) | ||
|
||
```python | ||
torch.special.exp2(input, *, out=None) | ||
``` | ||
|
||
Paddle 无此 API,需要组合实现。 | ||
|
||
### 转写示例 | ||
|
||
```python | ||
# Pytorch 写法 | ||
y = torch.special.exp2(x) | ||
|
||
# Paddle 写法 | ||
y = 2 ** x | ||
``` |
19 changes: 19 additions & 0 deletions
19
...model_convert/convert_from_pytorch/api_difference/others/torch.special.expit.md
This file contains 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.special.expit | ||
|
||
### [torch.special.expit](https://pytorch.org/docs/stable/special.html#torch.special.expit) | ||
|
||
```python | ||
torch.special.expit(input, *, out=None) | ||
``` | ||
|
||
Paddle 无此 API,需要组合实现。 | ||
|
||
### 转写示例 | ||
|
||
```python | ||
# Pytorch 写法 | ||
y = torch.special.expit(x) | ||
|
||
# Paddle 写法 | ||
y = 1 / (1 + 1 / paddle.exp(x)) | ||
``` |
34 changes: 34 additions & 0 deletions
34
...del_convert/convert_from_pytorch/api_difference/others/torch.special.gammaln.md
This file contains 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,34 @@ | ||
## [torch 参数更多]torch.special.gammaln | ||
|
||
### [torch.special.gammaln](https://pytorch.org/docs/stable/special.html#torch.special.gammaln) | ||
|
||
```python | ||
torch.special.gammaln(input, *, out=None) | ||
``` | ||
|
||
### [paddle.lgamma](https://pytorch.org/docs/stable/special.html#torch.special.gammaln) | ||
|
||
```python | ||
paddle.lgamma(x, name=None) | ||
``` | ||
|
||
其中 PyTorch 相比 Paddle 支持更多其他参数,具体如下: | ||
|
||
### 参数映射 | ||
|
||
| PyTorch | PaddlePaddle | 备注 | | ||
| ------- | ------------ | ---------------------------------------------------- | | ||
| input | x | 输入的 Tensor,仅参数名不一致。 | | ||
| out | - | 表示输出的 Tensor , Paddle 无此参数,需要转写。 | | ||
|
||
### 转写示例 | ||
|
||
#### out:指定输出 | ||
|
||
```python | ||
# Pytorch 写法 | ||
torch.special.gammaln(x, out=y) | ||
|
||
# Paddle 写法 | ||
paddle.assign(paddle.lgamma(x), y) | ||
``` |
25 changes: 25 additions & 0 deletions
25
...m_pytorch/api_difference/utils/torch.nn.utils.parametrizations.spectral_norm.md
This file contains 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,25 @@ | ||
## [ 仅参数名不一致 ]torch.nn.utils.parametrizations.spectral_norm | ||
|
||
### [torch.nn.utils.parametrizations.spectral_norm](https://pytorch.org/docs/stable/generated/torch.nn.utils.parametrizations.spectral_norm.html#torch.nn.utils.parametrizations.spectral_norm) | ||
|
||
```python | ||
torch.nn.utils.parametrizations.spectral_norm(module, name='weight', n_power_iterations=1, eps=1e-12, dim=None) | ||
``` | ||
|
||
### [paddle.nn.utils.spectral_norm](https://www.paddlepaddle.org.cn/documentation/docs/zh/develop/api/paddle/nn/utils/spectral_norm_cn.html#spectral-norm) | ||
|
||
```python | ||
paddle.nn.utils.spectral_norm(layer, name='weight', n_power_iterations=1, eps=1e-12, dim=None) | ||
``` | ||
|
||
PyTorch 和 Paddle 功能一致,仅参数名不一致,具体如下: | ||
|
||
### 参数映射 | ||
|
||
| PyTorch | PaddlePaddle | 备注 | | ||
| ------------------ | ------------------ | ---------------------------------------- | | ||
| module | layer | 要添加权重谱归一化的层,仅参数名不一致。 | | ||
| name | name | 权重参数的名字。 | | ||
| n_power_iterations | n_power_iterations | 将用于计算的 SpectralNorm 幂迭代次数。 | | ||
| eps | eps | 用于保证计算中的数值稳定性。 | | ||
| dim | dim | 重塑为矩阵之前应排列到第一个的维度索引。 | |
Oops, something went wrong.