Skip to content
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

[Fix] Fix the unit test of correlation op #1659

Merged
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
11 changes: 7 additions & 4 deletions tests/test_ops/test_correlation.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,13 @@ def _test_correlation(self, dtype=torch.float):
out = layer(input1, input2)
out.backward(torch.ones_like(out))

gt_out = torch.tensor(_gt_out, dtype=dtype)
assert_equal_tensor(out.cpu(), gt_out)
assert_equal_tensor(input1.grad.detach().cpu(), input2.cpu())
assert_equal_tensor(input2.grad.detach().cpu(), input1.cpu())
# `eq_cpu` is not implemented for 'Half' in torch1.5.0,
# so we need to make a comparison for cuda tensor
# rather than cpu tensor
gt_out = torch.tensor(_gt_out, dtype=dtype).cuda()
assert_equal_tensor(out, gt_out)
assert_equal_tensor(input1.grad.detach(), input2)
assert_equal_tensor(input2.grad.detach(), input1)

@pytest.mark.skipif(
not torch.cuda.is_available(), reason='requires CUDA support')
Expand Down