@@ -86,6 +86,29 @@ def is_option_enabled(option: str, fail_if_not_enabled: bool = False) -> bool:
8686 return False
8787
8888
89+ def maybe_get_tosa_collate_path () -> str | None :
90+ """
91+ Checks the environment variable TOSA_TESTCASES_BASE_PATH and returns the
92+ path to the where to store the current tests if it is set.
93+ """
94+ tosa_test_base = os .environ .get ("TOSA_TESTCASES_BASE_PATH" )
95+ if tosa_test_base :
96+ current_test = os .environ .get ("PYTEST_CURRENT_TEST" )
97+ #'backends/arm/test/ops/test_mean_dim.py::TestMeanDim::test_meandim_tosa_BI_0_zeros (call)'
98+ test_class = current_test .split ("::" )[1 ]
99+ test_name = current_test .split ("::" )[- 1 ].split (" " )[0 ]
100+ if "BI" in test_name :
101+ tosa_test_base = os .path .join (tosa_test_base , "tosa-bi" )
102+ elif "MI" in test_name :
103+ tosa_test_base = os .path .join (tosa_test_base , "tosa-mi" )
104+ else :
105+ tosa_test_base = os .path .join (tosa_test_base , "other" )
106+
107+ return os .path .join (tosa_test_base , test_class , test_name )
108+
109+ return None
110+
111+
89112def get_tosa_compile_spec (
90113 permute_memory_to_nhwc = True , custom_path = None
91114) -> list [CompileSpec ]:
@@ -101,7 +124,13 @@ def get_tosa_compile_spec_unbuilt(
101124 """Get the ArmCompileSpecBuilder for the default TOSA tests, to modify
102125 the compile spec before calling .build() to finalize it.
103126 """
104- intermediate_path = custom_path or tempfile .mkdtemp (prefix = "arm_tosa_" )
127+ if not custom_path :
128+ intermediate_path = maybe_get_tosa_collate_path () or tempfile .mkdtemp (
129+ prefix = "arm_tosa_"
130+ )
131+ else :
132+ intermediate_path = custom_path
133+
105134 if not os .path .exists (intermediate_path ):
106135 os .makedirs (intermediate_path , exist_ok = True )
107136 compile_spec_builder = (
0 commit comments