-
Notifications
You must be signed in to change notification settings - Fork 762
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
映射文档 No. 34 #5825
Closed
Closed
映射文档 No. 34 #5825
Changes from all commits
Commits
Show all changes
2 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
29 changes: 29 additions & 0 deletions
29
...del_convert/convert_from_pytorch/api_difference/Tensor/torch.Tensor.scatter_.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.Tensor.scatter_ | ||
|
||
### [torch.Tensor.scatter_](https://pytorch.org/docs/1.13/generated/torch.Tensor.scatter_.html#torch.Tensor.scatter_) | ||
|
||
```python | ||
torch.Tensor.scatter_(dim, | ||
index, | ||
src, | ||
reduce=None) | ||
``` | ||
|
||
### [paddle.Tensor.put_along_axis_](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/put_along_axis__cn.html) | ||
|
||
```python | ||
paddle.Tensor.put_along_axis_(indices, | ||
value, | ||
axis, | ||
reduce) | ||
``` | ||
|
||
两者功能一致且参数用法一致,仅参数名不一致,具体如下: | ||
|
||
### 参数差异 | ||
| PyTorch | PaddlePaddle | 备注 | | ||
| ------------- | ------------ | ------------------------------------------------------ | | ||
| dim | axis | 表示在哪一个维度 scatter ,仅参数名不一致。 | | ||
| index | indices | 表示输入的索引张量,仅参数名不一致。 | | ||
| src | values | 表示需要插入的值,仅参数名不一致。 | | ||
| reduce | reduce | 表示对输出 Tensor 的计算方式。 | |
28 changes: 28 additions & 0 deletions
28
...convert/convert_from_pytorch/api_difference/Tensor/torch.Tensor.scatter_add_.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,28 @@ | ||
## [仅 paddle 参数更多]torch.Tensor.scatter_add_ | ||
|
||
### [torch.Tensor.scatter_add_](https://pytorch.org/docs/1.13/generated/torch.Tensor.scatter_add_.html#torch.Tensor.scatter_add_) | ||
|
||
```python | ||
torch.Tensor.scatter_add_(dim, | ||
index, | ||
src) | ||
``` | ||
|
||
### [paddle.Tensor.put_along_axis_](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/put_along_axis__cn.html) | ||
|
||
```python | ||
paddle.Tensor.put_along_axis_(indices, | ||
value, | ||
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. API签名没写对,少个s |
||
axis, | ||
reduce) | ||
``` | ||
|
||
其中 Paddle 相比 Pytorch 支持更多其他参数,具体如下: | ||
|
||
### 参数差异 | ||
| PyTorch | PaddlePaddle | 备注 | | ||
| ------------- | ------------ | ------------------------------------------------------ | | ||
| dim | axis | 表示在哪一个维度 scatter ,仅参数名不一致。 | | ||
| index | indices | 表示输入的索引张量,仅参数名不一致。 | | ||
| src | values | 表示需要插入的值,仅参数名不一致。 | | ||
| - | reduce | 表示对输出 Tensor 的计算方式, PyTorch 无此参数, Paddle 应设置为 add 。 | | ||
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. 这两个API对比了结果没,应该不是完全一致的 |
76 changes: 38 additions & 38 deletions
76
...guides/model_convert/convert_from_pytorch/api_difference/ops/torch.bernoulli.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 |
---|---|---|
@@ -1,38 +1,38 @@ | ||
## [torch 参数更多 ]torch.bernoulli | ||
|
||
### [torch.bernoulli](https://pytorch.org/docs/stable/generated/torch.bernoulli.html?highlight=bernoulli#torch.bernoulli) | ||
|
||
```python | ||
torch.bernoulli(input, | ||
*, | ||
generator=None, | ||
out=None) | ||
``` | ||
|
||
### [paddle.bernoulli](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/bernoulli_cn.html#bernoulli) | ||
|
||
```python | ||
paddle.bernoulli(x, | ||
name=None) | ||
``` | ||
|
||
其中 Pytorch 相比 Paddle 支持更多其他参数,具体如下: | ||
|
||
### 参数映射 | ||
| PyTorch | PaddlePaddle | 备注 | | ||
| ------------- | ------------ | ------------------------------------------------------ | | ||
| <font color='red'>input</font>| <font color='red'>x</font> | 表示输入的 Tensor ,仅参数名不同。 | | ||
| <font color='red'>generator</font> | - | 用于采样的伪随机数生成器, Paddle 无此参数,一般对网络训练结果影响不大,可直接删除。 | | ||
| <font color='red'>out</font> | - | 表示输出的 Tensor , Paddle 无此参数,需要进行转写。 | | ||
|
||
|
||
|
||
### 转写示例 | ||
#### out:指定输出 | ||
```python | ||
# Pytorch 写法 | ||
torch.bernoulli([3, 5], out=y) | ||
|
||
# Paddle 写法 | ||
paddle.assign(paddle.bernoulli([3, 5]), y) | ||
``` | ||
## [torch 参数更多 ]torch.bernoulli | ||
### [torch.bernoulli](https://pytorch.org/docs/1.13/generated/torch.bernoulli.html#torch.bernoulli) | ||
```python | ||
torch.bernoulli(input, | ||
*, | ||
generator=None, | ||
out=None) | ||
``` | ||
### [paddle.bernoulli](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/bernoulli_cn.html) | ||
```python | ||
paddle.bernoulli(x, | ||
name=None) | ||
``` | ||
其中 Pytorch 相比 Paddle 支持更多其他参数,具体如下: | ||
### 参数映射 | ||
| PyTorch | PaddlePaddle | 备注 | | ||
| ------------- | ------------ | ------------------------------------------------------ | | ||
| input | x | 表示输入的 Tensor ,仅参数名不同。 | | ||
| generator | - | 用于采样的伪随机数生成器, Paddle 无此参数,一般对网络训练结果影响不大,可直接删除。 | | ||
| out | - | 表示输出的 Tensor , Paddle 无此参数,需要进行转写。 | | ||
### 转写示例 | ||
#### out:指定输出 | ||
```python | ||
# Pytorch 写法 | ||
torch.bernoulli(torch.tensor([3, 5]), out=y) | ||
# Paddle 写法 | ||
paddle.assign(paddle.bernoulli(paddle.to_tensor([3, 5])), y) | ||
``` |
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
70 changes: 35 additions & 35 deletions
70
docs/guides/model_convert/convert_from_pytorch/api_difference/ops/torch.nonzero.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 |
---|---|---|
@@ -1,35 +1,35 @@ | ||
## [torch 参数更多 ]torch.nonzero | ||
### [torch.nonzero](https://pytorch.org/docs/1.13/generated/torch.nonzero.html?highlight=nonzero#torch.nonzero) | ||
|
||
```python | ||
torch.nonzero(input, | ||
*, | ||
out=None, | ||
as_tuple=False) | ||
``` | ||
|
||
### [paddle.nonzero](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/nonzero_cn.html#nonzero) | ||
|
||
```python | ||
paddle.nonzero(x, | ||
as_tuple=False) | ||
``` | ||
|
||
其中 Pytorch 相比 Paddle 支持更多其他参数,具体如下: | ||
### 参数映射 | ||
| PyTorch | PaddlePaddle | 备注 | | ||
| ------------- | ------------ | ------------------------------------------------------ | | ||
| <font color='red'> input </font> | <font color='red'> x </font> | 表示输入的 Tensor ,仅参数名不一致。 | | ||
| <font color='red'> out </font> | - | 表示输出的 Tensor , Paddle 无此参数,需要进行转写。 | | ||
| as_tuple | as_tuple | 表示是否以元组格式返回。 | | ||
|
||
|
||
### 转写示例 | ||
#### out:指定输出 | ||
```python | ||
# Pytorch 写法 | ||
torch.nonzero(x, out=y) | ||
|
||
# Paddle 写法 | ||
paddle.assign(paddle.nonzero(x), y) | ||
``` | ||
## [torch 参数更多 ]torch.nonzero | ||
### [torch.nonzero](https://pytorch.org/docs/1.13/generated/torch.nonzero.html#torch.nonzero) | ||
```python | ||
torch.nonzero(input, | ||
*, | ||
out=None, | ||
as_tuple=False) | ||
``` | ||
### [paddle.nonzero](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/nonzero_cn.html) | ||
```python | ||
paddle.nonzero(x, | ||
as_tuple=False) | ||
``` | ||
其中 Pytorch 相比 Paddle 支持更多其他参数,具体如下: | ||
### 参数映射 | ||
| PyTorch | PaddlePaddle | 备注 | | ||
| ------------- | ------------ | ------------------------------------------------------ | | ||
| input | x | 表示输入的 Tensor ,仅参数名不一致。 | | ||
| out | - | 表示输出的 Tensor , Paddle 无此参数,需要进行转写。 | | ||
| as_tuple | as_tuple | bool 类型表示输出数据的格式,默认 False 时,输出一个张量,True 时输出一组一维张量。 | | ||
### 转写示例 | ||
#### out:指定输出 | ||
```python | ||
# Pytorch 写法 | ||
torch.nonzero(torch.tensor([3, 5]), out=y) | ||
# Paddle 写法 | ||
paddle.assign(paddle.nonzero(paddle.to_tensor([3, 5])), y) | ||
``` |
75 changes: 37 additions & 38 deletions
75
docs/guides/model_convert/convert_from_pytorch/api_difference/ops/torch.normal.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 |
---|---|---|
@@ -1,38 +1,37 @@ | ||
## [torch 参数更多 ]torch.normal | ||
### [torch.normal](https://pytorch.org/docs/stable/generated/torch.normal.html?highlight=normal#torch.normal) | ||
```python | ||
torch.normal(mean, | ||
std, | ||
size=None, | ||
*, | ||
generator=None, | ||
out=None) | ||
``` | ||
### [paddle.normal](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/normal_cn.html#normal) | ||
```python | ||
paddle.normal(mean=0.0, | ||
std=1.0, | ||
shape=None, | ||
name=None) | ||
``` | ||
|
||
其中 Pytorch 相比 Paddle 支持更多其他参数,具体如下: | ||
### 参数映射 | ||
| PyTorch | PaddlePaddle | 备注 | | ||
| ------------- | ------------ | ------------------------------------------------------ | | ||
| mean | mean | 表示正态分布的均值。 | | ||
| std | std | 表示正态分布的方差。 | | ||
| size | shape | 表示输出 Tensor 的形状,仅参数名不一致。 | | ||
| generator | - | 用于采样的伪随机数生成器,PaddlePaddle 无此参数,一般对网络训练结果影响不大,可直接删除。 | | ||
| out | - | 表示输出的 Tensor, Paddle 无此参数,需要进行转写。 | | ||
|
||
|
||
### 转写示例 | ||
#### out:指定输出 | ||
```python | ||
# Pytorch 写法 | ||
torch.normal(mean=[0., 0., 0.], std=[1., 2., 3.], out=y) | ||
|
||
# Paddle 写法 | ||
paddle.assign(paddle.normal(mean=[0., 0., 0.], std=[1., 2., 3.]), y) | ||
``` | ||
## [torch 参数更多 ]torch.normal | ||
### [torch.normal](https://pytorch.org/docs/1.13/generated/torch.normal.html#torch.normal) | ||
```python | ||
torch.normal(mean, | ||
std, | ||
*, | ||
generator=None, | ||
out=None) | ||
``` | ||
### [paddle.normal](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/normal_cn.html) | ||
```python | ||
paddle.normal(mean=0.0, | ||
std=1.0, | ||
shape=None, | ||
name=None) | ||
``` | ||
|
||
其中 Pytorch 相比 Paddle 支持更多其他参数,具体如下: | ||
### 参数映射 | ||
| PyTorch | PaddlePaddle | 备注 | | ||
| ------------- | ------------ | ------------------------------------------------------ | | ||
| mean | mean | 表示正态分布的均值。 | | ||
| std | std | 表示正态分布的方差。 | | ||
| - | shape | 表示输出 Tensor 的形状,Pytorch 无此参数, Paddle 保持默认即可。 | | ||
| generator | - | 用于采样的伪随机数生成器,PaddlePaddle 无此参数,一般对网络训练结果影响不大,可直接删除。 | | ||
| out | - | 表示输出的 Tensor, Paddle 无此参数,需要进行转写。 | | ||
|
||
|
||
### 转写示例 | ||
#### out:指定输出 | ||
```python | ||
# Pytorch 写法 | ||
torch.normal(torch.tensor([0, 0, 0]), torch.tensor([1.0, 2.0, 3.0]), out=y) | ||
|
||
# Paddle 写法 | ||
paddle.assign(paddle.normal(paddle.to_tensor([0, 0, 0]), paddle.to_tensor([1.0, 2.0, 3.0])), y) | ||
``` |
18 changes: 18 additions & 0 deletions
18
docs/guides/model_convert/convert_from_pytorch/api_difference/ops/torch.poisson.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,18 @@ | ||
## [torch 参数更多 ]torch.poisson | ||
### [torch.poisson](https://pytorch.org/docs/1.13/generated/torch.poisson.html#torch.poisson) | ||
```python | ||
torch.poisson(input, | ||
generator=None) | ||
``` | ||
### [paddle.poisson](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/poisson_cn.html) | ||
```python | ||
paddle.poisson(x, | ||
name=None) | ||
``` | ||
|
||
其中 Pytorch 相比 Paddle 支持更多其他参数,具体如下: | ||
### 参数映射 | ||
| PyTorch | PaddlePaddle | 备注 | | ||
| ------------- | ------------ | ------------------------------------------------------ | | ||
| input | x | 表示输入的 Tensor ,仅参数名不一致。 | | ||
| generator | - | 用于采样的伪随机数生成器,PaddlePaddle 无此参数,一般对网络训练结果影响不大,可直接删除。 | |
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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
API签名没写对,少个s