提交 087e8b9c 编写于 作者: F fengjiayi

Fix bug

上级 046af547
...@@ -307,7 +307,10 @@ class OpRegistry { ...@@ -307,7 +307,10 @@ 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 {
...@@ -351,37 +354,40 @@ class OpKernelRegistrar : public Registrar { ...@@ -351,37 +354,40 @@ 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"); \
static ::paddle::framework::OpRegistrar<op_class, op_maker_class> \
__op_registrar_##op_type##__(#op_type); \
int TouchOpRegistrar_##op_type() { \ int TouchOpRegistrar_##op_type() { \
static ::paddle::framework::OpRegistrar<op_class, op_maker_class> \ __op_registrar_##op_type##__.Touch(); \
__op_registrar_##op_type##__(#op_type); \
return 0; \ return 0; \
} }
/** /**
* Macro to Register Gradient Operator. * Macro to Register Gradient Operator.
*/ */
#define REGISTER_GRADIENT_OP(op_type, grad_op_type, grad_op_class) \ #define REGISTER_GRADIENT_OP(op_type, grad_op_type, grad_op_class) \
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() { \
return 0; \ __op_gradient_registrar_##op_type##_##grad_op_type##__.Touch(); \
return 0; \
} }
/** /**
* Macro to Register OperatorKernel. * Macro to Register OperatorKernel.
*/ */
#define REGISTER_OP_KERNEL(op_type, DEVICE_TYPE, place_class, ...) \ #define REGISTER_OP_KERNEL(op_type, DEVICE_TYPE, place_class, ...) \
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() { \
return 0; \ __op_kernel_registrar_##op_type##_##DEVICE_TYPE##__.Touch(); \
return 0; \
} }
/** /**
...@@ -436,6 +442,8 @@ class OpKernelRegistrar : public Registrar { ...@@ -436,6 +442,8 @@ class OpKernelRegistrar : public Registrar {
__attribute__((unused)) = \ __attribute__((unused)) = \
TouchOpKernelRegistrar_##op_type##_##DEVICE_TYPE() TouchOpKernelRegistrar_##op_type##_##DEVICE_TYPE()
// TODO(jiayi): The following macros seems ugly, do we have better method?
#ifdef PADDLE_ONLY_CPU #ifdef PADDLE_ONLY_CPU
#define USE_OP_KERNEL(op_type) USE_OP_DEVICE_KERNEL(op_type, CPU) #define USE_OP_KERNEL(op_type) USE_OP_DEVICE_KERNEL(op_type, CPU)
#else #else
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册