Skip to content

[Backend Tester] Add subtest index field #13311

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 21 commits into
base: gh/GregoryComer/120/head
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 10 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -757,6 +757,10 @@ if(EXECUTORCH_BUILD_PYBIND)
list(APPEND _dep_libs openvino_backend)
endif()

if(EXECUTORCH_BUILD_VULKAN)
list(APPEND _dep_libs vulkan_backend)
endif()

if(EXECUTORCH_BUILD_XNNPACK)
# need to explicitly specify XNNPACK and xnnpack-microkernels-prod here
# otherwise uses XNNPACK and microkernel-prod symbols from libtorch_cpu
Expand Down
3 changes: 3 additions & 0 deletions backends/test/suite/context.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
# Test run context management. This is used to determine the test context for reporting
# purposes.
class TestContext:
subtest_index: int

def __init__(
self, test_name: str, test_base_name: str, flow_name: str, params: dict | None
):
self.test_name = test_name
self.test_base_name = test_base_name
self.flow_name = flow_name
self.params = params
self.subtest_index = 0

def __enter__(self):
global _active_test_context
Expand Down
1 change: 1 addition & 0 deletions backends/test/suite/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ def run_model_test(
flow,
context.test_name,
context.test_base_name,
0, # subtest_index - currently unused for model tests
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So the hierarchy is
Test ID -> test -> subtest?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The naming is a bit confusing. I'm open to suggestions. The test_base_name is the test name (test_add_dtype, for example). Test name adds flow and parameterization (test_add_dtype_float32_xnnpack). The subtest index corresponds to a single python unittest function that runs multiple test cases.

context.params,
dynamic_shapes=dynamic_shapes,
)
Expand Down
4 changes: 4 additions & 0 deletions backends/test/suite/operators/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,12 +152,16 @@ def _test_op(
flow,
context.test_name,
context.test_base_name,
context.subtest_index,
context.params,
generate_random_test_inputs=generate_random_test_inputs,
)

log_test_summary(run_summary)

# This is reset when a new test is started - it creates the context per-test.
context.subtest_index = context.subtest_index + 1

if not run_summary.result.is_success():
if run_summary.result.is_backend_failure():
raise RuntimeError("Test failure.") from run_summary.error
Expand Down
5 changes: 5 additions & 0 deletions backends/test/suite/reporting.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
CSV_FIELD_NAMES = [
"Test ID",
"Test Case",
"Subtest",
"Flow",
"Params",
"Result",
Expand Down Expand Up @@ -163,6 +164,9 @@ class TestCaseSummary:
name: str
""" The full name of test, including flow and parameter suffixes. """

subtest_index: int
""" The subtest number. If a test case runs multiple tests, this field can be used to disambiguate. """

params: dict | None
""" Test-specific parameters, such as dtype. """

Expand Down Expand Up @@ -356,6 +360,7 @@ def write_csv_row(record: TestCaseSummary, output: TextIO):
row = {
"Test ID": record.name,
"Test Case": record.base_name,
"Subtest": record.subtest_index,
"Flow": record.flow,
"Params": _serialize_params(record.params),
"Result": record.result.to_short_str(),
Expand Down
2 changes: 2 additions & 0 deletions backends/test/suite/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ def run_test( # noqa: C901
flow: TestFlow,
test_name: str,
test_base_name: str,
subtest_index: int,
params: dict | None,
dynamic_shapes: Any | None = None,
generate_random_test_inputs: bool = True,
Expand All @@ -64,6 +65,7 @@ def build_result(
return TestCaseSummary(
backend=flow.backend,
base_name=test_base_name,
subtest_index=subtest_index,
flow=flow.name,
name=test_name,
params=params,
Expand Down
4 changes: 4 additions & 0 deletions backends/test/suite/tests/test_reporting.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
base_name="test1",
flow="flow1",
name="test1_backend1_flow1",
subtest_index=0,
params=None,
result=TestResult.SUCCESS,
error=None,
Expand All @@ -34,6 +35,7 @@
base_name="test1",
flow="flow1",
name="test1_backend2_flow1",
subtest_index=0,
params=None,
result=TestResult.LOWER_FAIL,
error=None,
Expand All @@ -44,6 +46,7 @@
base_name="test2",
flow="flow1",
name="test2_backend1_flow1",
subtest_index=0,
params={"dtype": torch.float32},
result=TestResult.SUCCESS_UNDELEGATED,
error=None,
Expand All @@ -54,6 +57,7 @@
base_name="test2",
flow="flow1",
name="test2_backend2_flow1",
subtest_index=0,
params={"use_dynamic_shapes": True},
result=TestResult.SKIPPED,
error=None,
Expand Down
Loading