Test if a node exists in the partition graphs. Args: node_name: (`str`) name of the node to be checked. device_name: optional device name. If None, will search for the node on all available devices. Otherwise, search for the node only on the given device. Return
(self, node_name, device_name=None)
| 1266 | return self._device_names |
| 1267 | |
| 1268 | def node_exists(self, node_name, device_name=None): |
| 1269 | """Test if a node exists in the partition graphs. |
| 1270 | |
| 1271 | Args: |
| 1272 | node_name: (`str`) name of the node to be checked. |
| 1273 | device_name: optional device name. If None, will search for the node |
| 1274 | on all available devices. Otherwise, search for the node only on |
| 1275 | the given device. |
| 1276 | |
| 1277 | Returns: |
| 1278 | A boolean indicating whether the node exists. |
| 1279 | |
| 1280 | Raises: |
| 1281 | LookupError: If no partition graphs have been loaded yet. |
| 1282 | ValueError: If device_name is specified but cannot be found. |
| 1283 | """ |
| 1284 | if not self._debug_graphs: |
| 1285 | raise LookupError( |
| 1286 | "Nodes have not been loaded from partition graphs yet.") |
| 1287 | |
| 1288 | if (device_name is not None) and device_name not in self._debug_graphs: |
| 1289 | raise ValueError( |
| 1290 | "The specified device_name '%s' cannot be found." % device_name) |
| 1291 | |
| 1292 | for _, debug_graph in self._debug_graphs.items(): |
| 1293 | if node_name in debug_graph.node_inputs: |
| 1294 | return True |
| 1295 | return False |
| 1296 | |
| 1297 | def node_device(self, node_name): |
| 1298 | """Get the names of the devices that has nodes of the specified name. |
no outgoing calls