Skip to content

Commit 2b0156a

Browse files
committed
Move op note into dev_guides (#4738)
* move op note into dev_guides * change doc title * change title and add tree
1 parent ac05a55 commit 2b0156a

File tree

9 files changed

+30
-29
lines changed

9 files changed

+30
-29
lines changed

docs/dev_guides/api_contributing_guides/api_contributing_guides_cn.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,5 +107,6 @@ API设计文档的目的是为了社区开发者更容易的参与开源项目
107107
api_design_guidelines_standard_cn.md
108108
new_python_api_cn.md
109109
new_cpp_op_cn.md
110+
new_cpp_op_notes_cn.md
110111
api_docs_guidelines_cn.md
111112
api_accpetance_criteria_cn.md

docs/dev_guides/api_contributing_guides/new_cpp_op_cn.md

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# C++ OP 开发(新增原生算子)
1+
# C++ OP 开发
22

33
> 注:飞桨原生算子的开发范式正在进行重构与升级,升级后算子开发方式会大幅简化,我们会及时更新本文档内容,升级后的算子开发范式预计会在2.3版本正式上线。
44
@@ -590,28 +590,28 @@ void TraceKernel(const Context& dev_ctx,
590590
仍然以trace op为例,首先在`paddle/phi/ops/compat`目录下新建`trace_sig.cc`文件,用于放置这里的映射函数。
591591
592592
- 由于函数式kernel的一个最重要的特别就是参数顺序和类型(顺序和类型是关键,变量名称不影响),我们需要定义一个函数来做一个从OpMaker中如何获取信息,并且按照顺序传递给新的kernel函数; 这个模块就是OpArgumentMapping, trace反向op的OpArgumentMapping定义如下, KernelSignature共包含4个内容
593-
1. kernel名称,这个是我们给kernel注册的时候的名称
594-
2. input list: 这个要和OpMaker(或者GradOpMaker)中定义的Key要完全一致
595-
3. attribute list: 这个要和OpMaker(或者GradOpMaker)中定义的Key要完全一致
596-
4. output list: 这个要和OpMaker(或者GradOpMaker)中定义的Key要完全一致
593+
1. kernel名称,这个是我们给kernel注册的时候的名称
594+
2. input list: 这个要和OpMaker(或者GradOpMaker)中定义的Key要完全一致
595+
3. attribute list: 这个要和OpMaker(或者GradOpMaker)中定义的Key要完全一致
596+
4. output list: 这个要和OpMaker(或者GradOpMaker)中定义的Key要完全一致
597597
598598
599-
```cpp
600-
#include "paddle/phi/core/compat/op_utils.h"
599+
```cpp
600+
#include "paddle/phi/core/compat/op_utils.h"
601601
602-
namespace phi {
602+
namespace phi {
603603
604-
KernelSignature TraceGradOpArgumentMapping(const ArgumentMappingContext& ctx) {
605-
return KernelSignature("trace_grad",
606-
{GradVarName("Out"), "Input"},
607-
{"offset", "axis1", "axis2"},
608-
{GradVarName("Input")});
609-
}
604+
KernelSignature TraceGradOpArgumentMapping(const ArgumentMappingContext& ctx) {
605+
return KernelSignature("trace_grad",
606+
{GradVarName("Out"), "Input"},
607+
{"offset", "axis1", "axis2"},
608+
{GradVarName("Input")});
609+
}
610610
611-
} // namespace phi
611+
} // namespace phi
612612
613-
PD_REGISTER_ARG_MAPPING_FN(trace_grad, phi::TraceGradOpArgumentMapping);
614-
```
613+
PD_REGISTER_ARG_MAPPING_FN(trace_grad, phi::TraceGradOpArgumentMapping);
614+
```
615615
616616
>注:没有input list或attribute list的,相应花括号内留空,不能省略花括号
617617

docs/guides/07_new_op/op_notes_cn.md renamed to docs/dev_guides/api_contributing_guides/new_cpp_op_notes_cn.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# 原生算子开发注意事项
1+
# C++ OP 开发注意事项
22

33
## Paddle中Op的构建逻辑
44
### 1.Paddle中Op的构建逻辑

docs/guides/07_new_op/index_cn.rst

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,12 @@
22
自定义算子
33
#############
44

5-
本部分将指导您如何在飞桨中新增算子(Operator,简称Op),也包括一些必要的注意事项。此处的算子是一个广义的概念,包括以下几类
5+
本部分将指导您如何使用飞桨的自定义算子(Operator,简称Op)机制,包括以下两类
66

7-
1. 原生算子:遵循飞桨框架内部算子开发规范,源码合入到飞桨框架中,与框架一起编译后使用的算子
8-
2. 外部算子:编写方法较为简洁,不涉及框架内部概念,无需重新编译飞桨框架,以外接模块的方式使用的算子
9-
3. Python算子:使用Python编写实现前向(forward)和反向(backward)方法,在模型组网中使用的自定义API
7+
1. C++算子:编写方法较为简洁,不涉及框架内部概念,无需重新编译飞桨框架,以外接模块的方式使用的算子
8+
2. Python算子:使用Python编写实现前向(forward)和反向(backward)方法,在模型组网中使用的自定义API
109

11-
- `原生算子开发注意事项 <./op_notes_cn.html>`_
12-
13-
- `自定义外部算子 <./new_custom_op_cn.html>`_
10+
- `自定义C++算子 <./new_custom_op_cn.html>`_
1411

1512
- `自定义Python算子 <./new_python_op_cn.html>`_
1613

docs/guides/07_new_op/index_en.rst

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,14 @@
22
Write New Operators
33
###################
44

5-
This section will guide you how to add an operator, and it also includes some necessary notes.
5+
This section will guide you on how to use the custom operator mechanism of Paddle, including the following two categories:
66

7-
- `How to write new operator <new_op_en.html>`_ :guides to write new operators
7+
1. C++ operator: The writing method is relatively simple, does not involve the internal concept of the framework, does not need to recompile the paddle framework, and is used as an external module.
8+
2. Python operator: use Python to implement forward and backward methods, then used in network.
89

9-
- `op notes <op_notes_en.html>`_ :notes on developing new operators
10+
- `Custom C++ Operator <./new_custom_op_cn.html>`_
11+
12+
- `Custom Python Operator <./new_python_op_cn.html>`_
1013

1114
- `Kernel Primitives API <./kernel_primitive_api/index_en.html>`_ : Introduce the block-level CUDA functions provided by PaddlePaddle to speed up operator development.
1215

docs/guides/07_new_op/new_custom_op_cn.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# 自定义外部算子
1+
# 自定义C++算子
22

33
## 概述
44

0 commit comments

Comments
 (0)