[exo-tflite] type inferencing including custom op (#6320)
author윤현식/On-Device Lab(SR)/Principal Engineer/삼성전자 <hyunsik.yoon@samsung.com>
Wed, 7 Aug 2019 05:52:28 +0000 (14:52 +0900)
committer박종현/On-Device Lab(SR)/Staff Engineer/삼성전자 <jh1302.park@samsung.com>
Wed, 7 Aug 2019 05:52:28 +0000 (14:52 +0900)
This commit enables exo-tflite to infer type canonical nodes as well as custop op.

Signed-off-by: Hyun Sik Yoon <hyunsik.yoon@samsung.com>
compiler/exo-tflite/src/TypeInference.cpp

index 18c56a3..ebfef90 100644 (file)
 
 #include <loco/IR/CanonicalNode.h>
 #include <loco/IR/CanonicalNodeVisitor.h>
+#include <loco/IR/CanonicalDialect.h>
 #include <loco/Service/TypeInference.h>
 
+#include <locoex/COpDialect.h>
+#include <locoex/Service/COpTypeInference.h>
+
 #include <stdex/Memory.h>
 
 #include <type_traits>
@@ -60,8 +64,15 @@ tflite::TensorType translateLocoTypeToTFLite(loco::DataType dtype)
 
 void TypeInference::run(loco::Graph *g)
 {
-  loco::CanonicalTypeInferenceRule rule;
-  loco::apply(&rule).to(g);
+  loco::CanonicalTypeInferenceRule canonical_rule;
+  locoex::COpTypeInferenceRule cop_rule; // rule for custom op
+
+  loco::MultiDialectTypeInferenceRule rules;
+
+  rules.bind(loco::CanonicalDialect::get(), &canonical_rule)
+      .bind(locoex::COpDialect::get(), &cop_rule);
+
+  loco::apply(&rules).to(g);
 }
 
 tflite::TensorType TypeInference::get(loco::Node *node)