From 11eb4d6ff681e01fae6ca0dc6dc42878a671abbc Mon Sep 17 00:00:00 2001 From: "Yao,kun" Date: Mon, 2 Jul 2018 11:46:04 +0800 Subject: [PATCH] fix codestyle --- src/operators/dropout_op.h | 8 +- src/operators/im2sequence_op.h | 10 +- src/operators/kernel/arm/dropout_kernel.cpp | 4 +- .../kernel/arm/im2sequence_kernel.cpp | 2 +- src/operators/kernel/dropout_kernel.h | 2 +- src/operators/op_param.h | 98 +++++++++---------- 6 files changed, 63 insertions(+), 61 deletions(-) diff --git a/src/operators/dropout_op.h b/src/operators/dropout_op.h index d10008d37f..380071dba2 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 32e2eeca80..868723be22 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 254bfb8a5d..0a4873d4d8 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 98146fab73..42b914b175 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 f713199c7f..c0f0fbc8a9 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 -- GitLab