Skip to content

Commit 3515dd4

Browse files
committed
Added an optional_import check for onnxruntime and applied the @unittest.skipUnless decorator to the test_onnx method.
Signed-off-by: ytl0623 <[email protected]>
1 parent 9a45627 commit 3515dd4

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

tests/apps/detection/networks/test_retinanet.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
from tests.test_utils import dict_product, skip_if_quick, test_onnx_save, test_script_save
2424

2525
_, has_torchvision = optional_import("torchvision")
26+
_, has_onnxruntime = optional_import("onnxruntime")
2627

2728
device = "cuda" if torch.cuda.is_available() else "cpu"
2829
num_anchors = 7
@@ -169,6 +170,7 @@ def test_script(self, model, input_param, input_shape):
169170
test_script_save(net, data)
170171

171172
@parameterized.expand(TEST_CASES_TS)
173+
@unittest.skipUnless(has_onnxruntime, "onnxruntime not installed")
172174
def test_onnx(self, model, input_param, input_shape):
173175
try:
174176
idx = int(self.id().split("test_onnx_")[-1])
@@ -203,4 +205,4 @@ def test_onnx(self, model, input_param, input_shape):
203205

204206

205207
if __name__ == "__main__":
206-
unittest.main()
208+
unittest.main()

0 commit comments

Comments
 (0)