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
68a2c0a1
"docs/vscode:/vscode.git/clone" did not exist on "ac3fc649066df9d347df519b3d0877d41fb847b1"
Unverified
Commit
68a2c0a1
authored
Mar 18, 2022
by
Wenhao Wu
Committed by
GitHub
Mar 18, 2022
Browse files
Update unittest for mmdet3d ops (#1811)
parent
e5ae1bfa
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
18 additions
and
6 deletions
+18
-6
tests/test_ops/test_gather_points.py
tests/test_ops/test_gather_points.py
+4
-0
tests/test_ops/test_roiaware_pool3d.py
tests/test_ops/test_roiaware_pool3d.py
+8
-0
tests/test_ops/test_roipoint_pool3d.py
tests/test_ops/test_roipoint_pool3d.py
+1
-1
tests/test_ops/test_scatter_points.py
tests/test_ops/test_scatter_points.py
+5
-5
No files found.
tests/test_ops/test_gather_points.py
View file @
68a2c0a1
...
@@ -45,3 +45,7 @@ def test_gather_points():
...
@@ -45,3 +45,7 @@ def test_gather_points():
[
-
0.7172
,
0.0462
,
-
0.6227
,
-
0.7172
,
-
0.7172
,
-
0.7172
]]]).
cuda
()
[
-
0.7172
,
0.0462
,
-
0.6227
,
-
0.7172
,
-
0.7172
,
-
0.7172
]]]).
cuda
()
assert
torch
.
allclose
(
output
,
expected_output
)
assert
torch
.
allclose
(
output
,
expected_output
)
# test fp16
output_half
=
gather_points
(
features
.
half
(),
idx
)
assert
torch
.
allclose
(
output_half
,
expected_output
.
half
())
tests/test_ops/test_roiaware_pool3d.py
View file @
68a2c0a1
...
@@ -133,3 +133,11 @@ def test_points_in_boxes_all():
...
@@ -133,3 +133,11 @@ def test_points_in_boxes_all():
dtype
=
torch
.
int32
).
cuda
()
dtype
=
torch
.
int32
).
cuda
()
assert
point_indices
.
shape
==
torch
.
Size
([
1
,
15
,
2
])
assert
point_indices
.
shape
==
torch
.
Size
([
1
,
15
,
2
])
assert
(
point_indices
==
expected_point_indices
).
all
()
assert
(
point_indices
==
expected_point_indices
).
all
()
if
torch
.
cuda
.
device_count
()
>
1
:
pts
=
pts
.
to
(
'cuda:1'
)
boxes
=
boxes
.
to
(
'cuda:1'
)
expected_point_indices
=
expected_point_indices
.
to
(
'cuda:1'
)
point_indices
=
points_in_boxes_all
(
points
=
pts
,
boxes
=
boxes
)
assert
point_indices
.
shape
==
torch
.
Size
([
1
,
15
,
2
])
assert
(
point_indices
==
expected_point_indices
).
all
()
tests/test_ops/test_roipoint_pool3d.py
View file @
68a2c0a1
...
@@ -7,7 +7,7 @@ from mmcv.ops import RoIPointPool3d
...
@@ -7,7 +7,7 @@ from mmcv.ops import RoIPointPool3d
@
pytest
.
mark
.
skipif
(
@
pytest
.
mark
.
skipif
(
not
torch
.
cuda
.
is_available
(),
reason
=
'requires CUDA support'
)
not
torch
.
cuda
.
is_available
(),
reason
=
'requires CUDA support'
)
def
test_
gather_
point
s
():
def
test_
roi
point
():
feats
=
torch
.
tensor
(
feats
=
torch
.
tensor
(
[[
1
,
2
,
3.3
],
[
1.2
,
2.5
,
3.0
],
[
0.8
,
2.1
,
3.5
],
[
1.6
,
2.6
,
3.6
],
[[
1
,
2
,
3.3
],
[
1.2
,
2.5
,
3.0
],
[
0.8
,
2.1
,
3.5
],
[
1.6
,
2.6
,
3.6
],
[
0.8
,
1.2
,
3.9
],
[
-
9.2
,
21.0
,
18.2
],
[
3.8
,
7.9
,
6.3
],
[
0.8
,
1.2
,
3.9
],
[
-
9.2
,
21.0
,
18.2
],
[
3.8
,
7.9
,
6.3
],
...
...
tests/test_ops/test_scatter_points.py
View file @
68a2c0a1
...
@@ -9,11 +9,6 @@ from mmcv.ops import DynamicScatter
...
@@ -9,11 +9,6 @@ from mmcv.ops import DynamicScatter
@
pytest
.
mark
.
skipif
(
@
pytest
.
mark
.
skipif
(
not
torch
.
cuda
.
is_available
(),
reason
=
'requires CUDA support'
)
not
torch
.
cuda
.
is_available
(),
reason
=
'requires CUDA support'
)
def
test_dynamic_scatter
():
def
test_dynamic_scatter
():
feats
=
torch
.
rand
(
size
=
(
200000
,
3
),
dtype
=
torch
.
float32
,
device
=
'cuda'
)
*
100
-
50
coors
=
torch
.
randint
(
low
=-
1
,
high
=
20
,
size
=
(
200000
,
3
),
dtype
=
torch
.
int32
,
device
=
'cuda'
)
dsmean
=
DynamicScatter
([
0.32
,
0.32
,
6
],
dsmean
=
DynamicScatter
([
0.32
,
0.32
,
6
],
[
-
74.88
,
-
74.88
,
-
2
,
74.88
,
74.88
,
4
],
True
)
[
-
74.88
,
-
74.88
,
-
2
,
74.88
,
74.88
,
4
],
True
)
dsmax
=
DynamicScatter
([
0.32
,
0.32
,
6
],
dsmax
=
DynamicScatter
([
0.32
,
0.32
,
6
],
...
@@ -53,6 +48,11 @@ def test_dynamic_scatter():
...
@@ -53,6 +48,11 @@ def test_dynamic_scatter():
assert
(
empty_o_feats
.
grad
==
0
).
all
()
assert
(
empty_o_feats
.
grad
==
0
).
all
()
# test non-empty input
# test non-empty input
feats
=
torch
.
rand
(
size
=
(
200000
,
3
),
dtype
=
torch
.
float32
,
device
=
'cuda'
)
*
100
-
50
coors
=
torch
.
randint
(
low
=-
1
,
high
=
20
,
size
=
(
200000
,
3
),
dtype
=
torch
.
int32
,
device
=
'cuda'
)
ref_voxel_coors
=
coors
.
unique
(
dim
=
0
,
sorted
=
True
)
ref_voxel_coors
=
coors
.
unique
(
dim
=
0
,
sorted
=
True
)
ref_voxel_coors
=
ref_voxel_coors
[
ref_voxel_coors
.
min
(
dim
=-
1
).
values
>=
0
]
ref_voxel_coors
=
ref_voxel_coors
[
ref_voxel_coors
.
min
(
dim
=-
1
).
values
>=
0
]
ref_voxel_feats_mean
=
[]
ref_voxel_feats_mean
=
[]
...
...
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