|
|
|
@ -126,6 +126,14 @@ class OpKernelRegistrar : public Registrar {
|
|
|
|
|
__test_global_namespace_##uniq_name##__>::value, \
|
|
|
|
|
msg)
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
The variadic arguments should be class types derived from one of the
|
|
|
|
|
following classes:
|
|
|
|
|
OpProtoAndCheckerMaker
|
|
|
|
|
GradOpDescMakerBase
|
|
|
|
|
VarTypeInference
|
|
|
|
|
InferShapeBase
|
|
|
|
|
*/
|
|
|
|
|
#define REGISTER_OPERATOR(op_type, op_class, ...) \
|
|
|
|
|
STATIC_ASSERT_GLOBAL_NAMESPACE( \
|
|
|
|
|
__reg_op__##op_type, \
|
|
|
|
@ -144,20 +152,29 @@ class OpKernelRegistrar : public Registrar {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Macro to register Operator.
|
|
|
|
|
* Macro to register Operator. When the input is duplicable, you should
|
|
|
|
|
* use REGISTER_OP_EX with deop_empty_grad=false instead.
|
|
|
|
|
*/
|
|
|
|
|
#define REGISTER_OP(op_type, op_class, op_maker_class, grad_op_type, \
|
|
|
|
|
grad_op_class) \
|
|
|
|
|
REGISTER_OPERATOR(grad_op_type, grad_op_class); \
|
|
|
|
|
class _GradOpDescMaker_##grad_op_type##_ \
|
|
|
|
|
: public ::paddle::framework::DefaultGradOpDescMaker<true> { \
|
|
|
|
|
using ::paddle::framework::DefaultGradOpDescMaker< \
|
|
|
|
|
true>::DefaultGradOpDescMaker; \
|
|
|
|
|
\
|
|
|
|
|
protected: \
|
|
|
|
|
virtual std::string GradOpType() const { return #grad_op_type; } \
|
|
|
|
|
}; \
|
|
|
|
|
REGISTER_OPERATOR(op_type, op_class, _GradOpDescMaker_##grad_op_type##_, \
|
|
|
|
|
#define REGISTER_OP(op_type, op_class, op_maker_class, grad_op_type, \
|
|
|
|
|
grad_op_class) \
|
|
|
|
|
REGISTER_OP_EX(op_type, op_class, op_maker_class, grad_op_type, \
|
|
|
|
|
grad_op_class, true)
|
|
|
|
|
|
|
|
|
|
// When an argument is duplicable, we need to use this version.
|
|
|
|
|
// Perhaps we can omit DropEmptyIG template parameter and
|
|
|
|
|
// only have one version of REGISTER_OP.
|
|
|
|
|
#define REGISTER_OP_EX(op_type, op_class, op_maker_class, grad_op_type, \
|
|
|
|
|
grad_op_class, drop_empty_grad) \
|
|
|
|
|
REGISTER_OPERATOR(grad_op_type, grad_op_class); \
|
|
|
|
|
class _GradOpDescMaker_##grad_op_type##_ \
|
|
|
|
|
: public ::paddle::framework::DefaultGradOpDescMaker<drop_empty_grad> { \
|
|
|
|
|
using ::paddle::framework::DefaultGradOpDescMaker< \
|
|
|
|
|
drop_empty_grad>::DefaultGradOpDescMaker; \
|
|
|
|
|
\
|
|
|
|
|
protected: \
|
|
|
|
|
virtual std::string GradOpType() const { return #grad_op_type; } \
|
|
|
|
|
}; \
|
|
|
|
|
REGISTER_OPERATOR(op_type, op_class, _GradOpDescMaker_##grad_op_type##_, \
|
|
|
|
|
op_maker_class);
|
|
|
|
|
|
|
|
|
|
#define REGISTER_OP_WITH_KERNEL(op_type, ...) \
|
|
|
|
|