Rename hasData to isConstant (#5046)
author오형석/On-Device Lab(SR)/Staff Engineer/삼성전자 <hseok82.oh@samsung.com>
Tue, 23 Apr 2019 10:37:34 +0000 (19:37 +0900)
committer이춘석/On-Device Lab(SR)/Staff Engineer/삼성전자 <chunseok.lee@samsung.com>
Tue, 23 Apr 2019 10:37:34 +0000 (19:37 +0900)
Rename hasData to isConstant
It is used to check operand is constant

Signed-off-by: Hyeongseok Oh <hseok82.oh@samsung.com>
13 files changed:
runtimes/neurun/backend/acl_cl/StageGenerator.cc
runtimes/neurun/core/include/model/operand/Object.h
runtimes/neurun/core/src/compiler/ConstantInitializer.cc
runtimes/neurun/core/src/compiler/OperationValidator.cc
runtimes/neurun/core/src/compiler/ParamChecker.cc
runtimes/neurun/core/src/compiler/SubTensorAnalyzer.cc
runtimes/neurun/core/src/dumper/dot/DotDumper.cc
runtimes/neurun/core/src/exec/interp/ExecManager.cc
runtimes/neurun/core/src/exec/interp/Interpreter.cc
runtimes/neurun/core/src/graph/Graph.cc
runtimes/neurun/core/src/linear/Linear.cc
runtimes/neurun/core/src/model/operand/Object.cc
runtimes/neurun/frontend/nnapi/wrapper/model.cc

index ef35f56..9828a19 100644 (file)
@@ -2713,7 +2713,7 @@ void StageGenerator::visit(const model::operation::ArgMaxNode &node)
   auto ofm_shape = _ctx.at(ofm_index).shape();
   auto axis_shape = _ctx.at(axis_index).shape();
 
-  assert(_ctx.at(axis_index).hasData());
+  assert(_ctx.at(axis_index).isConstant());
   // Axis dimension is always 1.
   assert(axis_shape.rank() == 1);
   assert((ifm_shape.rank() - 1) == ofm_shape.rank());
index fb4ba9e..256192a 100644 (file)
@@ -83,7 +83,7 @@ public:
    * @brief Get true if Object has data, otherwise @c false
    * @return @c true if Object has data, otherwise @c false
    */
-  bool hasData(void) const { return _data != nullptr; }
+  bool isConstant(void) const { return _data != nullptr; }
 
 public:
   template <typename T, typename... Args> void data(Args &&... args)
index 51bbad4..07cc799 100644 (file)
@@ -172,7 +172,7 @@ void ConstantInitializer::operator()()
     const auto &model_obj = _graph.operands().at(index);
 
     // For only CONSTANTS
-    if (!model_obj.hasData())
+    if (!model_obj.isConstant())
       return;
 
     auto type = model_obj.typeInfo().type();
index c181c26..8befb00 100644 (file)
@@ -104,7 +104,7 @@ void OperationValidator::visit(const model::operation::ReduceSumNode &node)
 
   assert(input_shape.rank() <= 4);
   assert(output_shape.rank() <= input_shape.rank());
-  assert(_ctx.at(axis_index).hasData());
+  assert(_ctx.at(axis_index).isConstant());
   assert(axis_shape.rank() == 0 || axis_shape.rank() == 1);
 
   // NOTE For the 4-dimensions, if the rank of input and output are different, this runtime only
@@ -171,7 +171,7 @@ void OperationValidator::visit(const model::operation::ReduceMaxNode &node)
 
   assert(input_shape.rank() <= 4);
   assert(output_shape.rank() <= input_shape.rank());
-  assert(_ctx.at(axis_index).hasData());
+  assert(_ctx.at(axis_index).isConstant());
   assert(axis_shape.rank() == 0 || axis_shape.rank() == 1);
 
   // NOTE For the 4-dimensions, if the rank of input and output are different, this runtime only
@@ -349,7 +349,7 @@ void OperationValidator::visit(const model::operation::TransposeConvNode &node)
   UNUSED_RELEASE(ifm_shape);
   UNUSED_RELEASE(ker_shape);
 
-  assert(_ctx.at(padding_index).hasData() == true);
+  assert(_ctx.at(padding_index).isConstant() == true);
 
   const int32_t vstride = _ctx.at(vstride_index).asScalar<int32_t>();
   const int32_t hstride = _ctx.at(hstride_index).asScalar<int32_t>();
@@ -393,7 +393,7 @@ void OperationValidator::visit(const model::operation::GatherNode &node)
   assert(ifm_shape.rank() <= 4);
   assert(indices_shape.rank() <= 3);
   assert(ofm_shape.rank() <= 4);
-  assert(_ctx.at(axis_index).hasData());
+  assert(_ctx.at(axis_index).isConstant());
   assert(axis_shape.rank() == 0);
 }
 
