Skip to content

Commit 68d9638

Browse files
author
Yang Yang
committed
remove REGISTER_OP and REGISTER_OP_EX
1 parent 4b1a32d commit 68d9638

File tree

4 files changed

+11
-33
lines changed

4 files changed

+11
-33
lines changed

paddle/fluid/framework/grad_op_desc_maker.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ See the License for the specific language governing permissions and
1313
limitations under the License. */
1414

1515
#pragma once
16+
#include <algorithm>
1617
#include <string>
1718
#include <unordered_set>
1819
#include <vector>
@@ -69,8 +70,7 @@ class GradOpDescMakerBase {
6970
" for input argument with a list of variables, "
7071
" drop_empty_grad is not allowed because it makes"
7172
" the correspondence bewteen a variable and its gradient"
72-
" ambiguous. Use REGISTER_OP_EX to register the op"
73-
" or call InputGrad(?,false) in GradOpDescMaker."
73+
" ambiguous."
7474
" Op type %s",
7575
fwd_op_.Type());
7676

paddle/fluid/framework/op_registry.h

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -143,32 +143,6 @@ class OpKernelRegistrar : public Registrar {
143143
return 0; \
144144
}
145145

146-
/**
147-
* Macro to register Operator. When the input is duplicable, you should
148-
* use REGISTER_OP_EX with drop_empty_grad=false instead.
149-
*/
150-
#define REGISTER_OP(op_type, op_class, op_maker_class, grad_op_type, \
151-
grad_op_class) \
152-
REGISTER_OP_EX(op_type, op_class, op_maker_class, grad_op_type, \
153-
grad_op_class, true)
154-
155-
// When an argument is duplicable, we need to use this version.
156-
// Perhaps we can omit DropEmptyIG template parameter and
157-
// only have one version of REGISTER_OP.
158-
#define REGISTER_OP_EX(op_type, op_class, op_maker_class, grad_op_type, \
159-
grad_op_class, drop_empty_grad) \
160-
REGISTER_OPERATOR(grad_op_type, grad_op_class); \
161-
class _GradOpDescMaker_##grad_op_type##_ \
162-
: public ::paddle::framework::DefaultGradOpDescMaker<drop_empty_grad> { \
163-
using ::paddle::framework::DefaultGradOpDescMaker< \
164-
drop_empty_grad>::DefaultGradOpDescMaker; \
165-
\
166-
protected: \
167-
virtual std::string GradOpType() const { return #grad_op_type; } \
168-
}; \
169-
REGISTER_OPERATOR(op_type, op_class, _GradOpDescMaker_##grad_op_type##_, \
170-
op_maker_class);
171-
172146
#define REGISTER_OP_WITHOUT_GRADIENT(op_type, op_class, op_maker_class) \
173147
REGISTER_OPERATOR(op_type, op_class, op_maker_class)
174148

paddle/fluid/operators/concat_op.cc

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,10 @@ class ConcatOpGrad : public framework::OperatorWithKernel {
103103
} // namespace paddle
104104

105105
namespace ops = paddle::operators;
106-
REGISTER_OP_EX(concat, ops::ConcatOp, ops::ConcatOpMaker, concat_grad,
107-
ops::ConcatOpGrad, false)
106+
REGISTER_OPERATOR(concat, ops::ConcatOp, ops::ConcatOpMaker,
107+
paddle::framework::DefaultGradOpDescMaker<
108+
false> /* set false to disable empty grad */)
109+
REGISTER_OPERATOR(concat_grad, ops::ConcatOpGrad)
108110
REGISTER_OP_CPU_KERNEL(
109111
concat, ops::ConcatKernel<paddle::platform::CPUDeviceContext, float>)
110112
REGISTER_OP_CPU_KERNEL(

paddle/fluid/operators/sequence_concat_op.cc

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -124,9 +124,11 @@ class SequenceConcatGradOp : public framework::OperatorWithKernel {
124124
} // namespace paddle
125125

126126
namespace ops = paddle::operators;
127-
REGISTER_OP_EX(sequence_concat, ops::SequenceConcatOp,
128-
ops::SequenceConcatOpMaker, sequence_concat_grad,
129-
ops::SequenceConcatGradOp, false);
127+
REGISTER_OPERATOR(sequence_concat, ops::SequenceConcatOp,
128+
ops::SequenceConcatOpMaker,
129+
paddle::framework::DefaultGradOpDescMaker<
130+
false> /* set false to disable empty grad */)
131+
REGISTER_OPERATOR(sequence_concat_grad, ops::SequenceConcatGradOp);
130132
REGISTER_OP_CPU_KERNEL(
131133
sequence_concat,
132134
ops::SequenceConcatOpKernel<paddle::platform::CPUDeviceContext, float>);

0 commit comments

Comments
 (0)