Skip to content

Commit e02faec

Browse files
jackzhxngper
andauthored
Add possibility to collect all TOSA tests to a specified path (#5028) (#6174)
Summary: Done in order to collect test vectors for backend compilers. Signed-off-by: Per Åstrand <[email protected]> Change-Id: I0fc6e4d6bfcccd6aae18847a9a33f76d3d19fe5f Pull Request resolved: #5028 Reviewed By: cccclai Differential Revision: D62242846 Pulled By: digantdesai fbshipit-source-id: 9ecfb7be3c5ed432a2cc36c2ea1eac7157ef6673 Co-authored-by: Per Åstrand <[email protected]>
1 parent f17c9e1 commit e02faec

File tree

1 file changed

+30
-1
lines changed

1 file changed

+30
-1
lines changed

backends/arm/test/common.py

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,29 @@ def is_option_enabled(option: str, fail_if_not_enabled: bool = False) -> bool:
8989
return False
9090

9191

92+
def maybe_get_tosa_collate_path() -> str | None:
93+
"""
94+
Checks the environment variable TOSA_TESTCASES_BASE_PATH and returns the
95+
path to the where to store the current tests if it is set.
96+
"""
97+
tosa_test_base = os.environ.get("TOSA_TESTCASES_BASE_PATH")
98+
if tosa_test_base:
99+
current_test = os.environ.get("PYTEST_CURRENT_TEST")
100+
#'backends/arm/test/ops/test_mean_dim.py::TestMeanDim::test_meandim_tosa_BI_0_zeros (call)'
101+
test_class = current_test.split("::")[1]
102+
test_name = current_test.split("::")[-1].split(" ")[0]
103+
if "BI" in test_name:
104+
tosa_test_base = os.path.join(tosa_test_base, "tosa-bi")
105+
elif "MI" in test_name:
106+
tosa_test_base = os.path.join(tosa_test_base, "tosa-mi")
107+
else:
108+
tosa_test_base = os.path.join(tosa_test_base, "other")
109+
110+
return os.path.join(tosa_test_base, test_class, test_name)
111+
112+
return None
113+
114+
92115
def get_tosa_compile_spec(
93116
permute_memory_to_nhwc=True, custom_path=None
94117
) -> list[CompileSpec]:
@@ -104,7 +127,13 @@ def get_tosa_compile_spec_unbuilt(
104127
"""Get the ArmCompileSpecBuilder for the default TOSA tests, to modify
105128
the compile spec before calling .build() to finalize it.
106129
"""
107-
intermediate_path = custom_path or tempfile.mkdtemp(prefix="arm_tosa_")
130+
if not custom_path:
131+
intermediate_path = maybe_get_tosa_collate_path() or tempfile.mkdtemp(
132+
prefix="arm_tosa_"
133+
)
134+
else:
135+
intermediate_path = custom_path
136+
108137
if not os.path.exists(intermediate_path):
109138
os.makedirs(intermediate_path, exist_ok=True)
110139
compile_spec_builder = (

0 commit comments

Comments
 (0)