Skip to content

Handle -inf for Torchscript of FX graphs #124

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
anijain2305 opened this issue Apr 6, 2022 · 0 comments
Closed

Handle -inf for Torchscript of FX graphs #124

anijain2305 opened this issue Apr 6, 2022 · 0 comments

Comments

@anijain2305
Copy link
Contributor

Repro

import torch
import torch.fx

x = torch.randn(4, 5)
mask = torch.randn(4, 5) > 0.5

def f(x, mask):
    # return x.masked_fill_(mask, 1.0) # PASSES
    return x.masked_fill_(mask, float("-inf"))

print(f(x, mask))

# Only fails when symbolic_trace
fx_mod = torch.fx.symbolic_trace(f)
scripted_f = torch.jit.script(fx_mod)
print(scripted_f(x, mask))

@eellison

facebook-github-bot pushed a commit to pytorch/pytorch that referenced this issue Apr 8, 2022
Summary:
Fixes pytorch/torchdynamo#124

Pull Request resolved: #75439
Approved by: https://github.com/anijain2305, https://github.com/davidberard98

Test Plan: contbuild & OSS CI, see https://hud.pytorch.org/commit/pytorch/pytorch/00d11de564313ec4e59c40674da3f9f400de7089

Reviewed By: b0noI

Differential Revision: D35485701

Pulled By: eellison

fbshipit-source-id: a67310d07c5b344645f5584ac1ac1caa23c7f0b9
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants