[loco] Remove "node" method from Graph Input/Output (#6759)
author박종현/On-Device Lab(SR)/Staff Engineer/삼성전자 <jh1302.park@samsung.com>
Wed, 21 Aug 2019 04:34:57 +0000 (13:34 +0900)
committerGitHub Enterprise <noreply-CODE@samsung.com>
Wed, 21 Aug 2019 04:34:57 +0000 (13:34 +0900)
This commit removes "node" method from GraphInput/GraphOutput class.

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

index 0e576dc..f9a53f7 100644 (file)
@@ -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};
 };
 
 /**
index c7c5984..7029f92 100644 (file)
@@ -50,26 +50,6 @@ void Mixin<Trait::TensorShaped>::shape(std::initializer_list<Dimension> 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<GraphInput>(size()));
@@ -98,7 +78,7 @@ std::vector<loco::Node *> 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);
   }
 
index 628621e..0641238 100644 (file)
@@ -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);
 }
index a7006a7..f480e7a 100644 (file)
@@ -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)
 {