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
vision
Commits
1ababf90
Unverified
Commit
1ababf90
authored
Dec 05, 2023
by
Nicolas Hug
Committed by
GitHub
Dec 05, 2023
Browse files
Add manual opcheck tests for roi ops (#8144)
parent
fe0d280d
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
38 additions
and
21 deletions
+38
-21
test/optests_failures_dict.json
test/optests_failures_dict.json
+1
-12
test/test_ops.py
test/test_ops.py
+37
-9
No files found.
test/optests_failures_dict.json
View file @
1ababf90
{
"_description"
:
"This is a dict containing failures for tests autogenerated by generate_opcheck_tests. For more details, please see https://docs.google.com/document/d/1Pj5HRZvdOq3xpFpbEjUZp2hBovhy7Wnxw14m6lF2154/edit"
,
"_version"
:
1
,
"data"
:
{
"torchvision::roi_align"
:
{
"TestRoIAlign.test_aot_dispatch_dynamic__test_mps_error_inputs"
:
{
"comment"
:
"RuntimeError: MPS does not support roi_align backward with float16 inputs"
,
"status"
:
"xfail"
},
"TestRoIAlign.test_autograd_registration__test_mps_error_inputs"
:
{
"comment"
:
"NotImplementedError: autograd_registration_check: NYI devices other than CPU/CUDA, got {'mps'}"
,
"status"
:
"xfail"
}
}
}
"data"
:
{}
}
test/test_ops.py
View file @
1ababf90
...
...
@@ -610,15 +610,6 @@ class TestRoIAlign(RoIOpTester):
self
.
_helper_jit_boxes_list
(
model
)
optests
.
generate_opcheck_tests
(
testcase
=
TestRoIAlign
,
namespaces
=
[
"torchvision"
],
failures_dict_path
=
os
.
path
.
join
(
os
.
path
.
dirname
(
__file__
),
"optests_failures_dict.json"
),
additional_decorators
=
[],
test_utils
=
OPTESTS
,
)
class
TestPSRoIAlign
(
RoIOpTester
):
mps_backward_atol
=
5e-2
...
...
@@ -676,6 +667,43 @@ class TestPSRoIAlign(RoIOpTester):
self
.
_helper_boxes_shape
(
ops
.
ps_roi_align
)
@
pytest
.
mark
.
parametrize
(
"op"
,
(
torch
.
ops
.
torchvision
.
roi_pool
,
torch
.
ops
.
torchvision
.
ps_roi_pool
,
torch
.
ops
.
torchvision
.
roi_align
,
torch
.
ops
.
torchvision
.
ps_roi_align
,
),
)
@
pytest
.
mark
.
parametrize
(
"dtype"
,
(
torch
.
float16
,
torch
.
float32
,
torch
.
float64
))
@
pytest
.
mark
.
parametrize
(
"device"
,
cpu_and_cuda
())
@
pytest
.
mark
.
parametrize
(
"requires_grad"
,
(
True
,
False
))
def
test_roi_opcheck
(
op
,
dtype
,
device
,
requires_grad
):
# This manually calls opcheck() on the roi ops. We do that instead of
# relying on opcheck.generate_opcheck_tests() as e.g. done for nms, because
# pytest and generate_opcheck_tests() don't interact very well when it comes
# to skipping tests - and these ops need to skip the MPS tests since MPS we
# don't support dynamic shapes yet for MPS.
rois
=
torch
.
tensor
(
[[
0
,
0
,
0
,
9
,
9
],
[
0
,
0
,
5
,
4
,
9
],
[
0
,
5
,
5
,
9
,
9
],
[
1
,
0
,
0
,
9
,
9
]],
dtype
=
dtype
,
device
=
device
,
requires_grad
=
requires_grad
,
)
pool_size
=
5
num_channels
=
2
*
(
pool_size
**
2
)
x
=
torch
.
rand
(
2
,
num_channels
,
10
,
10
,
dtype
=
dtype
,
device
=
device
)
kwargs
=
dict
(
rois
=
rois
,
spatial_scale
=
1
,
pooled_height
=
pool_size
,
pooled_width
=
pool_size
)
if
op
in
(
torch
.
ops
.
torchvision
.
roi_align
,
torch
.
ops
.
torchvision
.
ps_roi_align
):
kwargs
[
"sampling_ratio"
]
=
-
1
if
op
is
torch
.
ops
.
torchvision
.
roi_align
:
kwargs
[
"aligned"
]
=
True
optests
.
opcheck
(
op
,
args
=
(
x
,),
kwargs
=
kwargs
)
class
TestMultiScaleRoIAlign
:
def
make_obj
(
self
,
fmap_names
=
None
,
output_size
=
(
7
,
7
),
sampling_ratio
=
2
,
wrap
=
False
):
if
fmap_names
is
None
:
...
...
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