You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
为了使`OpKernel`的计算过程书写更加简单,并且CPU、CUDA的代码可以复用,我们通常借助 Eigen unsupported Tensor模块来实现`Compute`接口。关于在PaddlePaddle中如何使用Eigen库,请参考[使用文档](https://github.com/PaddlePaddle/FluidDoc/blob/develop/doc/fluid/dev/use_eigen_cn.md)。
233
+
为了使`OpKernel`的计算过程书写更加简单,并且CPU、CUDA的代码可以复用,我们通常借助 Eigen unsupported Tensor模块来实现`Compute`接口。关于在PaddlePaddle中如何使用Eigen库,请参考[使用文档](https://github.com/PaddlePaddle/FluidDoc/blob/release/1.2/doc/fluid/dev/use_eigen_cn.md)。
Copy file name to clipboardExpand all lines: doc/fluid/advanced_usage/development/new_op/new_op_en.md
+5-5Lines changed: 5 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -103,7 +103,7 @@ The equation is: Out = X * Y
103
103
104
104
The constructor utilizes `AddInput` to add input parameter, `AddOutput` to add output parameter, and `AddComment` to add comments for the Op, so that the corresponding information will be added to `OpProto`.
105
105
106
-
The code above adds two inputs `X` and `Y` to `MulOp`, an output `Out`, and their corresponding descriptions. Names are given in accordance to Paddle's [naming convention](https://github.com/PaddlePaddle/FluidDoc/blob/develop/doc/fluid/dev/name_convention.md).
106
+
The code above adds two inputs `X` and `Y` to `MulOp`, an output `Out`, and their corresponding descriptions. Names are given in accordance to Paddle's [naming convention](https://github.com/PaddlePaddle/FluidDoc/blob/release/1.2/doc/fluid/dev/name_convention.md).
107
107
108
108
109
109
An additional example [`ScaleOp`](https://github.com/PaddlePaddle/Paddle/blob/develop/paddle/fluid/operators/scale_op.cc#L38-L55) is implemented as follows:
@@ -134,7 +134,7 @@ Note `AddAttr<AttrType>("scale", "...").SetDefault(1.0);` adds `scale`constant a
134
134
<a name="Defining the GradProtoMaker class"></a>
135
135
### Defining the GradProtoMaker class
136
136
137
-
Each Op must have a corresponding GraProtoMaker. If GradProtoMaker corresponding to the forward Op is not customized, Fluid provides DefaultGradProtoMaker. The default registration will use all input and output, including Input, Output, Output@Grad and so on. Using unnecessary variables will cause waste of memory.
137
+
Each Op must have a corresponding GradProtoMaker. If GradProtoMaker corresponding to the forward Op is not customized, Fluid provides DefaultGradProtoMaker. The default registration will use all input and output, including Input, Output, Output@Grad and so on. Using unnecessary variables will cause waste of memory.
138
138
The following example defines ScaleOp's GradProtoMaker.
139
139
140
140
```cpp
@@ -244,7 +244,7 @@ Note that **different devices (CPU, CUDA)share one Op definition; whether or not
244
244
245
245
`MulOp`'s CPU and CUDA share the same `Kernel`. A non-sharing `OpKernel` example can be seen in [`OnehotCrossEntropyOpKernel`](https://github.com/PaddlePaddle/Paddle/blob/develop/paddle/fluid/operators/cross_entropy_op.cc).
246
246
247
-
To ease the writing of `OpKernel` compute, and for reusing code cross-device, [`Eigen-unsupported Tensor`](https://bitbucket.org/eigen/eigen/src/default/unsupported/Eigen/CXX11/src/Tensor/README.md?fileviewer=file-view-default) module is used to implement `Compute` interface. To learn about how the Eigen library is used in PaddlePaddle, please see [usage document](https://github.com/PaddlePaddle/FluidDoc/blob/develop/doc/fluid/dev/use_eigen_en.md).
247
+
To ease the writing of `OpKernel` compute, and for reusing code cross-device, [`Eigen-unsupported Tensor`](https://bitbucket.org/eigen/eigen/src/default/unsupported/Eigen/CXX11/src/Tensor/README.md?fileviewer=file-view-default) module is used to implement `Compute` interface. To learn about how the Eigen library is used in PaddlePaddle, please see [usage document](https://github.com/PaddlePaddle/FluidDoc/blob/release/1.2/doc/fluid/dev/use_eigen_cn.md).
248
248
249
249
250
250
This concludes the forward implementation of an operator. Next its operation and kernel need to be registered in a `.cc` file.
@@ -460,7 +460,7 @@ If it is not necessary or concise description is enough to clearly express the a
460
460
461
461
2.Using developer-defined variable abbreviations in error messages is not easy to understand.
462
462
463
-
Example of the problem:
463
+
Example of the problem:
464
464
```
465
465
PADDLE_ENFORCE(forward_pd != nullptr,
466
466
"Fail to find eltwise_fwd_pd in device context"); //eltwise_fwd_pduser may not be understood
@@ -481,7 +481,7 @@ If it is not necessary or concise description is enough to clearly express the a
481
481
482
482
483
483
<a name="Special instructions for OP InferShape check message"></a>
484
-
#### Special Instructions for OP InferShape Check Message
484
+
#### Special Instructions for OP InferShape Check Message
485
485
486
486
- Check input and output variables, please follow the following format
487
487
`Input(variable name) of OP name operator should not be null.`
0 commit comments