Skip to content

Commit

Permalink
[dynamo] Fix for #127696 (#128530)
Browse files Browse the repository at this point in the history
[dynamo] Fix for #127696 (#128358)

Test Plan:
`buck2 test @//mode/dev-nosan //executorch/exir/backend/...`
https://www.internalfb.com/intern/testinfra/testrun/12666373989243932

Differential Revision: D58384518

Pull Request resolved: #128358
Approved by: https://github.com/ydwu4

(cherry picked from commit 4345d98)

Co-authored-by: Angela Yi <angelayi@meta.com>
  • Loading branch information
pytorchbot and angelayi authored Jun 18, 2024
1 parent 1cd4199 commit 62417c6
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions torch/_dynamo/variables/higher_order_ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import torch.fx
import torch.nn
import torch.onnx.operators
from torch._dynamo.utils import deepcopy_to_fake_tensor, get_fake_value, get_real_value
from torch._dynamo.utils import get_fake_value
from torch._dynamo.variables import ConstantVariable
from torch._dynamo.variables.base import VariableTracker
from torch._dynamo.variables.builtin import BuiltinVariable
Expand Down Expand Up @@ -1149,17 +1149,15 @@ def call_function(

p_args = tuple(arg.as_proxy() for arg in args[1:])
real_sub_args = pytree.tree_map_only(
torch.fx.Proxy, lambda a: get_real_value(a.node, tx.output), p_args
torch.fx.Proxy, lambda a: get_fake_value(a.node, tx), p_args
)

example_res = lowered_module.original_module.module()(*real_sub_args)
example_value = lowered_module.original_module.module()(*real_sub_args)

# NOTE [Guaranteeing the 1-1 correspondence of FakeTensors and real tensors]:
# executorch modules promise not to alias inputs and outputs.
# Thus, output FakeTensors will correctly not alias input FakeTensors.
_assert_tensors_nonaliasing(real_sub_args, example_res)

example_value = deepcopy_to_fake_tensor(example_res, tx.fake_mode)
_assert_tensors_nonaliasing(real_sub_args, example_value)

p_args = (lowered_node,) + p_args

Expand Down

0 comments on commit 62417c6

Please sign in to comment.