Skip to content

Fix test_Conv2d_groups related errors (SWDEV-423016) (#1269) #1344

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

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 10 additions & 7 deletions test/nn/test_convolution.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand All @@ -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):
Expand Down