Skip to content

Commit

Permalink
Update python api and c++ op develop guide (#5189)
Browse files Browse the repository at this point in the history
* Update python api and c++ op develop guide, test=document_fix

* fix wrong links and update some topic titles

* delete images.

delete images.

* fix image links

fix image links

* fix bugs

fix bugs
  • Loading branch information
moguguo committed Aug 26, 2022
1 parent 2072c33 commit c69c327
Show file tree
Hide file tree
Showing 10 changed files with 639 additions and 539 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,8 @@ API 设计文档的目的是为了社区开发者更容易的参与开源项目
:hidden:

read_before_contributing_cn.md
api_design_guidelines_standard_cn.md
new_python_api_cn.md
new_cpp_op_cn.md
api_design_guidelines_standard_cn.md
api_docs_guidelines_cn.md
api_accpetance_criteria_cn.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# 飞桨 API 的设计和命名规范
# API 设计和命名规范

## API 设计规范

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# 飞桨 API 文档书写规范
# API 文档书写规范

1. **至关重要:** **API 文档对该 API 的描述,一定要与 API 的行为保持一致。中英文文档的内容要严格一致。**
2. **API 文档的字段:** API 名称、API 功能描述、API 参数、API 返回、API 代码示例、API 属性(class)、API 方法(methods)等。是否写 API 抛出异常的情况,不做强制要求。
Expand Down
Binary file not shown.
Binary file modified docs/dev_guides/api_contributing_guides/images/paddle_api.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
720 changes: 369 additions & 351 deletions docs/dev_guides/api_contributing_guides/new_cpp_op_cn.md

Large diffs are not rendered by default.

424 changes: 253 additions & 171 deletions docs/dev_guides/api_contributing_guides/new_python_api_cn.md

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,18 @@

飞桨框架 API 前端采用 Python 语言,以便获得更好的编程体验;后端的计算逻辑实现采用 C++ 语言,调用底层算子内核 (kernel)函数实现计算逻辑,以便获得更好的运行性能,如下图所示。

开发一个新的飞桨原生算子(Operator,OP),通常需要先开发 C++ OP,即通过 Yaml 配置定义算子描述、C++ 开发算子 kernel,再封装 Python API;如果要新增的算子可以用其他 Python API 组合得到,则可以只开发 Python API 代码。
开发一个新的飞桨原生算子通常需要先开发 C++ 算子,即通过 Yaml 配置定义算子描述、C++ 开发算子 kernel,再封装 Python API;如果要新增的算子可以用其他 Python API 组合得到,则可以只开发 Python API 代码。

- 使用 C++ 定义算子,开发门槛较高,需有一定 C++ 或 CUDA 等软件栈开发基础,但是具有性能优势;
- 使用 Python API 组合方式,只需 Python 编码,代码实现相对简单灵活,但会引入 Python 调度开销,影响性能;如果当前飞桨框架提供的基础算子 API 无法满足需求,仍然需要使用 C++ 实现算子。

<center><img src="https://github.com/PaddlePaddle/docs/blob/develop/docs/dev_guides/api_contributing_guides/images/paddle_api.png?raw=true" width="800" ></center>

## 二、飞桨 API 设计文档提交说明
## <span id="apiDesignDoc">二、飞桨 API 设计文档提交说明</span>

设计文档,通常也叫 RFC(Request for Comment)文档,可方便开发者与飞桨核心团队、其他社区开发者充分交流设计思路,以便进一步完善设计方案,并确保与飞桨设计理念一致。请参考如下步骤完成 API 设计文档的提交:

1. 阅读 [飞桨 API 设计和命名规范](api_design_guidelines_standard_cn.html),确保新增 API 符合飞桨相关规范。
1. 阅读 [API 设计和命名规范](api_design_guidelines_standard_cn.html),确保新增 API 符合飞桨相关规范。
2. 根据 [API 设计文档模版](https://github.com/PaddlePaddle/community/blob/master/rfcs/APIs/api_design_template.md),填写必要的设计内容。另外可参考 [API 设计文档样例](https://github.com/PaddlePaddle/community/blob/master/rfcs/APIs/20200301_api_design_for_quantile.md)
3. 将设计文档提交 Pull Request (PR)到 [community/rfcs/APIs/ ](https://github.com/PaddlePaddle/community/tree/master/rfcs/APIs) 目录下。
4. 等待文档接受评审和讨论,并根据各方意见修改文档。通常飞桨团队会在三个工作日内回复,如果 API 功能较复杂,还将发起评审会议,并提前在 PR 的评论区公布会议时间、会议地址、参与人、议题等内容,请及时关注 PR 中最新动态。
Expand All @@ -28,10 +28,10 @@

当 API 设计文档合入后,开发者即可进行代码开发。此过程请参考相应的开发规范,包括如下步骤:

- 如果新增 API 不需要开发新的 C++ OP,可以用其他 Python API 组合得到新的 API,请参考 [飞桨 API Python 端开发指南](new_python_api_cn.html) 章节完成,包括开发 Python 代码、单元测试代码和 API 文档等步骤。
- 如果新增 API 需要开发新的 C++ OP,请参考 [C++ 算子开发指南](new_cpp_op_cn.html) 章节完成,包括开发 OP 实现代码、封装 Python API 代码、单元测试代码和 API 文档等步骤。
- 在 paddle/phi/kernels 目录下存放了飞桨框架已经实现的不同硬件的算子内核,可供开发 C++ OP 时调用。
- 有时也需要自己开发新的算子内核(OP Kernel),这时可能需要使用硬件支持的软件栈(如 CUDA)来实现,或者使用飞桨框架提供的 Kernel Primitive API 来实现,后者具体介绍请参见 [Kernel Primitive API](../op_optimization/kernel_primitive_api/index_cn.html) 章节。
- 如果新增 API 不需要开发新的 C++ 算子,可以用其他 Python API 组合得到新的 API,请参考 [开发 API Python ](new_python_api_cn.html) 章节完成,包括开发 Python 代码、单元测试代码和 API 文档等步骤。
- 如果新增 API 需要开发新的 C++ 算子,请参考 [开发 C++ 算子](new_cpp_op_cn.html) 章节完成,包括开发算子实现代码、封装 Python API 代码、单元测试代码和 API 文档等步骤。
- 在 paddle/phi/kernels 目录下存放了飞桨框架已经实现的不同硬件的算子内核,可供开发 C++ 算子 时调用。
- 有时也需要自己开发新的算子内核,这时可能需要使用硬件支持的软件栈(如 CUDA)来实现,或者使用飞桨框架提供的 Kernel Primitive API 来实现,后者具体介绍请参见 [Kernel Primitive API](../op_optimization/kernel_primitive_api/index_cn.html) 章节。

值得注意的是,代码开发完成后,请确保通过了单元测试和 CI 测试。

Expand All @@ -42,7 +42,7 @@

请遵循如下开发规范和测试要求:

- [代码风格规范](../style_guide_and_references/style_guides_cn.html)
- [飞桨 API 设计和命名规范](api_design_guidelines_standard_cn.html)
- [飞桨 API 单元测试及验收规范](api_accpetance_criteria_cn.html)
- [Paddle CI 测试详解](../style_guide_and_references/paddle_ci_manual_cn.html)
- [代码风格规范](../git_guides/codestyle_check_guide_cn.html)
- [API 设计和命名规范](api_design_guidelines_standard_cn.html)
- [API 单元测试及验收规范](api_accpetance_criteria_cn.html)
- [Paddle CI 测试详解](../git_guides/paddle_ci_manual_cn.html)
6 changes: 3 additions & 3 deletions docs/dev_guides/code_contributing_path_cn.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

请提前阅读贡献流程、代码规范、单元测试规范等信息,以确保您提交的代码符合飞桨的相关准则,尽可能高效地合入代码。

通常你需要提前阅读本章节,以及通用的 [规范和参考信息](style_guide_and_references/index_cn.html),然后根据贡献内容阅读对应模块的指南,比如需要贡献一个新的 API,则需阅读 [新增 API 贡献指南](api_contributing_guides/api_contributing_guides_cn.html),后续飞桨也将提供其他的如功能增强、性能优化等相关贡献指南,当然也欢迎开发者贡献这些指南。
通常你需要提前阅读本章节,以及通用的 [规范和参考信息](style_guide_and_references/index_cn.html),然后根据贡献内容阅读对应模块的指南,比如需要贡献一个新的 API,则需阅读 [新增 API 开发&提交流程](api_contributing_guides/api_contributing_guides_cn.html),后续飞桨也将提供其他的如功能增强、性能优化等相关贡献指南,当然也欢迎开发者贡献这些指南。

> 说明:文档的贡献流程与代码有所不同,直接阅读 [文档贡献指南](docs_contributing_guides_cn.html) 即可。
Expand Down Expand Up @@ -75,7 +75,7 @@ Paddle 使用的 pre-commit 是 2.17.0 版本,首先安装并在本地仓库
(2)开发代码

可根据贡献内容,参考对应模块的贡献指南开发代码,如 [新增 API 贡献指南](api_contributing_guides/api_contributing_guides_cn.html),包括:
可根据贡献内容,参考对应模块的贡献指南开发代码,如 [新增 API 开发&提交流程](api_contributing_guides/api_contributing_guides_cn.html),包括:

- 功能实现代码
- 单元测试代码
Expand Down Expand Up @@ -233,7 +233,7 @@ upstream https://github.com/PaddlePaddle/Paddle.git (push)

<span id="CItest">(6)确保通过 CI 测试</span>

提交 Pull Request 后会触发 CI(Continuous Integration,持续集成)测试,并且之后每提交一次代码合入(`git push`)都会触发一次 CI 测试。CI 测试可尽可能保障代码质量,详细测试内容可参见 [Paddle CI 测试详解](style_guide_and_references/paddle_ci_manual_cn.html)
提交 Pull Request 后会触发 CI(Continuous Integration,持续集成)测试,并且之后每提交一次代码合入(`git push`)都会触发一次 CI 测试。CI 测试可尽可能保障代码质量,详细测试内容可参见 [Paddle CI 测试详解](../git_guides/paddle_ci_manual_cn.html)

提交 Pull Request 后,请关注 CI 测试进程,一般会在几个小时内完成。

Expand Down

0 comments on commit c69c327

Please sign in to comment.