Skip to content
523 changes: 397 additions & 126 deletions test/functorch/test_control_flow.py

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion torch/_dynamo/trace_rules.py
Original file line number Diff line number Diff line change
Expand Up @@ -2284,7 +2284,7 @@
"torch._guards.compile_context",
"torch._guards.detect_fake_mode",
"torch._guards.tracing",
"torch._higher_order_ops.map._has_potential_branch_input_alias",
"torch._higher_order_ops.map._has_potential_branch_input_output_alias",
"torch._higher_order_ops.map._has_potential_branch_input_mutation",
"torch._higher_order_ops.map._stack_pytree",
"torch._higher_order_ops.map._unstack_pytree",
Expand Down
4 changes: 2 additions & 2 deletions torch/_higher_order_ops/cond.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
from torch._functorch.utils import exposed_in
from torch._guards import detect_fake_mode
from torch._higher_order_ops.utils import (
_has_potential_branch_input_alias,
_has_potential_branch_input_mutation,
_has_potential_branch_input_output_alias,
_maybe_run_with_interpreter,
_set_compilation_env,
reenter_make_fx,
Expand Down Expand Up @@ -469,7 +469,7 @@ def cond_func(ctx, pred, true_fn, false_fn, inputs):
"One of torch.cond branch might be modifying the input!"
)
for branch in [true_fn, false_fn]:
if _has_potential_branch_input_alias(
if _has_potential_branch_input_output_alias(
branch, unwrapped_inputs, pre_dispatch=pre_dispatch
):
raise UnsupportedAliasMutationException(
Expand Down
4 changes: 2 additions & 2 deletions torch/_higher_order_ops/hints_wrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
import torch.utils._pytree as pytree
from torch._C import DispatchKey
from torch._higher_order_ops.utils import (
_has_potential_branch_input_alias,
_has_potential_branch_input_mutation,
_has_potential_branch_input_output_alias,
autograd_not_implemented,
reenter_make_fx,
unique_graph_id,
Expand Down Expand Up @@ -103,7 +103,7 @@ def hints_wrapper_functionalize(ctx, body_fn, args, kwargs, hints):
raise UnsupportedAliasMutationException(
"body_fn of hints_wrapper might be modifying the input!"
)
if _has_potential_branch_input_alias(
if _has_potential_branch_input_output_alias(
functional_body_fn, unwrapped_args, pre_dispatch=pre_dispatch
):
raise UnsupportedAliasMutationException(
Expand Down
4 changes: 2 additions & 2 deletions torch/_higher_order_ops/map.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
from torch._dispatch.python import suspend_functionalization
from torch._functorch.aot_autograd import AOTConfig, create_joint
from torch._higher_order_ops.utils import (
_has_potential_branch_input_alias,
_has_potential_branch_input_mutation,
_has_potential_branch_input_output_alias,
_maybe_run_with_interpreter,
reenter_make_fx,
UnsupportedAliasMutationException,
Expand Down Expand Up @@ -255,7 +255,7 @@ def map_functionalize(ctx, f, xs, pos_args):
):
raise UnsupportedAliasMutationException("torch.map is mutating the input!")

if _has_potential_branch_input_alias(
if _has_potential_branch_input_output_alias(
f, example_inputs, pre_dispatch=pre_dispatch
):
raise UnsupportedAliasMutationException("torch.map is aliasing the input!")
Expand Down
Loading