mirror of
https://github.com/pytorch/pytorch.git
synced 2025-10-20 21:14:14 +08:00
[Dynamo] Fix inspect.getattr_static doesn't work well for torch.utils._cxx_pytree.PyTreeSpec (#120812)
Fixes #118793 Pull Request resolved: https://github.com/pytorch/pytorch/pull/120812 Approved by: https://github.com/zou3519
This commit is contained in:
committed by
PyTorch MergeBot
parent
311cc564f6
commit
46c9d646dd
@ -19,6 +19,11 @@ try:
|
||||
except ModuleNotFoundError:
|
||||
np = None
|
||||
|
||||
try:
|
||||
from torch.utils._cxx_pytree import PyTreeSpec
|
||||
except ImportError:
|
||||
PyTreeSpec = type(None)
|
||||
|
||||
import torch._dynamo.config
|
||||
|
||||
import torch.nn
|
||||
@ -697,7 +702,7 @@ class UserDefinedObjectVariable(UserDefinedVariable):
|
||||
|
||||
def _getattr_static(self, name):
|
||||
if (
|
||||
isinstance(self.value, torch.nn.Module)
|
||||
isinstance(self.value, (torch.nn.Module, PyTreeSpec))
|
||||
or "__slots__" in self.value.__class__.__dict__
|
||||
or type(self.value) == threading.local
|
||||
):
|
||||
|
Reference in New Issue
Block a user