From b8d1609c2bc21ba72c798ad7e0f2942cdb7ef088 Mon Sep 17 00:00:00 2001 From: Erik Lundell Date: Thu, 25 Sep 2025 10:38:50 +0200 Subject: [PATCH] Arm backend: Better error message in PassManager. The fx.PassManager ArmPassManager inherits from catches all pass errors and wraps them with a rasie ... from e, which means the top level error message that is often shown in ci is not very useful. Instead, catch the error and dig out the original error. Signed-off-by: Erik Lundell Change-Id: I47902d35519c85f9277c8e053bcffe6e40434a8e --- backends/arm/_passes/arm_pass_manager.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/backends/arm/_passes/arm_pass_manager.py b/backends/arm/_passes/arm_pass_manager.py index 70470890317..037b2bb8bbd 100644 --- a/backends/arm/_passes/arm_pass_manager.py +++ b/backends/arm/_passes/arm_pass_manager.py @@ -112,6 +112,8 @@ from executorch.exir.pass_manager import PassManager from executorch.exir.passes.remove_graph_asserts_pass import RemoveGraphAssertsPass from torch.fx import GraphModule +from torch.fx.passes.infra.pass_base import PassResult +from torch.nn.modules import Module class ArmPassManager(PassManager): @@ -355,3 +357,20 @@ def transform_for_annotation_pipeline(self, graph_module: GraphModule): self.add_pass(DecomposeMaskedFill()) return self._transform(graph_module) + + def __call__(self, module: Module) -> PassResult: + try: + return super().__call__(module) + except Exception as e: + first_exception = e.__cause__ or e.__context__ or e + import re + + message = e.args[0] + m = re.search(r"An error occurred when running the '([^']+)' pass", message) + if m: + pass_name = m.group(1) + first_exception.args = ( + f"{pass_name}: {first_exception.args[0]}", + *first_exception.args[1:], + ) + raise first_exception