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
b5d81f02
Unverified
Commit
b5d81f02
authored
Sep 29, 2021
by
Aditya Oke
Committed by
GitHub
Sep 29, 2021
Browse files
Add JIT tests (#4472)
Co-authored-by:
Francisco Massa
<
fvsmassa@gmail.com
>
parent
a9d710a8
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
0 deletions
+24
-0
test/test_ops.py
test/test_ops.py
+24
-0
No files found.
test/test_ops.py
View file @
b5d81f02
...
@@ -959,6 +959,14 @@ class TestBoxArea:
...
@@ -959,6 +959,14 @@ class TestBoxArea:
expected
=
torch
.
tensor
([
605113.875
,
600495.1875
,
592247.25
])
expected
=
torch
.
tensor
([
605113.875
,
600495.1875
,
592247.25
])
area_check
(
box_tensor
,
expected
)
area_check
(
box_tensor
,
expected
)
def
test_box_area_jit
(
self
):
box_tensor
=
torch
.
tensor
([[
0
,
0
,
100
,
100
],
[
0
,
0
,
0
,
0
]],
dtype
=
torch
.
float
)
TOLERANCE
=
1e-3
expected
=
ops
.
box_area
(
box_tensor
)
scripted_fn
=
torch
.
jit
.
script
(
ops
.
box_area
)
scripted_area
=
scripted_fn
(
box_tensor
)
torch
.
testing
.
assert_close
(
scripted_area
,
expected
,
rtol
=
0.0
,
atol
=
TOLERANCE
)
class
TestBoxIou
:
class
TestBoxIou
:
def
test_iou
(
self
):
def
test_iou
(
self
):
...
@@ -980,6 +988,14 @@ class TestBoxIou:
...
@@ -980,6 +988,14 @@ class TestBoxIou:
expected
=
torch
.
tensor
([[
1.0
,
0.9933
,
0.9673
],
[
0.9933
,
1.0
,
0.9737
],
[
0.9673
,
0.9737
,
1.0
]])
expected
=
torch
.
tensor
([[
1.0
,
0.9933
,
0.9673
],
[
0.9933
,
1.0
,
0.9737
],
[
0.9673
,
0.9737
,
1.0
]])
iou_check
(
box_tensor
,
expected
,
tolerance
=
0.002
if
dtype
==
torch
.
float16
else
1e-4
)
iou_check
(
box_tensor
,
expected
,
tolerance
=
0.002
if
dtype
==
torch
.
float16
else
1e-4
)
def
test_iou_jit
(
self
):
box_tensor
=
torch
.
tensor
([[
0
,
0
,
100
,
100
],
[
0
,
0
,
50
,
50
],
[
200
,
200
,
300
,
300
]],
dtype
=
torch
.
float
)
TOLERANCE
=
1e-3
expected
=
ops
.
box_iou
(
box_tensor
,
box_tensor
)
scripted_fn
=
torch
.
jit
.
script
(
ops
.
box_iou
)
scripted_iou
=
scripted_fn
(
box_tensor
,
box_tensor
)
torch
.
testing
.
assert_close
(
scripted_iou
,
expected
,
rtol
=
0.0
,
atol
=
TOLERANCE
)
class
TestGenBoxIou
:
class
TestGenBoxIou
:
def
test_gen_iou
(
self
):
def
test_gen_iou
(
self
):
...
@@ -1001,6 +1017,14 @@ class TestGenBoxIou:
...
@@ -1001,6 +1017,14 @@ class TestGenBoxIou:
expected
=
torch
.
tensor
([[
1.0
,
0.9933
,
0.9673
],
[
0.9933
,
1.0
,
0.9737
],
[
0.9673
,
0.9737
,
1.0
]])
expected
=
torch
.
tensor
([[
1.0
,
0.9933
,
0.9673
],
[
0.9933
,
1.0
,
0.9737
],
[
0.9673
,
0.9737
,
1.0
]])
gen_iou_check
(
box_tensor
,
expected
,
tolerance
=
0.002
if
dtype
==
torch
.
float16
else
1e-3
)
gen_iou_check
(
box_tensor
,
expected
,
tolerance
=
0.002
if
dtype
==
torch
.
float16
else
1e-3
)
def
test_giou_jit
(
self
):
box_tensor
=
torch
.
tensor
([[
0
,
0
,
100
,
100
],
[
0
,
0
,
50
,
50
],
[
200
,
200
,
300
,
300
]],
dtype
=
torch
.
float
)
TOLERANCE
=
1e-3
expected
=
ops
.
generalized_box_iou
(
box_tensor
,
box_tensor
)
scripted_fn
=
torch
.
jit
.
script
(
ops
.
generalized_box_iou
)
scripted_iou
=
scripted_fn
(
box_tensor
,
box_tensor
)
torch
.
testing
.
assert_close
(
scripted_iou
,
expected
,
rtol
=
0.0
,
atol
=
TOLERANCE
)
class
TestMasksToBoxes
:
class
TestMasksToBoxes
:
def
test_masks_box
(
self
):
def
test_masks_box
(
self
):
...
...
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