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,
)
| 280 | |
| 281 | |
| 282 | def 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) |