Skip to content

Commit 5f2ab0e

Browse files
ydwu4facebook-github-bot
authored andcommitted
make the predicate truly data dependent. (#4130)
Summary: Pull Request resolved: #4130 Make the pred truely data-dependent to avoid specializing into one of the branches if we land pytorch/pytorch#128709. Reviewed By: angelayi Differential Revision: D59287189 fbshipit-source-id: 0302cf385b441680cbacc3dafedef54f407ea0f1
1 parent a33936b commit 5f2ab0e

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

exir/tests/control_flow_models.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def false_branch(x):
2020
return x * x
2121

2222
return torch.ops.higher_order.cond(
23-
inp.size(0) > 4, true_branch, false_branch, [inp]
23+
inp.sum() > 4, true_branch, false_branch, [inp]
2424
)
2525

2626
def get_random_inputs(self):
@@ -39,7 +39,7 @@ def false_branch(x):
3939
return x * x * x
4040

4141
return torch.ops.higher_order.cond(
42-
inp.size(0) > 4, true_branch, false_branch, [inp]
42+
inp.sum() > 4, true_branch, false_branch, [inp]
4343
)
4444

4545
def get_upper_bound_inputs(self):
@@ -72,7 +72,7 @@ def false_branch(x):
7272
return x * 2
7373

7474
return torch.ops.higher_order.cond(
75-
inp.size(0) > 4, true_branch, false_branch, [inp]
75+
inp.sum() > 4, true_branch, false_branch, [inp]
7676
)
7777

7878
def get_random_inputs(self):

0 commit comments

Comments
 (0)