[neurun] Use 'UNUSED_RELEASE' macro for unused variable (#4362)
author김수진/On-Device Lab(SR)/Engineer/삼성전자 <sjsujin.kim@samsung.com>
Fri, 1 Feb 2019 04:13:44 +0000 (13:13 +0900)
committer박세희/On-Device Lab(SR)/Principal Engineer/삼성전자 <saehie.park@samsung.com>
Fri, 1 Feb 2019 04:13:44 +0000 (13:13 +0900)
* [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 <sjsujin.kim@samsung.com>
* change macro name

runtimes/neurun/src/backend/cpu/operand/Tensor.cc
runtimes/neurun/src/compiler/OperationValidator.cc
runtimes/neurun/src/util/Utils.h
runtimes/neurun/src/util/feature/nhwc/Reader.h
runtimes/neurun/src/util/feature/nhwc/View.h

index a525129..5df5c9e 100644 (file)
@@ -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.");
 }
 
index b0e98cf..8a0a718 100644 (file)
@@ -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());
 }
 
index a1e5bf0..cb668e3 100644 (file)
@@ -25,6 +25,8 @@
 
 #include "NeuralNetworks.h"
 
+#define UNUSED_RELEASE(a) (void)(a)
+
 namespace neurun
 {
 namespace util
index 85b8cab..471f62a 100644 (file)
@@ -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);
   }
 
index 1b9be9e..e4b8e80 100644 (file)
@@ -20,6 +20,7 @@
 #include <cassert>
 
 #include "Utils.h"
+#include "util/Utils.h"
 
 #include "misc/feature/Reader.h"
 
@@ -37,7 +38,7 @@ template <typename T> class View final : public nnfw::misc::feature::Reader<T>
 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);
   }