Add LowerInfoMap as member into class IKernelGenerator (#8742)
author장지섭/On-Device Lab(SR)/Engineer/삼성전자 <jiseob.jang@samsung.com>
Tue, 5 Nov 2019 06:51:41 +0000 (15:51 +0900)
committer오형석/On-Device Lab(SR)/Staff Engineer/삼성전자 <hseok82.oh@samsung.com>
Tue, 5 Nov 2019 06:51:41 +0000 (15:51 +0900)
This commit LowerInfoMap as member into class IKernelGenerator.

Signed-off-by: jiseob.jang <jiseob.jang@samsung.com>
runtime/neurun/core/include/backend/IKernelGenerator.h
runtime/neurun/core/include/graph/Graph.h
runtime/neurun/core/src/compiler/ExecutorFactory.cc
runtime/neurun/core/src/compiler/Linear.h

index 542a553..3964c80 100644 (file)
@@ -22,6 +22,7 @@
 
 #include "ITensorBuilder.h"
 #include "compiler/IExecutionBuilder.h"
+#include "graph/LowerInfoMap.h"
 #include "model/OperationVisitor.h"
 #include "model/Subgraph.h"
 #include "cpp14/memory.h"
@@ -36,9 +37,11 @@ class IKernelGenerator : public model::OperationVisitor
 public:
   virtual ~IKernelGenerator() = default;
 
-  void generate(const model::Operation &node, neurun::compiler::IExecutionBuilder *executionBuilder)
+  void generate(const model::Operation &node, neurun::compiler::IExecutionBuilder *executionBuilder,
+                const graph::LowerInfoMap *lower_info_map)
   {
     _execution_builder = executionBuilder;
+    _lower_info_map = lower_info_map;
     node.accept(*this);
   }
 
@@ -55,6 +58,7 @@ protected:
 
 protected:
   neurun::compiler::IExecutionBuilder *_execution_builder;
+  const graph::LowerInfoMap *_lower_info_map;
 };
 
 } // namespace backend
index 97e8f7c..ee1203b 100644 (file)
@@ -175,6 +175,7 @@ private:
 
   // For LOWERED phase
 public:
+  const LowerInfoMap *getLowerInfo() const { return _lower_info_map.get(); }
   const operation::LowerInfo *getLowerInfo(const model::SubgraphIndex &subg_index) const;
   void setLowerInfo(const model::SubgraphIndex &subg_index,
                     std::unique_ptr<operation::LowerInfo> &&lower_info);
index 07adcd3..476f0cf 100644 (file)
@@ -142,7 +142,7 @@ exec::IExecutor *ExecutorFactory::createLinearExecutor(graph::Graph &graph)
   linear->iterate([&](const compiler::Linear::Element &element) {
     auto backend = element.lower_info->backend();
     auto kernel_gen = linear->getBackendContext(backend)->kernel_gen;
-    kernel_gen->generate(*element.subgraph, execution_builder.get());
+    kernel_gen->generate(*element.subgraph, execution_builder.get(), linear->getLowerInfo());
   });
 
   for (auto &tensor_builder : tensor_builders)
@@ -303,7 +303,7 @@ exec::IExecutor *ExecutorFactory::createDataflowExecutor(graph::Graph &graph, bo
         // TODO This approach is temporal. See declaration of `setNextIndex`.
         execution_builder->setNextIndex(subg_index);
         auto kernel_gen = graph.backend_resolver()->getBackendContext(backend)->kernel_gen;
-        kernel_gen->generate(subg, execution_builder.get());
+        kernel_gen->generate(subg, execution_builder.get(), graph.getLowerInfo());
       });
 
   for (const auto &tensor_builder : tensor_builders)
index 78c782a..c60a441 100644 (file)
@@ -76,7 +76,7 @@ public:
   void generateConstantInitializers(void) const;
 
   std::unique_ptr<graph::LowerInfoMap> releaseLowerInfo() { return std::move(_lower_info_map); }
-  graph::LowerInfoMap *getLowerInfo() { return _lower_info_map.get(); }
+  const graph::LowerInfoMap *getLowerInfo() { return _lower_info_map.get(); }
 
   std::unique_ptr<model::Subgraphs> releaseSubgraphs() { return std::move(_subgraphs); }