Revise compile state (#4086)
author오형석/On-Device Lab(SR)/Staff Engineer/삼성전자 <hseok82.oh@samsung.com>
Wed, 2 Jan 2019 02:17:54 +0000 (11:17 +0900)
committerGitHub Enterprise <noreply-CODE@samsung.com>
Wed, 2 Jan 2019 02:17:54 +0000 (11:17 +0900)
Move lower, linearize state setting to plan

Signed-off-by: Hyeongseok Oh <hseok82.oh@samsung.com>
runtimes/neurun/src/compiler/Compiler.cc
runtimes/neurun/src/compiler/Plan.h
runtimes/neurun/src/graph/Graph.cc
runtimes/neurun/src/graph/Graph.h
runtimes/neurun/src/graph/pass/PermutationInsertionPass.cc

index fb5f504..e1d24d8 100644 (file)
@@ -52,10 +52,12 @@ void Compiler::compile(void)
 
   // Lower: decide backend
   graph.lower();
+  plan.state(State::LOWERED);
 
   dot_dumper.dumpIfNeeded("after_lower");
 
   auto linear = graph.linearize();
+  plan.state(State::LINEARIZED);
 
   // Dump ops
   linear->accept(neurun::graph::dumper::Dumper{});
@@ -105,7 +107,7 @@ void Compiler::compile(void)
    * Code generation phase finished
    ********************************/
 
-  plan.state(State::PLANNED);
+  plan.state(State::COMPILED);
 }
 
 } // namespace compiler
index d7ba31f..f2a526e 100644 (file)
@@ -28,10 +28,11 @@ namespace compiler
 
 enum class State
 {
-  NONE,    // Initial state
-  FAILED,  // Failed
-  PLANNED, // Success planned
-  NO_PLAN  // Not planned by environment or graph status
+  NONE,        // Initial state
+  LOWERED,     // Backend is decided
+  LINEARIZED,  // Everything is moved to Linear object so this Graph object is no longer effective
+  COMPILED,    // Success compilation
+  NOT_COMPILED // Not compiled by environment or graph status
 };
 
 class Plan
index 33f30ea..280125a 100644 (file)
@@ -206,8 +206,6 @@ void Graph::lower(void)
     });
   }
 
-  _phase = Phase::LOWERED;
-
   // Run PermutationInsertionPass
   {
     pass::PermutationInsertionPass pi_pass(*this);
@@ -225,14 +223,11 @@ void Graph::lower(void)
 
 std::unique_ptr<linear::Linear> Graph::linearize(void)
 {
-  assert(isLowered());
+  assert(_phase == Phase::MODEL);
 
   auto linear = nnfw::cpp14::make_unique<linear::Linear>(*this);
 
   // TODO Move the operations and operands to linear object
-
-  _phase = Phase::LINEARIZED;
-
   return std::move(linear);
 }
 
index 6078793..7b9d639 100644 (file)
@@ -49,9 +49,7 @@ private:
   enum class Phase
   {
     BUILDING,
-    MODEL,
-    LOWERED,
-    LINEARIZED // Everything is moved to Linear object so this Graph object is no longer effective
+    MODEL
   };
 
 public:
@@ -110,7 +108,6 @@ public:
   void removeOperand(const model::operand::Index &ind) { _model->operands.remove(ind); }
   std::unique_ptr<linear::Linear> linearize(void);
   bool isBuildingPhase(void) const { return _phase == Phase::BUILDING; }
-  bool isLowered(void) const { return _phase == Phase::LOWERED; }
 
 private:
   void initializeUseDef();
index 1f49c91..a5d2752 100644 (file)
@@ -117,7 +117,7 @@ model::operation::Index
 PermutationInsertionPass::insertPermute(const model::operand::Index &operand_index,
                                         const backend::Backend *backend)
 {
-  assert(_graph.isLowered());
+  assert(!_graph.isBuildingPhase());
 
   auto &operand = _graph.operands().at(operand_index);