提交 323f2111 编写于 作者: Z zhaojiaying01

simplify op registry

上级 0be7fe4c
...@@ -96,42 +96,39 @@ class OpRegistry { ...@@ -96,42 +96,39 @@ class OpRegistry {
} }
}; };
#define REGISTER_OPERATOR(op_type, op_class, device_name, device_type) \ #define REGISTER_OPERATOR(op_type, op_class, device_name, device_type) \
template <typename Dtype, typename T> \ template <typename Dtype, typename T> \
class _OpClass_##op_type##_##device_name : public op_class<Dtype, T> { \ class _OpClass_##op_type##_##device_name : public op_class<Dtype, T> { \
public: \ public: \
DEFINE_OP_CONSTRUCTOR(_OpClass_##op_type##_##device_name, op_class); \ DEFINE_OP_CONSTRUCTOR(_OpClass_##op_type##_##device_name, op_class); \
}; \ }; \
static paddle_mobile::framework::OperatorRegistrar< \ static paddle_mobile::framework::OperatorRegistrar< \
device_type, _OpClass_##op_type##_##device_name<device_type, float>> \ device_type, _OpClass_##op_type##_##device_name<device_type, float>> \
__op_registrar_##op_type##_##device_name(#op_type); \ __op_registrar_##op_type##_##device_name(#op_type); \
int TouchOpRegistrar_##op_type##_##device_name() { \ int TouchOpRegistrar_##op_type##_##device_name() { \
__op_registrar_##op_type##_##device_name.Touch(); \ __op_registrar_##op_type##_##device_name.Touch(); \
return 0; \ return 0; \
} }
#define REGISTER_OPERATOR_CPU(op_type, op_class) \ #define REGISTER_OPERATOR_CPU(op_type, op_class) \
REGISTER_OPERATOR(op_type, op_class, cpu, paddle_mobile::CPU); \ REGISTER_OPERATOR(op_type, op_class, cpu, paddle_mobile::CPU);
#define REGISTER_OPERATOR_MALI_GPU(op_type, op_class) \ #define REGISTER_OPERATOR_MALI_GPU(op_type, op_class) \
REGISTER_OPERATOR(op_type, op_class, mali_gpu, paddle_movile::GPU_MALI); \ REGISTER_OPERATOR(op_type, op_class, mali_gpu, paddle_movile::GPU_MALI);
#define REGISTER_OPERATOR_FPGA(op_type, op_class) \ #define REGISTER_OPERATOR_FPGA(op_type, op_class) \
REGISTER_OPERATOR(op_type, op_class, fpga, paddle_movile::FPGA); \ REGISTER_OPERATOR(op_type, op_class, fpga, paddle_movile::FPGA);
#define USE_OP(op_type, device_name) \ #define USE_OP(op_type, device_name) \
extern int TouchOpRegistrar_##op_type##_##device_name(); \ extern int TouchOpRegistrar_##op_type##_##device_name(); \
static int use_op_itself_##op_type##_##device_name __attribute__((unused)) = \ static int use_op_itself_##op_type##_##device_name __attribute__((unused)) = \
TouchOpRegistrar_##op_type##_##device_name() TouchOpRegistrar_##op_type##_##device_name()
#define USE_OP_CPU(op_type) \ #define USE_OP_CPU(op_type) USE_OP(op_type, cpu);
USE_OP(op_type, cpu); \
#define USE_OP_MALI_GPU(op_type) \ #define USE_OP_MALI_GPU(op_type) USE_OP(op_type, mali_gpu);
USE_OP(op_type, mali_gpu); \
#define USE_OP_FPGA(op_type) \ #define USE_OP_FPGA(op_type) USE_OP(op_type, fpga);
USE_OP(op_type, fpga); \
} // namespace framework } // namespace framework
} // namespace paddle_mobile } // namespace paddle_mobile
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册