diff --git a/doc/design/register_grad_op.md b/doc/design/register_grad_op.md index 1c961a61588b0cb102f0741acf1f4a9e9660f13c..a793cfe96bd1447759c6665bb4573a030a30e54c 100644 --- a/doc/design/register_grad_op.md +++ b/doc/design/register_grad_op.md @@ -51,13 +51,19 @@ struct OpInfo { The `grad_op_maker_ ` is `nullptr` if the operator does not have associated gradient operators. -We should chagne register macros at the same time. In the current solution, there is no difference between forwarding operators and backward operators. So `REGISTER_OP` just register one operator. If the `REGISTER_OP` contains `OpProtoAndCheckerMaker` and `GradOpDescMaker Æ’`, we just list them in the same macro. It can be done by a macro contains `__VA_ARGS__`. +We should chagne register macros at the same time. In the current solution, there is no difference between forwarding operators and backward operators. So `REGISTER_OP` just register one operator. If the `REGISTER_OPERATOR ` contains `OpProtoAndCheckerMaker` and `GradOpDescMaker`, we just list them in the same macro. It can be done by a macro contains `__VA_ARGS__`. The user interface should be ```cpp vector SumOpGradMakerÆ’(OpDesc) {...} -REGISTER_OP(sum, SumOp, SumOpProtoAndCheckerMaker, SumOpGradMaker); +REGISTER_OPERATOR(sum, SumOp, SumOpProtoAndCheckerMaker, SumOpGradMaker); // Developers can still manually implement gradient operator. -REGISTER_OP(sum_grad, SumGradOp); +REGISTER_OPERATOR(sum_grad, SumGradOp); +``` + +The interface of current `REGISTER_OP` macro could not be changed. In `REGISTER_OP`, it will invoke `REGISTER_OPERATOR` two times and generate GradOpDescMaker inside. + +```cpp +REGISTER_OP(sum, SumOp, SumOpProtoAndCheckerMaker, sum_grad, SumGradOp); ```