Skip to content

Commit d35dca0

Browse files
authored
Handle -inf for Fx to TS (#671)
t p
1 parent 10e1c9d commit d35dca0

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

functorch/_src/compilers.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,11 @@ def ts_compile(fx_g: fx.GraphModule, _) -> Callable:
4040
args = list(node.args)
4141
args[1] = [1]
4242
node.args = tuple(args)
43+
elif node.target is torch.ops.aten.masked_fill and node.args[2] == float("-inf"):
44+
# Fx graph to torchscript fails for -inf
45+
args = list(node.args)
46+
args[2] = -3.403 * 10**37
47+
node.args = tuple(args)
4348

4449
for node in fx_g.graph.nodes:
4550
new_kwargs = {}

0 commit comments

Comments
 (0)