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
f517300d
"doc/vscode:/vscode.git/clone" did not exist on "74bb7fdcf66098bf26f35486f2674cfa0faec586"
Unverified
Commit
f517300d
authored
Apr 19, 2021
by
Nicolas Hug
Committed by
GitHub
Apr 19, 2021
Browse files
[FBcode->GH] Fix some tests in fbcode (#3686)
parent
963abb67
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
8 deletions
+15
-8
test/test_functional_tensor.py
test/test_functional_tensor.py
+14
-8
test/test_models.py
test/test_models.py
+1
-0
No files found.
test/test_functional_tensor.py
View file @
f517300d
...
@@ -24,17 +24,18 @@ class Tester(TransformsTester):
...
@@ -24,17 +24,18 @@ class Tester(TransformsTester):
def
setUp
(
self
):
def
setUp
(
self
):
self
.
device
=
"cpu"
self
.
device
=
"cpu"
def
_test_fn_on_batch
(
self
,
batch_tensors
,
fn
,
**
fn_kwargs
):
def
_test_fn_on_batch
(
self
,
batch_tensors
,
fn
,
scripted_fn_atol
=
1e-8
,
**
fn_kwargs
):
transformed_batch
=
fn
(
batch_tensors
,
**
fn_kwargs
)
transformed_batch
=
fn
(
batch_tensors
,
**
fn_kwargs
)
for
i
in
range
(
len
(
batch_tensors
)):
for
i
in
range
(
len
(
batch_tensors
)):
img_tensor
=
batch_tensors
[
i
,
...]
img_tensor
=
batch_tensors
[
i
,
...]
transformed_img
=
fn
(
img_tensor
,
**
fn_kwargs
)
transformed_img
=
fn
(
img_tensor
,
**
fn_kwargs
)
self
.
assertTrue
(
transformed_img
.
equal
(
transformed_batch
[
i
,
...]))
self
.
assertTrue
(
transformed_img
.
equal
(
transformed_batch
[
i
,
...]))
if
scripted_fn_atol
>=
0
:
scripted_fn
=
torch
.
jit
.
script
(
fn
)
scripted_fn
=
torch
.
jit
.
script
(
fn
)
# scriptable function test
# scriptable function test
s_transformed_batch
=
scripted_fn
(
batch_tensors
,
**
fn_kwargs
)
s_transformed_batch
=
scripted_fn
(
batch_tensors
,
**
fn_kwargs
)
self
.
assertTrue
(
transformed_batch
.
allclose
(
s_transformed_batch
))
self
.
assertTrue
(
transformed_batch
.
allclose
(
s_transformed_batch
,
atol
=
scripted_fn_atol
))
def
test_assert_image_tensor
(
self
):
def
test_assert_image_tensor
(
self
):
shape
=
(
100
,)
shape
=
(
100
,)
...
@@ -166,7 +167,7 @@ class Tester(TransformsTester):
...
@@ -166,7 +167,7 @@ class Tester(TransformsTester):
self
.
assertLess
(
max_diff
,
1e-5
)
self
.
assertLess
(
max_diff
,
1e-5
)
s_hsv_img
=
scripted_fn
(
rgb_img
)
s_hsv_img
=
scripted_fn
(
rgb_img
)
self
.
assertTrue
(
hsv_img
.
allclose
(
s_hsv_img
))
self
.
assertTrue
(
hsv_img
.
allclose
(
s_hsv_img
,
atol
=
1e-7
))
batch_tensors
=
self
.
_create_data_batch
(
120
,
100
,
num_samples
=
4
,
device
=
self
.
device
).
float
()
batch_tensors
=
self
.
_create_data_batch
(
120
,
100
,
num_samples
=
4
,
device
=
self
.
device
).
float
()
self
.
_test_fn_on_batch
(
batch_tensors
,
F_t
.
_rgb2hsv
)
self
.
_test_fn_on_batch
(
batch_tensors
,
F_t
.
_rgb2hsv
)
...
@@ -348,7 +349,7 @@ class Tester(TransformsTester):
...
@@ -348,7 +349,7 @@ class Tester(TransformsTester):
atol
=
1.0
atol
=
1.0
self
.
assertTrue
(
adjusted_tensor
.
allclose
(
scripted_result
,
atol
=
atol
),
msg
=
msg
)
self
.
assertTrue
(
adjusted_tensor
.
allclose
(
scripted_result
,
atol
=
atol
),
msg
=
msg
)
self
.
_test_fn_on_batch
(
batch_tensors
,
fn
,
**
config
)
self
.
_test_fn_on_batch
(
batch_tensors
,
fn
,
scripted_fn_atol
=
atol
,
**
config
)
def
test_adjust_brightness
(
self
):
def
test_adjust_brightness
(
self
):
self
.
_test_adjust_fn
(
self
.
_test_adjust_fn
(
...
@@ -822,9 +823,14 @@ class Tester(TransformsTester):
...
@@ -822,9 +823,14 @@ class Tester(TransformsTester):
if
dt
is
not
None
:
if
dt
is
not
None
:
batch_tensors
=
batch_tensors
.
to
(
dtype
=
dt
)
batch_tensors
=
batch_tensors
.
to
(
dtype
=
dt
)
# Ignore the equivalence between scripted and regular function on float16 cuda. The pixels at
# the border may be entirely different due to small rounding errors.
scripted_fn_atol
=
-
1
if
(
dt
==
torch
.
float16
and
self
.
device
==
"cuda"
)
else
1e-8
for
spoints
,
epoints
in
test_configs
:
for
spoints
,
epoints
in
test_configs
:
self
.
_test_fn_on_batch
(
self
.
_test_fn_on_batch
(
batch_tensors
,
F
.
perspective
,
startpoints
=
spoints
,
endpoints
=
epoints
,
interpolation
=
NEAREST
batch_tensors
,
F
.
perspective
,
scripted_fn_atol
=
scripted_fn_atol
,
startpoints
=
spoints
,
endpoints
=
epoints
,
interpolation
=
NEAREST
)
)
# assert changed type warning
# assert changed type warning
...
...
test/test_models.py
View file @
f517300d
...
@@ -65,6 +65,7 @@ autocast_flaky_numerics = (
...
@@ -65,6 +65,7 @@ autocast_flaky_numerics = (
"fcn_resnet50"
,
"fcn_resnet50"
,
"fcn_resnet101"
,
"fcn_resnet101"
,
"lraspp_mobilenet_v3_large"
,
"lraspp_mobilenet_v3_large"
,
"maskrcnn_resnet50_fpn"
,
)
)
...
...
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