-
Notifications
You must be signed in to change notification settings - Fork 777
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
【Hackathon 5th No.47】API转换 103-124 -part (#6380)
- Loading branch information
Showing
17 changed files
with
396 additions
and
39 deletions.
There are no files selected for viewing
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
20 changes: 11 additions & 9 deletions
20
.../model_convert/convert_from_pytorch/api_difference/Tensor/torch.Tensor.hypot.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,19 +1,21 @@ | ||
## [ 组合替代实现 ]torch.Tensor.hypot | ||
## [ 仅参数名不一致 ]torch.Tensor.hypot | ||
|
||
### [torch.Tensor.hypot](https://pytorch.org/docs/stable/generated/torch.Tensor.hypot.html#torch.Tensor.hypot) | ||
|
||
```python | ||
torch.Tensor.hypot(other) | ||
``` | ||
|
||
给定直角三角形的直角边,求斜边; Paddle 无此 API,需要组合实现。 | ||
|
||
### 转写示例 | ||
### [paddle.Tensor.hypot](https://www.paddlepaddle.org.cn/documentation/docs/zh/develop/api/paddle/hypot_cn.html) | ||
|
||
```python | ||
# Pytorch 写法 | ||
y = a.hypot(b) | ||
|
||
# Paddle 写法 | ||
y = (a**2 + b**2) ** (1/2) | ||
paddle.Tensor.hypot(y) | ||
``` | ||
|
||
两者功能一致且参数用法一致,仅参数名不一致,具体如下: | ||
|
||
### 参数映射 | ||
|
||
| PyTorch | PaddlePaddle | 备注 | | ||
| ------- | ------------ | ----------------------------- | | ||
| other | y | 输入 Tensor,仅参数名不一致。 | |
21 changes: 21 additions & 0 deletions
21
...model_convert/convert_from_pytorch/api_difference/Tensor/torch.Tensor.hypot_.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,21 @@ | ||
## [ 仅参数名不一致 ]torch.Tensor.hypot_ | ||
|
||
### [torch.Tensor.hypot_](https://pytorch.org/docs/stable/generated/torch.Tensor.hypot_.html#torch.Tensor.hypot_) | ||
|
||
```python | ||
torch.Tensor.hypot_(other) | ||
``` | ||
|
||
### [paddle.Tensor.hypot_](https://www.paddlepaddle.org.cn/documentation/docs/zh/develop/api/paddle/hypot__cn.html) | ||
|
||
```python | ||
paddle.Tensor.hypot_(y) | ||
``` | ||
|
||
两者功能一致且参数用法一致,仅参数名不一致,具体如下: | ||
|
||
### 参数映射 | ||
|
||
| PyTorch | PaddlePaddle | 备注 | | ||
| ------- | ------------ | ----------------------------- | | ||
| other | y | 输入 Tensor,仅参数名不一致。 | |
21 changes: 21 additions & 0 deletions
21
...onvert/convert_from_pytorch/api_difference/Tensor/torch.Tensor.masked_select.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,21 @@ | ||
## [参数完全一致 ]torch.Tensor.masked_select | ||
|
||
### [torch.Tensor.masked_select](https://pytorch.org/docs/stable/generated/torch.Tensor.masked_select.html?highlight=masked_select#torch.Tensor.masked_select) | ||
|
||
```python | ||
torch.Tensor.masked_select(mask) | ||
``` | ||
|
||
### [paddle.Tensor.masked_select](https://www.paddlepaddle.org.cn/documentation/docs/zh/develop/api/paddle/Tensor_cn.html#masked-select-mask-name-none) | ||
|
||
```python | ||
paddle.Tensor.masked_select(mask, name=None) | ||
``` | ||
|
||
两者功能一致,参数完全一致,具体如下: | ||
|
||
### 参数映射 | ||
|
||
| PyTorch | PaddlePaddle | 备注 | | ||
| ------- | ------------ | ------------------------------------ | | ||
| mask | mask | 表示用于索引的二进制掩码的 Tensor 。 | |
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
35 changes: 35 additions & 0 deletions
35
.../convert_from_pytorch/api_difference/linalg/torch.linalg.householder_product.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,35 @@ | ||
## [ torch 参数更多 ]torch.linalg.householder_product | ||
|
||
### [torch.linalg.householder_product](https://pytorch.org/docs/stable/generated/torch.linalg.householder_product.html#torch.linalg.householder_product) | ||
|
||
```python | ||
torch.linalg.householder_product(A, tau, *, out=None) | ||
``` | ||
|
||
### [paddle.linalg.householder_product](https://github.com/PaddlePaddle/Paddle/blob/d6ea911bd1bfda5604807eeb18318e71b395ac58/python/paddle/tensor/linalg.py#L3744) | ||
|
||
```python | ||
paddle.linalg.householder_product(x, tau, name=None) | ||
``` | ||
|
||
Pytorch 相比 Paddle 支持更多其他参数,具体如下: | ||
|
||
### 参数映射 | ||
|
||
| PyTorch | PaddlePaddle | 备注 | | ||
| ------- | ------------ | ---------------------------------------------- | | ||
| A | x | 表示输入的 Tensor,仅参数名不一致。 | | ||
| tau | tau | 表示输入的 Tensor。 | | ||
| out | - | 表示输出的 Tensor,Paddle 无此参数,需要转写。 | | ||
|
||
### 转写示例 | ||
|
||
#### out 参数:输出的 Tensor | ||
|
||
```python | ||
# PyTorch 写法: | ||
torch.linalg.householder_product(x, tau, out=y) | ||
|
||
# Paddle 写法: | ||
paddle.assign(paddle.linalg.householder_product(x, tau), 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
23 changes: 23 additions & 0 deletions
23
...des/model_convert/convert_from_pytorch/api_difference/ops/torch.combinations.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,23 @@ | ||
## [ 仅参数名不一致 ]torch.combinations | ||
|
||
### [torch.combinations](https://pytorch.org/docs/stable/generated/torch.combinations.html#torch.combinations) | ||
|
||
```python | ||
torch.combinations(input, r=2, with_replacement=False) | ||
``` | ||
|
||
### [paddle.combinations](https://github.com/PaddlePaddle/Paddle/blob/8932f1c5e26788ab1eed226e70fafb1ea67ce737/python/paddle/tensor/math.py#L7099) | ||
|
||
```python | ||
paddle.combinations(x, r=2, with_replacement=False, name=None) | ||
``` | ||
|
||
两者功能一致,仅参数名不一致,具体如下: | ||
|
||
### 参数映射 | ||
|
||
| PyTorch | PaddlePaddle | 备注 | | ||
| ---------------- | ---------------- | ----------------------------- | | ||
| input | x | 输入 Tensor,仅参数名不一致。 | | ||
| r | r | 需要合并元素数量。 | | ||
| with_replacement | with_replacement | 是否允许合并中替换。 | |
24 changes: 20 additions & 4 deletions
24
docs/guides/model_convert/convert_from_pytorch/api_difference/ops/torch.hypot.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,19 +1,35 @@ | ||
## [ 组合替代实现 ]torch.hypot | ||
## [ torch 参数更多 ]torch.hypot | ||
|
||
### [torch.hypot](https://pytorch.org/docs/stable/generated/torch.hypot.html#torch.hypot) | ||
|
||
```python | ||
torch.hypot(input, other, *, out=None) | ||
``` | ||
|
||
给定直角三角形的直角边,求斜边; Paddle 无此 API,需要组合实现。 | ||
### [paddle.hypot](https://www.paddlepaddle.org.cn/documentation/docs/zh/develop/api/paddle/hypot_cn.html) | ||
|
||
```python | ||
paddle.hypot(x, y, name=None) | ||
``` | ||
|
||
Pytorch 相比 Paddle 支持更多其他参数,具体如下: | ||
|
||
### 参数映射 | ||
|
||
| PyTorch | PaddlePaddle | 备注 | | ||
| ------- | ------------ | ---------------------------------------------- | | ||
| input | x | 输入 Tensor,仅参数名不一致。 | | ||
| other | y | 输入 Tensor,仅参数名不一致。 | | ||
| out | - | 表示输出的 Tensor,Paddle 无此参数,需要转写。 | | ||
|
||
### 转写示例 | ||
|
||
#### out:指定输出 | ||
|
||
```python | ||
# Pytorch 写法 | ||
y = torch.hypot(a, b) | ||
torch.hypot(x, y, out=out) | ||
|
||
# Paddle 写法 | ||
y = (a**2 + b**2) ** (1/2) | ||
paddle.assign(paddle.hypot(x, y), out) | ||
``` |
24 changes: 24 additions & 0 deletions
24
...uides/model_convert/convert_from_pytorch/api_difference/ops/torch.index_fill.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,24 @@ | ||
## [ 仅参数名不一致 ]torch.index_fill | ||
|
||
### [torch.index_fill](https://pytorch.org/docs/stable/generated/torch.Tensor.index_fill.html#torch.Tensor.index_fill) | ||
|
||
```python | ||
torch.index_fill(input, dim, index, value) | ||
``` | ||
|
||
### [paddle.index_fill](https://github.com/PaddlePaddle/Paddle/blob/1e3761d119643af19cb6f8a031a77f315d782409/python/paddle/tensor/manipulation.py#L5900) | ||
|
||
```python | ||
paddle.index_fill(x, index, axis, value, name=None) | ||
``` | ||
|
||
两者功能一致且参数用法一致,仅参数名不一致,具体如下: | ||
|
||
### 参数映射 | ||
|
||
| PyTorch | PaddlePaddle | 备注 | | ||
| ------- | ------------ | ---------------------------------- | | ||
| input | x | 输入的 Tensor,仅参数名不一致。 | | ||
| dim | axis | 表示进行运算的轴,仅参数名不一致。 | | ||
| index | index | 包含索引下标的 1-D Tensor。 | | ||
| value | value | 填充的值。 | |
23 changes: 23 additions & 0 deletions
23
...ides/model_convert/convert_from_pytorch/api_difference/ops/torch.masked_fill.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,23 @@ | ||
## [ 仅参数名不一致 ] torch.masked_fill | ||
|
||
### [torch.masked_fill](https://pytorch.org/docs/stable/generated/torch.Tensor.masked_fill.html#torch.Tensor.masked_fill) | ||
|
||
```python | ||
torch.masked_fill(input, mask, value) | ||
``` | ||
|
||
### [paddle.masked_fill](https://github.com/PaddlePaddle/Paddle/blob/1e3761d119643af19cb6f8a031a77f315d782409/python/paddle/tensor/manipulation.py#L5111) | ||
|
||
```python | ||
paddle.masked_fill(x, mask, value, name=None) | ||
``` | ||
|
||
两者功能一致,参数完全一致,具体如下: | ||
|
||
### 参数映射 | ||
|
||
| PyTorch | PaddlePaddle | 备注 | | ||
| ------- | ------------ | ------------------------------- | | ||
| input | x | 输入的 Tensor,仅参数名不一致。 | | ||
| mask | mask | 布尔张量,表示要填充的位置 | | ||
| value | value | 用于填充目标张量的值 | |
Oops, something went wrong.