Skip to content
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.16/17/18/19 #5955

Merged
merged 9 commits into from
Jul 5, 2023
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
## [ torch 参数更多 ]torch.cummin

### [torch.cummin](https://pytorch.org/docs/stable/generated/torch.cummin.html)

```python
torch.cummin(input,
dim,
*,
out=None)
```

### [paddle.cummin](https://www.paddlepaddle.org.cn/documentation/docs/zh/develop/api/paddle/cummin_cn.html)

```python
paddle.cummin(x,
axis=None,
dtype='int64',
name=None)
```

两者功能一致,torch 参数更多,具体如下:

### 参数映射
| PyTorch | PaddlePaddle | 备注 |
| ------------- | ------------ | ------------------------------------------------------ |
| input | x | 表示输入的 Tensor,仅参数名不一致。 |
| dim | axis | 用于指定 index 获取输入的维度,仅参数名不一致。 |
| - | dtype | 指定输出索引的数据格式,PyTorch 无此参数,Paddle 保持默认即可。 |
| out | - | 表示输出的 Tensor,Paddle 无此参数,需要进行转写。 |

### 转写示例
#### out:指定输出

```python
# Pytorch 写法
torch.cummin(x,1, out=(values, indices))

# Paddle 写法
paddle.assign(paddle.cummin(x,1), (values, indices))
```
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,5 @@ torch.gather(t, dim = 1, index = torch.tensor([[0, 0], [1, 0]]), out = y)

# Paddle 写法:
t = paddle.to_tensor([[1, 2], [3, 4]])
paddle.assign(paddle.gather(t, axis = 1, indices = [[0, 0], [1, 0]]), y)
paddle.assign(paddle.take_along_axis(t, axis = 1, indices = [[0, 0], [1, 0]]), y)
```
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,24 @@
### [torch.searchsorted](https://pytorch.org/docs/1.13/generated/torch.searchsorted.html#torch-searchsorted)

```python
torch.searchsorted(sorted_sequence, values, *, out_int32=False, right=False, side='left', out=None, sorter=None)
torch.searchsorted(sorted_sequence,
values,
*,
out_int32=False,
right=False,
side='left',
out=None,
sorter=None)
```

### [paddle.searchsorted](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/searchsorted_cn.html#searchsorted)

```python
paddle.searchsorted(sorted_sequence, values, out_int32=False, right=False, name=None)
paddle.searchsorted(sorted_sequence,
values,
out_int32=False,
right=False,
name=None)
```

其中 PyTorch 相比 Paddle 支持更多其他参数,具体如下:
Expand All @@ -23,8 +34,9 @@ paddle.searchsorted(sorted_sequence, values, out_int32=False, right=False, name=
| right | right | 表示查找对应的上边界或下边界。 |
| side | - | 表示查找对应的上边界或下边界,Paddle 无此参数,需要进行转写。 |
| out | - | 表示输出的 Tensor,Paddle 无此参数,需要进行转写。 |
| sorter | - | 表示 sorted_sequence 元素无序时对应的升序索引,Paddle 无此参数,一般对网络训练结果影响不大,可直接删除。 |
| sorter | - | 表示 sorted_sequence 元素无序时对应的升序索引,Paddle 无此参数,一般对网络训练结果影响不大。 |
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

有转写方式的话:加一个 需要转写

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

好的,已修改。


### 转写示例
#### side:指定查找对应的上边界或下边界

```python
Expand All @@ -44,3 +56,13 @@ torch.searchsorted(x,y, out=output)
# Paddle 写法
paddle.assign(paddle.searchsorted(x,y), output)
```

#### sorter: 提供 sorted_sequence 为无序 Tensor 时,相对应的升序索引

```python
# Pytorch 写法
torch.searchsorted(x,y, sorter=sorter)

# Paddle 写法
paddle.searchsorted(x.take_along_axis(axis = -1, indices = sorter), y)
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
## [ 仅参数名不一致 ]torch.vander

### [torch.vander](https://pytorch.org/docs/stable/generated/torch.vander.html?highlight=vander#torch.vander)

```python
torch.vander(x,
N,
increasing)
```

### [paddle.vander](https://www.paddlepaddle.org.cn/documentation/docs/zh/develop/api/paddle/vander_cn.html#vander)

```python
paddle.vander(x,
n,
increasing)
```

两者功能一致,仅参数名不一致,具体如下:

### 参数映射
| PyTorch | PaddlePaddle | 备注 |
| ------------- | ------------ | ------------------------------------------------------ |
| x | x | 表示输入的 Tensor。 |
| N | n | 用于指定输出的列数, 仅参数名大小写的区别。 |
| increasing | increasing | 指定输出列的幂次顺序。如果为 True,则幂次从左到右增加。 |
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,7 @@
| 252 | [torch.frexp](https://pytorch.org/docs/1.13/generated/torch.frexp.html?highlight=frexp#torch.frexp) | [paddle.frexp](暂无对应文档) | 功能一致, torch 参数更多 , [差异对比](/~https://github.com/PaddlePaddle/docs/tree/develop/docs/guides/model_convert/convert_from_pytorch/api_difference/ops/torch.frexp.md) |
| 253 | [torch.nanmean](https://pytorch.org/docs/1.13/generated/torch.nanmean.html?highlight=nanmean#torch.nanmean) | [paddle.nanmean](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/nanmean_cn.html) | 功能一致, torch 参数更多 , [差异对比](/~https://github.com/PaddlePaddle/docs/tree/develop/docs/guides/model_convert/convert_from_pytorch/api_difference/ops/torch.nanmean.md) |
| 254 | [torch.take_along_dim](https://pytorch.org/docs/1.13/generated/torch.take_along_dim.html?highlight=torch+take_along_dim#torch.take_along_dim) | [paddle.take_along_axis](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/take_along_axis_cn.html) | 功能一致, torch 参数更多 , [差异对比](/~https://github.com/PaddlePaddle/docs/tree/develop/docs/guides/model_convert/convert_from_pytorch/api_difference/ops/torch.take_along_dim.md) |
| 254 | [torch.geqrf](https://pytorch.org/docs/stable/generated/torch.geqrf.html?highlight=geqrf#torch.geqrf) | | 功能缺失 |

***持续更新...***

Expand Down