Skip to content

Conversation

hd9568
Copy link
Contributor

@hd9568 hd9568 commented Sep 8, 2025

No description provided.

Copy link

paddle-bot bot commented Sep 8, 2025

感谢你贡献飞桨文档,文档预览构建中,Docs-New 跑完后即可预览,预览链接:http://preview-pr-7425.paddle-docs-preview.paddlepaddle.org.cn/documentation/docs/zh/api/index_cn.html
预览工具的更多说明,请参考:飞桨文档预览工具

1. **参数与 API 名均一致**:无需参数映射与转写示例。

2. **参数完全一致**无需转写示例
2. **参数一致但 API 名不一致**无需参数映射转写示例
Copy link
Collaborator

Choose a reason for hiding this comment

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

无需映射文档

参数映射以表格的形式呈现,表格的第 1 列是`PyTorch` 所有参数,第 2 列是`Paddle`对应参数,表格顺序按第 1 列 `PyTorch` 的参数顺序来。

1. **无参数**:无需参数映射与转写示例。
1. **参数与 API 名均一致**:无需参数映射与转写示例。
Copy link
Collaborator

Choose a reason for hiding this comment

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

无需映射文档

| 1 | 无参数 |||
| 2 | 参数完全一致 |||
| 1 | 参数与 API 名均一致 |||
| 2 | 参数一致但 API 名不一致 |||
Copy link
Collaborator

Choose a reason for hiding this comment

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

前面两种都不需要 映射文档,什么都不用写了



## 分类 1:无参数
## 分类 1:参数与 API 名均一致
Copy link
Collaborator

Choose a reason for hiding this comment

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

前面两种分类 就不需要映射文档了,在映射主页的表头说明将 torch. 改成 paddle. 就行



## 分类 2:参数完全一致
## 分类 2:参数一致但 API 名不一致
Copy link
Collaborator

Choose a reason for hiding this comment

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

这一类也不需要映射文档,模板也就不需要了。在映射主页的表头里说明就可以

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

```python
torch.Tensor.t()
Copy link
Collaborator

Choose a reason for hiding this comment

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

这个在实际代码中是这种写法,实际代码不会去写 torch.Tensor.t()

x.t()

换个 torch.matmul 来说明吧,多用几种不同的写法

## 参数一致但 API 名不一致
此类 API 功能和使用方法在 PyTorch 和 PaddlePaddle 中完全一致,但是 API 名称不同,需要用户进行 API 名称替换。

##### 转写示例
Copy link
Collaborator

Choose a reason for hiding this comment

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

示例是给几个示例代码

##### 分类依据
此类 API 功能和使用方法在 PyTorch 和 PaddlePaddle 中完全一致,只需将 ``torch.`` 替换为 ``paddle.``

##### 转写示例
Copy link
Collaborator

Choose a reason for hiding this comment

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

示例是要给几个示例代码,你看下现在的映射文档里,示例代码的写法

| 106 | [torchvision.transforms.functional.pad](https://pytorch.org/vision/main/generated/torchvision.transforms.functional.pad.html) | [paddle.vision.transforms.pad](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/vision/transforms/pad_cn.html) | - |
| 107 | [torchvision.transforms.functional.to_grayscale](https://pytorch.org/vision/main/generated/torchvision.transforms.functional.to_grayscale.html?highlight=to_grayscale#torchvision.transforms.functional.to_grayscale) | [paddle.vision.transforms.to_grayscale](https://www.paddlepaddle.org.cn/documentation/docs/zh/develop/api/paddle/vision/transforms/to_grayscale_cn.html#to-grayscale) | - |
| 108 | [torchvision.transforms.functional.vflip](https://pytorch.org/vision/main/generated/torchvision.transforms.functional.vflip.html) | [paddle.vision.transforms.vflip](https://www.paddlepaddle.org.cn/documentation/docs/zh/develop/api/paddle/vision/transforms/vflip_cn.html) | - |


## <span id="id1">torch.XX API 映射列表</span>
Copy link
Collaborator

Choose a reason for hiding this comment

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

这个要与上面的分类一致

这次一起改了吧,这个是根据api_difference来扫描生成的,所以还得改apply_reference.py。

同时上面的461+108篇映射文档,是应该要移动到deprecated里的,这个工作量比较大,这次一起做吧。整体开展。

@zhwesky2010 zhwesky2010 changed the title update category1 Update pytorch api mapping Sep 9, 2025
@zhwesky2010
Copy link
Collaborator

@hd9568 由于下面那些分类是在对应目录里扫描并自动生成的,所以这个 目录层级 与 子标题 是对应的。

目前的 子标题 由之前的 torch.nn.* torch.nn.functional.* 换成了 torch参数更多paddle参数更多 这种映射分类。所以相应的目录层级也需要修改,将同一映射分类的api_difference放到一个目录里,方便apply_reference做扫描。

可以本地写一些脚本,来做目录的自动归类。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants