[moco_tf] Do shape,type inference before Canonicalizer (#6718)
author박세희/On-Device Lab(SR)/Principal Engineer/삼성전자 <saehie.park@samsung.com>
Tue, 20 Aug 2019 07:46:23 +0000 (16:46 +0900)
committerGitHub Enterprise <noreply-CODE@samsung.com>
Tue, 20 Aug 2019 07:46:23 +0000 (16:46 +0900)
This will run shape and type inference before Canonicalizer and use Restart type phase when any node type has changed

Signed-off-by: SaeHie Park <saehie.park@samsung.com>
compiler/moco-tf/src/Canonicalizer.cpp

index 163424e..d27aa2a 100644 (file)
@@ -20,6 +20,9 @@
 #include "Phase.h"
 #include "Transforms.h"
 
+#include "Transforms/ShapeInferencePass.h"
+#include "Transforms/TypeInferencePass.h"
+
 #include "Canonicalization/AddCanonicalizer.h"
 #include "Canonicalization/AvgPoolCanonicalizer.h"
 #include "Canonicalization/BiasAddCanonicalizer.h"
@@ -78,6 +81,10 @@ void Canonicalizer::canonicalize(loco::Graph *g) const
   moco::tf::Phase phase;
 
   /* TRANSFORM DECLARATION BEGIN */
+  // Run shape and type inference at the top
+  phase.emplace_back(stdex::make_unique<ShapeInferencePass>());
+  phase.emplace_back(stdex::make_unique<TypeInferencePass>());
+
   phase.emplace_back(stdex::make_unique<AddCanonicalizer>());
   phase.emplace_back(stdex::make_unique<AvgPoolCanonicalizer>());
   phase.emplace_back(stdex::make_unique<BiasAddCanonicalizer>());
@@ -99,7 +106,7 @@ void Canonicalizer::canonicalize(loco::Graph *g) const
   phase.emplace_back(stdex::make_unique<SubCanonicalizer>());
   /* TRANSFORM DECLARATION END */
 
-  moco::tf::PhaseRunner<moco::tf::PhaseStrategy::Saturate> phase_runner{g};
+  moco::tf::PhaseRunner<moco::tf::PhaseStrategy::Restart> phase_runner{g};
   phase_runner.run(phase);
 
   // Assert if graph has TF dialect nodes