[neurun] Garden and remove redundunt code from ExecManager Test (#4930)
author이상규/On-Device Lab(SR)/Principal Engineer/삼성전자 <sg5.lee@samsung.com>
Thu, 4 Apr 2019 22:05:38 +0000 (07:05 +0900)
committer박세희/On-Device Lab(SR)/Principal Engineer/삼성전자 <saehie.park@samsung.com>
Thu, 4 Apr 2019 22:05:38 +0000 (07:05 +0900)
- Merge duplicated calls into one
  model->operands.at(operand_activation).usage(Usage::CONSTANT);
  model->operands.at(operand_activation).usage(operand::Usage::CONSTANT);

- Group the related statements by operand and operator

Signed-off-by: Sanggyu Lee <sg5.lee@samsung.com>
runtimes/neurun/test/interp/ExecManager.cc

index ac2b406..0538881 100644 (file)
@@ -45,6 +45,8 @@ protected:
     // activation: none (constant)
     std::unique_ptr<neurun::model::Model> model = nnfw::cpp14::make_unique<neurun::model::Model>();
 
+    // Add operands
+
     operand::Shape shape{1, 2, 2, 1};
     operand::TypeInfo type{DataType::INT32};
     operand::Shape shape_scalar(0);
@@ -52,29 +54,33 @@ protected:
 
     auto operand_lhs = model->operands.append(shape, type);
     auto operand_rhs = model->operands.append(shape, type);
-    auto input_set = operand::IndexSet{operand_lhs, operand_rhs};
 
     auto operand_activation = model->operands.append(shape_scalar, type_scalar);
     model->operands.at(operand_activation).usage(Usage::CONSTANT);
-    operation::AddNode::Param param;
-    param.activation_index = operand_activation;
-    model->operands.at(operand_activation).usage(operand::Usage::CONSTANT);
     model->operands.at(operand_activation)
         .data(nnfw::cpp14::make_unique<operand::CachedData>(
             reinterpret_cast<const uint8_t *>(&_activation_value), 4));
 
     auto operand_result = model->operands.append(shape, type);
-    auto output_set = operand::IndexSet{operand_result};
 
-    model->operands.at(operand_result).usage(Usage::OPERATION_OUTPUT);
+    // Add operations
+
+    operation::AddNode::Param param;
+    param.activation_index = operand_activation;
+    auto input_set = operand::IndexSet{operand_lhs, operand_rhs};
+    auto output_set = operand::IndexSet{operand_result};
     model->operations.append(
         nnfw::cpp14::make_unique<operation::AddNode>(input_set, output_set, param));
 
+    // Identify model inputs and outputs
+
     model->operands.at(operand_lhs).usage(Usage::MODEL_INPUT);
-    model->operands.at(operand_rhs).usage(Usage::MODEL_INPUT);
     model->inputs.append(operand_lhs);
+    model->operands.at(operand_rhs).usage(Usage::MODEL_INPUT);
     model->inputs.append(operand_rhs);
+    model->operands.at(operand_result).usage(Usage::OPERATION_OUTPUT);
     model->outputs.append(operand_result);
+
     _graph = nnfw::cpp14::make_unique<::neurun::graph::Graph>(std::move(model));
     _graph->finishBuilding();