mirror of
https://github.com/zebrajr/pytorch.git
synced 2025-12-06 00:20:18 +01:00
Revert "[dynamo] add sourceless builder for types.MethodType (#147880)"
This reverts commit 08f4c1a233.
Reverted https://github.com/pytorch/pytorch/pull/147880 on behalf of https://github.com/wdvr due to failing trunk tests ([comment](https://github.com/pytorch/pytorch/pull/147880#issuecomment-2686436432))
This commit is contained in:
parent
84e60eece8
commit
915eb012e1
|
|
@ -2071,18 +2071,6 @@ class FunctionTests(torch._dynamo.test_case.TestCase):
|
|||
mytuple.z = a
|
||||
return hasattr(mytuple, "x"), mytuple.x + mytuple.y, mytuple.z
|
||||
|
||||
@make_test
|
||||
def test_sourceless_build_method_type(a, b):
|
||||
cls = collections.namedtuple("Foo", ["x", "y"]) # sourceless variable
|
||||
|
||||
# The type of `cls._make` and `cls._asdict` is method type
|
||||
if callable(getattr(cls, "_make", None)) and callable(
|
||||
getattr(cls, "_asdict", None)
|
||||
):
|
||||
return a + b
|
||||
else:
|
||||
return a - b
|
||||
|
||||
@make_test
|
||||
def test_torch_size_hasattr(x):
|
||||
if hasattr(x.shape, "_fields"):
|
||||
|
|
|
|||
|
|
@ -3060,15 +3060,6 @@ class SourcelessBuilder:
|
|||
return UserDefinedClassVariable(value)
|
||||
elif isinstance(value, types.MethodWrapperType):
|
||||
return MethodWrapperVariable(value)
|
||||
elif (
|
||||
isinstance(value, types.MethodType)
|
||||
# We only support sourceless class objects
|
||||
# An instance variable is not allowed and it should have source
|
||||
and isinstance(value.__self__, (type, abc.ABCMeta))
|
||||
):
|
||||
assert getattr(value.__self__, value.__func__.__name__) == value
|
||||
cls_obj_vt = SourcelessBuilder.create(tx, value.__self__)
|
||||
return cls_obj_vt.var_getattr(tx, value.__func__.__name__)
|
||||
elif isinstance(value, torch.fx.graph_module.GraphModule):
|
||||
return SourcelessGraphModuleVariable(value)
|
||||
elif isinstance(
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user