Skip to content

Commit 3e5a389

Browse files
aorenstefacebook-github-bot
authored andcommitted
Fix dynamo use of list[int] in graph break (#145554)
Summary: This reintroduces the change backed out by #145393 and fixes the underlying problem. Although using a BuiltinVariable was better than nothing when we saw a GenericAlias it had problems if there was a graph break and we had to reconstruct the original python code which BuiltinVariable did as a simple `list` instead of a `list[int]`. This changes it to use a TypingVariable instead and then teaches TypingVariable how to reconstruct. Original commit changeset: 77b9193acb23 python test/dynamo/test_repros.py ReproTests.test_graph_break_on_jit_isinstance X-link: pytorch/pytorch#145554 Approved by: https://github.com/anijain2305 ghstack dependencies: #145551, #145552, #145553 Reviewed By: ZainRizvi Differential Revision: D68924393 fbshipit-source-id: 82fa9bd3f62df08df9ed80c08e98426f61d12f5e
1 parent 7b7276d commit 3e5a389

File tree

1 file changed

+10
-1
lines changed
  • userbenchmark/dynamo/dynamobench/_dynamo

1 file changed

+10
-1
lines changed

userbenchmark/dynamo/dynamobench/_dynamo/utils.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2162,7 +2162,16 @@ def rot_n_helper(n):
21622162
def is_safe_constant(v):
21632163
if istype(v, (tuple, frozenset)):
21642164
return all(map(is_safe_constant, v))
2165-
return isinstance(v, (enum.Enum, type, torch.Size)) or istype(
2165+
return isinstance(
2166+
v,
2167+
(
2168+
enum.Enum,
2169+
type,
2170+
torch.Size,
2171+
typing._GenericAlias, # type: ignore[attr-defined]
2172+
types.GenericAlias,
2173+
),
2174+
) or istype(
21662175
v,
21672176
common_constant_types | {slice},
21682177
)

0 commit comments

Comments
 (0)