Verifies that the list of collective nodes in `graph` matches `expected_collective_nodes`, and that the list of control edges between these collective nodes matches `expected_collective_control_edges`.
| 32 | // `expected_collective_nodes`, and that the list of control edges between these |
| 33 | // collective nodes matches `expected_collective_control_edges`. |
| 34 | void VerifyGraph(const Graph& graph, |
| 35 | const std::vector<string>& expected_collective_nodes, |
| 36 | const std::vector<std::pair<string, string>>& |
| 37 | expected_collective_control_edges) { |
| 38 | std::vector<string> actual_collective_nodes; |
| 39 | std::vector<std::pair<string, string>> actual_collective_control_edges; |
| 40 | for (const Node* src : graph.nodes()) { |
| 41 | if (!src->IsCollective()) { |
| 42 | continue; |
| 43 | } |
| 44 | actual_collective_nodes.push_back(src->name()); |
| 45 | for (const Edge* edge : src->out_edges()) { |
| 46 | VLOG(2) << "collective edge " << edge->src()->name() << " -> " |
| 47 | << edge->dst()->name(); |
| 48 | // Add all control edges found except those to `_SINK`. |
| 49 | if (!edge->IsControlEdge() || edge->dst()->name() == "_SINK") { |
| 50 | continue; |
| 51 | } |
| 52 | actual_collective_control_edges.emplace_back(src->name(), |
| 53 | edge->dst()->name()); |
| 54 | } |
| 55 | } |
| 56 | EXPECT_THAT(actual_collective_nodes, |
| 57 | UnorderedElementsAreArray(expected_collective_nodes)); |
| 58 | EXPECT_THAT(actual_collective_control_edges, |
| 59 | UnorderedElementsAreArray(expected_collective_control_edges)); |
| 60 | } |
| 61 | |
| 62 | // Verifies that the `wait_for` attribute on collective nodes matches |
| 63 | // `wait_for_map`. |
no test coverage detected