Skip to content

Commit a36907f

Browse files
committed
test: add test test_tensorrt_with_wrong_default_device.
1 parent a9047fe commit a36907f

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

tests/tests_pytorch/models/test_torch_tensorrt.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import tests_pytorch.helpers.pipelines as pipes
1010
from lightning.pytorch.core.module import _TORCH_TRT_AVAILABLE
1111
from lightning.pytorch.demos.boring_classes import BoringModel
12+
from lightning.pytorch.utilities.exceptions import MisconfigurationException
1213
from tests_pytorch.helpers.runif import RunIf
1314

1415

@@ -22,6 +23,15 @@ def test_missing_tensorrt_package():
2223
model.to_tensorrt("model.trt")
2324

2425

26+
@RunIf(tensorrt=True, min_torch="2.2.0")
27+
def test_tensorrt_with_wrong_default_device(tmp_path):
28+
model = BoringModel()
29+
input_sample = torch.randn((1, 32))
30+
file_path = os.path.join(tmp_path, "model.trt")
31+
with pytest.raises(MisconfigurationException):
32+
model.to_tensorrt(file_path, input_sample, default_device="cpu")
33+
34+
2535
@RunIf(tensorrt=True, min_cuda_gpus=1, min_torch="2.2.0")
2636
def test_tensorrt_saves_with_input_sample(tmp_path):
2737
model = BoringModel()

0 commit comments

Comments
 (0)