[loco] Introduce "link" helper (#6190)
author박종현/On-Device Lab(SR)/Staff Engineer/삼성전자 <jh1302.park@samsung.com>
Mon, 5 Aug 2019 04:33:26 +0000 (13:33 +0900)
committerGitHub Enterprise <noreply-CODE@samsung.com>
Mon, 5 Aug 2019 04:33:26 +0000 (13:33 +0900)
This commit introdues "link" helper which associates
GraphInput/GraphOutout with Pull/Push node, respectively.

Signed-off-by: Jonghyun Park <jh1302.park@samsung.com>
compiler/loco/include/loco/IR/Graph.h
compiler/loco/include/loco/IR/Nodes.h
compiler/loco/src/IR/Nodes.cpp

index 8f635c2..e0fa5a2 100644 (file)
@@ -118,6 +118,9 @@ private:
 
 public:
   Pull *node(void) const { return _pull; }
+  // DEPRECATED
+  //
+  // Use a dialect-specific helper instead.
   void node(Pull *pull);
 
 private:
@@ -150,6 +153,9 @@ private:
 
 public:
   Push *node(void) const { return _push; }
+  // DEPRECATED
+  //
+  // Use a dialect-specific helper instead.
   void node(Push *push);
 
 private:
index 49cdbcc..df2b060 100644 (file)
@@ -35,6 +35,9 @@
 namespace loco
 {
 
+class GraphInput;
+class GraphOutput;
+
 // TODO Find a proper location for these declarations
 using GraphInputIndex = uint32_t;
 using GraphOutputIndex = uint32_t;
@@ -77,6 +80,8 @@ private:
   int64_t _index = -1; // Uninitialized
 };
 
+void link(GraphOutput *, Push *push);
+
 /**
  * @brief Create a value from user data
  */
@@ -122,6 +127,8 @@ private:
   DataType _dtype = DataType::Unknown;
 };
 
+void link(GraphInput *, Pull *pull);
+
 /**
  * @brief Create a new value identical to its input
  *
index af173c0..47b61d7 100644 (file)
@@ -57,6 +57,8 @@ GraphOutputIndex Push::index(void) const
   return static_cast<GraphOutputIndex>(_index);
 }
 
+void link(GraphOutput *output, Push *push) { output->node(push); }
+
 } // namespace loco
 
 /**
@@ -135,6 +137,8 @@ DataType Pull::dtype(void) const
   }
 }
 
+void link(GraphInput *input, Pull *pull) { input->node(pull); }
+
 } // namespace loco
 
 /**