Change Element in Linear to have lower_info (#4462)
author김용섭/On-Device Lab(SR)/Engineer/삼성전자 <yons.kim@samsung.com>
Tue, 26 Feb 2019 07:51:07 +0000 (16:51 +0900)
committer이춘석/On-Device Lab(SR)/Staff Engineer/삼성전자 <chunseok.lee@samsung.com>
Tue, 26 Feb 2019 07:51:07 +0000 (16:51 +0900)
Change Element in Linear to have lower_info for accessing backend
directly on compilation phase

Signed-off-by: Yongseop Kim <yons.kim@samsung.com>
runtimes/neurun/src/compiler/Compiler.cc
runtimes/neurun/src/linear/Linear.cc
runtimes/neurun/src/linear/Linear.h

index 8a4c8f1..3d04634 100644 (file)
@@ -103,9 +103,7 @@ void Compiler::compile(void)
 
   // Plan building
   linear->iterate([&](const linear::Element &element) {
-    // Assume that the backend of all nodes on a subgraph are identified on the subgraph
-    const auto &first_ind = element.subgraph->operations()[0].index;
-    auto backend = _model->getLowerInfo(first_ind)->backend();
+    auto backend = element.lower_info->backend();
 
     // Generate Stage
     auto stage_gen = backend->stage_gen();
index ebcef95..197bf8c 100644 (file)
@@ -128,7 +128,12 @@ Linear::Linear(const graph::Graph &graph) : _graph(graph)
 
   // Now ordered subgraphs are ready
   for (auto &subgraph : *subgraph_set)
-    _elements.emplace_back(std::move(subgraph));
+  {
+    // Assume that the backend of all nodes on a subgraph are identified on the subgraph
+    const auto &first_ind = subgraph->operations()[0].index;
+    auto lower_info = _graph.getLowerInfo(first_ind);
+    _elements.emplace_back(std::move(subgraph), lower_info);
+  }
 
   VERBOSE(LINEAR) << "Subgraphs" << std::endl;
   for (const auto &element : _elements)
index 43563fd..6c0d873 100644 (file)
@@ -52,10 +52,11 @@ struct Element
   // TODO: Change unique_ptr to ptr after Graph has Subgraphs
   std::unique_ptr<model::operation::Subgraph> subgraph;
 
-  // TODO
-  // graph::operation::LowerInfo *lower_info;
+  const graph::operation::LowerInfo *lower_info;
 
-  Element(std::unique_ptr<model::operation::Subgraph> subgraph) : subgraph{std::move(subgraph)}
+  Element(std::unique_ptr<model::operation::Subgraph> subgraph,
+          const graph::operation::LowerInfo *lower_info)
+      : subgraph{std::move(subgraph)}, lower_info{lower_info}
   {
     // DO NOTHING
   }