Make interpolate_bilinear deterministic using decomposition (#101115)

Signed-off-by: Edward Z. Yang <ezyang@meta.com>

Pull Request resolved: https://github.com/pytorch/pytorch/pull/101115
Approved by: https://github.com/ngimel
This commit is contained in:
Edward Z. Yang
2023-05-11 08:49:23 -07:00
committed by PyTorch MergeBot
parent daed3bf8f9
commit c567748e16
3 changed files with 29 additions and 1 deletions

View File

@ -1439,6 +1439,24 @@ else:
'upsample_bilinear2d_backward_out_cuda',
torch.device(device).type == 'cuda')
@skipIfTorchInductor("aot-autograd issue")
def test_deterministic_interpolate_bilinear(self, device):
input = torch.randn(1, 2, 4, 4, device=device, requires_grad=True)
grad = None
with DeterministicGuard(True):
for _ in range(5):
res = torch.nn.functional.interpolate(
input,
size=12,
mode='bilinear',
align_corners=False)
res.backward(torch.ones_like(res))
if grad is None:
grad = input.grad
else:
self.assertEqual(grad, input.grad, atol=0, rtol=0)
input.grad = None
@skipIfMps
@skipIfTorchInductor("aot-autograd issue")
def test_nondeterministic_alert_interpolate_bicubic(self, device):