Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
MMCV
Commits
227037fc
Unverified
Commit
227037fc
authored
Jan 13, 2022
by
Zaida Zhou
Committed by
GitHub
Jan 13, 2022
Browse files
[Fix] Fix the unit test of correlation op (#1659)
parent
ccdc61c0
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
4 deletions
+7
-4
tests/test_ops/test_correlation.py
tests/test_ops/test_correlation.py
+7
-4
No files found.
tests/test_ops/test_correlation.py
View file @
227037fc
...
@@ -30,10 +30,13 @@ class TestCorrelation:
...
@@ -30,10 +30,13 @@ class TestCorrelation:
out
=
layer
(
input1
,
input2
)
out
=
layer
(
input1
,
input2
)
out
.
backward
(
torch
.
ones_like
(
out
))
out
.
backward
(
torch
.
ones_like
(
out
))
gt_out
=
torch
.
tensor
(
_gt_out
,
dtype
=
dtype
)
# `eq_cpu` is not implemented for 'Half' in torch1.5.0,
assert_equal_tensor
(
out
.
cpu
(),
gt_out
)
# so we need to make a comparison for cuda tensor
assert_equal_tensor
(
input1
.
grad
.
detach
().
cpu
(),
input2
.
cpu
())
# rather than cpu tensor
assert_equal_tensor
(
input2
.
grad
.
detach
().
cpu
(),
input1
.
cpu
())
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
(
@
pytest
.
mark
.
skipif
(
not
torch
.
cuda
.
is_available
(),
reason
=
'requires CUDA support'
)
not
torch
.
cuda
.
is_available
(),
reason
=
'requires CUDA support'
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment