Skip to content

Commit 1f70227

Browse files
rascaniclaude
andcommitted
Move SubstitutionFn after AtenToDialectPass class definition
The TypeAlias RHS is a runtime expression, not an annotation, so __future__.annotations does not defer it. Move it after the class so AtenToDialectPass is defined when the Callable type evaluates. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent d07a763 commit 1f70227

1 file changed

Lines changed: 8 additions & 6 deletions

File tree

backends/transforms/aten_to_dialect_pass.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,6 @@ class DialectNodeSpec:
2727
kwargs: dict = None
2828

2929

30-
# Expected type to be used for substitution functions
31-
SubstitutionFn: TypeAlias = Callable[
32-
[torch.fx.Node, AtenToDialectPass], DialectNodeSpec | None
33-
]
34-
35-
3630
class AtenToDialectPass(ExportPass):
3731
"""
3832
General pass to convert ops from ATen to a specific dialect.
@@ -117,3 +111,11 @@ def call(self, graph_module: torch.fx.GraphModule) -> PassResult:
117111
graph_module = super().call(graph_module).graph_module
118112

119113
return PassResult(graph_module, modified)
114+
115+
116+
# Defined after the class so AtenToDialectPass is available at runtime.
117+
# Class-body references to SubstitutionFn are annotation-only and resolve
118+
# via __future__.annotations.
119+
SubstitutionFn: TypeAlias = Callable[
120+
[torch.fx.Node, AtenToDialectPass], DialectNodeSpec | None
121+
]

0 commit comments

Comments
 (0)