Initialize the pending count for each node.
| 28 | |
| 29 | // Initialize the pending count for each node. |
| 30 | void InitializePending(const Graph* graph, std::vector<int>* pending) { |
| 31 | pending->resize(graph->num_node_ids()); |
| 32 | for (const Node* node : graph->nodes()) { |
| 33 | const int id = node->id(); |
| 34 | int num_in_edges = 0; |
| 35 | if (IsMerge(node)) { |
| 36 | // For forward execution order, Merge nodes are special. We process |
| 37 | // them only once when one of its inputs is processed. |
| 38 | for (const Edge* edge : node->in_edges()) { |
| 39 | if (edge->IsControlEdge()) { |
| 40 | // Bit 0 is reserved to indicate if there is a data input. |
| 41 | num_in_edges += 2; |
| 42 | } |
| 43 | } |
| 44 | } else { |
| 45 | num_in_edges = node->in_edges().size(); |
| 46 | } |
| 47 | (*pending)[id] = num_in_edges; |
| 48 | } |
| 49 | } |
| 50 | |
| 51 | // Return true if the update makes the destination of the edge ready to run. |
| 52 | bool UpdatePending(const Edge* edge, std::vector<int>* pending_count) { |
no test coverage detected