| 65 | bool HasNode(const string& name) { return FindNode(name) != nullptr; } |
| 66 | |
| 67 | void ExpectNodes(const string& nodes) { |
| 68 | int count = 0; |
| 69 | std::vector<string> actual_nodes; |
| 70 | for (Node* n : g_->nodes()) { |
| 71 | if (n->IsOp()) { |
| 72 | count++; |
| 73 | actual_nodes.push_back(n->name()); |
| 74 | } |
| 75 | } |
| 76 | std::sort(actual_nodes.begin(), actual_nodes.end()); |
| 77 | |
| 78 | LOG(INFO) << "Nodes present: " << absl::StrJoin(actual_nodes, " "); |
| 79 | |
| 80 | std::vector<string> expected_nodes = str_util::Split(nodes, ','); |
| 81 | std::sort(expected_nodes.begin(), expected_nodes.end()); |
| 82 | for (const string& s : expected_nodes) { |
| 83 | Node* n = FindNode(s); |
| 84 | EXPECT_TRUE(n != nullptr) << s; |
| 85 | if (n->type_string() == "_Send" || n->type_string() == "_Recv") { |
| 86 | EXPECT_EQ(device_info_.name(), n->assigned_device_name()) << s; |
| 87 | } |
| 88 | } |
| 89 | |
| 90 | EXPECT_TRUE(actual_nodes.size() == expected_nodes.size()) |
| 91 | << "\nActual: " << absl::StrJoin(actual_nodes, ",") |
| 92 | << "\nExpected: " << absl::StrJoin(expected_nodes, ","); |
| 93 | } |
| 94 | |
| 95 | bool HasEdge(const string& src, int src_out, const string& dst, int dst_in) { |
| 96 | for (const Edge* e : g_->edges()) { |