From: 이한종/동작제어Lab(SR)/Engineer/삼성전자 Date: Tue, 11 Sep 2018 06:23:10 +0000 (+0900) Subject: [neurun] Add assert condition to insertOperation (#2639) X-Git-Tag: 0.2~48 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=82dced96e626d1ad6ce9f248be48d38208101a5b;p=platform%2Fcore%2Fml%2Fnnfw.git [neurun] Add assert condition to insertOperation (#2639) The node to be added in `Graph::insertOperation` must not have any inputs. Signed-off-by: Hanjoung Lee --- diff --git a/runtimes/neurun/src/graph/Graph.cc b/runtimes/neurun/src/graph/Graph.cc index 06116ec..19bc26b 100644 --- a/runtimes/neurun/src/graph/Graph.cc +++ b/runtimes/neurun/src/graph/Graph.cc @@ -65,6 +65,7 @@ operation::Index Graph::insertOperation(const operand::Index &prev_operand_index auto next_input_indexes = next_operation.getInputs(); assert(next_input_indexes.contains(prev_operand_index)); + assert(node->getInputs().size() == 0); // node to be inserted must not have any inputs node->setInputs({prev_operand_index}); diff --git a/runtimes/neurun/test/graph/operation/Insert.cc b/runtimes/neurun/test/graph/operation/Insert.cc index 6f3f53f..c938ab4 100644 --- a/runtimes/neurun/test/graph/operation/Insert.cc +++ b/runtimes/neurun/test/graph/operation/Insert.cc @@ -61,17 +61,17 @@ TEST(graph_operation_manipulation, operation_insertion) // Insert node1 (between 1 and 2) auto inserted_operand1 = graph.addOperand(shape, type); - auto inserted_index1 = graph.insertOperation( - operand1, mocknode_index2, - nnfw::make_unique(IndexSet{operand1}, IndexSet{inserted_operand1})); + auto inserted_index1 = + graph.insertOperation(operand1, mocknode_index2, + nnfw::make_unique(IndexSet{}, 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(IndexSet{operand2}, IndexSet{inserted_operand2})); + auto inserted_index2 = + graph.insertOperation(operand2, mocknode_index3, + nnfw::make_unique(IndexSet{}, IndexSet{inserted_operand2})); ASSERT_EQ(inserted_index2.asInt(), 4); @@ -121,17 +121,17 @@ TEST(graph_operation_manipulation, operation_insertion_multi_input) // Insert node1 (between 1 and multi) auto inserted_operand1 = graph.addOperand(shape, type); - auto inserted_index1 = graph.insertOperation( - operand1, multiinput_index, - nnfw::make_unique(IndexSet{operand1}, IndexSet{inserted_operand1})); + auto inserted_index1 = + graph.insertOperation(operand1, multiinput_index, + nnfw::make_unique(IndexSet{}, 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(IndexSet{operand2}, IndexSet{inserted_operand2})); + auto inserted_index2 = + graph.insertOperation(operand2, multiinput_index, + nnfw::make_unique(IndexSet{}, IndexSet{inserted_operand2})); ASSERT_EQ(inserted_index2.asInt(), 4);