Skip to content

Commit

Permalink
Use safe_is_leaf to test leafness
Browse files Browse the repository at this point in the history
This fixes one of the problems in #101160 (comment)
but I don't have a test case because the full example is fairly
difficult to minify.

Signed-off-by: Edward Z. Yang <ezyangmeta.com>

ghstack-source-id: 6a4e9aa7bb7693d87971caecab7c9c72e9accba8
Pull Request resolved: #102706
  • Loading branch information
ezyang committed Jun 1, 2023
1 parent 9fd14fc commit e9a1628
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion torch/_functorch/aot_autograd.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import torch.utils._pytree as pytree
import torch.utils.dlpack
from torch import Tensor
from torch._subclasses.meta_utils import safe_is_leaf
from torch._dispatch.python import enable_python_dispatcher
from torch._dynamo.utils import dynamo_timed, lazy_format_graph_code
from torch._guards import detect_fake_mode, tracing
Expand Down Expand Up @@ -748,7 +749,7 @@ def inner(*flat_args):
mutates_metadata = False

input_info.append(InputAliasInfo(
is_leaf=isinstance(arg, torch.Tensor) and arg.is_leaf,
is_leaf=isinstance(arg, torch.Tensor) and safe_is_leaf(arg),
mutates_data=mutates_data,
mutates_metadata=mutates_metadata
))
Expand Down

0 comments on commit e9a1628

Please sign in to comment.