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
0e45022a
"...text-generation-inference.git" did not exist on "b2b5df0e946cfcbb7c679d94c0642bc7a6ad8f5e"
Unverified
Commit
0e45022a
authored
Mar 01, 2023
by
Andrey Talman
Committed by
GitHub
Mar 01, 2023
Browse files
Add smoke test Using a simple RN50 with torch.compile (#7359)
parent
924d373c
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
0 deletions
+11
-0
test/smoke_test.py
test/smoke_test.py
+11
-0
No files found.
test/smoke_test.py
View file @
0e45022a
...
...
@@ -4,6 +4,7 @@ import os
from
pathlib
import
Path
import
torch
import
torch.nn
as
nn
import
torchvision
from
torchvision.io
import
read_image
from
torchvision.models
import
resnet50
,
ResNet50_Weights
...
...
@@ -26,6 +27,12 @@ def smoke_test_torchvision_read_decode() -> None:
if
img_png
.
ndim
!=
3
or
img_png
.
numel
()
<
100
:
raise
RuntimeError
(
f
"Unexpected shape of img_png:
{
img_png
.
shape
}
"
)
def
smoke_test_compile
()
->
None
:
model
=
resnet50
().
cuda
()
model
=
torch
.
compile
(
model
)
x
=
torch
.
randn
(
1
,
3
,
224
,
224
,
device
=
"cuda"
)
out
=
model
(
x
)
print
(
f
"torch.compile model output:
{
out
.
shape
}
"
)
def
smoke_test_torchvision_resnet50_classify
(
device
:
str
=
"cpu"
)
->
None
:
img
=
read_image
(
str
(
SCRIPT_DIR
/
".."
/
"gallery"
/
"assets"
/
"dog2.jpg"
)).
to
(
device
)
...
...
@@ -54,14 +61,18 @@ def smoke_test_torchvision_resnet50_classify(device: str = "cpu") -> None:
def
main
()
->
None
:
print
(
f
"torchvision:
{
torchvision
.
__version__
}
"
)
print
(
f
"torch.cuda.is_available:
{
torch
.
cuda
.
is_available
()
}
"
)
smoke_test_torchvision
()
smoke_test_torchvision_read_decode
()
smoke_test_torchvision_resnet50_classify
()
if
torch
.
cuda
.
is_available
():
smoke_test_torchvision_resnet50_classify
(
"cuda"
)
smoke_test_compile
()
if
torch
.
backends
.
mps
.
is_available
():
smoke_test_torchvision_resnet50_classify
(
"mps"
)
if
__name__
==
"__main__"
:
main
()
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