Skip to content

Commit 2f11fa4

Browse files
ydwu4facebook-github-bot
authored andcommitted
Avoid directly calling the map operator
Summary: Calling the higher order operator directly is not recommended since it skips the safety check. Differential Revision: D74036464
1 parent 385d860 commit 2f11fa4

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

exir/tests/control_flow_models.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
import torch
88
from torch.nn import Module # @manual
9+
from torch._higher_order_ops.map import map as torch_map
910

1011

1112
class FTCondBasic(Module):
@@ -87,7 +88,7 @@ def forward(self, xs, y):
8788
def f(x, y):
8889
return x + y
8990

90-
return torch.ops.higher_order.map(f, xs, y) + xs
91+
return torch_map(f, xs, y) + xs
9192

9293
def get_random_inputs(self):
9394
return torch.rand(2, 4), torch.rand(4)
@@ -101,7 +102,7 @@ def forward(self, xs, y):
101102
def f(x, y):
102103
return x + y
103104

104-
return torch.ops.higher_order.map(f, xs, y) + xs
105+
return torch_map(f, xs, y) + xs
105106

106107
def get_upper_bound_inputs(self):
107108
return torch.rand(4, 4), torch.rand(4)

0 commit comments

Comments
 (0)