From d4ac36efb00585f94737556e1afb37b102f6f729 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: Wed, 21 Aug 2019 13:34:57 +0900 Subject: [PATCH] [loco] Remove "node" method from Graph Input/Output (#6759) This commit removes "node" method from GraphInput/GraphOutput class. Signed-off-by: Jonghyun Park --- compiler/loco/include/loco/IR/Graph.h | 27 +-------------------------- compiler/loco/src/IR/Graph.cpp | 22 +--------------------- compiler/loco/src/IR/Graph.test.cpp | 6 ++---- compiler/loco/src/IR/Nodes.cpp | 12 ++---------- 4 files changed, 6 insertions(+), 61 deletions(-) diff --git a/compiler/loco/include/loco/IR/Graph.h b/compiler/loco/include/loco/IR/Graph.h index 0e576dc..f9a53f7 100644 --- a/compiler/loco/include/loco/IR/Graph.h +++ b/compiler/loco/include/loco/IR/Graph.h @@ -18,6 +18,7 @@ #define __LOCO_IR_GRAPH_H__ #include "loco/IR/DataType.h" +// TODO Include "Node.h" instead #include "loco/IR/Nodes.h" #include "loco/IR/NodePool.h" #include "loco/IR/GraphInputIndex.h" @@ -126,19 +127,6 @@ public: private: uint32_t _index; - -public: - Pull *node(void) const { return _pull; } -private: - // DEPRECATED - // - // Use a dialect-specific helper instead. - // - // TODO Remove this method - void node(Pull *pull); - -private: - Pull *_pull{nullptr}; }; /** @@ -170,19 +158,6 @@ public: private: uint32_t _index; - -public: - Push *node(void) const { return _push; } -private: - // DEPRECATED - // - // Use a dialect-specific helper instead. - // - // TODO Remove this method - void node(Push *push); - -private: - Push *_push{nullptr}; }; /** diff --git a/compiler/loco/src/IR/Graph.cpp b/compiler/loco/src/IR/Graph.cpp index c7c5984..7029f92 100644 --- a/compiler/loco/src/IR/Graph.cpp +++ b/compiler/loco/src/IR/Graph.cpp @@ -50,26 +50,6 @@ void Mixin::shape(std::initializer_list dims) shape(make_tensor_shape(dims)); } -void GraphInput::node(Pull *pull) -{ - _pull = pull; - assert(!_pull->indexed() or _pull->index() == _index); - if (!_pull->indexed()) - { - _pull->index(_index); - } -} - -void GraphOutput::node(Push *push) -{ - _push = push; - assert(!_push->indexed() or _push->index() == _index); - if (!_push->indexed()) - { - _push->index(_index); - } -} - GraphInput *Graph::InputContext::create(void) { return take(stdex::make_unique(size())); @@ -98,7 +78,7 @@ std::vector output_nodes(loco::Graph *g) for (uint32_t n = 0; n < g->outputs()->size(); ++n) { - auto node = g->outputs()->at(n)->node(); + auto node = push_node(g, n); res.emplace_back(node); } diff --git a/compiler/loco/src/IR/Graph.test.cpp b/compiler/loco/src/IR/Graph.test.cpp index 628621e..0641238 100644 --- a/compiler/loco/src/IR/Graph.test.cpp +++ b/compiler/loco/src/IR/Graph.test.cpp @@ -156,8 +156,6 @@ TEST(GraphTest, getters_over_const_instance) EXPECT_EQ(ptr->nodes()->size(), 2); EXPECT_EQ(ptr->inputs()->size(), 1); - EXPECT_EQ(ptr->inputs()->at(0)->node(), pull); - EXPECT_EQ(ptr->outputs()->at(0)->node(), push); } TEST(GraphTest, graph_node_enumeration) @@ -200,6 +198,6 @@ TEST(GraphTest, graph_inout_enumeration) auto output_nodes = loco::output_nodes(g.get()); ASSERT_EQ(output_nodes.size(), 2); - ASSERT_EQ(output_nodes.at(0), g->outputs()->at(0)->node()); - ASSERT_EQ(output_nodes.at(1), g->outputs()->at(1)->node()); + ASSERT_EQ(output_nodes.at(0), push_1); + ASSERT_EQ(output_nodes.at(1), push_3); } diff --git a/compiler/loco/src/IR/Nodes.cpp b/compiler/loco/src/IR/Nodes.cpp index a7006a7..f480e7a 100644 --- a/compiler/loco/src/IR/Nodes.cpp +++ b/compiler/loco/src/IR/Nodes.cpp @@ -71,11 +71,7 @@ const Dimension &Push::dim(uint32_t axis) const return graph()->outputs()->at(index())->shape()->dim(axis); } -void link(GraphOutput *output, Push *push) -{ - output->node(push); - push->index(output->index()); -} +void link(GraphOutput *output, Push *push) { push->index(output->index()); } Push *push_node(Graph *g, const GraphOutputIndex &index) { @@ -170,11 +166,7 @@ DataType Pull::dtype(void) const } } -void link(GraphInput *input, Pull *pull) -{ - input->node(pull); - pull->index(input->index()); -} +void link(GraphInput *input, Pull *pull) { pull->index(input->index()); } Pull *pull_node(Graph *g, const GraphInputIndex &index) { -- 2.7.4