From 95e02238c92dc4cfecf4e6ca8210405f90504138 Mon Sep 17 00:00:00 2001 From: =?utf8?q?=EA=B9=80=EC=88=98=EC=A7=84/On-Device=20Lab=28SR=29/Enginee?= =?utf8?q?r/=EC=82=BC=EC=84=B1=EC=A0=84=EC=9E=90?= Date: Fri, 1 Feb 2019 13:13:44 +0900 Subject: [PATCH] [neurun] Use 'UNUSED_RELEASE' macro for unused variable (#4362) * [neurun] Move and use 'NO_USE' macro This commit moves and use `NO_USE` macro instead of the casting with `(void)`. Signed-off-by: sjsujinkim * change macro name --- runtimes/neurun/src/backend/cpu/operand/Tensor.cc | 5 +---- runtimes/neurun/src/compiler/OperationValidator.cc | 11 +++++++---- runtimes/neurun/src/util/Utils.h | 2 ++ runtimes/neurun/src/util/feature/nhwc/Reader.h | 3 ++- runtimes/neurun/src/util/feature/nhwc/View.h | 3 ++- 5 files changed, 14 insertions(+), 10 deletions(-) diff --git a/runtimes/neurun/src/backend/cpu/operand/Tensor.cc b/runtimes/neurun/src/backend/cpu/operand/Tensor.cc index a525129..5df5c9e 100644 --- a/runtimes/neurun/src/backend/cpu/operand/Tensor.cc +++ b/runtimes/neurun/src/backend/cpu/operand/Tensor.cc @@ -16,8 +16,6 @@ #include "Tensor.h" -#define NO_USE(a) (void)(a) - namespace neurun { namespace backend @@ -27,9 +25,8 @@ namespace cpu namespace operand { -size_t Tensor::calcOffset(const neurun::util::feature::Coordinate4D &coords) +size_t Tensor::calcOffset(const neurun::util::feature::Coordinate4D &) { - NO_USE(coords); throw std::runtime_error("offset_element_in_bytes is not supported for cpu::Tensor now."); } diff --git a/runtimes/neurun/src/compiler/OperationValidator.cc b/runtimes/neurun/src/compiler/OperationValidator.cc index b0e98cf..8a0a718 100644 --- a/runtimes/neurun/src/compiler/OperationValidator.cc +++ b/runtimes/neurun/src/compiler/OperationValidator.cc @@ -22,6 +22,7 @@ #include "graph/operation/LowerInfo.h" #include "util/logging.h" +#include "util/Utils.h" namespace neurun { @@ -65,27 +66,29 @@ void OperationValidator::visit(const model::operation::ReshapeNode &) void OperationValidator::visit(const model::operation::SoftmaxNode &node) { - (void)node; // NOTE To prevent from unused variable warning - VERBOSE(Softmax) << "Configure SOFTMAX operation" << std::endl; const auto output_index{node.getOutputs().at(0)}; const auto input_index{node.getInputs().at(0)}; const auto scale_index{node.param().scale_index}; + UNUSED_RELEASE(output_index); + UNUSED_RELEASE(input_index); + assert(_ctx.at(output_index).shape().rank() == _ctx.at(input_index).shape().rank()); assert(_ctx.at(scale_index).shape().rank() == 0); } void OperationValidator::visit(const model::operation::PermuteNode &node) { - (void)node; // NOTE To prevent from unused variable warning - VERBOSE(Permute) << "Configure Permute operation" << std::endl; const auto output_index{node.getOutputs().at(0)}; const auto input_index{node.getInputs().at(0)}; + UNUSED_RELEASE(output_index); + UNUSED_RELEASE(input_index); + assert(_ctx.at(output_index).shape().rank() == _ctx.at(input_index).shape().rank()); } diff --git a/runtimes/neurun/src/util/Utils.h b/runtimes/neurun/src/util/Utils.h index a1e5bf0..cb668e3 100644 --- a/runtimes/neurun/src/util/Utils.h +++ b/runtimes/neurun/src/util/Utils.h @@ -25,6 +25,8 @@ #include "NeuralNetworks.h" +#define UNUSED_RELEASE(a) (void)(a) + namespace neurun { namespace util diff --git a/runtimes/neurun/src/util/feature/nhwc/Reader.h b/runtimes/neurun/src/util/feature/nhwc/Reader.h index 85b8cab..471f62a 100644 --- a/runtimes/neurun/src/util/feature/nhwc/Reader.h +++ b/runtimes/neurun/src/util/feature/nhwc/Reader.h @@ -17,6 +17,7 @@ #ifndef __NEURUN_UTIL_FEATURE_NHWC_READER_H__ #define __NEURUN_UTIL_FEATURE_NHWC_READER_H__ +#include "util/Utils.h" #include "Utils.h" #include "misc/feature/Reader.h" @@ -36,7 +37,7 @@ public: Reader(const ::nnfw::misc::feature::Shape &shape, const T *ptr, size_t len) : _shape{shape}, _ptr{ptr} { - (void)len; // Workaround for unused variable in release mode + UNUSED_RELEASE(len); // Workaround for unused variable in release mode assert(shape.N * shape.C * shape.H * shape.W * sizeof(T) == len); } diff --git a/runtimes/neurun/src/util/feature/nhwc/View.h b/runtimes/neurun/src/util/feature/nhwc/View.h index 1b9be9e..e4b8e80 100644 --- a/runtimes/neurun/src/util/feature/nhwc/View.h +++ b/runtimes/neurun/src/util/feature/nhwc/View.h @@ -20,6 +20,7 @@ #include #include "Utils.h" +#include "util/Utils.h" #include "misc/feature/Reader.h" @@ -37,7 +38,7 @@ template class View final : public nnfw::misc::feature::Reader public: View(const ::nnfw::misc::feature::Shape &shape, T *ptr, size_t len) : _shape{shape}, _ptr{ptr} { - (void)len; // Workaround for unused variable in release mode + UNUSED_RELEASE(len); // Workaround for unused variable in release mode assert(shape.N * shape.C * shape.H * shape.W * sizeof(T) == len); } -- 2.7.4