-
Notifications
You must be signed in to change notification settings - Fork 764
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.79 #5853
Closed
Closed
映射文档No.79 #5853
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
e248500
No.79
zhangtailai 53d9301
fix some errors
zhangtailai e931707
fix some errors
zhangtailai 101ab04
修改文档格式
zhangtailai f3fb432
修改文档格式
zhangtailai b446a54
修改文档格式
zhangtailai 628ee63
修改文档格式
zhangtailai ed00a1d
修改文档格式
zhangtailai a5e9de6
修改文档格式
zhangtailai e03139a
Merge branch 'develop' into No.79
zhangtailai 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
31 changes: 31 additions & 0 deletions
31
...odel_convert/convert_from_pytorch/api_difference/Tensor/torch.Tensor.permute.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.Tensor.permute | ||
|
||
### [torch.Tensor.permute](https://pytorch.org/docs/1.13/generated/torch.Tensor.permute.html) | ||
|
||
```python | ||
torch.Tensor.permute(*dims) | ||
``` | ||
|
||
### [paddle.Tensor.transpose](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/Tensor_cn.html#transpose-perm-name-none) | ||
|
||
```python | ||
paddle.Tensor.transpose(perm, name=None) | ||
``` | ||
|
||
Pytorch 的 `dims` 与 paddle 的 `perm` 两者部分参数用法不同,具体如下: | ||
### 参数映射 | ||
| PyTorch | PaddlePaddle | 备注 | | ||
| ------------- | ------------ | ------------------------------------------------------ | | ||
| *dims | perm | torch 支持可变参数或 list/tuple,paddle 仅支持 list/tuple,参数用法不一致,需要进行转写。 | | ||
|
||
### 转写示例 | ||
#### *dim: Tensor 的维度序列,可变参数用法 | ||
```python | ||
# pytorch | ||
x = torch.randn(2, 3, 5) | ||
y = x.permute(2,0,1) | ||
|
||
# paddle | ||
x = paddle.randn([2, 3, 5]) | ||
y = x.transpose([2, 0, 1]) | ||
``` |
31 changes: 31 additions & 0 deletions
31
...model_convert/convert_from_pytorch/api_difference/Tensor/torch.Tensor.repeat.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.Tensor.repeat | ||
|
||
### [torch.Tensor.repeat](https://pytorch.org/docs/1.13/generated/torch.Tensor.repeat.html) | ||
|
||
```python | ||
torch.Tensor.repeat(*sizes) | ||
``` | ||
|
||
### [paddle.Tensor.tile](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/Tensor_cn.html#tile-repeat-times-name-none) | ||
|
||
```python | ||
paddle.Tensor.tile(repeat_times, name=None) | ||
``` | ||
|
||
Pytorch 的 `sizes` 参数与 Paddle 的 `repeat_times` 参数用法不同,具体如下: | ||
### 参数映射 | ||
| PyTorch | PaddlePaddle | 备注 | | ||
| ------------- | ------------ | ------------------------------------------------------ | | ||
| *sizes | repeat_times | torch 支持可变参数或 list/tuple,paddle 仅支持 list/tuple/Tensor,参数用法不一致,需要进行转写。| | ||
|
||
### 转写示例 | ||
#### *sizes: 各个维度重复的次数,可变参数用法 | ||
```python | ||
# pytorch | ||
x = torch.randn(2, 3, 5) | ||
y = x.repeat(4,2,1) | ||
|
||
# paddle | ||
x = paddle.randn([2, 3, 5]) | ||
y = x.tile((4,2,1)) | ||
``` |
31 changes: 31 additions & 0 deletions
31
...odel_convert/convert_from_pytorch/api_difference/Tensor/torch.Tensor.reshape.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.Tensor.reshape | ||
|
||
### [torch.Tensor.reshape](https://pytorch.org/docs/1.13/generated/torch.Tensor.reshape.html) | ||
|
||
```python | ||
torch.Tensor.reshape(*shape) | ||
``` | ||
|
||
### [paddle.Tensor.reshape](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/Tensor_cn.html#reshape-shape-name-none) | ||
|
||
```python | ||
paddle.Tensor.reshape(shape, name=None) | ||
``` | ||
|
||
Pytorch 的 `*shape` 参数与 Paddle 的 `shape` 参数用法不同,具体如下: | ||
### 参数映射 | ||
| PyTorch | PaddlePaddle | 备注 | | ||
| ------------- | ------------ | ------------------------------------------------------ | | ||
| *shape | shape | torch 的 *shape 既可以接收 list 也可接收可变参数。需要转写。| | ||
|
||
### 转写示例 | ||
#### *shape: 新数组的维度序列,可变参数用法 | ||
```python | ||
# pytorch | ||
x = torch.randn(2, 3, 5) | ||
y = x.reshape(6,5) | ||
|
||
# paddle | ||
x = paddle.randn([2, 3, 5]) | ||
y = x.tile((6,5)) | ||
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. 这个应该是x.reshape |
||
``` |
32 changes: 32 additions & 0 deletions
32
.../model_convert/convert_from_pytorch/api_difference/Tensor/torch.Tensor.split.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,32 @@ | ||
## [参数不一致]torch.Tensor.split | ||
|
||
### [torch.Tensor.split](https://pytorch.org/docs/1.13/generated/torch.Tensor.split.html) | ||
|
||
```python | ||
torch.Tensor.split(split_size_or_sections, dim=0) | ||
``` | ||
|
||
### [paddle.Tensor.split](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/Tensor_cn.html#split-num-or-sections-axis-0-name-none) | ||
|
||
```python | ||
paddle.Tensor.split(num_or_sections, axis=0, name=None) | ||
``` | ||
|
||
Pytorch 的 `split_size_or_sections` 与 Paddle 的 `num_or_sections` 用法不同,具体如下: | ||
### 参数映射 | ||
| PyTorch | PaddlePaddle | 备注 | | ||
| ------------- | ------------ | ------------------------------------------------------ | | ||
| dim | axis | 表示需要分割的维度,仅参数名不同。 | | ||
| split_size_or_sections | num_or_sections | torch 的 split_size_or_sections :int 时表示块的大小, list 时表示块的大小; paddle 的 num_or_sections : int 时表示块的个数, list 时表示块的大小。参数类型为 int 时需要转写。| | ||
|
||
### 转写示例 | ||
#### split_size_or_sections: 参数类型为 int 时表示块的大小 | ||
```python | ||
# pytorch | ||
x = torch.randn(8, 2) | ||
y = x.split(4) | ||
|
||
# paddle | ||
x = paddle.randn([8, 2]) | ||
y = x.split(2) | ||
``` |
31 changes: 31 additions & 0 deletions
31
...el_convert/convert_from_pytorch/api_difference/Tensor/torch.Tensor.transpose.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.Tensor.transpose | ||
|
||
### [torch.Tensor.transpose](https://pytorch.org/docs/1.13/generated/torch.Tensor.transpose.html) | ||
|
||
```python | ||
torch.Tensor.transpose(dim0, dim1) | ||
``` | ||
|
||
### [paddle.Tensor.transpose](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/Tensor_cn.html#transpose-perm-name-none) | ||
|
||
```python | ||
paddle.Tensor.transpose(perm, name=None) | ||
``` | ||
|
||
Pytorch 的 `dim0, dim1` 与 Paddle 的 `perm` 用法不同,具体如下: | ||
### 参数映射 | ||
| PyTorch | PaddlePaddle | 备注 | | ||
| ------------- | ------------ | ------------------------------------------------------ | | ||
| dim0, dim1 | perm | torch 的 dim0 与 dim1 表示要交换的两个维度, 为整数。 paddle 的 perm 表示重排的维度序列,为 list/tuple 。需要转写。| | ||
|
||
### 转写示例 | ||
#### dim0, dim1: 表示要交换的两个维度 | ||
```python | ||
# pytorch | ||
x = torch.randn(2, 3, 5) | ||
y = x.transpose(0,1) | ||
|
||
# paddle | ||
x = paddle.randn([2, 3, 5]) | ||
y = x.transpose(perm=[1, 0, 2]) | ||
``` |
28 changes: 28 additions & 0 deletions
28
...des/model_convert/convert_from_pytorch/api_difference/cuda/torch.cuda.device.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 @@ | ||
## [参数不一致]torch.cuda.device | ||
|
||
### [torch.cuda.device](https://pytorch.org/docs/1.13/generated/torch.cuda.device.html) | ||
|
||
```python | ||
torch.cuda.device(device) | ||
``` | ||
|
||
### [paddle.CUDAPlace](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/CUDAPlace_cn.html#cudaplace) | ||
|
||
```python | ||
paddle.CUDAPlace(id) | ||
``` | ||
|
||
Pytorch 的 `device` 与 Paddle 的 `id` 用法不同,具体如下: | ||
### 参数映射 | ||
| PyTorch | PaddlePaddle | 备注 | | ||
| ------------- | ------------ | ------------------------------------------------------ | | ||
| device | id | torch 的 device 参数类型为 torch.device 或 int 。paddle 的 id 为 int。 torch 参数为 int 时无需转写, 参数为 torch.device 时,需要转写。| | ||
|
||
### 转写示例 | ||
```python | ||
# PyTorch 写法 | ||
torch.cuda.device(torch.device('cuda:0')) | ||
|
||
# Paddle 写法 | ||
paddle.CUDAPlace(0) | ||
``` |
29 changes: 29 additions & 0 deletions
29
..._convert/convert_from_pytorch/api_difference/cuda/torch.cuda.get_device_name.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.cuda.get_device_name | ||
|
||
### [torch.cuda.get_device_name](https://pytorch.org/docs/1.13/generated/torch.cuda.get_device_name.html) | ||
|
||
```python | ||
torch.cuda.get_device_name(device=None) | ||
``` | ||
|
||
### [paddle.device.cuda.get_device_properties](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/device/cuda/get_device_properties_cn.html#get-device-properties) | ||
|
||
```python | ||
paddle.device.cuda.get_device_properties(device) | ||
``` | ||
|
||
两者的返回参数不一致,具体如下: | ||
### 参数映射 | ||
| PyTorch | PaddlePaddle | 备注 | | ||
| ------------- | ------------ | ------------------------------------------------------ | | ||
| device | device | torch 的 device 参数类型为 torch.device 或 int 或 str。paddle 的 device 为 paddle.CUDAPlace 或 int 或 str。 | | ||
| Returns | Returns | 两者返回类型不一致。 paddle 的返回数据中 name 属性内容与 torch 的返回内容一致。需要转写。| | ||
|
||
### 转写示例 | ||
```python | ||
# pytorch | ||
y = torch.cuda.get_device_name() | ||
|
||
# paddle | ||
y = paddle.device.cuda.get_device_properties().name | ||
``` |
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.
paddle的支持哪些也写下
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.
torch 的 *shape 既可以是可变参数,也可以是 list/tuple