From 8843ab7ad7be339f70de4da779e75683bc589fbf Mon Sep 17 00:00:00 2001 From: =?utf8?q?=EC=9D=B4=ED=95=9C=EC=A2=85/=EB=8F=99=EC=9E=91=EC=A0=9C?= =?utf8?q?=EC=96=B4Lab=28SR=29/Engineer/=EC=82=BC=EC=84=B1=EC=A0=84?= =?utf8?q?=EC=9E=90?= Date: Thu, 30 Aug 2018 16:51:27 +0900 Subject: [PATCH] [neurun] Enable compile option Wall/Wextra/Werror (#2517) To keep our code clean, let us introduce those compile options. - Wall : Enable most(not exactly all) of compiler warnings - Wextra : Enable extra compiler warnings - Werror : Treat warnings as error Signed-off-by: Hanjoung Lee --- include/util/feature/IndexIterator.h | 8 ++++---- runtimes/neurun/CMakeLists.txt | 2 ++ runtimes/neurun/src/codegen/Planner.cc | 4 +--- runtimes/neurun/src/frontend/compilation.cc | 2 +- runtimes/neurun/src/frontend/execution.cc | 26 ++++++++++++++------------ runtimes/neurun/src/graph/operand/Set.cc | 2 +- runtimes/neurun/src/internal/Sink.h | 1 + runtimes/neurun/src/internal/Source.h | 1 + 8 files changed, 25 insertions(+), 21 deletions(-) diff --git a/include/util/feature/IndexIterator.h b/include/util/feature/IndexIterator.h index f076b38..e2a7196 100644 --- a/include/util/feature/IndexIterator.h +++ b/include/util/feature/IndexIterator.h @@ -37,13 +37,13 @@ public: public: template IndexIterator &iter(Callable cb) { - for (uint32_t batch = 0; batch < _shape.N; ++batch) + for (int32_t batch = 0; batch < _shape.N; ++batch) { - for (uint32_t ch = 0; ch < _shape.C; ++ch) + for (int32_t ch = 0; ch < _shape.C; ++ch) { - for (uint32_t row = 0; row < _shape.H; ++row) + for (int32_t row = 0; row < _shape.H; ++row) { - for (uint32_t col = 0; col < _shape.W; ++col) + for (int32_t col = 0; col < _shape.W; ++col) { cb(batch, ch, row, col); } diff --git a/runtimes/neurun/CMakeLists.txt b/runtimes/neurun/CMakeLists.txt index 3dc0d03..ebdfcad 100644 --- a/runtimes/neurun/CMakeLists.txt +++ b/runtimes/neurun/CMakeLists.txt @@ -39,6 +39,8 @@ target_link_libraries(${LIB_NEURUN} nnfw_support_nnapi) target_link_libraries(${LIB_NEURUN} ${LIB_NEURUN_BACKEND_CPU}) target_link_libraries(${LIB_NEURUN} ${LIB_NEURUN_BACKEND_ACL_CL}) +target_compile_options(${LIB_NEURUN} PRIVATE -Wall -Wextra -Werror) + set_target_properties(${LIB_NEURUN} PROPERTIES OUTPUT_NAME neuralnetworks) install(TARGETS ${LIB_NEURUN} DESTINATION lib/neurun) diff --git a/runtimes/neurun/src/codegen/Planner.cc b/runtimes/neurun/src/codegen/Planner.cc index 526b5b6..0e7f8c4 100644 --- a/runtimes/neurun/src/codegen/Planner.cc +++ b/runtimes/neurun/src/codegen/Planner.cc @@ -92,8 +92,6 @@ void Planner::visit(const graph::operation::Concat::Node &node) _builder.addShapeConstr(ofm_index, ::internal::asTensorInfo(ofm_shape)); // Set Shape Constraints (for input) - uint32_t depth = 0; - for (const auto &index : node.getInputs().list()) { const ::neurun::graph::operand::Index ifm_index{index}; @@ -204,7 +202,7 @@ void Planner::visit(const graph::operation::Softmax::Node &node) _builder.addStage(stage_gen->generate(node)); } -void Planner::visit(const graph::operation::NOP::Node &node) +void Planner::visit(const graph::operation::NOP::Node & /* node */) { // DO NOTHING // TODO : It's just for graph manipulation test now, it should be added tensor copy stage later. diff --git a/runtimes/neurun/src/frontend/compilation.cc b/runtimes/neurun/src/frontend/compilation.cc index af14604..9f3a986 100644 --- a/runtimes/neurun/src/frontend/compilation.cc +++ b/runtimes/neurun/src/frontend/compilation.cc @@ -45,7 +45,7 @@ void ANeuralNetworksCompilation_free(ANeuralNetworksCompilation *compilation) } int ANeuralNetworksCompilation_setPreference(ANeuralNetworksCompilation *compilation, - int32_t preference) + int32_t /* preference */) { if (compilation == nullptr) { diff --git a/runtimes/neurun/src/frontend/execution.cc b/runtimes/neurun/src/frontend/execution.cc index eb34203..98c502f 100644 --- a/runtimes/neurun/src/frontend/execution.cc +++ b/runtimes/neurun/src/frontend/execution.cc @@ -34,8 +34,8 @@ int ANeuralNetworksExecution_create(ANeuralNetworksCompilation *compilation, } int ANeuralNetworksExecution_setInput(ANeuralNetworksExecution *execution, int32_t index, - const ANeuralNetworksOperandType *type, const void *buffer, - size_t length) + const ANeuralNetworksOperandType * /* type */, + const void *buffer, size_t length) { // Don't check type // Comment about ANeuralNetworksOperandType in NeuralNetworks.h: @@ -80,7 +80,7 @@ int ANeuralNetworksExecution_setInput(ANeuralNetworksExecution *execution, int32 } int ANeuralNetworksExecution_setOutput(ANeuralNetworksExecution *execution, int32_t index, - const ANeuralNetworksOperandType *type, void *buffer, + const ANeuralNetworksOperandType * /* type */, void *buffer, size_t length) { // Don't check type @@ -184,12 +184,13 @@ int ANeuralNetworksExecution_startCompute(ANeuralNetworksExecution *execution, return ANEURALNETWORKS_NO_ERROR; } -void ANeuralNetworksExecution_free(ANeuralNetworksExecution *execution) {} +void ANeuralNetworksExecution_free(ANeuralNetworksExecution * /* execution */) {} -int ANeuralNetworksExecution_setInputFromMemory(ANeuralNetworksExecution *execution, int32_t index, - const ANeuralNetworksOperandType *type, - const ANeuralNetworksMemory *memory, size_t offset, - size_t length) +int ANeuralNetworksExecution_setInputFromMemory(ANeuralNetworksExecution *execution, + int32_t /* index */, + const ANeuralNetworksOperandType * /* type */, + const ANeuralNetworksMemory *memory, + size_t /* offset */, size_t /* length */) { if ((execution == nullptr) || (memory == nullptr)) { @@ -200,10 +201,11 @@ int ANeuralNetworksExecution_setInputFromMemory(ANeuralNetworksExecution *execut return ANEURALNETWORKS_NO_ERROR; } -int ANeuralNetworksExecution_setOutputFromMemory(ANeuralNetworksExecution *execution, int32_t index, - const ANeuralNetworksOperandType *type, - const ANeuralNetworksMemory *memory, size_t offset, - size_t length) +int ANeuralNetworksExecution_setOutputFromMemory(ANeuralNetworksExecution *execution, + int32_t /* index */, + const ANeuralNetworksOperandType * /* type */, + const ANeuralNetworksMemory *memory, + size_t /* offset */, size_t /* length */) { if ((execution == nullptr) || (memory == nullptr)) { diff --git a/runtimes/neurun/src/graph/operand/Set.cc b/runtimes/neurun/src/graph/operand/Set.cc index 0e107b9..c5cc17b 100644 --- a/runtimes/neurun/src/graph/operand/Set.cc +++ b/runtimes/neurun/src/graph/operand/Set.cc @@ -29,7 +29,7 @@ const Object &Set::at(const Index &index) const { return *(_objects.at(index.asI Object &Set::at(const Index &index) { return *(_objects.at(index.asInt())); } -bool Set::exist(const Index &index) const { return index.asInt() < _objects.size(); } +bool Set::exist(const Index &index) const { return index.value() < _objects.size(); } } // namespace operand } // namespace graph diff --git a/runtimes/neurun/src/internal/Sink.h b/runtimes/neurun/src/internal/Sink.h index e300d03..cf0de1c 100644 --- a/runtimes/neurun/src/internal/Sink.h +++ b/runtimes/neurun/src/internal/Sink.h @@ -27,6 +27,7 @@ class VectorSink final : public Sink public: VectorSink(const int32_t vlen, uint8_t *base, const size_t size) : _vlen{vlen}, _base{base} { + (void)size; // Workaround for unused variable in release mode assert(size >= _vlen * sizeof(float)); } diff --git a/runtimes/neurun/src/internal/Source.h b/runtimes/neurun/src/internal/Source.h index 7d626fd..b3cad38 100644 --- a/runtimes/neurun/src/internal/Source.h +++ b/runtimes/neurun/src/internal/Source.h @@ -30,6 +30,7 @@ public: VectorSource(const int32_t vlen, const uint8_t *base, const size_t size) : _vlen{vlen}, _base{base} { + (void)size; // Workaround for unused variable in release mode assert(size >= _vlen * sizeof(float)); } -- 2.7.4