Remove exeuction interface method to return plan (#4457)
author오형석/On-Device Lab(SR)/Staff Engineer/삼성전자 <hseok82.oh@samsung.com>
Thu, 21 Feb 2019 10:16:07 +0000 (19:16 +0900)
committer이춘석/On-Device Lab(SR)/Staff Engineer/삼성전자 <chunseok.lee@samsung.com>
Thu, 21 Feb 2019 10:16:07 +0000 (19:16 +0900)
Remove exeuction interface method to return plan
Make field in ANeuralNetworksExecution to reference graph model

Signed-off-by: Hyeongseok Oh <hseok82.oh@samsung.com>
runtimes/neurun/src/exec/Executor.h
runtimes/neurun/src/exec/IExecutor.h
runtimes/neurun/src/frontend/wrapper/execution.cc
runtimes/neurun/src/frontend/wrapper/execution.h

index f688cb1..d92016e 100644 (file)
@@ -49,11 +49,6 @@ public:
 
 public:
   /**
-   * @brief   Return plan
-   * @return  Plan
-   */
-  const neurun::compiler::Plan &plan(void) const { return *_plan; }
-  /**
    * @brief     Set input data's information
    * @param[in] index   Input index
    * @param[in] type    Input data's type info
index 48c167c..3754d85 100644 (file)
@@ -43,11 +43,6 @@ struct IExecutor
   virtual ~IExecutor() = default;
 
   /**
-   * @brief   Return plan
-   * @return  Plan
-   */
-  virtual const neurun::compiler::Plan &plan(void) const = 0;
-  /**
    * @brief     Set input data's information
    * @param[in] index   Input index
    * @param[in] type    Input data's type info
index fb1527c..9d03d4a 100644 (file)
@@ -6,21 +6,21 @@ const neurun::model::operand::Index
 ANeuralNetworksExecution::getInputOperandIndex(uint32_t index) noexcept
 {
   neurun::model::operand::IO::Index input_index{index};
-  const auto operand_index = _executor->plan().model().getInputs().at(input_index);
+  const auto operand_index = _model.getInputs().at(input_index);
   return operand_index;
 }
 const neurun::model::operand::Index
 ANeuralNetworksExecution::getOutputOperandIndex(uint32_t index) noexcept
 {
   neurun::model::operand::IO::Index output_index{index};
-  const auto operand_index = _executor->plan().model().getInputs().at(output_index);
+  const auto operand_index = _model.getInputs().at(output_index);
   return operand_index;
 }
 
 bool ANeuralNetworksExecution::compareDataType(const ANeuralNetworksOperandType *type,
                                                const neurun::model::operand::Index index) noexcept
 {
-  const auto operand_type = _executor->plan().model().operands().at(index).typeInfo();
+  const auto operand_type = _model.operands().at(index).typeInfo();
   const auto typeInfo = ::neurun::util::getTypeInfo(type);
 
   if (operand_type != typeInfo)
@@ -35,7 +35,7 @@ bool ANeuralNetworksExecution::compareDataType(const ANeuralNetworksOperandType
 bool ANeuralNetworksExecution::compareShape(const ANeuralNetworksOperandType *type,
                                             const neurun::model::operand::Index index) noexcept
 {
-  const auto operand_shape = _executor->plan().model().operands().at(index).shape();
+  const auto operand_shape = _model.operands().at(index).shape();
   const auto shape_from_type = ::neurun::util::getShape(type);
 
   // Passed shape should be specified
@@ -72,7 +72,7 @@ bool ANeuralNetworksExecution::compareShape(const ANeuralNetworksOperandType *ty
 bool ANeuralNetworksExecution::haveUnspecifiedDims(
     const neurun::model::operand::Index index) noexcept
 {
-  const auto operand_shape = _executor->plan().model().operands().at(index).shape();
+  const auto operand_shape = _model.operands().at(index).shape();
 
   return ((operand_shape.element_nums() == 0) ? true : false);
 }
@@ -84,8 +84,8 @@ bool ANeuralNetworksExecution::setInput(uint32_t index, const ANeuralNetworksOpe
   {
     neurun::model::operand::IO::Index input_index{index};
     const auto operand_index = getInputOperandIndex(index);
-    const auto type_info = _executor->plan().model().operands().at(operand_index).typeInfo();
-    const auto shape = _executor->plan().model().operands().at(operand_index).shape();
+    const auto type_info = _model.operands().at(operand_index).typeInfo();
+    const auto shape = _model.operands().at(operand_index).shape();
 
     _executor->setInput(input_index, type_info, shape, buffer, length);
   }
@@ -107,8 +107,8 @@ bool ANeuralNetworksExecution::setOutput(uint32_t index,
   {
     neurun::model::operand::IO::Index output_index{index};
     const auto operand_index = getOutputOperandIndex(index);
-    const auto type_info = _executor->plan().model().operands().at(operand_index).typeInfo();
-    const auto shape = _executor->plan().model().operands().at(operand_index).shape();
+    const auto type_info = _model.operands().at(operand_index).typeInfo();
+    const auto shape = _model.operands().at(operand_index).shape();
 
     _executor->setOutput(output_index, type_info, shape, buffer, length);
   }
index aca23cc..8fbd3fa 100644 (file)
@@ -25,7 +25,7 @@ struct ANeuralNetworksExecution
 {
 public:
   ANeuralNetworksExecution(const std::shared_ptr<const neurun::compiler::Plan> &plan) noexcept
-      : _executor{new neurun::exec::Executor{plan}}
+      : _executor{new neurun::exec::Executor{plan}}, _model{plan->model()}
   {
     // DO NOTHING
   }
@@ -47,6 +47,7 @@ public:
 
 private:
   std::shared_ptr<neurun::exec::IExecutor> _executor;
+  const neurun::graph::Graph &_model;
 };
 
 #endif