Skip to content

Commit df8d03b

Browse files
authored
Arm backend: Better error message in PassManager. (pytorch#14587)
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 <[email protected]>
1 parent 85959e2 commit df8d03b

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

backends/arm/_passes/arm_pass_manager.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,8 @@
112112
from executorch.exir.pass_manager import PassManager
113113
from executorch.exir.passes.remove_graph_asserts_pass import RemoveGraphAssertsPass
114114
from torch.fx import GraphModule
115+
from torch.fx.passes.infra.pass_base import PassResult
116+
from torch.nn.modules import Module
115117

116118

117119
class ArmPassManager(PassManager):
@@ -355,3 +357,20 @@ def transform_for_annotation_pipeline(self, graph_module: GraphModule):
355357
self.add_pass(DecomposeMaskedFill())
356358

357359
return self._transform(graph_module)
360+
361+
def __call__(self, module: Module) -> PassResult:
362+
try:
363+
return super().__call__(module)
364+
except Exception as e:
365+
first_exception = e.__cause__ or e.__context__ or e
366+
import re
367+
368+
message = e.args[0]
369+
m = re.search(r"An error occurred when running the '([^']+)' pass", message)
370+
if m:
371+
pass_name = m.group(1)
372+
first_exception.args = (
373+
f"{pass_name}: {first_exception.args[0]}",
374+
*first_exception.args[1:],
375+
)
376+
raise first_exception

0 commit comments

Comments
 (0)