Skip to content

Commit 9cb32cd

Browse files
committed
Smoke test modifications
1 parent 45ecac7 commit 9cb32cd

File tree

1 file changed

+25
-5
lines changed

1 file changed

+25
-5
lines changed

test/smoke_test/smoke_test.py

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
44
import torchvision
55
import torchaudio
66

7-
def smoke_test_cuda() -> None:
8-
gpu_arch_ver = os.getenv('GPU_ARCH_VER')
9-
gpu_arch_type = os.getenv('GPU_ARCH_TYPE')
10-
is_cuda_system = gpu_arch_type == "cuda"
7+
gpu_arch_ver = os.getenv('GPU_ARCH_VER')
8+
gpu_arch_type = os.getenv('GPU_ARCH_TYPE')
9+
is_cuda_system = gpu_arch_type == "cuda"
1110

11+
def smoke_test_cuda() -> None:
1212
if(not torch.cuda.is_available() and is_cuda_system):
1313
print(f"Expected CUDA {gpu_arch_ver}. However CUDA is not loaded.")
1414
sys.exit(1)
@@ -21,6 +21,25 @@ def smoke_test_cuda() -> None:
2121
#todo add cudnn version validation
2222
print(f"torch cudnn: {torch.backends.cudnn.version()}")
2323

24+
def smoke_test_conv2d() -> None:
25+
import torch.nn as nn
26+
print(f"Calling smoke_test_conv2d")
27+
# With square kernels and equal stride
28+
m = nn.Conv2d(16, 33, 3, stride=2)
29+
# non-square kernels and unequal stride and with padding
30+
m = nn.Conv2d(16, 33, (3, 5), stride=(2, 1), padding=(4, 2))
31+
# non-square kernels and unequal stride and with padding and dilation
32+
m = nn.Conv2d(16, 33, (3, 5), stride=(2, 1), padding=(4, 2), dilation=(3, 1))
33+
input = torch.randn(20, 16, 50, 100)
34+
output = m(input)
35+
if(is_cuda_system):
36+
print(f"Testing smoke_test_conv2d with cuda")
37+
conv = nn.Conv2d(3, 3, 3).cuda()
38+
x = torch.randn(1, 3, 24, 24).cuda()
39+
with torch.cuda.amp.autocast():
40+
out = conv(x)
41+
print(out.sum())
42+
2443
def smoke_test_torchvision() -> None:
2544
import torchvision.datasets as dset
2645
import torchvision.transforms
@@ -53,7 +72,7 @@ def smoke_test_vision_resnet50_classify() -> None:
5372
class_id = prediction.argmax().item()
5473
score = prediction[class_id].item()
5574
category_name = weights.meta["categories"][class_id]
56-
expected_category = "German sheppard"
75+
expected_category = "German shepherd"
5776
print(f"{category_name}: {100 * score:.1f}%")
5877
if(category_name != expected_category):
5978
print(f"Failed ResNet50 classify {category_name} Expected: {expected_category}")
@@ -77,6 +96,7 @@ def main() -> None:
7796
print(f"torchvision: {torchvision.__version__}")
7897
print(f"torchaudio: {torchaudio.__version__}")
7998
smoke_test_cuda()
99+
smoke_test_conv2d()
80100
smoke_test_torchvision()
81101
smoke_test_torchaudio()
82102
smoke_test_vision_resnet50_classify()

0 commit comments

Comments
 (0)