pytorch
9a575e77 - inductor: align baddbmm behavior with eager mode for beta=0 and input has nan value (#96087)

Commit
2 years ago
inductor: align baddbmm behavior with eager mode for beta=0 and input has nan value (#96087) For ```torch.baddbmm(input, mat1,mat2, beta=0)```, if ```beta``` is zero, the multiplication of value ```input*beta``` will be ignored for the eager mode(always gets zero number, see https://pytorch.org/docs/stable/generated/torch.baddbmm.html?highlight=torch+baddbmm#torch.baddbmm), but the inductor is not, the inductor will get a different value if the input has a ```nan``` of ```inf``` value: ``` def fn_test(input, mat1, mat2): return torch.baddbmm(input, mat1, mat2, beta=0.0) opt_fn = torch._dynamo.optimize("inductor")(fn_test) a, b, c = [torch.rand((3,2,2)) for _ in range(3)] real_out = fn_test(a, b, c) a[:] = torch.nan compiled_out = opt_fn(a, b,c) print(compiled_out) print(real_out) ``` before this PR, the output will be like this: ``` tensor([[[0.4272, 0.6037], [0.4279, 0.4219]], [[0.0838, 0.4873], [0.1210, 0.5516]], [[ nan, nan], [ nan, nan]]]) tensor([[[0.4272, 0.6037], [0.4279, 0.4219]], [[0.0838, 0.4873], [0.1210, 0.5516]], [[0.4985, 0.1072], [0.0857, 0.0186]]]) ``` Pull Request resolved: https://github.com/pytorch/pytorch/pull/96087 Approved by: https://github.com/jansel, https://github.com/ngimel, https://github.com/jgong5
Author
Committer
Parents
Loading