MCPcopy Create free account
hub / github.com/pytorch/executorch / visualize_graph

Function visualize_graph

devtools/visualization/visualization_utils.py:282–305  ·  view source on GitHub ↗

Overrides the graph_module of the supplied exported_program with 'graph_module' before visualizing. Also disables validating operators to allow visualizing graphs containing custom ops. A typical example is after running passes, which returns a graph_module rather than an ExportedProgram.

(
    graph_module: GraphModule,
    exported_program: ExportedProgram | EdgeProgramManager | ExecutorchProgramManager,
    reuse_server: bool = True,
    no_open_in_browser: bool = False,
    **kwargs,
)

Source from the content-addressed store, hash-verified

280
281
282def visualize_graph(
283 graph_module: GraphModule,
284 exported_program: ExportedProgram | EdgeProgramManager | ExecutorchProgramManager,
285 reuse_server: bool = True,
286 no_open_in_browser: bool = False,
287 **kwargs,
288):
289 """Overrides the graph_module of the supplied exported_program with 'graph_module' before visualizing.
290 Also disables validating operators to allow visualizing graphs containing custom ops.
291
292 A typical example is after running passes, which returns a graph_module rather than an ExportedProgram.
293 """
294
295 class _any_op(Verifier):
296 dialect = "ANY_OP"
297
298 def allowed_op_types(self) -> tuple[Type[Any], ...]:
299 return (Callable,) # type: ignore
300
301 exported_program = _get_exported_program(exported_program)
302 exported_program = _update_exported_program_graph_module(
303 exported_program, graph_module, override_verifiers=[_any_op]
304 )
305 visualize(exported_program, reuse_server, no_open_in_browser, **kwargs)

Callers 2

callMethod · 0.90
test_visualize_graphFunction · 0.90

Calls 3

_get_exported_programFunction · 0.85
visualizeFunction · 0.85

Tested by 1

test_visualize_graphFunction · 0.72