diff --git a/test/nn/test_convolution.py b/test/nn/test_convolution.py index a204f1920b4da1..c7982def8c17e2 100644 --- a/test/nn/test_convolution.py +++ b/test/nn/test_convolution.py @@ -506,10 +506,11 @@ def test_Conv2d_groups_nobias(self): output2 = m2(i2) output2.backward(grad_output[:, 2:].contiguous()) - self.assertEqual(output, torch.cat([output1, output2], 1)) + self.assertEqual(output, torch.cat([output1, output2], 1), + atol=dtype2prec_DONTUSE[dtype], rtol=0) self.assertEqual(i.grad.data, torch.cat([i1.grad.data, i2.grad.data], 1), - atol=dtype2prec_DONTUSE[dtype], rtol=0) + atol=1e-1 if dtype == torch.half else dtype2prec_DONTUSE[dtype], rtol=0) self.assertEqual(m.weight.grad.data, torch.cat([m1.weight.grad.data, m2.weight.grad.data], 0), atol=1e-1 if dtype == torch.half else dtype2prec_DONTUSE[dtype], rtol=0) @@ -545,13 +546,14 @@ def test_Conv2d_groups_nobias_v2(self): output2 = m2(i2) output2.backward(grad_output[:, 8:].contiguous()) - self.assertEqual(output, torch.cat([output1, output2], 1)) + self.assertEqual(output, torch.cat([output1, output2], 1), + atol=dtype2prec_DONTUSE[dtype], rtol=0) self.assertEqual(i.grad.data, torch.cat([i1.grad.data, i2.grad.data], 1), - atol=dtype2prec_DONTUSE[dtype], rtol=0) + atol=1e-1 if dtype == torch.half else dtype2prec_DONTUSE[dtype], rtol=0) self.assertEqual(m.weight.grad.data, torch.cat([m1.weight.grad.data, m2.weight.grad.data], 0), - atol=1e-1 if dtype == torch.half else dtype2prec_DONTUSE[dtype], rtol=0) + atol=2e-1 if dtype in [torch.half, torch.bfloat16] else dtype2prec_DONTUSE[dtype], rtol=0) # CPU-only test for group conv3d fast implementation using bmm # See: https://github.com/pytorch/pytorch/pull/36355 @@ -2076,7 +2078,8 @@ def test_Conv2d_naive_groups(self, device, dtype): output2 = m2(i2) output2.backward(grad_output[:, 2:].contiguous()) - self.assertEqual(output, torch.cat([output1, output2], 1)) + self.assertEqual(output, torch.cat([output1, output2], 1), + atol=dtype2prec_DONTUSE[dtype], rtol=0) self.assertEqual(i.grad.data, torch.cat([i1.grad.data, i2.grad.data], 1), atol=dtype2prec_DONTUSE[dtype], rtol=0) @@ -2085,7 +2088,7 @@ def test_Conv2d_naive_groups(self, device, dtype): atol=dtype2prec_DONTUSE[dtype], rtol=0) self.assertEqual(m.weight.grad.data, torch.cat([m1.weight.grad.data, m2.weight.grad.data], 0), - atol=dtype2prec_DONTUSE[dtype], rtol=0) + atol=1e-1 if dtype == torch.half else dtype2prec_DONTUSE[dtype], rtol=0) @dtypes(torch.double, torch.cdouble) def test_Conv2d_backward_depthwise(self, device, dtype):