[moco] push_node implementation (#8616)
author박세희/On-Device Lab(SR)/Principal Engineer/삼성전자 <saehie.park@samsung.com>
Wed, 30 Oct 2019 10:05:33 +0000 (19:05 +0900)
committerGitHub Enterprise <noreply-CODE@samsung.com>
Wed, 30 Oct 2019 10:05:33 +0000 (19:05 +0900)
This will introduce push_node implementation that retuns TFPush node with given GraphOutputIndex

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

index 0ececf2..ec1e073 100644 (file)
@@ -97,4 +97,20 @@ loco::GraphOutputIndex TFPush::index(void) const
   assert(_index <= std::numeric_limits<loco::GraphOutputIndex>::max());
   return static_cast<loco::GraphOutputIndex>(_index);
 }
+
+TFPush *push_node(loco::Graph *g, const loco::GraphOutputIndex &index)
+{
+  for (uint32_t n = 0; n < g->nodes()->size(); ++n)
+  {
+    if (auto tfpush = dynamic_cast<TFPush *>(g->nodes()->at(n)))
+    {
+      if (tfpush->indexed() && tfpush->index() == index)
+      {
+        return tfpush;
+      }
+    }
+  }
+  return nullptr;
+}
+
 } // namespace moco