| 53 | } |
| 54 | |
| 55 | void DevAllocator::PartitionGraph(GenericEngine* engine, GraphExecutor* graph_executor, Graph* graph, |
| 56 | std::vector<Subgraph*>& sub_list) |
| 57 | { |
| 58 | int node_number = graph->seq_nodes.size(); |
| 59 | |
| 60 | std::vector<int> visited(node_number, 0); |
| 61 | std::queue<Node*> search_root_nodes; |
| 62 | |
| 63 | // push all output nodes into search_root_nodes |
| 64 | for(unsigned int i = 0; i < graph->output_nodes.size(); i++) |
| 65 | search_root_nodes.push(graph->output_nodes[i]); |
| 66 | |
| 67 | int sub_graph_count = 0; |
| 68 | |
| 69 | while(1) |
| 70 | { |
| 71 | if(search_root_nodes.empty()) |
| 72 | break; |
| 73 | |
| 74 | Node* node = search_root_nodes.front(); |
| 75 | search_root_nodes.pop(); |
| 76 | |
| 77 | if(visited[node->GetNodeIndex()]) |
| 78 | continue; |
| 79 | |
| 80 | visited[node->GetNodeIndex()] = 1; |
| 81 | |
| 82 | DevExecutor* dev_executor = any_cast<DevExecutor*>(node->GetAttr("dev_executor")); |
| 83 | |
| 84 | std::string sub_graph_name = graph->GetName(); |
| 85 | |
| 86 | sub_graph_name = sub_graph_name + ":" + std::to_string(sub_graph_count); |
| 87 | |
| 88 | sub_graph_count++; |
| 89 | |
| 90 | Subgraph* sub_graph = new Subgraph(sub_graph_name); |
| 91 | |
| 92 | sub_graph->seq_nodes.push_back(node); |
| 93 | |
| 94 | // for all nodes ... |
| 95 | std::queue<Node*> check_list; |
| 96 | |
| 97 | check_list.push(node); |
| 98 | |
| 99 | do |
| 100 | { |
| 101 | node = check_list.front(); |
| 102 | check_list.pop(); |
| 103 | |
| 104 | bool node_in_input = false; |
| 105 | |
| 106 | // check all parenet nodes, if any |
| 107 | for(int i = 0; i < node->GetParentNum(); i++) |
| 108 | { |
| 109 | Node* parent_node = node->GetParentNode(i); |
| 110 | |
| 111 | // input or const node |
| 112 | if(!parent_node->ExistAttr("dev_executor")) |
nothing calls this directly
no test coverage detected