Function to create `GraphDebugInfo` for the given `original_nodes`.
(original_nodes)
| 280 | converts them to a `GraphDebugInfo` for a given set of nodes. |
| 281 | """ |
| 282 | def f(original_nodes): |
| 283 | """Function to create `GraphDebugInfo` for the given `original_nodes`.""" |
| 284 | if not original_graph: |
| 285 | return None |
| 286 | # For the given nodes, gets all the op definitions in the original graph. |
| 287 | useful_ops = [] |
| 288 | for func, name in original_nodes: |
| 289 | try: |
| 290 | if not func: |
| 291 | useful_ops.append((func, original_graph.get_operation_by_name(name))) |
| 292 | else: |
| 293 | sub_func = original_graph._get_function(func) # pylint: disable=protected-access |
| 294 | if isinstance(sub_func, function._EagerDefinedFunction): # pylint: disable=protected-access |
| 295 | useful_ops.append( |
| 296 | (func, sub_func.graph.get_operation_by_name(name))) |
| 297 | else: |
| 298 | sys.stderr.write( |
| 299 | "Use '@tf.function' or '@defun' to decorate the function.") |
| 300 | continue |
| 301 | except KeyError: |
| 302 | # New node created by graph optimizer. No stack trace from source code. |
| 303 | continue |
| 304 | # Convert all the op definitions to stack traces in terms of GraphDebugInfo. |
| 305 | return _error_interpolation.create_graph_debug_info_def(useful_ops) |
| 306 | |
| 307 | return f |
| 308 |