diff --git a/src/common/types.h b/src/common/types.h index 7e7046dea9e6ebd32380c9ad3f34daabe43dd23d..2927e838fc772a8ccfdcc6212efc09ce8bbbdacd 100644 --- a/src/common/types.h +++ b/src/common/types.h @@ -131,9 +131,12 @@ extern const char *G_OP_TYPE_FUSION_CONV_BN_ADD_RELU; extern const char *G_OP_TYPE_FUSION_DWCONV_BN_RELU; extern const char *G_OP_TYPE_FUSION_CONV_BN_RELU; +extern const char *G_OP_TYPE_GRU; +extern const char *G_OP_TYPE_GRU_UNIT; extern const char *G_OP_TYPE_LRN; extern const char *G_OP_TYPE_MUL; extern const char *G_OP_TYPE_MULTICLASS_NMS; +extern const char *G_OP_TYPE_NORM; extern const char *G_OP_TYPE_POOL2D; extern const char *G_OP_TYPE_PRIOR_BOX; extern const char *G_OP_TYPE_RELU; @@ -163,6 +166,10 @@ extern const char *G_OP_TYPE_CAST; extern const char *G_OP_TYPE_LOG; extern const char *G_OP_TYPE_LOD_RESET; extern const char *G_OP_TYPE_LESS_THAN; +extern const char *G_OP_TYPE_LOGICAL_AND; +extern const char *G_OP_TYPE_LOGICAL_OR; +extern const char *G_OP_TYPE_LOGICAL_NOT; +extern const char *G_OP_TYPE_LOGICAL_XOR; extern const char *G_OP_TYPE_QUANTIZE; extern const char *G_OP_TYPE_DEQUANTIZE; diff --git a/src/framework/load_ops.h b/src/framework/load_ops.h index 1caefe5ae77c9f4328d4d99af9e0b5c3b408d921..fca5fd82a09984ae32f354205e62fda1e3c20423 100644 --- a/src/framework/load_ops.h +++ b/src/framework/load_ops.h @@ -168,6 +168,9 @@ LOAD_FUSION_MATCHER(fusion_conv_bn_relu); #ifdef GRU_OP LOAD_OP1(gru, CPU); #endif +#ifdef GRU_UNIT_OP +LOAD_OP1(gru_unit, CPU); +#endif #ifdef FUSION_CONVADDBN_OP LOAD_OP2(fusion_conv_add_bn, CPU, FPGA); LOAD_FUSION_MATCHER(fusion_conv_add_bn); @@ -189,6 +192,9 @@ LOAD_OP1(crf_decoding, CPU); #ifdef MUL_OP LOAD_OP2(mul, CPU, MALI_GPU); #endif +#ifdef NORM_OP +LOAD_OP1(norm, CPU); +#endif #ifdef RELU_OP LOAD_OP2(relu, CPU, MALI_GPU); LOAD_OP1(relu6, CPU); @@ -279,3 +285,15 @@ LOAD_OP1(lod_reset, CPU); #ifdef LESS_THAN_OP LOAD_OP1(less_than, CPU); #endif +#ifdef LOGICAL_AND_OP +LOAD_OP1(logical_and, CPU); +#endif +#ifdef LOGICAL_OR_OP +LOAD_OP1(logical_or, CPU); +#endif +#ifdef LOGICAL_NOT_OP +LOAD_OP1(logical_not, CPU); +#endif +#ifdef LOGICAL_XOR_OP +LOAD_OP1(logical_xor, CPU); +#endif diff --git a/src/operators/kernel/arm/logical_kernel.cpp b/src/operators/kernel/arm/logical_kernel.cpp index 50c59a61282804e02fe1c94bb68202357fa956a9..3cffcf5c691fde551ad01f42757da8eaae98833e 100644 --- a/src/operators/kernel/arm/logical_kernel.cpp +++ b/src/operators/kernel/arm/logical_kernel.cpp @@ -56,12 +56,13 @@ void BinaryLogicalCompute(const Tensor* inputX, const Tensor* inputY, #ifdef LOGICAL_AND_OP template <> -bool LogicalAndKernel::Init(LogicalAndParam* param) { +bool LogicalAndKernel::Init(LogicalBinaryParam* param) { return true; } template <> -void LogicalAndKernel::Compute(const LogicalAndParam& param) { +void LogicalAndKernel::Compute( + const LogicalBinaryParam& param) { auto* inputX = param.InputX(); auto* inputY = param.InputY(); auto* out = param.Out(); @@ -72,12 +73,13 @@ void LogicalAndKernel::Compute(const LogicalAndParam& param) { #ifdef LOGICAL_OR_OP template <> -bool LogicalOrKernel::Init(LogicalOrParam* param) { +bool LogicalOrKernel::Init(LogicalBinaryParam* param) { return true; } template <> -void LogicalOrKernel::Compute(const LogicalOrParam& param) { +void LogicalOrKernel::Compute( + const LogicalBinaryParam& param) { auto* inputX = param.InputX(); auto* inputY = param.InputY(); auto* out = param.Out(); @@ -88,12 +90,13 @@ void LogicalOrKernel::Compute(const LogicalOrParam& param) { #ifdef LOGICAL_NOT_OP template <> -bool LogicalNotKernel::Init(LogicalNotParam* param) { +bool LogicalNotKernel::Init(LogicalUnaryParam* param) { return true; } template <> -void LogicalNotKernel::Compute(const LogicalNotParam& param) { +void LogicalNotKernel::Compute( + const LogicalUnaryParam& param) { auto* inputX = param.InputX(); auto* out = param.Out(); out->mutable_data(); @@ -103,12 +106,13 @@ void LogicalNotKernel::Compute(const LogicalNotParam& param) { #ifdef LOGICAL_XOR_OP template <> -bool LogicalXorKernel::Init(LogicalXorParam* param) { +bool LogicalXorKernel::Init(LogicalBinaryParam* param) { return true; } template <> -void LogicalXorKernel::Compute(const LogicalXorParam& param) { +void LogicalXorKernel::Compute( + const LogicalBinaryParam& param) { auto* inputX = param.InputX(); auto* inputY = param.InputY(); auto* out = param.Out(); diff --git a/src/operators/kernel/logical_kernel.h b/src/operators/kernel/logical_kernel.h index d9cea15bbcfb3eadbcc9945ad6176f36af998f99..8c49669fa8f276b28e4d3b50db16937f766f70a1 100644 --- a/src/operators/kernel/logical_kernel.h +++ b/src/operators/kernel/logical_kernel.h @@ -21,19 +21,19 @@ namespace paddle_mobile { namespace operators { #ifdef LOGICAL_AND_OP -DECLARE_KERNEL(LogicalAnd, LogicalAndParam); +DECLARE_KERNEL(LogicalAnd, LogicalBinaryParam); #endif #ifdef LOGICAL_OR_OP -DECLARE_KERNEL(LogicalOr, LogicalOrParam); +DECLARE_KERNEL(LogicalOr, LogicalBinaryParam); #endif #ifdef LOGICAL_NOT_OP -DECLARE_KERNEL(LogicalNot, LogicalNotParam); +DECLARE_KERNEL(LogicalNot, LogicalUnaryParam); #endif #ifdef LOGICAL_XOR_OP -DECLARE_KERNEL(LogicalXor, LogicalXorParam); +DECLARE_KERNEL(LogicalXor, LogicalBinaryParam); #endif } // namespace operators diff --git a/src/operators/logical_op.h b/src/operators/logical_op.h index f7ebce5665ed194717e24532661ea0d40b3bb046..a3cd2fb605f3f081e06eee740d9c47873a29ca97 100644 --- a/src/operators/logical_op.h +++ b/src/operators/logical_op.h @@ -23,19 +23,19 @@ namespace paddle_mobile { namespace operators { #ifdef LOGICAL_AND_OP -DECLARE_OPERATOR(LogicalAnd, LogicalAndParam, LogicalAndKernel); +DECLARE_OPERATOR(LogicalAnd, LogicalBinaryParam, LogicalAndKernel); #endif #ifdef LOGICAL_OR_OP -DECLARE_OPERATOR(LogicalOr, LogicalOrParam, LogicalOrKernel); +DECLARE_OPERATOR(LogicalOr, LogicalBinaryParam, LogicalOrKernel); #endif #ifdef LOGICAL_NOT_OP -DECLARE_OPERATOR(LogicalNot, LogicalNotParam, LogicalNotKernel); +DECLARE_OPERATOR(LogicalNot, LogicalUnaryParam, LogicalNotKernel); #endif #ifdef LOGICAL_XOR_OP -DECLARE_OPERATOR(LogicalXor, LogicalXorParam, LogicalXorKernel); +DECLARE_OPERATOR(LogicalXor, LogicalBinaryParam, LogicalXorKernel); #endif } // namespace operators diff --git a/src/operators/op_param.h b/src/operators/op_param.h index eb97671f3d241c10a5b06008cf6fb719b1ef4d7d..1f20f5505668e79a8453d9b14ef25478fc7e3af7 100644 --- a/src/operators/op_param.h +++ b/src/operators/op_param.h @@ -2942,40 +2942,16 @@ class CompareParam : public OpParam { }; #endif // LESS_THAN_OP -#ifdef LOGICAL_AND_OP +#if defined(LOGICAL_AND_OP) || defined(LOGICAL_OR_OP) || defined(LOGICAL_XOR_OP) template -class LogicalAndParam : public OpParam { +class LogicalBinaryParam : public OpParam { typedef typename DtypeTensorTrait::gtype GType; typedef typename DtypeTensorTrait::rtype RType; public: - LogicalAndParam(const VariableNameMap &inputs, const VariableNameMap &outputs, - const AttributeMap &attrs, const Scope &scope) { - input_x_ = InputXFrom(inputs, scope); - input_y_ = InputYFrom(inputs, scope); - output_ = OutFrom(outputs, scope); - } - - const GType *InputX() const { return input_x_; } - const GType *InputY() const { return input_y_; } - GType *Out() const { return output_; } - - public: - GType *input_x_; - GType *input_y_; - GType *output_; -}; -#endif // LOGICAL_AND_OP - -#ifdef LOGICAL_OR_OP -template -class LogicalOrParam : public OpParam { - typedef typename DtypeTensorTrait::gtype GType; - typedef typename DtypeTensorTrait::rtype RType; - - public: - LogicalOrParam(const VariableNameMap &inputs, const VariableNameMap &outputs, - const AttributeMap &attrs, const Scope &scope) { + LogicalBinaryParam(const VariableNameMap &inputs, + const VariableNameMap &outputs, const AttributeMap &attrs, + const Scope &scope) { input_x_ = InputXFrom(inputs, scope); input_y_ = InputYFrom(inputs, scope); output_ = OutFrom(outputs, scope); @@ -2990,17 +2966,18 @@ class LogicalOrParam : public OpParam { GType *input_y_; GType *output_; }; -#endif // LOGICAL_OR_OP +#endif // LOGICAL_AND_OP LOGICAL_OR_OP LOGICAL_XOR_OP #ifdef LOGICAL_NOT_OP template -class LogicalNotParam : public OpParam { +class LogicalUnaryParam : public OpParam { typedef typename DtypeTensorTrait::gtype GType; typedef typename DtypeTensorTrait::rtype RType; public: - LogicalNotParam(const VariableNameMap &inputs, const VariableNameMap &outputs, - const AttributeMap &attrs, const Scope &scope) { + LogicalUnaryParam(const VariableNameMap &inputs, + const VariableNameMap &outputs, const AttributeMap &attrs, + const Scope &scope) { input_x_ = InputXFrom(inputs, scope); output_ = OutFrom(outputs, scope); } @@ -3014,30 +2991,5 @@ class LogicalNotParam : public OpParam { }; #endif // LOGICAL_NOT_OP -#ifdef LOGICAL_XOR_OP -template -class LogicalXorParam : public OpParam { - typedef typename DtypeTensorTrait::gtype GType; - typedef typename DtypeTensorTrait::rtype RType; - - public: - LogicalXorParam(const VariableNameMap &inputs, const VariableNameMap &outputs, - const AttributeMap &attrs, const Scope &scope) { - input_x_ = InputXFrom(inputs, scope); - input_y_ = InputYFrom(inputs, scope); - output_ = OutFrom(outputs, scope); - } - - const GType *InputX() const { return input_x_; } - const GType *InputY() const { return input_y_; } - GType *Out() const { return output_; } - - public: - GType *input_x_; - GType *input_y_; - GType *output_; -}; -#endif // LOGICAL_XOR_OP - } // namespace operators } // namespace paddle_mobile