Returns the debug info for the original nodes in the `converted_graph`. Args: nodes_to_debug_info_func: The method to collect the op debug info for the nodes. converted_graph: A `GraphDef` after optimization and transfermation. Returns: `GraphDebugInfo` for all the original nod
(nodes_to_debug_info_func, converted_graph)
| 308 | |
| 309 | |
| 310 | def get_debug_info(nodes_to_debug_info_func, converted_graph): |
| 311 | """Returns the debug info for the original nodes in the `converted_graph`. |
| 312 | |
| 313 | Args: |
| 314 | nodes_to_debug_info_func: The method to collect the op debug info for the |
| 315 | nodes. |
| 316 | converted_graph: A `GraphDef` after optimization and transfermation. |
| 317 | |
| 318 | Returns: |
| 319 | `GraphDebugInfo` for all the original nodes in `converted_graph`. |
| 320 | """ |
| 321 | if not nodes_to_debug_info_func: |
| 322 | return None |
| 323 | |
| 324 | # Collect all the debug info nodes from the converted_graph |
| 325 | original_nodes = set() |
| 326 | for node in converted_graph.node: |
| 327 | debug_nodes = node.experimental_debug_info.original_node_names |
| 328 | debug_funcs = node.experimental_debug_info.original_func_names |
| 329 | # If the `original_node_names` are empty, uses the node name directly. |
| 330 | if not debug_nodes: |
| 331 | original_nodes.add(("", node.name)) |
| 332 | else: |
| 333 | for i in range(len(debug_nodes)): |
| 334 | original_nodes.add((debug_funcs[i], debug_nodes[i])) |
| 335 | |
| 336 | # Convert the nodes to the debug info proto object. |
| 337 | return nodes_to_debug_info_func(original_nodes) |