name_convention.md 1.6 KB
Newer Older
D
dongzhihong 已提交
1 2
## Operator Name Convention

D
dongzhihong 已提交
3
To make the operator document itself more clear, we recommend operator names obey the listing conventions.
D
dongzhihong 已提交
4

D
dongzhihong 已提交
5
### OpMaker names
D
dongzhihong 已提交
6

D
dongzhihong 已提交
7
When defining an operator in Paddle, a corresponding `OpMaker` need to be defined. All the `Input`/`Output` and `attrs` will write into the `OpProto` , and will be used in client language to create operator. 
D
dongzhihong 已提交
8

D
dongzhihong 已提交
9 10 11
- Input/Output.
  -  names follow the `CamelCase` but the first character is uppercase. e.g. `X`, `Y`, `Matrix`, `LastAxisInMatrix`. Input/Output much more like Variables, we prefer to meaningful English words.
  - If an operator's Input/Output are not meaningful words, input name starts from `X`. e.g. `X`, `Y`, and output name starts from `Out`. e.g. `Out`.
D
dongzhihong 已提交
12

D
dongzhihong 已提交
13 14 15 16 17
* Attribute.
  * Attribute name follows the normal `CamelCase`. e.g. `x`, `y`, `axis`, `rowwiseMatrix`. Also, attribute name prefers to meaningful English words.
* Comments.
  * Input/Output/Attr comment follow the format of `type:meaning`. e.g. `AddOutput("Out", "EigenTensor,Tensor: Output of XX")`. we prefer to more meaningful comment. Some comments like `The first input of Operator` contains no information, we forbid it.
  * Operator comment format of` R"DOC(your comment here)DOC"`. if there is math calculation in this operator, you should write the equation in the comment. e.g. `Out = X + Y`. 
D
dongzhihong 已提交
18 19

### Best Practice
D
dongzhihong 已提交
20 21 22 23 24 25 26 27

- The operator has one input, one output. e.g.`relu`, inputs: `X`, outputs: `Out`. 

- The operator has two input, one output. e.g. `rowwise_add`, inputs : `X`, `Y`, outputs : `Out`.

- The operator contains attribute. e.g. `cosine`, inputs : `X`, `axis`, outputs : `Out`.