From 8fbc9df45e59fa71ca6add41de1114163dba3ee3 Mon Sep 17 00:00:00 2001 From: Animesh Jain Date: Sun, 9 Feb 2025 23:45:21 -0800 Subject: [PATCH] Update on "[dynamo][lists] Support list subclasses" cc voznesenskym penguinwu EikanWang jgong5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng wenzhe-nrv jiayisunx chenyang78 kadeng chauhang amjames [ghstack-poisoned] --- torch/_dynamo/source.py | 1 + torch/_dynamo/utils.py | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/torch/_dynamo/source.py b/torch/_dynamo/source.py index 6ded79f01c1..d9c4051ad7f 100644 --- a/torch/_dynamo/source.py +++ b/torch/_dynamo/source.py @@ -559,6 +559,7 @@ class DictGetItemSource(ChainedSource): self.index.reconstruct(codegen) else: codegen.append_output(codegen.create_load_const(self.index)) + # TODO(anijain2305) - Change this to dict.__getitem__(d, k) codegen.append_output(create_instruction("BINARY_SUBSCR")) def name(self): diff --git a/torch/_dynamo/utils.py b/torch/_dynamo/utils.py index 6130c1168f4..f240413f0c0 100644 --- a/torch/_dynamo/utils.py +++ b/torch/_dynamo/utils.py @@ -2409,7 +2409,7 @@ def to_subclass(t, cls): def dict_keys_getitem(d, n): - return next(itertools.islice(iter(d), n, n + 1)) + return next(itertools.islice(iter(dict(d)), n, n + 1)) def enum_repr(value, local):