diff --git a/src/operators/op_param.h b/src/operators/op_param.h index cf2367b9f3e5bbcb2ada32fb6715d39edb781713..e1f6864f54df4cbecdc9c31ff9fe1428badea0bc 100644 --- a/src/operators/op_param.h +++ b/src/operators/op_param.h @@ -232,7 +232,6 @@ class ConvParam : OpParam { Print &operator<<(Print &printer, const ConvParam &conv_param); #endif -#ifdef ELEMENTWISEADD_OP class ElementwiseAddParam : OpParam { public: ElementwiseAddParam(const VariableNameMap &inputs, @@ -259,6 +258,8 @@ class ElementwiseAddParam : OpParam { int axis_; }; +#ifdef FUSION_ELEMENTWISEADDRELU_OP +using ElementwiseAddReluParam = ElementwiseAddParam; #endif #ifdef MUL_OP @@ -421,7 +422,7 @@ class PoolParam : public OpParam { strides_ = GetAttr>("strides", attrs); paddings_ = GetAttr>("paddings", attrs); ceil_mode_ = GetAttr("ceil_mode", attrs); - gloabal_pooling_ = GetAttr("global_pooling", attrs); + global_pooling_ = GetAttr("global_pooling", attrs); } const Tensor *Input() const { return input_; } @@ -448,9 +449,81 @@ class PoolParam : public OpParam { vector strides_; vector paddings_; bool ceil_mode_; - bool gloabal_pooling_ = false; + bool global_pooling_ = false; }; +#endif + +#ifdef FUSION_POOLBN_OP +class PoolBNParam : OpParam { + public: + PoolBNParam(const VariableNameMap &inputs, const VariableNameMap &outputs, + const AttributeMap &attrs, const Scope &scope) { + input_ = InputXFrom(inputs, scope); + pooling_type_ = GetAttr("pooling_type", attrs); + ksize_ = GetAttr>("ksize", attrs); + strides_ = GetAttr>("strides", attrs); + paddings_ = GetAttr>("paddings", attrs); + ceil_mode_ = GetAttr("ceil_mode", attrs); + global_pooling_ = GetAttr("global_pooling", attrs); + output_y_ = OutputYFrom(outputs, scope); + input_bias_ = InputBiasFrom(inputs, scope); + input_mean_ = InputMeanFrom(inputs, scope); + input_scale_ = InputScaleFrom(inputs, scope); + input_variance_ = InputVarianceFrom(inputs, scope); + epsilon_ = GetAttr("epsilon", attrs); + momentum_ = GetAttr("momentum", attrs); + // is_test_ = GetAttr("is_test", attrs); + } + const Tensor *Input() const { return input_; } + + const string &PoolingType() const { return pooling_type_; } + + const vector &Ksize() const { return ksize_; } + + const vector &Strides() const { return strides_; } + + const vector &Paddings() const { return paddings_; } + + bool isCeilMode() const { return ceil_mode_; } + + bool isGlobalPooling() const { return gloabal_pooling_; } + + Tensor *OutputY() const { return output_y_; } + + const Tensor *InputBias() const { return input_bias_; } + + const Tensor *InputMean() const { return input_mean_; } + const Tensor *InputScale() const { return input_scale_; } + + const Tensor *InputVariance() const { return input_variance_; } + + const float &Epsilon() const { return epsilon_; } + + const float &Momentum() const { return momentum_; } + + const bool &IsTest() const { return is_test_; } + + const string &DataFormat() const { return data_format_; } + + private: + Tensor *input_; + string pooling_type_; + vector ksize_; + vector strides_; + vector paddings_; + bool ceil_mode_; + bool global_pooling_ = false; + Tensor *output_y_; + Tensor *input_bias_; + Tensor *input_mean_; + Tensor *input_scale_; + Tensor *input_variance_; + float epsilon_; + float momentum_; + bool is_test_; + string data_format_; +}; #endif #ifdef PRIORBOX_OP @@ -875,7 +948,6 @@ class PReluParam : public OpParam { }; #endif -#ifdef FUSION_FC_OP class FusionFcParam : public OpParam { public: FusionFcParam(const VariableNameMap &inputs, const VariableNameMap &outputs, @@ -911,9 +983,11 @@ class FusionFcParam : public OpParam { int y_num_col_dims_; int axis_; }; + +#ifdef FUSION_FCRELU_OP +using FusionFcReluParam = FusionFcParam; #endif -#ifdef FUSION_CONVADD_OP class FusionConvAddParam : public OpParam { public: FusionConvAddParam(const VariableNameMap &inputs, @@ -960,7 +1034,6 @@ class FusionConvAddParam : public OpParam { }; Print &operator<<(Print &printer, const FusionConvAddParam &conv_param); -#endif #ifdef FUSION_CONVADDRELU_OP class FusionConvAddReluParam : public FusionConvAddParam { @@ -1055,8 +1128,91 @@ class FusionConvAddBNReluParam : public OpParam { Tensor *new_bias_; Tensor *new_scale_; }; +#endif -Print &operator<<(Print &printer, const FusionConvAddParam &conv_param); +#ifdef FUSION_CONVADDBN_OP +class FusionConvAddBNParam : public OpParam { + public: + FusionConvAddBNParam(const VariableNameMap &inputs, + const VariableNameMap &outputs, + const AttributeMap &attrs, const Scope &scope) { + bias_ = InputYFrom(inputs, scope); + axis_ = GetAttr("axis", attrs); + filter_ = FilterFrom(inputs, scope); + input_ = InputFrom(inputs, scope); + output_y_ = OutputYFrom(outputs, scope); + strides_ = GetAttr>("strides", attrs); + paddings_ = GetAttr>("paddings", attrs); + dilations_ = GetAttr>("dilations", attrs); + groups = GetAttr("groups", attrs); + input_bias_ = InputBiasFrom(inputs, scope); + input_mean_ = InputMeanFrom(inputs, scope); + input_scale_ = InputScaleFrom(inputs, scope); + input_variance_ = InputVarianceFrom(inputs, scope); + epsilon_ = GetAttr("epsilon", attrs); + momentum_ = GetAttr("momentum", attrs); + // is_test_ = GetAttr("is_test", attrs); + } + Tensor *Bias() const { return bias_; } + + const int &Axis() const { return axis_; } + + const Tensor *Input() const { return input_; } + + const Tensor *Filter() const { return filter_; } + + Tensor *OutputY() const { return output_y_; } + + const vector &Strides() const { return strides_; } + + const vector &Paddings() const { return paddings_; } + + const vector &Dilations() const { return dilations_; } + + const int &Groups() const { return groups; } + + const Tensor *InputBias() const { return input_bias_; } + + const Tensor *InputMean() const { return input_mean_; } + + const Tensor *InputScale() const { return input_scale_; } + + const Tensor *InputVariance() const { return input_variance_; } + + const float &Epsilon() const { return epsilon_; } + + const float &Momentum() const { return momentum_; } + + const bool &IsTest() const { return is_test_; } + + void SetNewScale(Tensor *new_scale) { new_scale_ = new_scale; } + + void SetNewBias(Tensor *new_bias) { new_bias_ = new_bias; } + + const Tensor *NewScale() const { return new_scale_; } + + const Tensor *NewBias() const { return new_bias_; } + + protected: + Tensor *bias_; + int axis_; + Tensor *input_; + Tensor *output_y_; + Tensor *filter_; + vector strides_; + vector paddings_; + vector dilations_; + int groups; + Tensor *input_bias_; + Tensor *input_mean_; + Tensor *input_scale_; + Tensor *input_variance_; + float epsilon_; + float momentum_; + bool is_test_; + Tensor *new_bias_; + Tensor *new_scale_; +}; #endif #ifdef FUSION_DWCONVBNRELU_OP @@ -1269,5 +1425,9 @@ class DropoutParam : public OpParam { }; #endif +#ifdef REGION_OP +class RegionParam : public OpParam {}; +#endif + } // namespace operators } // namespace paddle_mobile