From 26924997cb009e6699f04fa47f560c3a262c83eb Mon Sep 17 00:00:00 2001 From: Adrian Lundell Date: Wed, 5 Feb 2025 10:46:18 +0100 Subject: [PATCH] Add visualization debug pass Change-Id: I731da8f2622a05b6cd45e86a8cb77d1a40ebe8dc --- backends/arm/_passes/_debug_passes.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 backends/arm/_passes/_debug_passes.py diff --git a/backends/arm/_passes/_debug_passes.py b/backends/arm/_passes/_debug_passes.py new file mode 100644 index 00000000000..7809885d465 --- /dev/null +++ b/backends/arm/_passes/_debug_passes.py @@ -0,0 +1,23 @@ +# Copyright 2025 Arm Limited and/or its affiliates. +# +# This source code is licensed under the BSD-style license found in the +# LICENSE file in the root directory of this source tree. + +import torch +from executorch.devtools.visualization.visualization_utils import visualize_graph +from executorch.exir import ExportedProgram +from executorch.exir.pass_base import ExportPass, PassResult + + +class VisualizePass(ExportPass): + """ + This pass visualizes the graph at the point of insertion in the pass manager + """ + + def __init__(self, exported_program: ExportedProgram) -> None: + super().__init__() + self.exported_program = exported_program + + def call(self, graph_module: torch.fx.GraphModule) -> PassResult: + visualize_graph(graph_module, self.exported_program) + return PassResult(graph_module, False)