[dynamo] Fix source for default dict default_factory (#120864)

Pull Request resolved: https://github.com/pytorch/pytorch/pull/120864
Approved by: https://github.com/yanboliang, https://github.com/Skylion007, https://github.com/jansel
This commit is contained in:
Animesh Jain 2024-02-28 20:17:10 -08:00 committed by PyTorch MergeBot
parent df1e855313
commit 66d05a8900

View File

@ -468,10 +468,13 @@ class VariableBuilder:
)
if istype(value, collections.defaultdict):
factory_source = AttrSource(self.source, "default_factory")
result = DefaultDictVariable(
result,
type(value),
default_factory=self._wrap(value.default_factory),
default_factory=VariableBuilder(self.tx, factory_source)(
value.default_factory
),
source=self.source,
)
else: