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

【映射文档自动化】 添加 PyTorch 与 Paddle 映射关系主目录的自动生成 #6256

Merged
merged 41 commits into from
Nov 1, 2023

Conversation

RedContritio
Copy link
Contributor

@RedContritio RedContritio commented Oct 28, 2023

添加了映射主目录的表单自动生成脚本 apply_reference_from_api_difference.py,根据 api_difference/ 目录下的映射文档,提取其映射的元数据,更新到映射目录中。
同时,将元数据保存,得到 api_mappings.json,用于后续 PaConvert 与文档部分的对齐。

尚未添加对映射文档合法性检查的规则。

当前仍有 10 个表单项(存量)来自手动维护,由于尚无这部分映射文档,对于手动维护内容,目前进行跳过不处理。


主目录映射记法:

  1. 引用映射文档 REFERENCE-MAPPING-ITEM(<torch_api>, <mapping_document_url>)
  2. 功能缺失 NOT-IMPLEMENTED-ITEM(<torch_api>, <torch_api_url>)

功能描述:

  1. <torch_api> 支持反引号记法 (`torch.XX`)、 \_ 记法 (torch.manual\_seed)等,后续查找时会对不同记法进行统一处理,来确保匹配正确
  2. 对于 REFERENCE-MAPPING-ITEM,根据其实际对应的 api 名称,到 api_difference 目录中查找名称符合 <torch_api>.md 的映射文档,并从中提取 torch_api_url, paddle_api, paddle_api_url, 映射类型 mapping_type 这些元信息,用于映射目录生成。
  3. NOT-IMPLEMENTED-ITEM 不进行映射文档查找,直接将该项作为 “功能缺失” 类别。

生成结果(源文件)预览见

页面预览见


本 PR 中含有部分映射文档更新,单独 PR 于

@SigureMo @zhwesky2010

@paddle-bot
Copy link

paddle-bot bot commented Oct 28, 2023

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

@RedContritio RedContritio requested a review from SigureMo October 30, 2023 07:50
@@ -1,15 +1,15 @@
# PyTorch 1.13 与 Paddle 2.4 API 映射表
Copy link
Collaborator

Choose a reason for hiding this comment

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

这个改成Pytorch 2.1.0,Paddle develop 吧

Copy link
Contributor Author

Choose a reason for hiding this comment

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

已更新


## 贡献代码
本文档梳理了 PyTorch(v1.13)常用 API 与 PaddlePaddle 2.4.0 API 对应关系与差异分析。通过本文档,帮助开发者快速迁移 PyTorch 使用经验,完成模型的开发与调优。
Copy link
Collaborator

Choose a reason for hiding this comment

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

本文梳理了 Pytorch最新发行版(当前v2.1.0)API与PaddlePaddle develop版本API 对应关系与差异分析。通过本文档,帮助开发者快速迁移 PyTorch 使用经验,完成模型的开发与调优。

Copy link
Contributor Author

Choose a reason for hiding this comment

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

已更新

DOCROOT=${FLUIDDOCDIR}/docs/


APIMAPPING_ROOT=${DOCROOT}/guides/model_convert/convert_from_pytorch
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.

  1. 关于能否删除这几个变量
    这几个变量是因为其他脚本统一采用这一系列变量作为 docs 根目录来处理,考虑之后的脚本间同步问题,所以用了这几个变量
  2. 关于变量定义位置
    已经将 APIMAPPING_ROOT 移动到第三步中,其余两个变量因为可能会其他步骤用到,所以继续留在开头

Copy link
Collaborator

@zhwesky2010 zhwesky2010 left a comment

Choose a reason for hiding this comment

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

LGTM,后续注意观察效果

@zhwesky2010 zhwesky2010 merged commit 52acbcd into PaddlePaddle:develop Nov 1, 2023
@RedContritio
Copy link
Contributor Author

LGTM,后续注意观察效果

好的了解,目前仍然有两个问题:

  • 现有的文档目录仍然是 “# PyTorch 1.13 与 Paddle 2.4 API 映射表”,后续更新
  • 现有缺少 10 个目录中出现但缺失的映射文档,后续补充

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

Successfully merging this pull request may close these issues.

3 participants