Update include order and comment in Compiler.cc (#3684)
author오형석/동작제어Lab(SR)/Staff Engineer/삼성전자 <hseok82.oh@samsung.com>
Mon, 26 Nov 2018 05:57:04 +0000 (14:57 +0900)
committerGitHub Enterprise <noreply-CODE@samsung.com>
Mon, 26 Nov 2018 05:57:04 +0000 (14:57 +0900)
Update include order: categorize as
- header for Compiler.cc
- header in same directory
- header in differnt neurun directory
- header in include

Add and update comment
- Update comment for SubTensorAnlyzer
- Add comment for compilation phase (backend independent, lower, backend dependent, codegen)

Signed-off-by: Hyeongseok Oh <hseok82.oh@samsung.com>
runtimes/neurun/src/compiler/Compiler.cc

index eaa3522..983b9b0 100644 (file)
  */
 
 #include "Compiler.h"
+
 #include "OperationValidator.h"
 #include "SubTensorAnalyzer.h"
 #include "PlanBuilder.h"
 #include "ConstantInitializer.h"
 
 #include "graph/dumper/Dumper.h"
-#include "dumper/dot/DotDumper.h"
 #include "graph/operation/LowerInfo.h"
-
+#include "dumper/dot/DotDumper.h"
 #include "linear/Linear.h"
+
 #include "util/EnvVar.h"
 
 namespace neurun
@@ -39,6 +40,14 @@ void Compiler::compile(void)
   auto &graph = plan.model();
   const auto &operands = graph.operands();
 
+  /***************************************************
+   * Backend independent analysis & optimization phase
+   ***************************************************/
+
+  /*************************************************************
+   *  Backend independent analysis & optimization phase finished
+   *************************************************************/
+
   // dump graph to .dot
   // TODO : These can be moved to another place.
   const auto &dotdump_env = ::nnfw::util::EnvVar{"GRAPH_DOT_DUMP"}.asInt(0);
@@ -48,6 +57,7 @@ void Compiler::compile(void)
     dot_dumper.dump("before_lower", dotdump_env);
   }
 
+  // Lower: decide backend
   graph.lower();
 
   if (dotdump_env)
@@ -61,17 +71,30 @@ void Compiler::compile(void)
   // Dump ops
   linear->accept(neurun::graph::dumper::Dumper{});
 
-  // SubTensorInfo should be generated after lower, before planner & finalize
+  linear->accept(OperationValidator{operands});
+
+  /*************************************************
+   * Backend dependent analysis & optimization phase
+   *************************************************/
+
+  // SubTensorInfo should be generated after lower, before stage generation and finalize
+  // because SubTensorAnalyzer assume that insert permutation is already finished
   //    lower: decide backend and insert permutation
-  //    planner: stage generate (use SubTensorInfo to return stage. prepare to optimization)
+  //    stage generation: prepare codegen to optimization
   //    finalize: generate tensor using subtensor info, then execute stage
   // Generated SubTensorInfo is in operand(Object)
   // for easy pass SubTensorInfo to plan builder and tensor builder
   linear->accept(SubTensorAnalyzer{graph.operands()});
 
-  PlanBuilder plan_builder{plan};
+  /**********************************************************
+   * Backend dependent analysis & optimization phase finished
+   **********************************************************/
 
-  linear->accept(OperationValidator{operands});
+  /***********************
+   * Code generation phase
+   ***********************/
+
+  PlanBuilder plan_builder{plan};
 
   // Plan building
   linear->iterate([&](const neurun::graph::operation::Node *node) {
@@ -88,6 +111,10 @@ void Compiler::compile(void)
   plan_builder.finalize(tensor_builders);
 
   ConstantInitializer{graph, plan}();
+
+  /********************************
+   * Code generation phase finished
+   ********************************/
 }
 
 } // namespace compiler