[moco-tf] adding constant folding into optimizer (#6065)
author윤현식/On-Device Lab(SR)/Principal Engineer/삼성전자 <hyunsik.yoon@samsung.com>
Thu, 1 Aug 2019 06:49:47 +0000 (15:49 +0900)
committer박세희/On-Device Lab(SR)/Principal Engineer/삼성전자 <saehie.park@samsung.com>
Thu, 1 Aug 2019 06:49:47 +0000 (15:49 +0900)
This commit adds constant folding into optimizer and turns the Knob ON.

Signed-off-by: Hyun Sik Yoon <hyunsik.yoon@samsung.com>
compiler/moco-tf/src/Knob.lst
compiler/moco-tf/src/Optimizer.cpp

index 73382be..578ec4a 100644 (file)
@@ -22,6 +22,7 @@ KNOB_BOOL(CanonicalizeConst, true, Enable Canonicalize for Const node)
 KNOB_BOOL(CanonicalizeConv2D, true, Enable Canonicalize for Conv2D node)
 
 // Canonical transforms
+KNOB_BOOL(ConstantFolding, true, Enable constant-folding optimization)
 KNOB_BOOL(RemoveForwardNode, true, Enable RemoveForwardNode optimization)
 KNOB_BOOL(ReorderDecode, true, Enable ReorderDecode optimization)
 // BEG: These knobs are valid only when ReorderDecode is enabled
index 46bfbe2..819b40e 100644 (file)
@@ -32,6 +32,11 @@ void Optimizer::optimize(loco::Graph *g) const
   moco::tf::Phase phase;
 
   /* TRANSFORM DECLARATION BEGIN */
+  if (moco::tf::get<moco::tf::Knob::ConstantFolding>())
+  {
+    phase.emplace_back(stdex::make_unique<ConstantFoldingTransform>());
+  }
+
   if (moco::tf::get<moco::tf::Knob::RemoveDeadNode>())
   {
     phase.emplace_back(stdex::make_unique<RemoveDeadNodeTransform>());