[neurun] Use MockNode.h in Insert test (#2565)
author김수진/동작제어Lab(SR)/Engineer/삼성전자 <sjsujin.kim@samsung.com>
Tue, 4 Sep 2018 03:56:43 +0000 (12:56 +0900)
committer오형석/동작제어Lab(SR)/Staff Engineer/삼성전자 <hseok82.oh@samsung.com>
Tue, 4 Sep 2018 03:56:43 +0000 (12:56 +0900)
This commit uses `MockNode.h` in Insert test.

Signed-off-by: sjsujinkim <sjsujin.kim@samsung.com>
runtimes/neurun/test/graph/operation/Insert.cc

index fba7555..b1ae8ac 100644 (file)
@@ -4,43 +4,14 @@
 #include "graph/verifier/IVerifier.h"
 #include "nnfw/std/memory.h"
 #include "graph/operand/Index.h"
+#include "MockNode.h"
 
 #include <typeindex>
 
 using IOIndex = neurun::graph::operand::IO::Index;
 using Index = neurun::graph::operand::Index;
 using IndexSet = neurun::graph::operand::IndexSet;
-
-namespace
-{
-
-class MockNode : public neurun::graph::operation::Node
-{
-public:
-  MockNode(Index input, Index output)
-  {
-    setInputs({input});
-    setOutputs({output});
-  }
-
-public:
-  virtual void accept(neurun::graph::operation::NodeVisitor &&) const override {}
-};
-
-class MultiInputMockNode : public neurun::graph::operation::Node
-{
-public:
-  MultiInputMockNode(IndexSet inputs, Index output)
-  {
-    setInputs(inputs);
-    setOutputs({output});
-  }
-
-public:
-  virtual void accept(neurun::graph::operation::NodeVisitor &&) const override {}
-};
-
-} // namespace anonymous
+using MockNode = neurun_test::graph::operation::SimpleMockNode;
 
 TEST(graph_operation_manipulation, operation_insertion)
 {
@@ -60,26 +31,31 @@ TEST(graph_operation_manipulation, operation_insertion)
 
   // MockNode1
   auto operand1 = graph.addOperand(shape, type);
-  auto mocknode_index1 = graph.addOperation(nnfw::make_unique<MockNode>(input_operand, operand1));
+  auto mocknode_index1 =
+      graph.addOperation(nnfw::make_unique<MockNode>(IndexSet{input_operand}, IndexSet{operand1}));
   // MockNode2
   auto operand2 = graph.addOperand(shape, type);
-  auto mocknode_index2 = graph.addOperation(nnfw::make_unique<MockNode>(operand1, operand2));
+  auto mocknode_index2 =
+      graph.addOperation(nnfw::make_unique<MockNode>(IndexSet{operand1}, IndexSet{operand2}));
   // MockNode3
-  auto mocknode_index3 = graph.addOperation(nnfw::make_unique<MockNode>(operand2, output_operand));
+  auto mocknode_index3 =
+      graph.addOperation(nnfw::make_unique<MockNode>(IndexSet{operand2}, IndexSet{output_operand}));
 
   ASSERT_EQ(verifier.verify(graph), true);
 
   // Insert node1 (between 1 and 2)
   auto inserted_operand1 = graph.addOperand(shape, type);
   auto inserted_index1 = graph.insertOperation(
-      operand1, mocknode_index2, nnfw::make_unique<MockNode>(operand1, inserted_operand1));
+      operand1, mocknode_index2,
+      nnfw::make_unique<MockNode>(IndexSet{operand1}, IndexSet{inserted_operand1}));
 
   ASSERT_EQ(inserted_index1.asInt(), 3);
 
   // Insert node2 (between 2 and 3)
   auto inserted_operand2 = graph.addOperand(shape, type);
   auto inserted_index2 = graph.insertOperation(
-      operand2, mocknode_index3, nnfw::make_unique<MockNode>(operand2, inserted_operand2));
+      operand2, mocknode_index3,
+      nnfw::make_unique<MockNode>(IndexSet{operand2}, IndexSet{inserted_operand2}));
 
   ASSERT_EQ(inserted_index2.asInt(), 4);
 
@@ -115,27 +91,31 @@ TEST(graph_operation_manipulation, operation_insertion_multi_input)
 
   // MockNode1
   auto operand1 = graph.addOperand(shape, type);
-  auto mocknode_index1 = graph.addOperation(nnfw::make_unique<MockNode>(input_operand, operand1));
+  auto mocknode_index1 =
+      graph.addOperation(nnfw::make_unique<MockNode>(IndexSet{input_operand}, IndexSet{operand1}));
   // MockNode2
   auto operand2 = graph.addOperand(shape, type);
-  auto mocknode_index2 = graph.addOperation(nnfw::make_unique<MockNode>(input_operand, operand2));
+  auto mocknode_index2 =
+      graph.addOperation(nnfw::make_unique<MockNode>(IndexSet{input_operand}, IndexSet{operand2}));
   // MultiInputMockNode
   auto multiinput_index = graph.addOperation(
-      nnfw::make_unique<MultiInputMockNode>(IndexSet{operand1, operand2}, output_operand));
+      nnfw::make_unique<MockNode>(IndexSet{operand1, operand2}, IndexSet{output_operand}));
 
   ASSERT_EQ(verifier.verify(graph), true);
 
   // Insert node1 (between 1 and multi)
   auto inserted_operand1 = graph.addOperand(shape, type);
   auto inserted_index1 = graph.insertOperation(
-      operand1, multiinput_index, nnfw::make_unique<MockNode>(operand1, inserted_operand1));
+      operand1, multiinput_index,
+      nnfw::make_unique<MockNode>(IndexSet{operand1}, IndexSet{inserted_operand1}));
 
   ASSERT_EQ(inserted_index1.asInt(), 3);
 
   // Insert node2 (between 2 and multi)
   auto inserted_operand2 = graph.addOperand(shape, type);
   auto inserted_index2 = graph.insertOperation(
-      operand2, multiinput_index, nnfw::make_unique<MockNode>(operand2, inserted_operand2));
+      operand2, multiinput_index,
+      nnfw::make_unique<MockNode>(IndexSet{operand2}, IndexSet{inserted_operand2}));
 
   ASSERT_EQ(inserted_index2.asInt(), 4);