-
Notifications
You must be signed in to change notification settings - Fork 833
映射文档 No.48 #5840
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
映射文档 No.48 #5840
Changes from 6 commits
Commits
Show all changes
9 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
33 changes: 33 additions & 0 deletions
33
...uides/model_convert/convert_from_pytorch/api_difference/linalg/torch.inverse.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 参数更多 ]torch.inverse | ||
|
||
### [torch.inverse](https://pytorch.org/docs/1.13/generated/torch.inverse.html?highlight=inverse#torch.inverse) | ||
|
||
```python | ||
torch.inverse(input, *, out=None) | ||
``` | ||
|
||
### [paddle.linalg.inv](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/linalg/inv_cn.html) | ||
|
||
```python | ||
paddle.linalg.inv(x, name=None) | ||
``` | ||
|
||
其中 Pytorch 相比 Paddle 支持更多其他参数,具体如下: | ||
|
||
### 参数映射 | ||
| PyTorch | PaddlePaddle | 备注 | | ||
| ------------- | ------------ | ------------------------------------------------------ | | ||
| <font color='red'> input </font> | <font color='red'> x </font> | 输入的 Tensor ,仅参数名不同。 | | ||
| <font color='red'> out </font> | - | 表示输出的 Tensor,PaddlePaddle 无此参数,需要进行转写。 | | ||
|
||
|
||
### 转写示例 | ||
|
||
#### out:指定输出 | ||
```python | ||
# Pytorch 写法 | ||
torch.inverse(torch.tensor([[2., 0.], [0., 2.]]), out=y) | ||
|
||
# Paddle 写法 | ||
paddle.assign(paddle.inverse(paddle.to_tensor([[2., 0], [0, 2.]])), y) | ||
``` |
30 changes: 30 additions & 0 deletions
30
..._convert/convert_from_pytorch/api_difference/linalg/torch.linalg.matrix_rank.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,30 @@ | ||
## [torch 参数更多 ]torch.linalg.matrix_rank | ||
### [torch.linalg.matrix_rank](https://pytorch.org/docs/1.13/generated/torch.linalg.matrix_rank.html?highlight=matrix_rank#torch.linalg.matrix_rank) | ||
```python | ||
torch.linalg.matrix_rank(A, tol=None, hermitian=False, *, out=None) | ||
``` | ||
|
||
### [paddle.linalg.matrix_rank](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/linalg/matrix_rank_cn.html) | ||
```python | ||
paddle.linalg.matrix_rank(x, tol=None, hermitian=False, name=None) | ||
``` | ||
|
||
其中 Pytorch 相比 Paddle 支持更多其他参数,具体如下: | ||
### 参数映射 | ||
| PyTorch | PaddlePaddle | 备注 | | ||
| ------------- | ------------ | ------------------------------------------------------ | | ||
| A | x | 输入的 Tensor ,仅参数名不同。 | | ||
| tol | tol | 输入的 Tensor 或者 float,参数完全一致。 | | ||
| hermitian | hermitian | 输入的 bool ,参数完全一致。 | | ||
| out | - | 表示输出的 Tensor,PaddlePaddle 无此参数,需要进行转写。 | | ||
|
||
|
||
### 转写示例 | ||
#### out:指定输出 | ||
```python | ||
# Pytorch 写法 | ||
torch.linalg.matrix_rank(torch.ones(3, 4, 5, 5), tol=0.01, hermitian=True, out=y) | ||
|
||
# Paddle 写法 | ||
paddle.assign(paddle.linalg.matrix_rank(paddle.ones(shape=[3, 4, 5, 5]), tol=0.01, hermitian=True), y) | ||
``` |
34 changes: 34 additions & 0 deletions
34
docs/guides/model_convert/convert_from_pytorch/api_difference/linalg/torch.lu.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,34 @@ | ||
## [torch 参数更多 ]torch.lu | ||
|
||
### [torch.lu](https://pytorch.org/docs/1.13/generated/torch.lu.html?highlight=lu#torch.lu) | ||
|
||
```python | ||
torch.lu(A, pivots=True, get_infos=False, *, out) | ||
``` | ||
|
||
### [paddle.linalg.lu](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/linalg/lu_cn.html) | ||
|
||
```python | ||
paddle.linalg.lu(x, pivot=True, get_infos=False, name=None) | ||
``` | ||
|
||
其中 Pytorch 相比 Paddle 支持更多其他参数,具体如下: | ||
|
||
### 参数映射 | ||
| PyTorch | PaddlePaddle | 备注 | | ||
| ------------- | ------------ | ------------------------------------------------------ | | ||
| <font color='red'> A </font> | <font color='red'> x </font> | 输入的 Tensor ,仅参数名不同。 | | ||
| <font color='red'> pivots </font> | <font color='red'> pivot </font> | 输入的 bool ,参数完全一致。 | | ||
| <font color='red'> get_infos </font> | <font color='red'> get_infos </font> | 输入的 bool ,参数完全一致。 | | ||
| <font color='red'> out </font> | - | 表示输出的 Tensor,PaddlePaddle 无此参数,需要进行转写。 | | ||
|
||
### 转写示例 | ||
|
||
#### out:指定输出 | ||
```python | ||
# Pytorch 写法 | ||
torch.lu(torch.tensor([[1.0, 2.0], [3.0, 4.0], [5.0, 6.0]]), get_infos=True, out=(A_LU, pivots, info)) | ||
|
||
# Paddle 写法 | ||
lu, p, info = paddle.linalg.lu(paddle.to_tensor([[1.0, 2.0], [3.0, 4.0], [5.0, 6.0]]), get_infos=True) | ||
``` |
34 changes: 34 additions & 0 deletions
34
...des/model_convert/convert_from_pytorch/api_difference/linalg/torch.lu_unpack.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,34 @@ | ||
## [torch 参数更多 ]torch.lu_unpack | ||
### [torch.lu_unpack](https://pytorch.org/docs/1.13/generated/torch.lu_unpack.html?highlight=lu_unpack#torch.lu_unpack) | ||
|
||
```python | ||
torch.lu_unpack(LU_data, LU_pivots, unpack_data=True, unpack_pivots=True, *, out=None) | ||
``` | ||
|
||
### [paddle.linalg.lu_unpack](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/linalg/lu_unpack_cn.html) | ||
|
||
```python | ||
paddle.linalg.lu_unpack(x, y, unpack_ludata=True, unpack_pivots=True, name=None) | ||
``` | ||
|
||
其中 Pytorch 相比 Paddle 支持更多其他参数,具体如下: | ||
|
||
### 参数映射 | ||
| PyTorch | PaddlePaddle | 备注 | | ||
| ------------- | ------------ | ------------------------------------------------------ | | ||
| <font color='red'> LU_data </font> | <font color='red'> x </font> | 输入的 Tensor ,仅参数名不同。 | | ||
| <font color='red'> LU_pivots </font> | <font color='red'> y </font> | 输入的 Tensor ,仅参数名不同。 | | ||
| <font color='red'> unpack_data </font> | <font color='red'> unpack_ludata </font> | 输入的 bool ,仅参数名不同。 | | ||
| <font color='red'> unpack_pivots </font> | <font color='red'> unpack_pivots </font> | 输入的 bool ,参数完全一致。 | | ||
| <font color='red'> out </font> | - | 表示输出的 Tensor,PaddlePaddle 无此参数,需要进行转写。 | | ||
|
||
### 转写示例 | ||
|
||
#### out:指定输出 | ||
```python | ||
# Pytorch 写法 | ||
torch.lu_unpack(*torch.lu(torch.tensor([[1.0, 2.0], [3.0, 4.0], [5.0, 6.0]])), out=(P, L, U)) | ||
|
||
# Paddle 写法 | ||
P,L,U = paddle.linalg.lu_unpack(*paddle.linalg.lu(paddle.to_tensor([[1.0, 2.0], [3.0, 4.0], [5.0, 6.0]]))) | ||
``` |
29 changes: 29 additions & 0 deletions
29
.../model_convert/convert_from_pytorch/api_difference/linalg/torch.matrix_power.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,29 @@ | ||
## [torch 参数更多 ]torch.matrix_power | ||
### [torch.matrix_power](https://pytorch.org/docs/1.13/generated/torch.matrix_power.html?highlight=matrix_power) | ||
```python | ||
torch.matrix_power(input, n, *, out=None) | ||
``` | ||
|
||
### [paddle.linalg.matrix_power](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/linalg/matrix_power_cn.html) | ||
```python | ||
paddle.linalg.matrix_power(x, n, name=None) | ||
``` | ||
|
||
其中 Pytorch 相比 Paddle 支持更多其他参数,具体如下: | ||
### 参数映射 | ||
| PyTorch | PaddlePaddle | 备注 | | ||
| ------------- | ------------ | ------------------------------------------------------ | | ||
| input | x | 输入的 Tensor ,仅参数名不同。 | | ||
| n | n | 输入的 int ,参数完全一致。 | | ||
| out | - | 表示输出的 Tensor,PaddlePaddle 无此参数,需要进行转写。 | | ||
|
||
|
||
### 转写示例 | ||
#### out:指定输出 | ||
```python | ||
# Pytorch 写法 | ||
torch.matrix_power(torch.tensor([[1., 2., 3.],[1., 4., 9.],[1., 8., 27.]]), 2, out=y) | ||
|
||
# Paddle 写法 | ||
paddle.assign(paddle.linalg.matrix_power(paddle.to_tensor([[1., 2., 3.],[1., 4., 9.],[1., 8., 27.]]), 2), y) | ||
``` |
34 changes: 34 additions & 0 deletions
34
docs/guides/model_convert/convert_from_pytorch/api_difference/ops/torch.dot.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,34 @@ | ||
## [torch 参数更多 ]torch.dot | ||
|
||
### [torch.dot](https://pytorch.org/docs/1.13/generated/torch.dot.html?highlight=dot#torch.dot) | ||
|
||
```python | ||
torch.dot(input, other, *, out=None) | ||
``` | ||
|
||
### [paddle.dot](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/dot_cn.html#dot) | ||
|
||
```python | ||
paddle.dot(x, y, name=None) | ||
``` | ||
|
||
其中 Pytorch 相比 Paddle 支持更多其他参数,具体如下: | ||
|
||
### 参数映射 | ||
| PyTorch | PaddlePaddle | 备注 | | ||
| ------------- | ------------ | ------------------------------------------------------ | | ||
| <font color='red'> input </font> | <font color='red'> x </font> | 输入的 Tensor ,仅参数名不同。 | | ||
| <font color='red'> other </font> | <font color='red'> y </font> | 输入的 Tensor ,仅参数名不同。 | | ||
| <font color='red'> out </font> | - | 表示输出的 Tensor,PaddlePaddle 无此参数,需要进行转写。 | | ||
|
||
|
||
### 转写示例 | ||
|
||
#### out:指定输出 | ||
```python | ||
# Pytorch 写法 | ||
torch.dot(torch.tensor([2, 3]), torch.tensor([2, 1]), out=y) | ||
|
||
# Paddle 写法 | ||
paddle.assign(paddle.dot(paddle.to_tensor([2, 3]), paddle.to_tensor([2, 1])), y) | ||
``` |
34 changes: 34 additions & 0 deletions
34
docs/guides/model_convert/convert_from_pytorch/api_difference/ops/torch.ger.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,34 @@ | ||
## [torch 参数更多 ]torch.ger | ||
|
||
### [torch.ger](https://pytorch.org/docs/1.13/generated/torch.ger.html?highlight=ger#torch.ger) | ||
|
||
```python | ||
torch.ger(input, vec2, *, out=None) | ||
``` | ||
|
||
### [paddle.outer](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/outer_cn.html) | ||
|
||
```python | ||
paddle.outer(x, y, name=None) | ||
``` | ||
|
||
其中 Pytorch 相比 Paddle 支持更多其他参数,具体如下: | ||
|
||
### 参数映射 | ||
| PyTorch | PaddlePaddle | 备注 | | ||
| ------------- | ------------ | ------------------------------------------------------ | | ||
| <font color='red'> input </font> | <font color='red'> x </font> | 输入的 Tensor ,仅参数名不同。 | | ||
| <font color='red'> vec2 </font> | <font color='red'> y </font> | 输入的 Tensor ,仅参数名不同。 | | ||
| <font color='red'> out </font> | - | 表示输出的 Tensor,PaddlePaddle 无此参数,需要进行转写。 | | ||
|
||
|
||
### 转写示例 | ||
|
||
#### out:指定输出 | ||
```python | ||
# Pytorch 写法 | ||
torch.ger(torch.arange(1., 5.), torch.arange(1., 4.), out=y) | ||
|
||
# Paddle 写法 | ||
paddle.assign(paddle.outer(paddle.arange(1, 5).astype('float32'), paddle.arange(1, 4).astype('float32')), y) | ||
``` |
34 changes: 34 additions & 0 deletions
34
docs/guides/model_convert/convert_from_pytorch/api_difference/ops/torch.inner.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,34 @@ | ||
## [torch 参数更多 ]torch.inner | ||
|
||
### [torch.inner](https://pytorch.org/docs/1.13/generated/torch.inner.html?highlight=inner#torch.inner) | ||
|
||
```python | ||
torch.inner(input, other, *, out=None) | ||
``` | ||
|
||
### [paddle.inner](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/inner_cn.html) | ||
|
||
```python | ||
paddle.inner(x, y, name=None) | ||
``` | ||
|
||
其中 Pytorch 相比 Paddle 支持更多其他参数,具体如下: | ||
|
||
### 参数映射 | ||
| PyTorch | PaddlePaddle | 备注 | | ||
| ------------- | ------------ | ------------------------------------------------------ | | ||
| <font color='red'> input </font> | <font color='red'> x </font> | 输入的 Tensor ,仅参数名不同。 | | ||
| <font color='red'> other </font> | <font color='red'> y </font> | 输入的 Tensor ,仅参数名不同。 | | ||
| <font color='red'> out </font> | - | 表示输出的 Tensor,PaddlePaddle 无此参数,需要进行转写。 | | ||
|
||
|
||
### 转写示例 | ||
|
||
#### out:指定输出 | ||
```python | ||
# Pytorch 写法 | ||
torch.inner(torch.arange(1., 7.).reshape((2, 3)), torch.arange(1., 10.).reshape((3, 3)), out=y) | ||
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. 后面可以尽量把示例写的简单些,直接写list表示Tensor也行,这个本质是伪代码的形式让用户一眼看了就懂转换思路的。写出核心转换思路就可以,辅助运行的代码应省尽省。 |
||
|
||
# Paddle 写法 | ||
paddle.assign(paddle.inner(paddle.arange(1, 7).reshape((2, 3)).astype('float32'), paddle.arange(1, 10).reshape((3, 3)).astype('float32')), y) | ||
``` |
34 changes: 34 additions & 0 deletions
34
docs/guides/model_convert/convert_from_pytorch/api_difference/ops/torch.outer.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,34 @@ | ||
## [torch 参数更多 ]torch.outer | ||
|
||
### [torch.outer](https://pytorch.org/docs/1.13/generated/torch.outer.html#torch.outer) | ||
|
||
```python | ||
torch.outer(input, vec2, *, out=None) | ||
``` | ||
|
||
### [paddle.outer](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/outer_cn.html) | ||
|
||
```python | ||
paddle.outer(x, y, name=None) | ||
``` | ||
|
||
其中 Pytorch 相比 Paddle 支持更多其他参数,具体如下: | ||
|
||
### 参数映射 | ||
| PyTorch | PaddlePaddle | 备注 | | ||
| ------------- | ------------ | ------------------------------------------------------ | | ||
| <font color='red'> input </font> | <font color='red'> x </font> | 输入的 Tensor ,仅参数名不同。 | | ||
| <font color='red'> vec2 </font> | <font color='red'> y </font> | 输入的 Tensor ,仅参数名不同。 | | ||
| <font color='red'> out </font> | - | 表示输出的 Tensor,PaddlePaddle 无此参数,需要进行转写。 | | ||
|
||
|
||
### 转写示例 | ||
|
||
#### out:指定输出 | ||
```python | ||
# Pytorch 写法 | ||
torch.outer(torch.arange(1., 5.), torch.arange(1., 4.), out=y) | ||
|
||
# Paddle 写法 | ||
paddle.assign(paddle.outer(paddle.arange(1, 5).astype('float32'), paddle.arange(1, 4).astype('float32')), y) | ||
``` |
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.
写的比较复杂,建议写简略一些