mirror of
https://github.com/pytorch/pytorch.git
synced 2025-10-20 21:14:14 +08:00
[dynamo] Graph break on torch.Tensor.data
assignment with mismatched dtype (#156623)
Fixes #152162. Discussed with @bdhirsh and decided this is the easiest workaround for now. Pull Request resolved: https://github.com/pytorch/pytorch/pull/156623 Approved by: https://github.com/bdhirsh
This commit is contained in:
committed by
PyTorch MergeBot
parent
e8cf5ff564
commit
d06a406656
@ -2175,6 +2175,17 @@ class BuiltinVariable(VariableTracker):
|
||||
"the mutation out of `torch.compile` region",
|
||||
],
|
||||
)
|
||||
elif obj.dtype != val.dtype: # type: ignore[attr-defined]
|
||||
unimplemented_v2(
|
||||
gb_type="Failed to mutate tensor data attribute to different dtype",
|
||||
context=f"setattr({obj}, {name}, {val})",
|
||||
explanation="Dyanmo only supports mutating `.data`"
|
||||
" of tensor to a new one with the same dtype",
|
||||
hints=[
|
||||
"Don't mutate `.data` on this tensor, or move "
|
||||
"the mutation out of `torch.compile` region",
|
||||
],
|
||||
)
|
||||
|
||||
# Remove the old reference in tracked fakes - if we don't do this
|
||||
# new .data value size and shape differences will cause
|
||||
|
Reference in New Issue
Block a user