1717if importlib .util .find_spec ("torchvision" ):
1818 import torchvision .models as models
1919
20- trt_ep_path = os .path .join (tempfile .gettempdir (), "trt.ep" )
21-
2220
2321@pytest .mark .unit
2422@pytest .mark .critical
@@ -27,6 +25,8 @@ def test_base_full_compile(ir):
2725 This tests export serde functionality on a base model
2826 which is fully TRT convertible
2927 """
28+ tmp_dir = tempfile .mkdtemp (prefix = "test_base_full_compile" )
29+ trt_ep_path = os .path .join (tmp_dir , "trt.ep" )
3030
3131 class MyModule (torch .nn .Module ):
3232 def __init__ (self ):
@@ -82,6 +82,9 @@ def test_base_full_compile_multiple_outputs(ir):
8282 with multiple outputs which is fully TRT convertible
8383 """
8484
85+ tmp_dir = tempfile .mkdtemp (prefix = "test_base_full_compile_multiple_outputs" )
86+ trt_ep_path = os .path .join (tmp_dir , "trt.ep" )
87+
8588 class MyModule (torch .nn .Module ):
8689 def __init__ (self ):
8790 super ().__init__ ()
@@ -141,6 +144,8 @@ def test_no_compile(ir):
141144 This tests export serde functionality on a model
142145 which won't convert to TRT because of min_block_size=5 constraint
143146 """
147+ tmp_dir = tempfile .mkdtemp (prefix = "test_no_compile" )
148+ trt_ep_path = os .path .join (tmp_dir , "trt.ep" )
144149
145150 class MyModule (torch .nn .Module ):
146151 def __init__ (self ):
@@ -202,6 +207,9 @@ def test_hybrid_relu_fallback(ir):
202207 fallback
203208 """
204209
210+ tmp_dir = tempfile .mkdtemp (prefix = "test_hybrid_relu_fallback" )
211+ trt_ep_path = os .path .join (tmp_dir , "trt.ep" )
212+
205213 class MyModule (torch .nn .Module ):
206214 def __init__ (self ):
207215 super ().__init__ ()
@@ -262,6 +270,9 @@ def test_resnet18(ir):
262270 """
263271 This tests export save and load functionality on Resnet18 model
264272 """
273+ tmp_dir = tempfile .mkdtemp (prefix = "test_resnet18" )
274+ trt_ep_path = os .path .join (tmp_dir , "trt.ep" )
275+
265276 model = models .resnet18 ().eval ().cuda ()
266277 input = torch .randn ((1 , 3 , 224 , 224 )).to ("cuda" )
267278
@@ -307,6 +318,9 @@ def test_resnet18_cpu_offload(ir):
307318 """
308319 This tests export save and load functionality on Resnet18 model
309320 """
321+ tmp_dir = tempfile .mkdtemp (prefix = "test_resnet18_cpu_offload" )
322+ trt_ep_path = os .path .join (tmp_dir , "trt.ep" )
323+
310324 model = models .resnet18 ().eval ().cuda ()
311325 input = torch .randn ((1 , 3 , 224 , 224 )).to ("cuda" )
312326
@@ -359,6 +373,9 @@ def test_resnet18_dynamic(ir):
359373 """
360374 This tests export save and load functionality on Resnet18 model
361375 """
376+ tmp_dir = tempfile .mkdtemp (prefix = "test_resnet18_dynamic" )
377+ trt_ep_path = os .path .join (tmp_dir , "trt.ep" )
378+
362379 model = models .resnet18 ().eval ().cuda ()
363380 input = torch .randn ((1 , 3 , 224 , 224 )).to ("cuda" )
364381
@@ -399,6 +416,9 @@ def test_resnet18_torch_exec_ops_serde(ir):
399416 """
400417 This tests export save and load functionality on Resnet18 model
401418 """
419+ tmp_dir = tempfile .mkdtemp (prefix = "test_resnet18_torch_exec_ops_serde" )
420+ trt_ep_path = os .path .join (tmp_dir , "trt.ep" )
421+
402422 model = models .resnet18 ().eval ().cuda ()
403423 input = torch .randn ((1 , 3 , 224 , 224 )).to ("cuda" )
404424
@@ -432,6 +452,9 @@ def test_hybrid_conv_fallback(ir):
432452 model where a conv (a weighted layer) has been forced to fallback to Pytorch.
433453 """
434454
455+ tmp_dir = tempfile .mkdtemp (prefix = "test_hybrid_conv_fallback" )
456+ trt_ep_path = os .path .join (tmp_dir , "trt.ep" )
457+
435458 class MyModule (torch .nn .Module ):
436459 def __init__ (self ):
437460 super ().__init__ ()
@@ -493,6 +516,9 @@ def test_hybrid_conv_fallback_cpu_offload(ir):
493516 model where a conv (a weighted layer) has been forced to fallback to Pytorch.
494517 """
495518
519+ tmp_dir = tempfile .mkdtemp (prefix = "test_hybrid_conv_fallback_cpu_offload" )
520+ trt_ep_path = os .path .join (tmp_dir , "trt.ep" )
521+
496522 class MyModule (torch .nn .Module ):
497523 def __init__ (self ):
498524 super ().__init__ ()
@@ -555,6 +581,8 @@ def test_arange_export(ir):
555581 Here the arange output is a static constant (which is registered as input to the graph)
556582 in the exporter.
557583 """
584+ tmp_dir = tempfile .mkdtemp (prefix = "test_arange_export" )
585+ trt_ep_path = os .path .join (tmp_dir , "trt.ep" )
558586
559587 class MyModule (torch .nn .Module ):
560588 def __init__ (self ):
0 commit comments