visited[index.value()] = true;
on_stack[index.value()] = true;
- auto outputs = node.getOutputs();
- for (auto output : outputs)
+ for (auto output : node.getOutputs())
{
- // TODO Fix traversing algorithm
- // Every time need to search for operations that has `outgoing` as incoming from all
- // operations but we can hold that info cached
- operations.iterate([&](const operation::Index &cand_index, const operation::Node &cand_node) {
- auto inputs = cand_node.getInputs();
- for (auto input : inputs)
- {
- if (output == input)
- {
- dfs_recursive(cand_index, cand_node);
- }
- }
- });
+ const auto &operand = graph.operands().at(output);
+ for (const auto &use : operand.getUses().list())
+ {
+ dfs_recursive(use, graph.operations().at(use));
+ }
}
on_stack[index.value()] = false;
graph.addOperation(nnfw::make_unique<MockNode>(IndexSet{operand1}, IndexSet{operand2}));
- ASSERT_EQ(verifier.verify(graph), true);
-
- // Create cycle
- graph.operands().at(operand1).setAsOperationOutput();
- graph.addOperation(nnfw::make_unique<MockNode>(IndexSet{operand2}, IndexSet{operand1}));
+ graph.finishBuilding();
- ASSERT_EQ(verifier.verify(graph), false);
+ ASSERT_EQ(verifier.verify(graph), true);
}