Skip to content

Commit a2b6092

Browse files
StrongerXifacebook-github-bot
authored andcommitted
Fix handling of setattr with some tensor attributes (#149791)
Summary: We weren't handling `setattr(tensor_obj, "real", 42)` correctly, because the attribute is a `GetSetDescriptorType` that has special setter logic. See added test and comments for more explanations. This patch makes it so that we graph break in those cases, rather than resulting in silent incorrectness. X-link: pytorch/pytorch#149791 Approved by: https://github.com/mlazos ghstack dependencies: #149481 Reviewed By: yangw-dev Differential Revision: D71844103 fbshipit-source-id: 01afafc2b1332541477f6779597cecbda5918448
1 parent 7481a40 commit a2b6092

File tree

1 file changed

+8
-0
lines changed
  • userbenchmark/dynamo/dynamobench/_dynamo

1 file changed

+8
-0
lines changed

userbenchmark/dynamo/dynamobench/_dynamo/utils.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4072,6 +4072,14 @@ def is_tensor_base_attr_getter(value):
40724072
)
40734073

40744074

4075+
def is_tensor_getset_descriptor(name):
4076+
try:
4077+
attr = inspect.getattr_static(torch.Tensor, name)
4078+
return type(attr) is types.GetSetDescriptorType
4079+
except AttributeError:
4080+
return False
4081+
4082+
40754083
def is_torch_function_object(value):
40764084
return hasattr(value, "__torch_function__")
40774085

0 commit comments

Comments
 (0)