[enco] Introduce FeatureUnificationPass (#3048)
author박종현/On-Device Lab(SR)/Staff Engineer/삼성전자 <jh1302.park@samsung.com>
Thu, 7 Mar 2019 02:28:35 +0000 (11:28 +0900)
committerGitHub Enterprise <noreply-CODE@samsung.com>
Thu, 7 Mar 2019 02:28:35 +0000 (11:28 +0900)
This commit introduces FeatureUnificationPass which wraps unify_feature
optimization function, and uses it instead of unify_feature.

Signed-off-by: Jonghyun Park <jh1302.park@samsung.com>
contrib/enco/core/src/Backend.cpp
contrib/enco/core/src/Transforms/FeatureUnification.h

index 0712032..423527c 100644 (file)
@@ -103,6 +103,7 @@ void BackendImpl::compile(coco::Module *m, coco::Data *d)
   //
   // BagDuplicationPass creates a copy of such bags in order to eliminate such a pair.
   pipeline.append(make_unique<BagDuplicationPass>());
+  pipeline.append(make_unique<FeatureUnificationPass>());
 
   // Apply transforms in the pipeline
   for (uint32_t n = 0; n < pipeline.size(); ++n)
@@ -121,8 +122,6 @@ void BackendImpl::compile(coco::Module *m, coco::Data *d)
   // that share the same bag as their underlying bag
   assert(!has_inout_bag(code(sess)->module()));
 
-  unify_feature(code(sess));
-
   lower_avgpool(code(sess));
 
   // Select Intrinsic(API)
index 91286bc..5ab0f9d 100644 (file)
@@ -18,6 +18,7 @@
 #define __ENCO_TRANSFORM_FEATURE_UNIFICATION_H__
 
 #include "Code.h"
+#include "Pass.h"
 
 namespace enco
 {
@@ -53,6 +54,15 @@ namespace enco
  */
 void unify_feature(enco::Code *code);
 
+struct FeatureUnificationPass final : public Pass
+{
+  PASS_CTOR(FeatureUnificationPass)
+  {
+    // DO NOTHING
+  }
+  void run(const SessionID &sess) const override { unify_feature(code(sess)); }
+};
+
 } // namespace enco
 
 #endif // __ENCO_TRANSFORM_FEATURE_UNIFICATION_H__