-
Notifications
You must be signed in to change notification settings - Fork 873
【映射文档】补全缺失的映射文档 #6519
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
【映射文档】补全缺失的映射文档 #6519
Changes from all commits
Commits
Show all changes
5 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
23 changes: 23 additions & 0 deletions
23
...es/model_convert/convert_from_pytorch/api_difference/Tensor/torch.BoolTensor.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,23 @@ | ||
| ## [ 仅 paddle 参数更多 ] torch.BoolTensor | ||
|
|
||
| ### [torch.BoolTensor](https://pytorch.org/docs/stable/tensors.html) | ||
|
|
||
| ```python | ||
| torch.BoolTensor(data) | ||
| ``` | ||
|
|
||
| ### [paddle.to_tensor](https://www.paddlepaddle.org.cn/documentation/docs/zh/develop/api/paddle/to_tensor_cn.html#to-tensor) | ||
|
|
||
| ```python | ||
| paddle.to_tensor(data, dtype='bool', place='cpu') | ||
| ``` | ||
|
|
||
| Paddle 比 PyTorch 支持更多参数,具体如下: | ||
|
|
||
| ### 参数映射 | ||
|
|
||
| | PyTorch | PaddlePaddle | 备注 | | ||
| | ------- | ------------ | ----------------------------------------------------------- | | ||
| | data | data | 要转换的数据。 | | ||
| | - | dtype | Tensor 的数据类型,PyTorch 无此参数,Paddle 需设置为 'bool'。 | | ||
| | - | place | Tensor 的设备,PyTorch 无此参数,Paddle 需设置为 'cpu' 。 | |
23 changes: 23 additions & 0 deletions
23
...s/model_convert/convert_from_pytorch/api_difference/Tensor/torch.FloatTensor.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,23 @@ | ||
| ## [ 仅 paddle 参数更多 ] torch.FloatTensor | ||
|
|
||
| ### [torch.FloatTensor](https://pytorch.org/docs/stable/tensors.html) | ||
|
|
||
| ```python | ||
| torch.FloatTensor(data) | ||
| ``` | ||
|
|
||
| ### [paddle.to_tensor](https://www.paddlepaddle.org.cn/documentation/docs/zh/develop/api/paddle/to_tensor_cn.html#to-tensor) | ||
|
|
||
| ```python | ||
| paddle.to_tensor(data, dtype='float32', place='cpu') | ||
| ``` | ||
|
|
||
| Paddle 比 PyTorch 支持更多参数,具体如下: | ||
|
|
||
| ### 参数映射 | ||
|
|
||
| | PyTorch | PaddlePaddle | 备注 | | ||
| | ------- | ------------ | ----------------------------------------------------------- | | ||
| | data | data | 要转换的数据。 | | ||
| | - | dtype | Tensor 的数据类型,PyTorch 无此参数,Paddle 需设置为 'float32'。 | | ||
| | - | place | Tensor 的设备,PyTorch 无此参数,Paddle 需设置为 'cpu' 。 | |
23 changes: 23 additions & 0 deletions
23
...des/model_convert/convert_from_pytorch/api_difference/Tensor/torch.IntTensor.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,23 @@ | ||
| ## [ 仅 paddle 参数更多 ] torch.IntTensor | ||
|
|
||
| ### [torch.IntTensor](https://pytorch.org/docs/stable/tensors.html) | ||
|
|
||
| ```python | ||
| torch.IntTensor(data) | ||
| ``` | ||
|
|
||
| ### [paddle.to_tensor](https://www.paddlepaddle.org.cn/documentation/docs/zh/develop/api/paddle/to_tensor_cn.html#to-tensor) | ||
|
|
||
| ```python | ||
| paddle.to_tensor(data, dtype='int32', place='cpu') | ||
| ``` | ||
|
|
||
| Paddle 比 PyTorch 支持更多参数,具体如下: | ||
|
|
||
| ### 参数映射 | ||
|
|
||
| | PyTorch | PaddlePaddle | 备注 | | ||
| | ------- | ------------ | ----------------------------------------------------------- | | ||
| | data | data | 要转换的数据。 | | ||
| | - | dtype | Tensor 的数据类型,PyTorch 无此参数,Paddle 需设置为 'int32'。 | | ||
| | - | place | Tensor 的设备,PyTorch 无此参数,Paddle 需设置为 'cpu' 。 | |
23 changes: 23 additions & 0 deletions
23
...es/model_convert/convert_from_pytorch/api_difference/Tensor/torch.LongTensor.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,23 @@ | ||
| ## [ 仅 paddle 参数更多 ] torch.LongTensor | ||
|
|
||
| ### [torch.LongTensor](https://pytorch.org/docs/stable/tensors.html) | ||
|
|
||
| ```python | ||
| torch.LongTensor(data) | ||
| ``` | ||
|
|
||
| ### [paddle.to_tensor](https://www.paddlepaddle.org.cn/documentation/docs/zh/develop/api/paddle/to_tensor_cn.html#to-tensor) | ||
|
|
||
| ```python | ||
| paddle.to_tensor(data, dtype='int64', place='cpu') | ||
| ``` | ||
|
|
||
| Paddle 比 PyTorch 支持更多参数,具体如下: | ||
|
|
||
| ### 参数映射 | ||
|
|
||
| | PyTorch | PaddlePaddle | 备注 | | ||
| | ------- | ------------ | ----------------------------------------------------------- | | ||
| | data | data | 要转换的数据。 | | ||
| | - | dtype | Tensor 的数据类型,PyTorch 无此参数,Paddle 需设置为 'int64'。 | | ||
| | - | place | Tensor 的设备,PyTorch 无此参数,Paddle 需设置为 'cpu' 。 | |
2 changes: 1 addition & 1 deletion
2
...convert_from_pytorch/api_difference/functional/torch.nn.functional.embedding.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
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
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
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
47 changes: 47 additions & 0 deletions
47
docs/guides/model_convert/convert_from_pytorch/api_difference/ops/torch.norm.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,47 @@ | ||
| ## [ torch 参数更多 ]torch.norm | ||
|
|
||
| ### [torch.norm](https://pytorch.org/docs/stable/generated/torch.norm.html) | ||
|
|
||
| ```python | ||
| torch.norm(input, p='fro', 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 相比 Paddle 支持更多其他参数,具体如下: | ||
|
|
||
| ### 参数映射 | ||
|
|
||
| | PyTorch | PaddlePaddle | 备注 | | ||
| | ------- | ------------ | -- | | ||
| | input | x | 输入 Tensor,仅参数名不一致。 | | ||
| | p | p | 范数(ord)的种类。 | | ||
| | dim | axis | 使用范数计算的轴,仅参数名不一致。 | | ||
| | keepdim | keepdim | 是否在输出的 Tensor 中保留和输入一样的维度。 | | ||
| | out | - | 表示输出的 Tensor,Paddle 无此参数,需要转写。 | | ||
| | dtype | - | 表示输出 Tensor 的数据类型, Paddle 无此参数,需要转写。 | | ||
|
|
||
| ### 转写示例 | ||
|
|
||
| #### out 参数:指定输出 | ||
| ``` python | ||
| # PyTorch 写法: | ||
| torch.norm(x, out=y) | ||
|
|
||
| # Paddle 写法: | ||
| paddle.assign(paddle.linalg.norm(x) , y) | ||
| ``` | ||
|
|
||
| #### dtype:表示输出 Tensor 的数据类型 | ||
|
|
||
| ```python | ||
| # PyTorch 写法 | ||
| torch.norm(x, dtype=torch.float64) | ||
|
|
||
| # Paddle 写法 | ||
| paddle.linalg.norm(x.astype(paddle.float64)) | ||
| ``` | ||
24 changes: 24 additions & 0 deletions
24
docs/guides/model_convert/convert_from_pytorch/api_difference/ops/torch.rrelu.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,24 @@ | ||
| ## [ 仅参数默认值不一致 ]torch.rrelu | ||
|
|
||
| ### [torch.rrelu](https://pytorch.org/docs/stable/generated/torch.nn.functional.rrelu.html#torch.nn.functional.rrelu) | ||
|
|
||
| ```python | ||
| torch.rrelu(input, lower=1./8, upper=1./3, training=False) | ||
| ``` | ||
|
|
||
| ### [paddle.nn.functional.rrelu](https://www.paddlepaddle.org.cn/documentation/docs/zh/develop/api/paddle/nn/functional/rrelu_cn.html) | ||
|
|
||
| ```python | ||
| paddle.nn.functional.rrelu(x, lower=1./8, upper=1./3, training=True, name=None) | ||
RedContritio marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| ``` | ||
|
|
||
| 其中 PyTorch 和 Paddle 功能一致,仅参数名与参数默认值不一致,具体如下: | ||
|
|
||
| ### 参数映射 | ||
|
|
||
| | PyTorch | PaddlePaddle | 备注 | | ||
| | -------- | ------------ | --------------------------------------------------------------------------------------------------------------- | | ||
| | input | x | 输入的 Tensor,仅参数名不一致。 | | ||
| | lower | lower | 负值斜率的随机值范围下限。 | | ||
| | upper | upper | 负值斜率的随机值范围上限。 | | ||
| | training | training | 标记是否为训练阶段,仅参数默认值不一致。 | | ||
23 changes: 23 additions & 0 deletions
23
docs/guides/model_convert/convert_from_pytorch/api_difference/ops/torch.selu.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,23 @@ | ||
| ## [仅 paddle 参数更多]torch.selu | ||
|
|
||
| ### [torch.selu](https://pytorch.org/docs/stable/generated/torch.nn.functional.selu.html#torch.nn.functional.selu) | ||
|
|
||
| ```python | ||
| torch.selu(input) | ||
| ``` | ||
|
|
||
| ### [paddle.nn.functional.selu](https://www.paddlepaddle.org.cn/documentation/docs/zh/develop/api/paddle/nn/functional/selu_cn.html) | ||
|
|
||
| ```python | ||
| paddle.nn.functional.selu(x, scale=1.0507009873554804934193349852946, alpha=1.6732632423543772848170429916717, name=None) | ||
RedContritio marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| ``` | ||
|
|
||
| 其中 Paddle 相比 PyTorch 支持更多其他参数,具体如下: | ||
|
|
||
| ### 参数映射 | ||
|
|
||
| | PyTorch | PaddlePaddle | 备注 | | ||
| | ------- | ------------ | --------------------------------------------------------------------------------------------------------------- | | ||
| | input | x | 输入的 Tensor,仅参数名不一致。 | | ||
| | - | scale | selu 激活计算公式中的 scale 值,PyTorch 无此参数,Paddle 保持默认即可。 | | ||
| | - | alpha | selu 激活计算公式中的 alpha 值,PyTorch 无此参数,Paddle 保持默认即可。 | | ||
33 changes: 33 additions & 0 deletions
33
...onvert/convert_from_pytorch/api_difference/ops/torch.set_default_tensor_type.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,33 @@ | ||
| ## [ 参数不一致 ]torch.set_default_tensor_type | ||
|
|
||
| ### [torch.set\_default\_tensor\_type](https://pytorch.org/docs/stable/generated/torch.set_default_tensor_type.html) | ||
|
|
||
| ```python | ||
| torch.set_default_tensor_type(t) | ||
| ``` | ||
|
|
||
| ### [paddle.set\_default\_dtype](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/set_default_dtype_cn.html#set-default-dtype) | ||
|
|
||
| ```python | ||
| paddle.set_default_dtype(d) | ||
| ``` | ||
|
|
||
| 其中 PyTorch 与 Paddle 的参数类型不一致,具体如下: | ||
|
|
||
| ### 参数映射 | ||
|
|
||
| | PyTorch | PaddlePaddle | 备注 | | ||
| | ------- | ------------ | -- | | ||
| | t | d | 指定的默认张量类型,参数类型不一致。PyTorch 支持张量类型或其名称字符串(如 `torch.FloatTensor`,Paddle 支持直接指定 `dtype`(如 `paddle.float32`),需要转写。 | | ||
|
|
||
| ### 转写示例 | ||
|
|
||
| #### t 张量类型 | ||
|
|
||
| ```python | ||
| # PyTorch | ||
| torch.set_default_tensor_type(torch.FloatTensor) | ||
|
|
||
| # Paddle | ||
| paddle.set_default_dtype(paddle.float32) | ||
| ``` |
36 changes: 36 additions & 0 deletions
36
docs/guides/model_convert/convert_from_pytorch/api_difference/ops/torch.softmax.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,36 @@ | ||
| ## [ torch 参数更多 ]torch.softmax | ||
|
|
||
| ### [torch.softmax](https://pytorch.org/docs/stable/generated/torch.softmax.html) | ||
|
|
||
| ```python | ||
| torch.softmax(input, dim, *, dtype=None, out=None) | ||
| ``` | ||
|
|
||
| ### [paddle.nn.functional.softmax](https://www.paddlepaddle.org.cn/documentation/docs/zh/develop/api/paddle/nn/functional/softmax_cn.html#softmax) | ||
|
|
||
| ```python | ||
| paddle.nn.functional.softmax(x, axis=-1, dtype=None, name=None) | ||
| ``` | ||
|
|
||
| PyTorch 相比 Paddle 支持更多其他参数,具体如下: | ||
|
|
||
| ### 参数映射 | ||
|
|
||
| | PyTorch | PaddlePaddle | 备注 | | ||
| | ------- | ------------ | -- | | ||
| | input | x | 表示输入张量,仅参数名不一致。 | | ||
| | dim | axis | 表示对输入 Tensor 进行运算的轴,仅参数名不一致。 | | ||
| | dtype | dtype | 表示返回张量所需的数据类型。 | | ||
| | out | - | 表示输出的 Tensor ,Paddle 无此参数,需要转写。 | | ||
|
|
||
| ### 转写示例 | ||
|
|
||
| #### out | ||
|
|
||
| ```python | ||
| # PyTorch | ||
| torch.softmax(x, dim, out=y) | ||
|
|
||
| # Paddle | ||
| paddle.assign(paddle.nn.functional.softmax(x, dim), y) | ||
| ``` |
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.
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.norm这个API可能存在一些更深层次的 API功能不一致 的问题,下个PR改一下吧,可能不仅仅是文档,Matcher、单测 同时存在问题torch.trunc_divide还没有实现,使用组合实现:paddle.divide+paddle.trunc,torch.floor_divide直接对应paddle.floor_divide,后面确认一下