From 1732cc74eb9f2dccefdb16874293f00210525883 Mon Sep 17 00:00:00 2001 From: =?utf8?q?=EA=B9=80=EC=88=98=EC=A7=84/=EB=8F=99=EC=9E=91=EC=A0=9C?= =?utf8?q?=EC=96=B4Lab=28SR=29/Engineer/=EC=82=BC=EC=84=B1=EC=A0=84?= =?utf8?q?=EC=9E=90?= Date: Tue, 4 Sep 2018 12:56:43 +0900 Subject: [PATCH] [neurun] Use MockNode.h in Insert test (#2565) This commit uses `MockNode.h` in Insert test. Signed-off-by: sjsujinkim --- runtimes/neurun/test/graph/operation/Insert.cc | 62 +++++++++----------------- 1 file changed, 21 insertions(+), 41 deletions(-) diff --git a/runtimes/neurun/test/graph/operation/Insert.cc b/runtimes/neurun/test/graph/operation/Insert.cc index fba7555..b1ae8ac 100644 --- a/runtimes/neurun/test/graph/operation/Insert.cc +++ b/runtimes/neurun/test/graph/operation/Insert.cc @@ -4,43 +4,14 @@ #include "graph/verifier/IVerifier.h" #include "nnfw/std/memory.h" #include "graph/operand/Index.h" +#include "MockNode.h" #include 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(input_operand, operand1)); + auto mocknode_index1 = + graph.addOperation(nnfw::make_unique(IndexSet{input_operand}, IndexSet{operand1})); // MockNode2 auto operand2 = graph.addOperand(shape, type); - auto mocknode_index2 = graph.addOperation(nnfw::make_unique(operand1, operand2)); + auto mocknode_index2 = + graph.addOperation(nnfw::make_unique(IndexSet{operand1}, IndexSet{operand2})); // MockNode3 - auto mocknode_index3 = graph.addOperation(nnfw::make_unique(operand2, output_operand)); + auto mocknode_index3 = + graph.addOperation(nnfw::make_unique(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(operand1, inserted_operand1)); + operand1, mocknode_index2, + nnfw::make_unique(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(operand2, inserted_operand2)); + operand2, mocknode_index3, + nnfw::make_unique(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(input_operand, operand1)); + auto mocknode_index1 = + graph.addOperation(nnfw::make_unique(IndexSet{input_operand}, IndexSet{operand1})); // MockNode2 auto operand2 = graph.addOperand(shape, type); - auto mocknode_index2 = graph.addOperation(nnfw::make_unique(input_operand, operand2)); + auto mocknode_index2 = + graph.addOperation(nnfw::make_unique(IndexSet{input_operand}, IndexSet{operand2})); // MultiInputMockNode auto multiinput_index = graph.addOperation( - nnfw::make_unique(IndexSet{operand1, operand2}, output_operand)); + nnfw::make_unique(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(operand1, inserted_operand1)); + operand1, multiinput_index, + nnfw::make_unique(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(operand2, inserted_operand2)); + operand2, multiinput_index, + nnfw::make_unique(IndexSet{operand2}, IndexSet{inserted_operand2})); ASSERT_EQ(inserted_index2.asInt(), 4); -- 2.7.4