-
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.
* model_convert add torch.is_nonzero .etc * model_convert add is_nonzero .etc * model_convert add is_nonzero .etc * model_convert add is_nonzero .etc * add xlogy.etc * add randn_like .etc * comment * add vdot etc. * add aminmax etc. * fix parameter * add bucketizr etc. * add bucketizr etc. * add bucketizr etc. * add sinc etc. * add sinc etc. * add sinc etc. * add cov etc. * add cov etc. * add cov etc. * add cov etc.
- Loading branch information
Showing
17 changed files
with
417 additions
and
7 deletions.
There are no files selected for viewing
20 changes: 20 additions & 0 deletions
20
...odel_convert/convert_from_pytorch/api_difference/Tensor/torch.Tensor.adjoint.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,20 @@ | ||
## [ 组合替代实现 ]torch.Tensor.adjoint | ||
|
||
### [torch.Tensor.adjoint](https://pytorch.org/docs/stable/generated/torch.Tensor.adjoint.html#torch.Tensor.adjoint) | ||
```python | ||
torch.Tensor.adjoint() | ||
``` | ||
|
||
Paddle 无此 API,需要组合实现。 | ||
|
||
### 转写示例 | ||
|
||
```python | ||
# Pytorch 写法 | ||
y = input.adjoint() | ||
|
||
# Paddle 写法 | ||
y = paddle.conj(paddle.transpose(input, perm=[0, 2, 1])) | ||
|
||
# 注:假设 input 为 3D Tensor, paddle 需要对 input 的后两维转置。 | ||
``` |
19 changes: 19 additions & 0 deletions
19
...del_convert/convert_from_pytorch/api_difference/Tensor/torch.Tensor.argwhere.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 @@ | ||
## [ 仅 paddle 参数更多 ]torch.Tensor.argwhere | ||
### [torch.Tensor.argwhere](https://pytorch.org/docs/stable/generated/torch.Tensor.argwhere.html#torch.Tensor.argwhere) | ||
|
||
```python | ||
torch.Tensor.argwhere() | ||
``` | ||
|
||
### [paddle.Tensor.nonzero](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/Tensor_cn.html#nonzero-as-tuple-false) | ||
|
||
```python | ||
paddle.Tensor.nonzero(as_tuple=False) | ||
``` | ||
|
||
其中 Paddle 相比 Pytorch 支持更多其他参数,具体如下: | ||
|
||
### 参数映射 | ||
| PyTorch | PaddlePaddle | 备注 | | ||
| ------------- | ------------ | ------------------------------------------------------ | | ||
| - | <font color='red'> as_tuple </font> | 返回格式。是否以 1-D Tensor 构成的元组格式返回。 Pytorch 无此参数, Paddle 保持默认即可。 | |
26 changes: 26 additions & 0 deletions
26
...es/model_convert/convert_from_pytorch/api_difference/Tensor/torch.Tensor.cov.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,26 @@ | ||
## [ 仅 paddle 参数更多 ]torch.Tenor.cov | ||
### [torch.Tenor.cov](https://pytorch.org/docs/stable/generated/torch.Tensor.cov.html#torch.Tensor.cov) | ||
|
||
```python | ||
torch.Tensor.cov(*, correction=1, fweights=None, aweights=None) | ||
``` | ||
|
||
### [paddle.linalg.cov](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/linalg/cov_cn.html#cov) | ||
|
||
```python | ||
paddle.linalg.cov(x, | ||
rowvar=True, | ||
ddof=True, | ||
fweights=None, | ||
aweights=None, | ||
name=None) | ||
``` | ||
|
||
仅 paddle 参数更多,具体如下: | ||
### 参数映射 | ||
| PyTorch | PaddlePaddle | 备注 | | ||
| ------------- | ------------ | ------------------------------------------------------ | | ||
| <font color='red'> correction </font> | <font color='red'> ddof </font> | 样本量和样本自由度之间的差异, 若为 True ,返回无偏估计结果;若为 False ,返回普通平均值计算结果。 | | ||
| fweights | fweights | 表示每一个观测向量的重复次数。 | | ||
| aweights | aweights | 表示每一个观测向量的重要性。 | | ||
| - | <font color='red'> rowvar </font> | 以行或列作为一个观测变量, Pytorch 无此参数, Paddle 保持默认即可。 | |
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
31 changes: 31 additions & 0 deletions
31
...es/model_convert/convert_from_pytorch/api_difference/linalg/torch.linalg.det.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,31 @@ | ||
## [ torch 参数更多 ]torch.linalg.det | ||
### [torch.linalg.det](https://pytorch.org/docs/stable/generated/torch.linalg.det.html#torch.linalg.det) | ||
|
||
```python | ||
torch.linalg.det(A, *, out=None) | ||
``` | ||
|
||
### [paddle.linalg.det](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/linalg/det_cn.html#det) | ||
|
||
```python | ||
paddle.linalg.det(x) | ||
``` | ||
|
||
torch 参数更多,具体如下: | ||
### 参数映射 | ||
| PyTorch | PaddlePaddle | 备注 | | ||
| ------------- | ------------ | ------------------------------------------------------ | | ||
| <font color='red'> A </font> | <font color='red'> x </font> | 表示输入的 Tensor ,仅参数名不一致。 | | ||
| <font color='red'> out </font> | <font color='red'> - </font> | 表示输出 Tensor, Paddle 无此参数,需要进行转写。 | | ||
|
||
### 转写示例 | ||
|
||
#### out:指定输出 | ||
|
||
```python | ||
# Pytorch 写法 | ||
torch.linalg.det(x, out=y) | ||
|
||
# Paddle 写法 | ||
paddle.assign(paddle.linalg.det(x), y) | ||
``` |
46 changes: 46 additions & 0 deletions
46
...s/model_convert/convert_from_pytorch/api_difference/linalg/torch.linalg.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,46 @@ | ||
## [ torch 参数更多 ]torch.linalg.norm | ||
|
||
### [torch.linalg.norm](https://pytorch.org/docs/stable/generated/torch.linalg.norm.html#torch.linalg.norm) | ||
|
||
```python | ||
torch.linalg.norm(input, ord=None, dim=None, keepdim=False, *, out=None, dtype=None) | ||
``` | ||
|
||
### [paddle.linalg.norm](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/linalg/norm_cn.html#norm) | ||
|
||
```python | ||
paddle.linalg.norm(x, p='fro', axis=None, keepdim=False, name=None) | ||
``` | ||
|
||
Pytorch 支持更多的参数,具体如下: | ||
### 参数映射 | ||
| PyTorch | PaddlePaddle | 备注 | | ||
| ------------- | ------------ | ------------------------------------------------------ | | ||
| input | x | 表示输入的一个 tensor 列表 ,仅参数名不一致。 | | ||
| ord | p | 范数的种类。参数不一致。Pytorch 支持负实数的范数,Paddle 暂不支持,暂无转写方式。 | | ||
| dim | axis | 使用范数计算的轴 ,仅参数名不一致。 | | ||
| keepdim | keepdim | 是否在输出的 Tensor 中保留和输入一样的维度。 | | ||
| out | - | 表示输出的 Tensor , Paddle 无此参数,需要进行转写。 | | ||
| dtype | - | 表示输出 Tensor 的数据类型, Paddle 无此参数,需要进行转写。 | | ||
|
||
### 转写示例 | ||
|
||
#### out:指定输出 | ||
|
||
```python | ||
# Pytorch 写法 | ||
torch.linalg.norm(x, out=y) | ||
|
||
# Paddle 写法 | ||
paddle.assign(paddle.linalg.norm(x), y) | ||
``` | ||
|
||
#### dtype:表示输出 Tensor 的数据类型 | ||
|
||
```python | ||
# Pytorch 写法 | ||
torch.linalg.norm(x, dtype=torch.float64) | ||
|
||
# Paddle 写法 | ||
paddle.linalg.norm(x.astype(paddle.float64)) | ||
``` |
20 changes: 20 additions & 0 deletions
20
docs/guides/model_convert/convert_from_pytorch/api_difference/ops/torch.adjoint.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,20 @@ | ||
## [ 组合替代实现 ]torch.adjoint | ||
|
||
### [torch.adjoint](https://pytorch.org/docs/stable/generated/torch.adjoint.html#torch.adjoint) | ||
```python | ||
torch.adjoint(input) | ||
``` | ||
|
||
Paddle 无此 API,需要组合实现。 | ||
|
||
### 转写示例 | ||
|
||
```python | ||
# Pytorch 写法 | ||
y = torch.adjoint(input) | ||
|
||
# Paddle 写法 | ||
y = paddle.conj(paddle.transpose(input, perm=[0, 2, 1])) | ||
|
||
# 注:假设 input 为 3D Tensor, paddle 需要对 input 的后两维转置。 | ||
``` |
37 changes: 37 additions & 0 deletions
37
docs/guides/model_convert/convert_from_pytorch/api_difference/ops/torch.arctan2.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,37 @@ | ||
## [torch 参数更多 ]torch.arctan2 | ||
### [torch.arctan2](https://pytorch.org/docs/stable/generated/torch.arctan2.html#torch.arctan2) | ||
|
||
```python | ||
torch.arctan2(input, | ||
other, | ||
*, | ||
out=None) | ||
``` | ||
|
||
### [paddle.atan2](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/atan2_cn.html) | ||
|
||
```python | ||
paddle.atan2(x, | ||
y, | ||
name=None) | ||
``` | ||
|
||
其中 Pytorch 相比 Paddle 支持更多其他参数,具体如下: | ||
|
||
### 参数映射 | ||
| PyTorch | PaddlePaddle | 备注 | | ||
| ------------- | ------------ | ------------------------------------------------------ | | ||
| input | x | 表示输入的 Tensor ,仅参数名不一致。 | | ||
| other | y | 表示输入的 Tensor ,仅参数名不一致。 | | ||
| out | - | 表示输出的 Tensor , Paddle 无此参数,需要进行转写。 | | ||
|
||
|
||
### 转写示例 | ||
#### out:指定输出 | ||
```python | ||
# Pytorch 写法 | ||
torch.arctan2(input, other, out=y) | ||
|
||
# Paddle 写法 | ||
paddle.assign(paddle.atan2(input, other), output=y) | ||
``` |
20 changes: 20 additions & 0 deletions
20
.../guides/model_convert/convert_from_pytorch/api_difference/ops/torch.argwhere.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,20 @@ | ||
## [ 仅 paddle 参数更多 ]torch.argwhere | ||
### [torch.argwhere](https://pytorch.org/docs/stable/generated/torch.argwhere.html#torch.argwhere) | ||
|
||
```python | ||
torch.argwhere(input) | ||
``` | ||
|
||
### [paddle.nonzero](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/nonzero_cn.html#nonzero) | ||
|
||
```python | ||
paddle.nonzero(x, as_tuple=False) | ||
``` | ||
|
||
其中 Paddle 相比 Pytorch 支持更多其他参数,具体如下: | ||
|
||
### 参数映射 | ||
| PyTorch | PaddlePaddle | 备注 | | ||
| ------------- | ------------ | ------------------------------------------------------ | | ||
| <font color='red'>input</font> | <font color='red'>x</font> | 输入的 Tensor ,仅参数名不同。 | | ||
| - | <font color='red'> as_tuple </font> | 返回格式。是否以 1-D Tensor 构成的元组格式返回。 Pytorch 无此参数, Paddle 保持默认即可。 | |
29 changes: 29 additions & 0 deletions
29
...es/model_convert/convert_from_pytorch/api_difference/ops/torch.conj_physical.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,29 @@ | ||
## [ torch 参数更多]torch.conj_physical | ||
### [torch.conj_physical](https://pytorch.org/docs/stable/generated/torch.conj_physical.html#torch.conj_physical) | ||
|
||
```python | ||
torch.conj_physical(input, *, out=None) | ||
``` | ||
|
||
### [paddle.conj](https://www.paddlepaddle.org.cn/documentation/docs/zh/develop/api/paddle/conj_cn.html#conj) | ||
|
||
```python | ||
paddle.conj(x, | ||
name=None) | ||
``` | ||
|
||
Pytorch 参数更多,具体如下: | ||
### 参数映射 | ||
| PyTorch | PaddlePaddle | 备注 | | ||
| ------------- | ------------ | ------------------------------------------------------ | | ||
| <font color='red'> input </font> | <font color='red'> x </font> | 表示输入的 Tensor ,仅参数名不一致。 | | ||
| <font color='red'> out </font> | - | 表示输出的 Tensor ,paddle 无此参数, 需要转写。 | | ||
|
||
#### out:指定输出 | ||
```python | ||
# Pytorch 写法 | ||
torch.conj_physical(input, out=out) | ||
|
||
# Paddle 写法 | ||
paddle.assign(paddle.conj(input), output=out) | ||
``` |
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
30 changes: 30 additions & 0 deletions
30
...del_convert/convert_from_pytorch/api_difference/others/torch.special.digamma.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,30 @@ | ||
## [ torch 参数更多 ]torch.special.digamma | ||
### [torch.special.digamma](https://pytorch.org/docs/stable/special.html#torch.special.digamma) | ||
```python | ||
torch.special.digamma(input, | ||
*, | ||
out=None) | ||
``` | ||
|
||
### [paddle.digamma](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/special.digamma_cn.html) | ||
```python | ||
paddle.digamma(x, | ||
name=None) | ||
``` | ||
|
||
其中 Pytorch 相比 Paddle 支持更多其他参数,具体如下: | ||
### 参数映射 | ||
| PyTorch | PaddlePaddle | 备注 | | ||
| ------------- | ------------ | ------------------------------------------------------ | | ||
| input | x | 表示输入的 Tensor ,仅参数名不一致。 | | ||
| out | - | 表示输出的 Tensor , Paddle 无此参数,需要进行转写。 | | ||
|
||
### 转写示例 | ||
#### out:指定输出 | ||
```python | ||
# Pytorch 写法 | ||
torch.special.digamma(input, out=y) | ||
|
||
# Paddle 写法 | ||
paddle.assign(paddle.digamma(input), y) | ||
``` |
33 changes: 33 additions & 0 deletions
33
...model_convert/convert_from_pytorch/api_difference/others/torch.special.log1p.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,33 @@ | ||
## [torch 参数更多 ]torch.special.log1p | ||
### [torch.special.log1p](https://pytorch.org/docs/stable/special.html#torch.special.log1p) | ||
|
||
```python | ||
torch.special.log1p(input, | ||
*, | ||
out=None) | ||
``` | ||
|
||
### [paddle.log1p](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/log1p_cn.html#log1p) | ||
|
||
```python | ||
paddle.log1p(x, | ||
name=None) | ||
``` | ||
|
||
其中 Pytorch 相比 Paddle 支持更多其他参数,具体如下: | ||
### 参数映射 | ||
| PyTorch | PaddlePaddle | 备注 | | ||
| ------------- | ------------ | ------------------------------------------------------ | | ||
| <font color='red'> input </font> | <font color='red'> x </font> | 表示输入的 Tensor ,仅参数名不一致。 | | ||
| <font color='red'> out </font> | - | 表示输出的 Tensor , Paddle 无此参数,需要进行转写。 | | ||
|
||
|
||
### 转写示例 | ||
#### out:指定输出 | ||
```python | ||
# Pytorch 写法 | ||
torch.special.log1p(input, out=y) | ||
|
||
# Paddle 写法 | ||
paddle.assign(paddle.log1p(input), y) | ||
``` |
31 changes: 31 additions & 0 deletions
31
...l_convert/convert_from_pytorch/api_difference/others/torch.special.logsumexp.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,31 @@ | ||
## [ torch 参数更多 ]torch.special.logsumexp | ||
### [torch.special.logsumexp](https://pytorch.org/docs/stable/special.html#torch.special.logsumexp) | ||
|
||
```python | ||
torch.special.logsumexp(input, dim, keepdim=False, *, out=None) | ||
``` | ||
|
||
### [paddle.logsumexp](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/logsumexp_cn.html) | ||
|
||
```python | ||
paddle.logsumexp(x, axis=None, keepdim=False, name=None) | ||
``` | ||
|
||
其中 PyTorch 相比 Paddle 支持更多其他参数,具体如下: | ||
### 参数映射 | ||
| PyTorch | PaddlePaddle | 备注 | | ||
| ------------- | ------------ | ------------------------------------------------------ | | ||
| input | x | 输入的 Tensor.仅参数名不一致。 | | ||
| dim | axis | 指定对输入进行计算的轴。仅参数名不一致。 | | ||
| keepdim | keepdim | 是否在输出 Tensor 中保留减小的维度。 | | ||
| out | - | 表示输出的 Tensor , Paddle 无此参数,需要进行转写。 | | ||
|
||
### 转写示例 | ||
#### out:指定输出 | ||
```python | ||
# Pytorch 写法 | ||
torch.special.logsumexp(input, dim=1, out=y) | ||
|
||
# Paddle 写法 | ||
paddle.assign(paddle.logsumexp(input, axis=1), y) | ||
``` |
Oops, something went wrong.