diff --git a/docs/guides/model_convert/convert_from_pytorch/api_difference/ops/torch.cummin.md b/docs/guides/model_convert/convert_from_pytorch/api_difference/ops/torch.cummin.md new file mode 100644 index 00000000000..88c9538ff73 --- /dev/null +++ b/docs/guides/model_convert/convert_from_pytorch/api_difference/ops/torch.cummin.md @@ -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)) +``` diff --git a/docs/guides/model_convert/convert_from_pytorch/api_difference/ops/torch.gather.md b/docs/guides/model_convert/convert_from_pytorch/api_difference/ops/torch.gather.md index 9a2cf22a7a4..4afe82ab9d8 100644 --- a/docs/guides/model_convert/convert_from_pytorch/api_difference/ops/torch.gather.md +++ b/docs/guides/model_convert/convert_from_pytorch/api_difference/ops/torch.gather.md @@ -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) ``` diff --git a/docs/guides/model_convert/convert_from_pytorch/api_difference/ops/torch.searchsorted.md b/docs/guides/model_convert/convert_from_pytorch/api_difference/ops/torch.searchsorted.md index 6cfa06c7881..174e73ace46 100644 --- a/docs/guides/model_convert/convert_from_pytorch/api_difference/ops/torch.searchsorted.md +++ b/docs/guides/model_convert/convert_from_pytorch/api_difference/ops/torch.searchsorted.md @@ -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 支持更多其他参数,具体如下: @@ -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 无此参数,一般对网络训练结果影响不大。需要进行转写。 | +### 转写示例 #### side:指定查找对应的上边界或下边界 ```python @@ -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) +``` diff --git a/docs/guides/model_convert/convert_from_pytorch/api_difference/ops/torch.vander.md b/docs/guides/model_convert/convert_from_pytorch/api_difference/ops/torch.vander.md new file mode 100644 index 00000000000..941c4ce98ba --- /dev/null +++ b/docs/guides/model_convert/convert_from_pytorch/api_difference/ops/torch.vander.md @@ -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,则幂次从左到右增加。 | diff --git a/docs/guides/model_convert/convert_from_pytorch/pytorch_api_mapping_cn.md b/docs/guides/model_convert/convert_from_pytorch/pytorch_api_mapping_cn.md index 7edbc09e798..f970ef2a6df 100644 --- a/docs/guides/model_convert/convert_from_pytorch/pytorch_api_mapping_cn.md +++ b/docs/guides/model_convert/convert_from_pytorch/pytorch_api_mapping_cn.md @@ -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) | | 功能缺失 | ***持续更新...***