@@ -493,7 +493,7 @@ void OperationValidator::visit(const model::operation::ReduceMinNode &node)
 
   assert(ifm_shape.rank() <= 4);
   assert(ofm_shape.rank() <= ifm_shape.rank());
-  assert(_ctx.at(axis_index).hasData());
+  assert(_ctx.at(axis_index).isConstant());
   assert(axis_shape.rank() == 0 || axis_shape.rank() == 1);
 
   // NOTE For the 4-dimensions, if the rank of input and output are different, this runtime only
index 68452ec..c9c063c 100644 (file)
@@ -34,7 +34,7 @@ void ParamChecker::visit(const model::operation::AddNode &node)
 {
   const auto activation_index = node.param().activation_index;
 
-  if (!_model->operands().at(activation_index).hasData())
+  if (!_model->operands().at(activation_index).isConstant())
   {
     _nonConstParam = true;
   }
index b1a1c5a..acca5a8 100644 (file)
@@ -38,7 +38,7 @@ void SubTensorAnalyzer::visit(const model::operation::ConcatNode &node)
   auto axis_index = node.param().axis_index;
 
   // To prepare concat elimination, axis should be constant
-  if (!_ctx.at(axis_index).hasData())
+  if (!_ctx.at(axis_index).isConstant())
   {
     VERBOSE(SUBTENSOR) << "Cannot handle non-constant axis" << std::endl;
     return;
index a03618f..9ba3515 100644 (file)
@@ -62,9 +62,9 @@ void DotDumper::dumpIfNeeded(const std::string &tag)
     }
     else
     {
-      showing_cond = !object.hasData();
+      showing_cond = !object.isConstant();
     }
-    if (object.hasData() || _graph.getInputs().contains(index))
+    if (object.isConstant() || _graph.getInputs().contains(index))
     {
       showing_cond = showing_cond && (object.getUses().size() > 0);
     }
index a941c7f..0a6ea43 100644 (file)
@@ -136,7 +136,7 @@ void ExecManager::execute(void)
   // Allocate constant tensor
   _model->operands.iterate([&](const model::operand::Index &ind,
                                const model::operand::Object &obj) {
-    if (obj.hasData())
+    if (obj.isConstant())
     {
       VERBOSE(INTERPRETER) << "Allocate and assign constant tensor. operand index:" << ind.value()
                            << std::endl;
index f452697..c57ea2d 100644 (file)
@@ -50,7 +50,7 @@ void Interpreter::run()
 
   _env->model().operands.iterate(
       [&](const model::operand::Index &ind, const model::operand::Object &obj) {
-        if (obj.hasData())
+        if (obj.isConstant())
         {
           VERBOSE(INTERPRETER) << "Constant: Push to operand stack " << ind.value() << std::endl;
 
index 512a338..4e37f74 100644 (file)
@@ -241,7 +241,7 @@ void Graph::lower(void)
             {
               // only valid_inputs
               const auto &operand = _model->operands.at(input);
-              if (operand.hasData())
+              if (operand.isConstant())
                 continue;
 
               // This operand is input of operation, not weight or bias
index 9659899..24fd936 100644 (file)
@@ -69,7 +69,7 @@ Linear::Linear(const std::shared_ptr<const model::Model> &model,
       {
         // only valid_inputs
         const auto &operand = _model->operands.at(input);
-        if (operand.hasData())
+        if (operand.isConstant())
           continue;
 
         auto it = input_to_subgs.find(input);
@@ -195,7 +195,7 @@ backend::TensorBuilderSet Linear::planTensors()
 
         // If a tensor is a constant, increase the use of the tensor.
         // It makes the tensor not be dealloced.
-        if (obj.hasData())
+        if (obj.isConstant())
         {
           constants.push_back(ind);
           uses_map[ind]++;
index 1ff5d6f..df58db6 100644 (file)
@@ -71,7 +71,7 @@ void Object::removeUse(const ::neurun::model::OperationIndex &idx)
 
 void Object::appendDef(const ::neurun::model::OperationIndex &idx)
 {
-  assert(_usage != Usage::NOT_DEFINED && !hasData());
+  assert(_usage != Usage::NOT_DEFINED && !isConstant());
   assert(_def.size() == 0);
 
   _def.append(idx);
index a15ac3e..fd95193 100644 (file)
@@ -238,7 +238,7 @@ bool ANeuralNetworksModel::isUsageSet(uint32_t index) noexcept
 bool ANeuralNetworksModel::isOperationOutput(uint32_t index) noexcept
 {
   const neurun::model::operand::Index ind{index};
-  return (!_model->operands.at(ind).hasData() && !_model->inputs.contains(ind));
+  return (!_model->operands.at(ind).isConstant() && !_model->inputs.contains(ind));
 }
 
 void ANeuralNetworksModel::setOptionalOperand(const neurun::model::operand::Index idx)