Skip to content

Commit eb19da6

Browse files
committed
Fix BC break: ShapeEnv.size_hint renamed to guarding_hint_or_throw
PyTorch renamed ShapeEnv.size_hint() to guarding_hint_or_throw(). Use hasattr to support both old and new PyTorch versions. This diff was authored with Claude.
1 parent 4035db9 commit eb19da6

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

exir/sym_util.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,10 @@ def eval_expr(symint: Union[int, torch.SymInt]) -> Optional[int]:
2525
shape_env = node.shape_env
2626
expr = node.expr
2727
try:
28-
output = shape_env.size_hint(expr)
28+
if hasattr(shape_env, "guarding_hint_or_throw"):
29+
output = shape_env.guarding_hint_or_throw(expr)
30+
else:
31+
output = shape_env.size_hint(expr)
2932
except torch.fx.experimental.symbolic_shapes.GuardOnDataDependentSymNode:
3033
return None
3134
return int(output)

0 commit comments

Comments
 (0)