From e6302412505a7ea28cda31c2dfa7bcedf2918f6c Mon Sep 17 00:00:00 2001 From: liuruilong Date: Fri, 15 Jun 2018 19:38:29 +0800 Subject: [PATCH] format files --- src/framework/operator.h | 12 +++++------- src/operators/batchnorm_op.h | 10 ++++++---- src/operators/box_coder_op.h | 13 +++++++++---- src/operators/concat_op.h | 15 ++++++++++----- src/operators/conv_op.h | 13 +++++++++---- src/operators/depthwise_conv_op.h | 16 +++++++++++----- src/operators/elementwise_add_op.h | 16 +++++++++++----- src/operators/fusion_conv_add.h | 13 +++++++++---- src/operators/fusion_fc_op.h | 16 +++++++++++----- src/operators/kernel/arm/batchnorm_kernel.cpp | 2 +- src/operators/kernel/mali/conv_kernel.cpp | 4 ++-- src/operators/lrn_op.h | 13 +++++++++---- src/operators/mul_op.h | 12 ++++++++---- src/operators/multiclass_nms_op.h | 16 +++++++++++----- src/operators/pool_op.h | 11 ++++++++--- src/operators/prior_box_op.h | 13 +++++++++---- src/operators/relu_op.h | 13 +++++++++---- src/operators/reshape_op.h | 13 +++++++++---- src/operators/sigmoid_op.h | 13 +++++++++---- src/operators/softmax_op.h | 13 +++++++++---- src/operators/transpose_op.h | 16 +++++++++++----- 21 files changed, 176 insertions(+), 87 deletions(-) diff --git a/src/framework/operator.h b/src/framework/operator.h index 2b26264ddb..6ca0999f70 100644 --- a/src/framework/operator.h +++ b/src/framework/operator.h @@ -109,15 +109,15 @@ class OperatorWithKernel : public OperatorBase { OperatorWithKernel(const std::string &type, const VariableNameMap &inputs, const VariableNameMap &outputs, const AttributeMap &attrs, std::shared_ptr scope) - : OperatorBase(type, inputs, outputs, attrs, scope), param_(inputs, outputs, attrs, *scope){ + : OperatorBase(type, inputs, outputs, attrs, scope), + param_(inputs, outputs, attrs, *scope) { kernel_.Init(param_); } - virtual void RunImpl() const { - this->kernel_.Compute(this->param_); - } + virtual void RunImpl() const { this->kernel_.Compute(this->param_); } virtual void InferShape() const = 0; + protected: KernelType kernel_; ParamType param_; @@ -135,9 +135,7 @@ class OpKernelBase { * 所有结构体存在与: paddle-mobile/src/operators/op_param.h * */ virtual void Compute(const P ¶) const = 0; - virtual bool Init(const P ¶) const { - return true; - }; + virtual bool Init(const P ¶) const { return true; }; virtual ~OpKernelBase() = default; }; diff --git a/src/operators/batchnorm_op.h b/src/operators/batchnorm_op.h index 876103a689..9ee0b2dcf6 100644 --- a/src/operators/batchnorm_op.h +++ b/src/operators/batchnorm_op.h @@ -25,15 +25,17 @@ namespace paddle_mobile { namespace operators { using std::string; template -class BatchNormOp : public framework::OperatorWithKernel> { +class BatchNormOp + : public framework::OperatorWithKernel> { public: BatchNormOp(const string &type, const VariableNameMap &inputs, const VariableNameMap &outputs, const framework::AttributeMap &attrs, std::shared_ptr scope) - : framework::OperatorWithKernel>(type, inputs, outputs, attrs, - scope) { - } + : framework::OperatorWithKernel>( + type, inputs, outputs, attrs, scope) {} void InferShape() const override; diff --git a/src/operators/box_coder_op.h b/src/operators/box_coder_op.h index 1c6f706d77..33ff2358bc 100644 --- a/src/operators/box_coder_op.h +++ b/src/operators/box_coder_op.h @@ -28,16 +28,21 @@ namespace operators { using paddle_mobile::framework::Tensor; template -class BoxCoderOp : public framework::OperatorWithKernel> { +class BoxCoderOp + : public framework::OperatorWithKernel< + DeviceType, BoxCoderParam, operators::BoxCoderKernel> { public: BoxCoderOp(const std::string &type, const VariableNameMap &inputs, const VariableNameMap &outputs, const framework::AttributeMap &attrs, std::shared_ptr scope) - : framework::OperatorWithKernel>(type, inputs, outputs, attrs, - scope) {} + : framework::OperatorWithKernel>( + type, inputs, outputs, attrs, scope) {} - using framework::OperatorWithKernel>::OperatorWithKernel; + using framework::OperatorWithKernel< + DeviceType, BoxCoderParam, + operators::BoxCoderKernel>::OperatorWithKernel; void InferShape() const override; protected: diff --git a/src/operators/concat_op.h b/src/operators/concat_op.h index 974924b1f0..93612c6b1b 100644 --- a/src/operators/concat_op.h +++ b/src/operators/concat_op.h @@ -24,17 +24,22 @@ namespace paddle_mobile { namespace operators { using std::string; template -class ConcatOp : public framework::OperatorWithKernel> { +class ConcatOp + : public framework::OperatorWithKernel< + DeviceType, ConcatParam, operators::ConcatKernel> { public: ConcatOp(const string &type, const VariableNameMap &inputs, const VariableNameMap &outputs, const framework::AttributeMap &attrs, std::shared_ptr scope) - : framework::OperatorWithKernel>(type, inputs, outputs, attrs, - scope) { - } + : framework::OperatorWithKernel>( + type, inputs, outputs, attrs, scope) {} - using framework::OperatorWithKernel>::OperatorWithKernel; + using framework::OperatorWithKernel< + DeviceType, ConcatParam, + operators::ConcatKernel>::OperatorWithKernel; void InferShape() const override; + protected: }; diff --git a/src/operators/conv_op.h b/src/operators/conv_op.h index 406d54b86e..fe723c574e 100644 --- a/src/operators/conv_op.h +++ b/src/operators/conv_op.h @@ -24,15 +24,20 @@ namespace paddle_mobile { namespace operators { using std::string; template -class ConvOp : public framework::OperatorWithKernel> { +class ConvOp + : public framework::OperatorWithKernel< + DeviceType, ConvParam, operators::ConvKernel> { public: ConvOp(const std::string &type, const VariableNameMap &inputs, const VariableNameMap &outputs, const framework::AttributeMap &attrs, std::shared_ptr scope) - : framework::OperatorWithKernel>(type, inputs, outputs, attrs, - scope){} + : framework::OperatorWithKernel>( + type, inputs, outputs, attrs, scope) {} - using framework::OperatorWithKernel>::OperatorWithKernel; + using framework::OperatorWithKernel< + DeviceType, ConvParam, + operators::ConvKernel>::OperatorWithKernel; void InferShape() const override; private: diff --git a/src/operators/depthwise_conv_op.h b/src/operators/depthwise_conv_op.h index 6534aba525..75bcf44cb8 100644 --- a/src/operators/depthwise_conv_op.h +++ b/src/operators/depthwise_conv_op.h @@ -24,16 +24,22 @@ namespace paddle_mobile { namespace operators { template -class DepthwiseConvOp : public framework::OperatorWithKernel> { +class DepthwiseConvOp : public framework::OperatorWithKernel< + DeviceType, ConvParam, + operators::DepthwiseConvKernel> { public: DepthwiseConvOp(const std::string &type, const VariableNameMap &inputs, const VariableNameMap &outputs, const framework::AttributeMap &attrs, std::shared_ptr scope) - : framework::OperatorWithKernel>(type, inputs, outputs, attrs, - scope) {} - - using framework::OperatorWithKernel>::OperatorWithKernel; + : framework::OperatorWithKernel< + DeviceType, ConvParam, + operators::DepthwiseConvKernel>( + type, inputs, outputs, attrs, scope) {} + + using framework::OperatorWithKernel< + DeviceType, ConvParam, + operators::DepthwiseConvKernel>::OperatorWithKernel; void InferShape() const override; private: diff --git a/src/operators/elementwise_add_op.h b/src/operators/elementwise_add_op.h index f3820db12c..6cb80d06d0 100644 --- a/src/operators/elementwise_add_op.h +++ b/src/operators/elementwise_add_op.h @@ -25,16 +25,22 @@ namespace paddle_mobile { namespace operators { using std::string; template -class ElementwiseAddOp : public framework::OperatorWithKernel> { +class ElementwiseAddOp : public framework::OperatorWithKernel< + DeviceType, ElementwiseAddParam, + operators::ElementwiseAddKernel> { public: ElementwiseAddOp(const string &type, const VariableNameMap &inputs, const VariableNameMap &outputs, const framework::AttributeMap &attrs, std::shared_ptr scope) - : framework::OperatorWithKernel>(type, inputs, outputs, attrs, - scope) {} - - using framework::OperatorWithKernel>::OperatorWithKernel; + : framework::OperatorWithKernel< + DeviceType, ElementwiseAddParam, + operators::ElementwiseAddKernel>( + type, inputs, outputs, attrs, scope) {} + + using framework::OperatorWithKernel< + DeviceType, ElementwiseAddParam, + operators::ElementwiseAddKernel>::OperatorWithKernel; void InferShape() const override; protected: diff --git a/src/operators/fusion_conv_add.h b/src/operators/fusion_conv_add.h index 1b9b85c9c9..56ce40a53f 100644 --- a/src/operators/fusion_conv_add.h +++ b/src/operators/fusion_conv_add.h @@ -47,16 +47,21 @@ class FusionConvAddMatcher : public framework::FusionOpMatcher { }; template -class FushionConvAddOp : public framework::OperatorWithKernel> { +class FushionConvAddOp : public framework::OperatorWithKernel< + DeviceType, FushionConvAddParam, + operators::ConvAddKernel> { public: FushionConvAddOp(const string &type, const VariableNameMap &inputs, const VariableNameMap &outputs, const framework::AttributeMap &attrs, std::shared_ptr scope) - : framework::OperatorWithKernel>(type, inputs, outputs, attrs, - scope) {} + : framework::OperatorWithKernel>( + type, inputs, outputs, attrs, scope) {} - using framework::OperatorWithKernel>::OperatorWithKernel; + using framework::OperatorWithKernel< + DeviceType, FushionConvAddParam, + operators::ConvAddKernel>::OperatorWithKernel; void InferShape() const override; protected: diff --git a/src/operators/fusion_fc_op.h b/src/operators/fusion_fc_op.h index cf2efa3f60..fbdad1e79c 100644 --- a/src/operators/fusion_fc_op.h +++ b/src/operators/fusion_fc_op.h @@ -45,16 +45,22 @@ class FusionFcMatcher : public framework::FusionOpMatcher { }; template -class FushionFcOp : public framework::OperatorWithKernel> { +class FushionFcOp : public framework::OperatorWithKernel< + DeviceType, FushionFcParam, + operators::FushionFcKernel> { public: FushionFcOp(const string &type, const VariableNameMap &inputs, const VariableNameMap &outputs, const framework::AttributeMap &attrs, std::shared_ptr scope) - : framework::OperatorWithKernel>(type, inputs, outputs, attrs, - scope) {} - - using framework::OperatorWithKernel>::OperatorWithKernel; + : framework::OperatorWithKernel< + DeviceType, FushionFcParam, + operators::FushionFcKernel>(type, inputs, outputs, + attrs, scope) {} + + using framework::OperatorWithKernel< + DeviceType, FushionFcParam, + operators::FushionFcKernel>::OperatorWithKernel; void InferShape() const override; protected: diff --git a/src/operators/kernel/arm/batchnorm_kernel.cpp b/src/operators/kernel/arm/batchnorm_kernel.cpp index 4103ef6dcd..cb30fb41e9 100644 --- a/src/operators/kernel/arm/batchnorm_kernel.cpp +++ b/src/operators/kernel/arm/batchnorm_kernel.cpp @@ -61,7 +61,7 @@ void BatchNormKernel::Compute(const BatchNormParam ¶m) const { /// std = (var + epsilon).sqrt(); /// inv_std = 1 / std; for (int i = 0; i < C * 4; i += 4) { - int index = i/4; + int index = i / 4; inv_std_ptr[i] = 1 / static_cast(pow((variance_ptr[index] + epsilon), 0.5)); inv_std_ptr[i + 1] = inv_std_ptr[i]; diff --git a/src/operators/kernel/mali/conv_kernel.cpp b/src/operators/kernel/mali/conv_kernel.cpp index 266fde69d8..6c140145e9 100644 --- a/src/operators/kernel/mali/conv_kernel.cpp +++ b/src/operators/kernel/mali/conv_kernel.cpp @@ -21,8 +21,8 @@ namespace operators { template <> void ConvKernel::Compute(const ConvParam ¶m) const { -// ArmConvImplement imp; -// imp.Compute(param); + // ArmConvImplement imp; + // imp.Compute(param); } template class ConvKernel; diff --git a/src/operators/lrn_op.h b/src/operators/lrn_op.h index 3e84bebb93..d67b9f6be7 100644 --- a/src/operators/lrn_op.h +++ b/src/operators/lrn_op.h @@ -25,16 +25,21 @@ namespace paddle_mobile { namespace operators { using std::string; template -class LrnOp : public framework::OperatorWithKernel> { +class LrnOp : public framework::OperatorWithKernel< + DeviceType, LrnParam, operators::LrnKernel> { public: LrnOp(const string &type, const VariableNameMap &inputs, const VariableNameMap &outputs, const framework::AttributeMap &attrs, std::shared_ptr scope) - : framework::OperatorWithKernel>(type, inputs, outputs, attrs, - scope) {} + : framework::OperatorWithKernel>( + type, inputs, outputs, attrs, scope) {} - using framework::OperatorWithKernel>::OperatorWithKernel; + using framework::OperatorWithKernel< + DeviceType, LrnParam, + operators::LrnKernel>::OperatorWithKernel; void InferShape() const override; + protected: }; diff --git a/src/operators/mul_op.h b/src/operators/mul_op.h index 08bda2a74b..ad5c9a3702 100644 --- a/src/operators/mul_op.h +++ b/src/operators/mul_op.h @@ -25,15 +25,19 @@ namespace paddle_mobile { namespace operators { template -class MulOp : public framework::OperatorWithKernel> { +class MulOp : public framework::OperatorWithKernel< + DeviceType, MulParam, operators::MulKernel> { public: MulOp(const std::string &type, const VariableNameMap &inputs, const VariableNameMap &outputs, const framework::AttributeMap &attrs, std::shared_ptr scope) - : framework::OperatorWithKernel>(type, inputs, outputs, attrs, - scope) {} + : framework::OperatorWithKernel>( + type, inputs, outputs, attrs, scope) {} - using framework::OperatorWithKernel>::OperatorWithKernel; + using framework::OperatorWithKernel< + DeviceType, MulParam, + operators::MulKernel>::OperatorWithKernel; void InferShape() const override; protected: diff --git a/src/operators/multiclass_nms_op.h b/src/operators/multiclass_nms_op.h index 2d65657c8d..30cf8f6794 100644 --- a/src/operators/multiclass_nms_op.h +++ b/src/operators/multiclass_nms_op.h @@ -28,16 +28,22 @@ namespace operators { using paddle_mobile::framework::Tensor; template -class MultiClassNMSOp : public framework::OperatorWithKernel> { +class MultiClassNMSOp : public framework::OperatorWithKernel< + DeviceType, MultiClassNMSParam, + operators::MultiClassNMSKernel> { public: MultiClassNMSOp(const std::string &type, const VariableNameMap &inputs, const VariableNameMap &outputs, const framework::AttributeMap &attrs, std::shared_ptr scope) - : framework::OperatorWithKernel>(type, inputs, outputs, attrs, - scope) {} - - using framework::OperatorWithKernel>::OperatorWithKernel; + : framework::OperatorWithKernel< + DeviceType, MultiClassNMSParam, + operators::MultiClassNMSKernel>( + type, inputs, outputs, attrs, scope) {} + + using framework::OperatorWithKernel< + DeviceType, MultiClassNMSParam, + operators::MultiClassNMSKernel>::OperatorWithKernel; void InferShape() const override; protected: diff --git a/src/operators/pool_op.h b/src/operators/pool_op.h index b9d679963c..5b436fb18b 100644 --- a/src/operators/pool_op.h +++ b/src/operators/pool_op.h @@ -29,13 +29,18 @@ using framework::OperatorWithKernel; using framework::Scope; using std::string; template -class PoolOp : public OperatorWithKernel> { +class PoolOp : public OperatorWithKernel> { public: PoolOp(const string &type, const VariableNameMap &inputs, const VariableNameMap &outputs, const AttributeMap &attrs, std::shared_ptr scope) - : OperatorWithKernel>(type, inputs, outputs, attrs, scope) {} - using OperatorWithKernel>::OperatorWithKernel; + : OperatorWithKernel>( + type, inputs, outputs, attrs, scope) {} + using OperatorWithKernel< + DeviceType, PoolParam, + operators::PoolKernel>::OperatorWithKernel; void InferShape() const override; private: diff --git a/src/operators/prior_box_op.h b/src/operators/prior_box_op.h index ad6b901041..5b3e3fffd6 100644 --- a/src/operators/prior_box_op.h +++ b/src/operators/prior_box_op.h @@ -28,16 +28,21 @@ namespace operators { using paddle_mobile::framework::Tensor; template -class PriorBoxOp : public framework::OperatorWithKernel> { +class PriorBoxOp + : public framework::OperatorWithKernel< + DeviceType, PriorBoxParam, operators::PriorBoxKernel> { public: PriorBoxOp(const std::string &type, const VariableNameMap &inputs, const VariableNameMap &outputs, const framework::AttributeMap &attrs, std::shared_ptr scope) - : framework::OperatorWithKernel>(type, inputs, outputs, attrs, - scope) {} + : framework::OperatorWithKernel>( + type, inputs, outputs, attrs, scope) {} - using framework::OperatorWithKernel>::OperatorWithKernel; + using framework::OperatorWithKernel< + DeviceType, PriorBoxParam, + operators::PriorBoxKernel>::OperatorWithKernel; void InferShape() const override; protected: diff --git a/src/operators/relu_op.h b/src/operators/relu_op.h index d8bfc8a5ec..8f9e55cf8a 100644 --- a/src/operators/relu_op.h +++ b/src/operators/relu_op.h @@ -28,7 +28,9 @@ namespace operators { using paddle_mobile::framework::Tensor; template -class ReluOp : public framework::OperatorWithKernel> { +class ReluOp + : public framework::OperatorWithKernel< + DeviceType, ReluParam, operators::ReluKernel> { public: /* * @b op 的实例化方法, 需要调用父类的实例化方法, 以及实例化自己的参数结构体 @@ -36,10 +38,13 @@ class ReluOp : public framework::OperatorWithKernel scope) - : framework::OperatorWithKernel>(type, inputs, outputs, attrs, - scope) {} + : framework::OperatorWithKernel>( + type, inputs, outputs, attrs, scope) {} - using framework::OperatorWithKernel>::OperatorWithKernel; + using framework::OperatorWithKernel< + DeviceType, ReluParam, + operators::ReluKernel>::OperatorWithKernel; void InferShape() const override; protected: diff --git a/src/operators/reshape_op.h b/src/operators/reshape_op.h index 46451fbda3..90d3115313 100644 --- a/src/operators/reshape_op.h +++ b/src/operators/reshape_op.h @@ -28,16 +28,21 @@ namespace operators { using paddle_mobile::framework::Tensor; template -class ReshapeOp : public framework::OperatorWithKernel> { +class ReshapeOp + : public framework::OperatorWithKernel< + DeviceType, ReshapeParam, operators::ReshapeKernel> { public: ReshapeOp(const std::string &type, const VariableNameMap &inputs, const VariableNameMap &outputs, const framework::AttributeMap &attrs, std::shared_ptr scope) - : framework::OperatorWithKernel>(type, inputs, outputs, attrs, - scope) {} + : framework::OperatorWithKernel>( + type, inputs, outputs, attrs, scope) {} - using framework::OperatorWithKernel>::OperatorWithKernel; + using framework::OperatorWithKernel< + DeviceType, ReshapeParam, + operators::ReshapeKernel>::OperatorWithKernel; void InferShape() const override; protected: diff --git a/src/operators/sigmoid_op.h b/src/operators/sigmoid_op.h index 77aff2efaf..bd914a6378 100644 --- a/src/operators/sigmoid_op.h +++ b/src/operators/sigmoid_op.h @@ -25,16 +25,21 @@ limitations under the License. */ namespace paddle_mobile { namespace operators { template -class SigmoidOp : public framework::OperatorWithKernel> { +class SigmoidOp + : public framework::OperatorWithKernel< + DeviceType, SigmoidParam, operators::SigmoidKernel> { public: SigmoidOp(const std::string &type, const VariableNameMap &inputs, const VariableNameMap &outputs, const framework::AttributeMap &attrs, std::shared_ptr scope) - : framework::OperatorWithKernel>(type, inputs, outputs, attrs, - scope) {} + : framework::OperatorWithKernel>( + type, inputs, outputs, attrs, scope) {} - using framework::OperatorWithKernel>::OperatorWithKernel; + using framework::OperatorWithKernel< + DeviceType, SigmoidParam, + operators::SigmoidKernel>::OperatorWithKernel; void InferShape() const override; }; diff --git a/src/operators/softmax_op.h b/src/operators/softmax_op.h index 7bf0bdb4ca..1445ca055e 100644 --- a/src/operators/softmax_op.h +++ b/src/operators/softmax_op.h @@ -25,16 +25,21 @@ limitations under the License. */ namespace paddle_mobile { namespace operators { template -class SoftmaxOp : public framework::OperatorWithKernel> { +class SoftmaxOp + : public framework::OperatorWithKernel< + DeviceType, SoftmaxParam, operators::SoftmaxKernel> { public: SoftmaxOp(const std::string &type, const VariableNameMap &inputs, const VariableNameMap &outputs, const framework::AttributeMap &attrs, std::shared_ptr scope) - : framework::OperatorWithKernel>(type, inputs, outputs, attrs, - scope) {} + : framework::OperatorWithKernel>( + type, inputs, outputs, attrs, scope) {} - using framework::OperatorWithKernel>::OperatorWithKernel; + using framework::OperatorWithKernel< + DeviceType, SoftmaxParam, + operators::SoftmaxKernel>::OperatorWithKernel; void InferShape() const override; diff --git a/src/operators/transpose_op.h b/src/operators/transpose_op.h index bfed556522..349220b58f 100644 --- a/src/operators/transpose_op.h +++ b/src/operators/transpose_op.h @@ -28,16 +28,22 @@ namespace operators { using paddle_mobile::framework::Tensor; template -class TransposeOp : public framework::OperatorWithKernel> { +class TransposeOp : public framework::OperatorWithKernel< + DeviceType, TransposeParam, + operators::TransposeKernel> { public: TransposeOp(const std::string &type, const VariableNameMap &inputs, const VariableNameMap &outputs, const framework::AttributeMap &attrs, std::shared_ptr scope) - : framework::OperatorWithKernel>(type, inputs, outputs, attrs, - scope) {} - - using framework::OperatorWithKernel>::OperatorWithKernel; + : framework::OperatorWithKernel< + DeviceType, TransposeParam, + operators::TransposeKernel>(type, inputs, outputs, + attrs, scope) {} + + using framework::OperatorWithKernel< + DeviceType, TransposeParam, + operators::TransposeKernel>::OperatorWithKernel; void InferShape() const override; }; -- GitLab