From: 박종현/동작제어Lab(SR)/Staff Engineer/삼성전자 Date: Thu, 13 Sep 2018 01:34:20 +0000 (+0900) Subject: [caffegen] Enable format check (#1481) X-Git-Tag: nncc_backup~1827 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=ef7be034d4d7e8032af506d89060a4279fa0e8e3;p=platform%2Fcore%2Fml%2Fnnfw.git [caffegen] Enable format check (#1481) This commit enables format check over caffegen code, and fixes existing format errors. Signed-off-by: Jonghyun Park --- diff --git a/contrib/caffegen/.FORMATCHECKED b/contrib/caffegen/.FORMATCHECKED new file mode 100644 index 0000000..e69de29 diff --git a/contrib/caffegen/include/internal/BlobShape.h b/contrib/caffegen/include/internal/BlobShape.h index 794f341..94bacc4 100644 --- a/contrib/caffegen/include/internal/BlobShape.h +++ b/contrib/caffegen/include/internal/BlobShape.h @@ -11,8 +11,8 @@ public: public: BlobShape &resize(uint32_t size) - { - _dims.resize(size); + { + _dims.resize(size); return (*this); } diff --git a/contrib/caffegen/include/internal/ConvolutionLayer.h b/contrib/caffegen/include/internal/ConvolutionLayer.h index daaac1b..aa612b9 100644 --- a/contrib/caffegen/include/internal/ConvolutionLayer.h +++ b/contrib/caffegen/include/internal/ConvolutionLayer.h @@ -32,15 +32,9 @@ public: caffe::LayerParameter ¶m(void) { return *_param; } public: - caffe::ConvolutionParameter &conv_param(void) - { - return *param().mutable_convolution_param(); - } + caffe::ConvolutionParameter &conv_param(void) { return *param().mutable_convolution_param(); } - const caffe::ConvolutionParameter &conv_param(void) const - { - return param().convolution_param(); - } + const caffe::ConvolutionParameter &conv_param(void) const { return param().convolution_param(); } public: const std::string &input_name(void) const; @@ -65,8 +59,8 @@ public: uint32_t dilation(uint32_t spatial_axe) const; private: - const Network * const _net; - caffe::LayerParameter * const _param; + const Network *const _net; + caffe::LayerParameter *const _param; }; #endif // __CONVOLUTION_LAYER_H__ diff --git a/contrib/caffegen/include/internal/InputLayer.h b/contrib/caffegen/include/internal/InputLayer.h index 6523cbe..3738c00 100644 --- a/contrib/caffegen/include/internal/InputLayer.h +++ b/contrib/caffegen/include/internal/InputLayer.h @@ -32,7 +32,7 @@ public: caffe::LayerParameter ¶m(void) { return *_param; } private: - caffe::LayerParameter * const _param; + caffe::LayerParameter *const _param; }; #endif // __INPUT_LAYER_H__ diff --git a/contrib/caffegen/src/DecodeCommand.cpp b/contrib/caffegen/src/DecodeCommand.cpp index 90f5df8..b977874 100644 --- a/contrib/caffegen/src/DecodeCommand.cpp +++ b/contrib/caffegen/src/DecodeCommand.cpp @@ -8,7 +8,7 @@ #include -int DecodeCommand::run(int, const char * const *) const +int DecodeCommand::run(int, const char *const *) const { caffe::NetParameter param; diff --git a/contrib/caffegen/src/DecodeCommand.h b/contrib/caffegen/src/DecodeCommand.h index 284059e..7db9d60 100644 --- a/contrib/caffegen/src/DecodeCommand.h +++ b/contrib/caffegen/src/DecodeCommand.h @@ -5,7 +5,7 @@ struct DecodeCommand final : public cli::Command { - int run(int argc, const char * const *argv) const override; + int run(int argc, const char *const *argv) const override; }; #endif // __DECODE_COMMAND_H__ diff --git a/contrib/caffegen/src/EncodeCommand.cpp b/contrib/caffegen/src/EncodeCommand.cpp index 3066f4c..d815d3f 100644 --- a/contrib/caffegen/src/EncodeCommand.cpp +++ b/contrib/caffegen/src/EncodeCommand.cpp @@ -8,7 +8,7 @@ #include -int EncodeCommand::run(int, const char * const *) const +int EncodeCommand::run(int, const char *const *) const { caffe::NetParameter param; diff --git a/contrib/caffegen/src/EncodeCommand.h b/contrib/caffegen/src/EncodeCommand.h index d1daa8a..854efb8 100644 --- a/contrib/caffegen/src/EncodeCommand.h +++ b/contrib/caffegen/src/EncodeCommand.h @@ -5,7 +5,7 @@ struct EncodeCommand final : public cli::Command { - int run(int argc, const char * const *argv) const override; + int run(int argc, const char *const *argv) const override; }; #endif // __ENCODE_COMMAND_H__ diff --git a/contrib/caffegen/src/FillCommand.cpp b/contrib/caffegen/src/FillCommand.cpp index 4043ff8..eb7d236 100644 --- a/contrib/caffegen/src/FillCommand.cpp +++ b/contrib/caffegen/src/FillCommand.cpp @@ -15,7 +15,7 @@ #include #include -int FillCommand::run(int, const char * const *) const +int FillCommand::run(int, const char *const *) const { auto param = nncc::foundation::make_unique<::caffe::NetParameter>(); diff --git a/contrib/caffegen/src/FillCommand.h b/contrib/caffegen/src/FillCommand.h index 38f127b..2b2f0dd 100644 --- a/contrib/caffegen/src/FillCommand.h +++ b/contrib/caffegen/src/FillCommand.h @@ -5,7 +5,7 @@ struct FillCommand final : public cli::Command { - int run(int argc, const char * const *argv) const override; + int run(int argc, const char *const *argv) const override; }; #endif // __FILL_COMMAND_H__ diff --git a/contrib/caffegen/src/InitCommand.cpp b/contrib/caffegen/src/InitCommand.cpp index 184c7d2..a1cabc9 100644 --- a/contrib/caffegen/src/InitCommand.cpp +++ b/contrib/caffegen/src/InitCommand.cpp @@ -10,7 +10,7 @@ #include -int InitCommand::run(int, const char * const *) const +int InitCommand::run(int, const char *const *) const { // Read prototxt from standard input ::caffe::NetParameter in; diff --git a/contrib/caffegen/src/InitCommand.h b/contrib/caffegen/src/InitCommand.h index 1334239..a97fbe4 100644 --- a/contrib/caffegen/src/InitCommand.h +++ b/contrib/caffegen/src/InitCommand.h @@ -5,7 +5,7 @@ struct InitCommand final : public cli::Command { - int run(int argc, const char * const *argv) const override; + int run(int argc, const char *const *argv) const override; }; #endif // __INIT_COMMAND_H__ diff --git a/contrib/caffegen/src/MergeCommand.cpp b/contrib/caffegen/src/MergeCommand.cpp index 58cc026..47eb64e 100644 --- a/contrib/caffegen/src/MergeCommand.cpp +++ b/contrib/caffegen/src/MergeCommand.cpp @@ -13,7 +13,8 @@ int MergeCommand::run(int argc, const char *const *argv) const { - if (argc != 2) { + if (argc != 2) + { std::cerr << "ERROR: this command requires exactly 2 arguments" << std::endl; return 254; } diff --git a/contrib/caffegen/src/MergeCommand.h b/contrib/caffegen/src/MergeCommand.h index 9ded07b..9add249 100644 --- a/contrib/caffegen/src/MergeCommand.h +++ b/contrib/caffegen/src/MergeCommand.h @@ -11,7 +11,7 @@ */ struct MergeCommand final : public cli::Command { - int run(int argc, const char * const *argv) const override; + int run(int argc, const char *const *argv) const override; }; #endif //__MERGE_COMMAND_H__ diff --git a/contrib/caffegen/src/internal/BlobContext.cpp b/contrib/caffegen/src/internal/BlobContext.cpp index a4b4a20..545ee19 100644 --- a/contrib/caffegen/src/internal/BlobContext.cpp +++ b/contrib/caffegen/src/internal/BlobContext.cpp @@ -1,9 +1,6 @@ #include "internal/BlobContext.h" -const BlobShape &BlobContext::at(const std::string &name) const -{ - return _shapes.at(name); -} +const BlobShape &BlobContext::at(const std::string &name) const { return _shapes.at(name); } BlobContext &BlobContext::insert(const std::string &name, const BlobShape &shape) { diff --git a/contrib/caffegen/src/internal/ConvolutionLayer.cpp b/contrib/caffegen/src/internal/ConvolutionLayer.cpp index ceb17a3..85223c6 100644 --- a/contrib/caffegen/src/internal/ConvolutionLayer.cpp +++ b/contrib/caffegen/src/internal/ConvolutionLayer.cpp @@ -93,25 +93,18 @@ BlobShape ConvolutionLayer::output_shape(void) const for (uint32_t spatial_axis = 0; spatial_axis < num_spatial_axes(); ++spatial_axis) { const uint32_t axis = num_batch_axes() + 1 + spatial_axis; - const int64_t kernel_ext = - dilation(spatial_axis) * (kernel_size(spatial_axis) - 1) + 1; + const int64_t kernel_ext = dilation(spatial_axis) * (kernel_size(spatial_axis) - 1) + 1; res.dim(axis) = - (input_shape().dim(axis) + 2 * pad(spatial_axis) - kernel_ext) / stride(spatial_axis); + (input_shape().dim(axis) + 2 * pad(spatial_axis) - kernel_ext) / stride(spatial_axis); } return res; } -uint32_t ConvolutionLayer::channel_axis(void) const -{ - return conv_param().axis(); -} +uint32_t ConvolutionLayer::channel_axis(void) const { return conv_param().axis(); } -uint32_t ConvolutionLayer::num_effective_output(void) const -{ - return conv_param().num_output(); -} +uint32_t ConvolutionLayer::num_effective_output(void) const { return conv_param().num_output(); } uint32_t ConvolutionLayer::num_spatial_axes(void) const { @@ -124,10 +117,7 @@ uint32_t ConvolutionLayer::num_batch_axes(void) const return input_shape().rank() - num_spatial_axes() - 1; } -uint32_t ConvolutionLayer::pad(uint32_t /*spatial_axis*/) const -{ - return conv_param().pad(0); -} +uint32_t ConvolutionLayer::pad(uint32_t /*spatial_axis*/) const { return conv_param().pad(0); } uint32_t ConvolutionLayer::kernel_size(uint32_t /*spatial_axis*/) const { @@ -139,7 +129,4 @@ uint32_t ConvolutionLayer::stride(uint32_t /*spatial_axis*/) const return conv_param().stride(0); } -uint32_t ConvolutionLayer::dilation(uint32_t /*spatial_axis*/) const -{ - return 1; -} +uint32_t ConvolutionLayer::dilation(uint32_t /*spatial_axis*/) const { return 1; } diff --git a/contrib/caffegen/src/internal/InputLayer.cpp b/contrib/caffegen/src/internal/InputLayer.cpp index e19e05e..655fc5e 100644 --- a/contrib/caffegen/src/internal/InputLayer.cpp +++ b/contrib/caffegen/src/internal/InputLayer.cpp @@ -14,15 +14,9 @@ InputLayer::InputLayer(const Network *, caffe::LayerParameter *p) : _param{p} uint32_t InputLayer::bottom_size(void) const { return 0; } -const std::string &InputLayer::bottom_name(uint32_t) const -{ - throw std::invalid_argument{"n"}; -} +const std::string &InputLayer::bottom_name(uint32_t) const { throw std::invalid_argument{"n"}; } -const BlobShape &InputLayer::bottom_shape(uint32_t) const -{ - throw std::invalid_argument{"n"}; -} +const BlobShape &InputLayer::bottom_shape(uint32_t) const { throw std::invalid_argument{"n"}; } uint32_t InputLayer::top_size(void) const { return param().top_size(); } diff --git a/contrib/caffegen/src/internal/LayerResolver.cpp b/contrib/caffegen/src/internal/LayerResolver.cpp index e3690a5..3e392ff 100644 --- a/contrib/caffegen/src/internal/LayerResolver.cpp +++ b/contrib/caffegen/src/internal/LayerResolver.cpp @@ -4,7 +4,7 @@ #include -template std::shared_ptr make_factory(void) +template std::shared_ptr make_factory(void) { struct LayerFactoryImpl final : public LayerFactory { diff --git a/contrib/caffegen/src/internal/ParameterRandomizePass.cpp b/contrib/caffegen/src/internal/ParameterRandomizePass.cpp index 9130379..6b0b3e6 100644 --- a/contrib/caffegen/src/internal/ParameterRandomizePass.cpp +++ b/contrib/caffegen/src/internal/ParameterRandomizePass.cpp @@ -22,8 +22,7 @@ void ParameterRandomizePass::visit(ConvolutionLayer &l) caffe::ConvolutionParameter *conv_param = l.param().mutable_convolution_param(); - auto element_count = [] (caffe::BlobShape &shape) - { + auto element_count = [](caffe::BlobShape &shape) { assert(shape.dim_size() > 0); int64_t count = 1;