[loco] Update index on link (#6381)
author박종현/On-Device Lab(SR)/Staff Engineer/삼성전자 <jh1302.park@samsung.com>
Thu, 8 Aug 2019 07:42:30 +0000 (16:42 +0900)
committerGitHub Enterprise <noreply-CODE@samsung.com>
Thu, 8 Aug 2019 07:42:30 +0000 (16:42 +0900)
Both "link" helpers now update the index of a corresponding node.

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

index 47b61d7..000b207 100644 (file)
@@ -57,7 +57,11 @@ GraphOutputIndex Push::index(void) const
   return static_cast<GraphOutputIndex>(_index);
 }
 
-void link(GraphOutput *output, Push *push) { output->node(push); }
+void link(GraphOutput *output, Push *push)
+{
+  output->node(push);
+  push->index(output->index());
+}
 
 } // namespace loco
 
@@ -137,7 +141,11 @@ DataType Pull::dtype(void) const
   }
 }
 
-void link(GraphInput *input, Pull *pull) { input->node(pull); }
+void link(GraphInput *input, Pull *pull)
+{
+  input->node(pull);
+  pull->index(input->index());
+}
 
 } // namespace loco
 
index 7496a18..9c352f0 100644 (file)
@@ -65,15 +65,11 @@ TEST(LOCO, identity_network)
   graph_output->name("output");
   loco::link(graph_output, push_node);
 
-  // Set Input Index
-  pull_node->index(0);
-
+  // loco::link SHOULD update "index"
   ASSERT_EQ(pull_node->index(), 0);
   ASSERT_EQ(graph_input->dtype(), loco::DataType::FLOAT32);
 
-  // Set Output Index
-  push_node->index(0);
-
+  // loco::link SHOULD update "index"
   ASSERT_EQ(push_node->index(), 0);
 }