MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / VerifyGraph

Function VerifyGraph

tensorflow/core/graph/collective_order_test.cc:34–60  ·  view source on GitHub ↗

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`.

Source from the content-addressed store, hash-verified

32// `expected_collective_nodes`, and that the list of control edges between these
33// collective nodes matches `expected_collective_control_edges`.
34void 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`.

Callers 1

TESTFunction · 0.85

Calls 8

IsCollectiveMethod · 0.80
nameMethod · 0.65
nodesMethod · 0.45
push_backMethod · 0.45
srcMethod · 0.45
dstMethod · 0.45
IsControlEdgeMethod · 0.45
emplace_backMethod · 0.45

Tested by

no test coverage detected