|
|
@ -307,10 +307,7 @@ class OpRegistry {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class Registrar {
|
|
|
|
class Registrar {};
|
|
|
|
public:
|
|
|
|
|
|
|
|
void Touch() {}
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
template <typename OpType, typename ProtoMakerType>
|
|
|
|
template <typename OpType, typename ProtoMakerType>
|
|
|
|
class OpRegistrar : public Registrar {
|
|
|
|
class OpRegistrar : public Registrar {
|
|
|
@ -354,10 +351,9 @@ class OpKernelRegistrar : public Registrar {
|
|
|
|
#define REGISTER_OP(op_type, op_class, op_maker_class) \
|
|
|
|
#define REGISTER_OP(op_type, op_class, op_maker_class) \
|
|
|
|
STATIC_ASSERT_GLOBAL_NAMESPACE( \
|
|
|
|
STATIC_ASSERT_GLOBAL_NAMESPACE( \
|
|
|
|
__reg_op__##op_type, "REGISTER_OP must be called in global namespace"); \
|
|
|
|
__reg_op__##op_type, "REGISTER_OP must be called in global namespace"); \
|
|
|
|
|
|
|
|
int TouchOpRegistrar_##op_type() { \
|
|
|
|
static ::paddle::framework::OpRegistrar<op_class, op_maker_class> \
|
|
|
|
static ::paddle::framework::OpRegistrar<op_class, op_maker_class> \
|
|
|
|
__op_registrar_##op_type##__(#op_type); \
|
|
|
|
__op_registrar_##op_type##__(#op_type); \
|
|
|
|
int TouchOpRegistrar_##op_type() { \
|
|
|
|
|
|
|
|
__op_registrar_##op_type##__.Touch(); \
|
|
|
|
|
|
|
|
return 0; \
|
|
|
|
return 0; \
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -368,11 +364,10 @@ class OpKernelRegistrar : public Registrar {
|
|
|
|
STATIC_ASSERT_GLOBAL_NAMESPACE( \
|
|
|
|
STATIC_ASSERT_GLOBAL_NAMESPACE( \
|
|
|
|
__reg_gradient_op__##op_type##_##grad_op_type, \
|
|
|
|
__reg_gradient_op__##op_type##_##grad_op_type, \
|
|
|
|
"REGISTER_GRADIENT_OP must be called in global namespace"); \
|
|
|
|
"REGISTER_GRADIENT_OP must be called in global namespace"); \
|
|
|
|
|
|
|
|
int TouchOpGradientRegistrar_##op_type() { \
|
|
|
|
static ::paddle::framework::GradOpRegistrar<grad_op_class> \
|
|
|
|
static ::paddle::framework::GradOpRegistrar<grad_op_class> \
|
|
|
|
__op_gradient_registrar_##op_type##_##grad_op_type##__(#op_type, \
|
|
|
|
__op_gradient_registrar_##op_type##_##grad_op_type##__(#op_type, \
|
|
|
|
#grad_op_type); \
|
|
|
|
#grad_op_type); \
|
|
|
|
int TouchOpGradientRegistrar_##op_type() { \
|
|
|
|
|
|
|
|
__op_gradient_registrar_##op_type##_##grad_op_type##__.Touch(); \
|
|
|
|
|
|
|
|
return 0; \
|
|
|
|
return 0; \
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -383,10 +378,9 @@ class OpKernelRegistrar : public Registrar {
|
|
|
|
STATIC_ASSERT_GLOBAL_NAMESPACE( \
|
|
|
|
STATIC_ASSERT_GLOBAL_NAMESPACE( \
|
|
|
|
__reg_op_kernel_##op_type##_##DEVICE_TYPE##__, \
|
|
|
|
__reg_op_kernel_##op_type##_##DEVICE_TYPE##__, \
|
|
|
|
"REGISTER_OP_KERNEL must be called in global namespace"); \
|
|
|
|
"REGISTER_OP_KERNEL must be called in global namespace"); \
|
|
|
|
|
|
|
|
int TouchOpKernelRegistrar_##op_type##_##DEVICE_TYPE() { \
|
|
|
|
static ::paddle::framework::OpKernelRegistrar<place_class, __VA_ARGS__> \
|
|
|
|
static ::paddle::framework::OpKernelRegistrar<place_class, __VA_ARGS__> \
|
|
|
|
__op_kernel_registrar_##op_type##_##DEVICE_TYPE##__(#op_type); \
|
|
|
|
__op_kernel_registrar_##op_type##_##DEVICE_TYPE##__(#op_type); \
|
|
|
|
int TouchOpKernelRegistrar_##op_type##_##DEVICE_TYPE() { \
|
|
|
|
|
|
|
|
__op_kernel_registrar_##op_type##_##DEVICE_TYPE##__.Touch(); \
|
|
|
|
|
|
|
|
return 0; \
|
|
|
|
return 0; \
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|