#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)
{
// 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);
// 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);