Skip test if torchvision is not available (#149494)

The test unconditionally imports torchvision and fails if the isn't installed.
Skip it in this case.

Pull Request resolved: https://github.com/pytorch/pytorch/pull/149494
Approved by: https://github.com/janeyx99
This commit is contained in:
Alexander Grund 2025-03-21 18:57:10 +00:00 committed by PyTorch MergeBot
parent b0a5d55c58
commit 19b763def1

View File

@ -58,7 +58,10 @@ class BenchmarkFusionTestTemplate:
@slowTest
def test_resnet18(self):
import torchvision
try:
import torchvision
except ImportError:
self.skipTest("TorchVision not available")
model = torchvision.models.resnet18()
model.eval()