Returns debugging info for the node referred to by 'node_root'.
| 1195 | |
| 1196 | // Returns debugging info for the node referred to by 'node_root'. |
| 1197 | string ColocationGraph::DebugInfo(const int node_root) const { |
| 1198 | string text( |
| 1199 | "\nColocation Debug Info:\n" |
| 1200 | "Colocation group had the following types and supported devices: "); |
| 1201 | |
| 1202 | // If this node is part of a colocation group, then we want to |
| 1203 | // collect the mapping of ops to supported devices, so that |
| 1204 | // the user can see why an unsatisfiable placement occurred. |
| 1205 | |
| 1206 | std::unordered_map<string, string> type_to_devices; |
| 1207 | std::vector<const Node*> colocation_nodes; |
| 1208 | int num_nodes_found = 0; |
| 1209 | |
| 1210 | for (const Node* node : graph_.nodes()) { |
| 1211 | if (!node->IsOp()) { |
| 1212 | continue; |
| 1213 | } |
| 1214 | int id = node->id(); |
| 1215 | if (FindRoot(id) != node_root) { |
| 1216 | continue; |
| 1217 | } |
| 1218 | ++num_nodes_found; |
| 1219 | colocation_nodes.push_back(node); |
| 1220 | |
| 1221 | PrioritizedDeviceTypeVector supported_types; |
| 1222 | SupportedDeviceTypesForNode(device_types_, node->def(), &supported_types, |
| 1223 | &local_address_spec_) |
| 1224 | .IgnoreError(); |
| 1225 | string devices_registered; |
| 1226 | for (const auto& device_type : supported_types) { |
| 1227 | strings::StrAppend(&devices_registered, |
| 1228 | DeviceTypeString(device_type.first), " "); |
| 1229 | } |
| 1230 | |
| 1231 | const string& op_type = node->type_string(); |
| 1232 | type_to_devices[op_type] = std::move(devices_registered); |
| 1233 | } |
| 1234 | strings::StrAppend(&text, "\nRoot ", members_[node_root].DebugString()); |
| 1235 | |
| 1236 | for (const auto& td : type_to_devices) { |
| 1237 | strings::StrAppend(&text, "\n", td.first, ": ", td.second); |
| 1238 | } |
| 1239 | strings::StrAppend(&text, |
| 1240 | "\n\nColocation members, user-requested devices, and " |
| 1241 | "framework assigned devices, if any:"); |
| 1242 | for (const Node* node : colocation_nodes) { |
| 1243 | strings::StrAppend(&text, "\n ", node->name(), " (", node->type_string(), |
| 1244 | ") ", node->requested_device()); |
| 1245 | if (node->has_assigned_device_name()) { |
| 1246 | strings::StrAppend( |
| 1247 | &text, " framework assigned device=", node->assigned_device_name()); |
| 1248 | } |
| 1249 | } |
| 1250 | strings::StrAppend(&text, "\n"); |
| 1251 | |
| 1252 | if (num_nodes_found <= 0) { |
| 1253 | text.clear(); |
| 1254 | } |
nothing calls this directly
no test coverage detected