[moco] GraphOutputIndexQueryService in TF dialect (#8726)
author박세희/On-Device Lab(SR)/Principal Engineer/삼성전자 <saehie.park@samsung.com>
Mon, 4 Nov 2019 23:22:54 +0000 (08:22 +0900)
committerGitHub Enterprise <noreply-CODE@samsung.com>
Mon, 4 Nov 2019 23:22:54 +0000 (08:22 +0900)
This will add GraphOutputIndexQueryService in TF dialect

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

index 6d87d6f..f7a34dc 100644 (file)
@@ -18,6 +18,7 @@
 #include "moco/IR/TFNode.h"
 
 #include <loco/IR/Graph.h>
+#include <loco/IR/GraphInputIndex.h>
 #include <loco/IR/GraphOutputIndex.h>
 
 #include <stdex/Memory.h>
 namespace
 {
 
+struct GiiQueryServiceImpl final : public loco::GraphInputIndexQueryService
+{
+  bool associated(const loco::Node *node) const final
+  {
+    if (auto tfplaceholder = dynamic_cast<const moco::TFPlaceholder *>(node))
+    {
+      return moco::indexed(tfplaceholder);
+    }
+    return false;
+  }
+
+  loco::GraphOutputIndex index(const loco::Node *node) const final
+  {
+    assert(associated(node));
+    auto tfplaceholder = dynamic_cast<const moco::TFPlaceholder *>(node);
+    assert(tfplaceholder != nullptr);
+    return moco::index(tfplaceholder);
+  }
+};
+
 struct GoiQueryServiceImpl final : public loco::GraphOutputIndexQueryService
 {
   bool associated(const loco::Node *node) const final
@@ -54,6 +75,7 @@ namespace moco
 
 TFDialect::TFDialect()
 {
+  service<loco::GraphInputIndexQueryService>(stdex::make_unique<GiiQueryServiceImpl>());
   service<loco::GraphOutputIndexQueryService>(stdex::make_unique<GoiQueryServiceImpl>());
 }