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
6381f7b2
"examples/git@developer.sourcefind.cn:OpenDAS/torchaudio.git" did not exist on "4a121aa5105c601691d076ed1e45f476387d6045"
Unverified
Commit
6381f7b2
authored
May 02, 2023
by
Philip Meier
Committed by
GitHub
May 02, 2023
Browse files
improve smoke test (#7550)
parent
9bc094ea
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
5 deletions
+11
-5
test/smoke_test.py
test/smoke_test.py
+11
-5
No files found.
test/smoke_test.py
View file @
6381f7b2
"""Run smoke tests"""
"""Run smoke tests"""
import
os
import
sys
import
sys
from
pathlib
import
Path
from
pathlib
import
Path
import
torch
import
torch
import
torch.nn
as
nn
import
torchvision
import
torchvision
from
torchvision.io
import
read_image
from
torchvision.io
import
decode_jpeg
,
read_file
,
read_image
from
torchvision.models
import
resnet50
,
ResNet50_Weights
from
torchvision.models
import
resnet50
,
ResNet50_Weights
SCRIPT_DIR
=
Path
(
__file__
).
parent
SCRIPT_DIR
=
Path
(
__file__
).
parent
...
@@ -22,13 +20,20 @@ def smoke_test_torchvision() -> None:
...
@@ -22,13 +20,20 @@ def smoke_test_torchvision() -> None:
def
smoke_test_torchvision_read_decode
()
->
None
:
def
smoke_test_torchvision_read_decode
()
->
None
:
img_jpg
=
read_image
(
str
(
SCRIPT_DIR
/
"assets"
/
"encode_jpeg"
/
"grace_hopper_517x606.jpg"
))
img_jpg
=
read_image
(
str
(
SCRIPT_DIR
/
"assets"
/
"encode_jpeg"
/
"grace_hopper_517x606.jpg"
))
if
img_jpg
.
ndim
!=
3
or
img_jpg
.
numel
()
<
100
:
if
img_jpg
.
shape
!=
(
3
,
606
,
517
)
:
raise
RuntimeError
(
f
"Unexpected shape of img_jpg:
{
img_jpg
.
shape
}
"
)
raise
RuntimeError
(
f
"Unexpected shape of img_jpg:
{
img_jpg
.
shape
}
"
)
img_png
=
read_image
(
str
(
SCRIPT_DIR
/
"assets"
/
"interlaced_png"
/
"wizard_low.png"
))
img_png
=
read_image
(
str
(
SCRIPT_DIR
/
"assets"
/
"interlaced_png"
/
"wizard_low.png"
))
if
img_png
.
ndim
!=
3
or
img_png
.
numel
()
<
100
:
if
img_png
.
shape
!=
(
4
,
471
,
354
)
:
raise
RuntimeError
(
f
"Unexpected shape of img_png:
{
img_png
.
shape
}
"
)
raise
RuntimeError
(
f
"Unexpected shape of img_png:
{
img_png
.
shape
}
"
)
def
smoke_test_torchvision_decode_jpeg_cuda
():
img_jpg_data
=
read_file
(
str
(
SCRIPT_DIR
/
"assets"
/
"encode_jpeg"
/
"grace_hopper_517x606.jpg"
))
img_jpg
=
decode_jpeg
(
img_jpg_data
,
device
=
"cuda"
)
if
img_jpg
.
shape
!=
(
3
,
606
,
517
):
raise
RuntimeError
(
f
"Unexpected shape of img_jpg:
{
img_jpg
.
shape
}
"
)
def
smoke_test_compile
()
->
None
:
def
smoke_test_compile
()
->
None
:
try
:
try
:
model
=
resnet50
().
cuda
()
model
=
resnet50
().
cuda
()
...
@@ -77,6 +82,7 @@ def main() -> None:
...
@@ -77,6 +82,7 @@ def main() -> None:
smoke_test_torchvision_read_decode
()
smoke_test_torchvision_read_decode
()
smoke_test_torchvision_resnet50_classify
()
smoke_test_torchvision_resnet50_classify
()
if
torch
.
cuda
.
is_available
():
if
torch
.
cuda
.
is_available
():
smoke_test_torchvision_decode_jpeg_cuda
()
smoke_test_torchvision_resnet50_classify
(
"cuda"
)
smoke_test_torchvision_resnet50_classify
(
"cuda"
)
smoke_test_compile
()
smoke_test_compile
()
...
...
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