diff --git a/src/operators/dropout_op.h b/src/operators/dropout_op.h index d10008d37f93afc744dc3ea1ab8ce81294ea63bf..380071dba280f2ebc6a42f46e3155bcce6fc2a49 100644 --- a/src/operators/dropout_op.h +++ b/src/operators/dropout_op.h @@ -28,8 +28,9 @@ namespace operators { using paddle_mobile::framework::Tensor; template -class DropoutOp : public framework::OperatorWithKernel> { +class DropoutOp + : public framework::OperatorWithKernel< + DeviceType, DropoutParam, operators::DropoutKernal> { public: DropoutOp(const std::string &type, const VariableNameMap &inputs, const VariableNameMap &outputs, const framework::AttributeMap attrs, @@ -39,7 +40,7 @@ class DropoutOp : public framework::OperatorWithKernel>; + operators::DropoutKernel>; void InferShape() const override; protected: @@ -49,4 +50,3 @@ class DropoutOp : public framework::OperatorWithKernel -class Im2SequenceOp : public framework::OperatorWithKernel> { +class Im2SequenceOp : public framework::OperatorWithKernel< + DeviceType, Im2SequenceParam, + operators::Im2SequenceKernal> { public: Im2SequenceOp(const std::string &type, const VariableNameMap &inputs, const VariableNameMap &outputs, @@ -37,8 +38,9 @@ class Im2SequenceOp : public framework::OperatorWithKernel>::OperatorWithKernel; + using framework::OperatorWithKernel< + DeviceType, Im2SequenceParam, + operators::Im2SequenceKernel>::OperatorWithKernel; void InferShape() const override; private: diff --git a/src/operators/kernel/arm/dropout_kernel.cpp b/src/operators/kernel/arm/dropout_kernel.cpp index 32e2eeca8022be8e5c20c44ebd98e9b55530965d..868723be22361b660d24169faf9f001a59f503b2 100644 --- a/src/operators/kernel/arm/dropout_kernel.cpp +++ b/src/operators/kernel/arm/dropout_kernel.cpp @@ -22,9 +22,9 @@ namespace operators { template <> bool DropoutKernel::Init(const DropoutParam ¶) const { - return true; + return true; } - + template struct DropoutFunctor { inline T operator()(T in) const { return in; } diff --git a/src/operators/kernel/arm/im2sequence_kernel.cpp b/src/operators/kernel/arm/im2sequence_kernel.cpp index 254bfb8a5d5cc2e455f51ab032ba818b98cd466b..0a4873d4d8f501fc8975e5ed461c8e137771d339 100644 --- a/src/operators/kernel/arm/im2sequence_kernel.cpp +++ b/src/operators/kernel/arm/im2sequence_kernel.cpp @@ -21,7 +21,7 @@ template <> bool Im2SequenceKernel::Init(const Im2SequenceParam ¶) const { return true; } - + inline int Im2SeqOutputSize(int input_size, int filter_size, int padding_0, int padding_1, int stride) { const int output_size = diff --git a/src/operators/kernel/dropout_kernel.h b/src/operators/kernel/dropout_kernel.h index 98146fab73e1e5b5ba96925a9a956944318d8fca..42b914b175154c3300f2388e5ac1375536a5d747 100644 --- a/src/operators/kernel/dropout_kernel.h +++ b/src/operators/kernel/dropout_kernel.h @@ -24,7 +24,7 @@ template class DropoutKernel : public framework::OpKernelBase { public: void Compute(const DropoutParam& param) const; - bool Init(const DropoutParam ¶) const; + bool Init(const DropoutParam& para) const; }; } // namespace operators } // namespace paddle_mobile diff --git a/src/operators/op_param.h b/src/operators/op_param.h index f713199c7fe751a6f9dc529107a5af374a848f7c..c0f0fbc8a9939bc4609e64359835a685dd4c67f9 100644 --- a/src/operators/op_param.h +++ b/src/operators/op_param.h @@ -934,57 +934,57 @@ class FusionConvAddBNReluParam : public OpParam { Print &operator<<(Print &printer, const FusionConvAddParam &conv_param); #endif - - #ifdef IM2SEQUENCE_OP - class Im2SequenceParam : public OpParam { - public: - Im2SequenceParam(const VariableNameMap &inputs, - const VariableNameMap &outputs, const AttributeMap &attrs, - const Scope &scope) { - input_x_ = InputXFrom(inputs, scope); - out_ = OutFrom(outputs, scope); - kernels_ = GetAttr>("kernels", attrs); - strides_ = GetAttr>("strides", attrs); - paddings_ = GetAttr>("paddings", attrs); - } - - const Tensor *Input() const { return input_x_; } - - Tensor *Output() const { return out_; } - - const vector &Kernels() const { return kernels_; } - - const vector &Strides() const { return strides_; } - - const vector &Paddings() const { return paddings_; } - - private: - Tensor *input_x_; - Tensor *out_; - vector kernels_; - vector strides_; - vector paddings_; - }; + +#ifdef IM2SEQUENCE_OP +class Im2SequenceParam : public OpParam { + public: + Im2SequenceParam(const VariableNameMap &inputs, + const VariableNameMap &outputs, const AttributeMap &attrs, + const Scope &scope) { + input_x_ = InputXFrom(inputs, scope); + out_ = OutFrom(outputs, scope); + kernels_ = GetAttr>("kernels", attrs); + strides_ = GetAttr>("strides", attrs); + paddings_ = GetAttr>("paddings", attrs); + } + + const Tensor *Input() const { return input_x_; } + + Tensor *Output() const { return out_; } + + const vector &Kernels() const { return kernels_; } + + const vector &Strides() const { return strides_; } + + const vector &Paddings() const { return paddings_; } + + private: + Tensor *input_x_; + Tensor *out_; + vector kernels_; + vector strides_; + vector paddings_; +}; #endif - + #ifdef DROPOUT_OP - class DropoutParam : public OpParam { - public: - DropoutParam(const VariableNameMap &inputs, const VariableNameMap &outputs, - const AttributeMap &attrs, const Scope &scope) { - input_x_ = InputXFrom(inputs, scope); - out_ = OutFrom(outputs, scope); - } - - const Tensor *InputX() const { return input_x_; } - - Tensor *Out() const { return out_; } - - private: - Tensor *input_x_; - Tensor *out_; - }; +class DropoutParam : public OpParam { + public: + DropoutParam(const VariableNameMap &inputs, const VariableNameMap &outputs, + const AttributeMap &attrs, const Scope &scope) { + input_x_ = InputXFrom(inputs, scope); + out_ = OutFrom(outputs, scope); + } + + const Tensor *InputX() const { return input_x_; } + + Tensor *Out() const { return out_; } + + private: + Tensor *input_x_; + Tensor *out_; +}; #endif - + } // namespace operators } // namespace paddle_mobile