From 22d5290d0787f56667378b9da7b67b12d30c2f73 Mon Sep 17 00:00:00 2001 From: =?utf8?q?=EB=B0=95=EC=A2=85=ED=98=84/On-Device=20Lab=28SR=29/Staff?= =?utf8?q?=20Engineer/=EC=82=BC=EC=84=B1=EC=A0=84=EC=9E=90?= Date: Mon, 5 Aug 2019 13:33:26 +0900 Subject: [PATCH] [loco] Introduce "link" helper (#6190) This commit introdues "link" helper which associates GraphInput/GraphOutout with Pull/Push node, respectively. Signed-off-by: Jonghyun Park --- compiler/loco/include/loco/IR/Graph.h | 6 ++++++ compiler/loco/include/loco/IR/Nodes.h | 7 +++++++ compiler/loco/src/IR/Nodes.cpp | 4 ++++ 3 files changed, 17 insertions(+) diff --git a/compiler/loco/include/loco/IR/Graph.h b/compiler/loco/include/loco/IR/Graph.h index 8f635c2..e0fa5a2 100644 --- a/compiler/loco/include/loco/IR/Graph.h +++ b/compiler/loco/include/loco/IR/Graph.h @@ -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: diff --git a/compiler/loco/include/loco/IR/Nodes.h b/compiler/loco/include/loco/IR/Nodes.h index 49cdbcc..df2b060 100644 --- a/compiler/loco/include/loco/IR/Nodes.h +++ b/compiler/loco/include/loco/IR/Nodes.h @@ -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 * diff --git a/compiler/loco/src/IR/Nodes.cpp b/compiler/loco/src/IR/Nodes.cpp index af173c0..47b61d7 100644 --- a/compiler/loco/src/IR/Nodes.cpp +++ b/compiler/loco/src/IR/Nodes.cpp @@ -57,6 +57,8 @@ GraphOutputIndex Push::index(void) const return static_cast(_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 /** -- 2.7.4