mirror of
https://github.com/pytorch/pytorch.git
synced 2025-10-20 21:14:14 +08:00
Revert "[Dynamo] Check for __bool__ attribute before accessing it (#120943)"
This reverts commit dd7aeedb72f8a96d0f168308292e0d41c095f01b. Reverted https://github.com/pytorch/pytorch/pull/120943 on behalf of https://github.com/DanilBaibak due to Broken trunk ([comment](https://github.com/pytorch/pytorch/pull/120943#issuecomment-2063098295))
This commit is contained in:
@ -409,14 +409,10 @@ def generic_jump(truth_fn: typing.Callable[[object], bool], push: bool):
|
||||
self.push(value)
|
||||
self.jump(inst)
|
||||
elif isinstance(value, UserDefinedObjectVariable):
|
||||
x = None
|
||||
has_bool = value.call_hasattr(self, "__bool__")
|
||||
if has_bool.is_python_constant() and has_bool.as_python_constant():
|
||||
x = value.var_getattr(self, "__bool__")
|
||||
else:
|
||||
has_len = value.call_hasattr(self, "__len__")
|
||||
if has_len.is_python_constant() and has_len.as_python_constant():
|
||||
x = value.var_getattr(self, "__len__")
|
||||
x = value.var_getattr(self, "__bool__")
|
||||
# if __bool__ is missing, trying __len__ to infer a truth value.
|
||||
if isinstance(x, GetAttrVariable):
|
||||
x = value.var_getattr(self, "__len__")
|
||||
|
||||
# __bool__ or __len__ is function
|
||||
if isinstance(x, UserMethodVariable):
|
||||
|
Reference in New Issue
Block a user