|
9 | 9 | import time |
10 | 10 | import unittest |
11 | 11 |
|
| 12 | +import pytest |
12 | 13 | import torch |
13 | 14 | import torch_tensorrt as torchtrt |
14 | 15 | from torch.testing._internal.common_utils import TestCase, run_tests |
15 | 16 | from torch_tensorrt._features import ENABLED_FEATURES |
| 17 | +from torch_tensorrt._utils import is_tensorrt_rtx_version_supported |
16 | 18 | from torch_tensorrt.dynamo.utils import COSINE_THRESHOLD, cosine_similarity |
17 | 19 | from torch_tensorrt.runtime import RuntimeSettings, apply_runtime_settings |
18 | 20 |
|
| 21 | +pytestmark = [pytest.mark.trt_api, pytest.mark.trt_rtx_only] |
| 22 | + |
19 | 23 |
|
20 | 24 | @unittest.skipIf( |
21 | 25 | not ENABLED_FEATURES.tensorrt_rtx, |
@@ -130,10 +134,16 @@ def test_mobilenet_v2_with_runtime_cache(self): |
130 | 134 | ref_output = model(input_tensor) |
131 | 135 | trt_output = compiled(input_tensor) |
132 | 136 |
|
| 137 | + is_turing = torch.cuda.get_device_capability() == (7, 5) |
| 138 | + threshold = COSINE_THRESHOLD |
| 139 | + if is_turing and not is_tensorrt_rtx_version_supported("1.8"): |
| 140 | + # The FP32 projection convolution returns inaccurate values on Turing. |
| 141 | + threshold = 0.98 |
| 142 | + |
133 | 143 | cos_sim = cosine_similarity(ref_output, trt_output) |
134 | 144 | self.assertTrue( |
135 | | - cos_sim > COSINE_THRESHOLD, |
136 | | - f"MobileNetV2 cosine similarity {cos_sim} below threshold {COSINE_THRESHOLD}", |
| 145 | + cos_sim > threshold, |
| 146 | + f"MobileNetV2 cosine similarity {cos_sim} below threshold {threshold}", |
137 | 147 | ) |
138 | 148 |
|
139 | 149 | del compiled |
|
0 commit comments