Skip to content
Merged
Show file tree
Hide file tree
Changes from 19 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
8 changes: 7 additions & 1 deletion backends/test/suite/flow.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import logging

from dataclasses import dataclass
from dataclasses import dataclass, field
from typing import Callable

from executorch.backends.test.harness import Tester
Expand Down Expand Up @@ -35,6 +35,12 @@ class TestFlow:
is_delegated: bool = True
""" Indicates whether the flow is expected to generate CALL_DELEGATE nodes. """

skip_patterns: list[str] = field(default_factory=lambda: [])
""" Tests with names containing any substrings in this list are skipped. """

def should_skip_test(self, test_name: str) -> bool:
return any(pattern in test_name for pattern in self.skip_patterns)


def all_flows() -> dict[str, TestFlow]:
flows = []
Expand Down
1 change: 1 addition & 0 deletions backends/test/suite/flows/coreml.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ def _create_coreml_flow(
CoreMLTester, minimum_deployment_target=minimum_deployment_target
),
quantize=quantize,
skip_patterns=["test_argmin", "test_argmax"],
Copy link
Contributor

Choose a reason for hiding this comment

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

How does this play when doing a cross delegate % - pass like comparison?

Copy link
Member Author

Choose a reason for hiding this comment

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

It's not directly reported as a fail. It's not ideal, but native crashes are unrecoverable without process isolation, so I've been accounting for this in the reported numbers. My plan is to switch to pytest with parallel execution to provide process isolation. But, for now, hiding those 2 faiing tests lets the run at least complete in CI.

)


Expand Down
1 change: 1 addition & 0 deletions backends/test/suite/flows/vulkan.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ def _create_vulkan_flow_base(
tester_factory=VulkanTester,
quantize=quantize_stage_factory is not None,
quantize_stage_factory=quantize_stage_factory,
skip_patterns=["float16", "float64"], # Not supported in swiftshader
)


Expand Down
24 changes: 22 additions & 2 deletions backends/test/suite/generate_markdown_summary.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,25 @@
#


def escape_for_markdown(text: str) -> str:
"""
Modify a string to properly display in a markdown table cell.
"""
if not text:
return text

# Replace newlines with <br /> tags
escaped = text.replace("\n", "<br />")

# Escape backslashes.
escaped = escaped.replace("\\", "\\\\")

# Escape pipe characters that would break table structure
escaped = escaped.replace("|", "\\|")

return escaped


def generate_markdown(csv_path: str, exit_code: int = 0): # noqa (C901)
# Print warning if exit code is non-zero
if exit_code != 0:
Expand Down Expand Up @@ -46,7 +65,7 @@ def generate_markdown(csv_path: str, exit_code: int = 0): # noqa (C901)

for row in data_rows:
# Make a copy of the row to avoid modifying the original
processed_row = row.copy()
processed_row = [escape_for_markdown(cell) for cell in row]

# Count results and collect failed tests
if result_column_index is not None and result_column_index < len(row):
Expand Down Expand Up @@ -96,7 +115,8 @@ def generate_markdown(csv_path: str, exit_code: int = 0): # noqa (C901)
# Generate Failed Tests section
print("# Failed Tests\n")
if failed_tests:
print("| " + " | ".join(header) + " |")
escaped_header = [escape_for_markdown(col) for col in header]
print("| " + " | ".join(escaped_header) + " |")
print("|" + "|".join(["---"] * len(header)) + "|")
for row in failed_tests:
print("| " + " | ".join(row) + " |")
Expand Down
3 changes: 3 additions & 0 deletions backends/test/suite/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ def wrapped_test(self):
"use_dynamic_shapes": use_dynamic_shapes,
}
with TestContext(test_name, test_func.__name__, flow.name, params):
if flow.should_skip_test(test_name):
raise unittest.SkipTest(f"Skipping test due to matching flow {flow.name} skip patterns")

test_func(self, flow, dtype, use_dynamic_shapes)

wrapped_test._name = test_func.__name__ # type: ignore
Expand Down
3 changes: 3 additions & 0 deletions backends/test/suite/operators/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,9 @@ def _make_wrapped_test(
):
def wrapped_test(self):
with TestContext(test_name, test_base_name, flow.name, params):
if flow.should_skip_test(test_name):
raise unittest.SkipTest(f"Skipping test due to matching flow {flow.name} skip patterns")
Copy link
Contributor

Choose a reason for hiding this comment

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

will this be counted and reported as SKIPPED in the report?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, it's reported as skipped.


test_kwargs = copy.copy(params) or {}
test_kwargs["flow"] = flow

Expand Down
3 changes: 3 additions & 0 deletions backends/test/suite/operators/test_abs.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
# pyre-unsafe


import unittest

import torch
from executorch.backends.test.suite.flow import TestFlow

Expand Down Expand Up @@ -45,6 +47,7 @@ def test_abs_shapes(self, flow: TestFlow) -> None:
# 3D tensor
self._test_op(AbsModel(), (torch.randn(3, 4, 5),), flow)

@unittest.skip("NaN and Inf are not enforced for backends.")
def test_abs_edge_cases(self, flow: TestFlow) -> None:
# Test edge cases

Expand Down
2 changes: 2 additions & 0 deletions backends/test/suite/operators/test_amax.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

# pyre-unsafe

import unittest
from typing import List, Optional, Tuple, Union

import torch
Expand Down Expand Up @@ -201,6 +202,7 @@ def test_amax_shapes(self, flow: TestFlow) -> None:
flow,
)

@unittest.skip("NaN and Inf are not enforced for backends.")
def test_amax_edge_cases(self, flow: TestFlow) -> None:
x = torch.tensor([[1.0, float("inf"), 3.0], [4.0, 5.0, float("inf")]])
self._test_op(
Expand Down
2 changes: 2 additions & 0 deletions backends/test/suite/operators/test_amin.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

# pyre-unsafe

import unittest
from typing import List, Optional, Tuple, Union

import torch
Expand Down Expand Up @@ -203,6 +204,7 @@ def test_amin_shapes(self, flow: TestFlow) -> None:
flow,
)

@unittest.skip("NaN and Inf are not enforced for backends.")
def test_amin_edge_cases(self, flow: TestFlow) -> None:
x = torch.tensor([[1.0, float("-inf"), 3.0], [4.0, 5.0, float("-inf")]])
self._test_op(
Expand Down
2 changes: 2 additions & 0 deletions backends/test/suite/operators/test_argmax.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

# pyre-unsafe

import unittest
from typing import Optional

import torch
Expand Down Expand Up @@ -143,6 +144,7 @@ def test_argmax_shapes(self, flow: TestFlow) -> None:
flow,
)

@unittest.skip("NaN and Inf are not enforced for backends.")
def test_argmax_edge_cases(self, flow: TestFlow) -> None:
x = torch.tensor([[1.0, float("inf"), 3.0], [4.0, 5.0, float("inf")]])
self._test_op(
Expand Down
2 changes: 2 additions & 0 deletions backends/test/suite/operators/test_argmin.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

# pyre-unsafe

import unittest
from typing import Optional

import torch
Expand Down Expand Up @@ -143,6 +144,7 @@ def test_argmin_shapes(self, flow: TestFlow) -> None:
flow,
)

@unittest.skip("NaN and Inf are not enforced for backends.")
def test_argmin_edge_cases(self, flow: TestFlow) -> None:
x = torch.tensor([[1.0, float("-inf"), 3.0], [4.0, 5.0, float("-inf")]])
self._test_op(
Expand Down
3 changes: 3 additions & 0 deletions backends/test/suite/operators/test_ceil.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
# pyre-unsafe


import unittest

import torch
from executorch.backends.test.suite.flow import TestFlow

Expand Down Expand Up @@ -45,6 +47,7 @@ def test_ceil_shapes(self, flow: TestFlow) -> None:
# 3D tensor
self._test_op(CeilModel(), (torch.randn(3, 4, 5),), flow)

@unittest.skip("NaN and Inf are not enforced for backends.")
def test_ceil_edge_cases(self, flow: TestFlow) -> None:
# Test edge cases

Expand Down
3 changes: 3 additions & 0 deletions backends/test/suite/operators/test_clamp.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
# pyre-unsafe


import unittest

import torch
from executorch.backends.test.suite.flow import TestFlow

Expand Down Expand Up @@ -56,6 +58,7 @@ def test_clamp_shapes(self, flow: TestFlow) -> None:
# 3D tensor
self._test_op(model, (torch.randn(3, 4, 5),), flow)

@unittest.skip("NaN and Inf are not enforced for backends.")
def test_clamp_edge_cases(self, flow: TestFlow) -> None:
# Test edge cases

Expand Down
3 changes: 3 additions & 0 deletions backends/test/suite/operators/test_elu.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
# pyre-unsafe


import unittest

import torch
from executorch.backends.test.suite.flow import TestFlow

Expand Down Expand Up @@ -42,5 +44,6 @@ def test_elu_f32_multi_dim(self, flow: TestFlow) -> None:
def test_elu_f32_alpha(self, flow: TestFlow) -> None:
self._test_op(Model(alpha=0.5), (torch.randn(3, 4, 5),), flow)

@unittest.skip("In place activations aren't properly defunctionalized yet.")
def test_elu_f32_inplace(self, flow: TestFlow) -> None:
self._test_op(Model(inplace=True), (torch.randn(3, 4, 5),), flow)
3 changes: 3 additions & 0 deletions backends/test/suite/operators/test_exp.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
# pyre-unsafe


import unittest

import torch
from executorch.backends.test.suite.flow import TestFlow

Expand Down Expand Up @@ -46,6 +48,7 @@ def test_exp_shapes(self, flow: TestFlow) -> None:
# 3D tensor
self._test_op(ExpModel(), (torch.randn(3, 4, 5),), flow)

@unittest.skip("NaN and Inf are not enforced for backends.")
def test_exp_edge_cases(self, flow: TestFlow) -> None:
# Test edge cases

Expand Down
3 changes: 3 additions & 0 deletions backends/test/suite/operators/test_floor.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
# pyre-unsafe


import unittest

import torch
from executorch.backends.test.suite.flow import TestFlow

Expand Down Expand Up @@ -42,6 +44,7 @@ def test_floor_shapes(self, flow: TestFlow) -> None:
# 3D tensor
self._test_op(FloorModel(), (torch.randn(3, 4, 5),), flow)

@unittest.skip("NaN and Inf are not enforced for backends.")
def test_floor_edge_cases(self, flow: TestFlow) -> None:
# Test edge cases

Expand Down
3 changes: 3 additions & 0 deletions backends/test/suite/operators/test_floor_divide.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

# pyre-unsafe

import unittest

import torch
from executorch.backends.test.suite.flow import TestFlow

Expand Down Expand Up @@ -178,6 +180,7 @@ def test_floor_divide_values(self, flow: TestFlow) -> None:
y = torch.tensor([-2.0]).expand_as(x).clone()
self._test_op(model, (x, y), flow, generate_random_test_inputs=False)

@unittest.skip("NaN and Inf are not enforced for backends.")
def test_floor_divide_edge_cases(self, flow: TestFlow) -> None:
# Test edge cases
model = FloorDivideModel()
Expand Down
3 changes: 3 additions & 0 deletions backends/test/suite/operators/test_hardsigmoid.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
# pyre-unsafe


import unittest

import torch
from executorch.backends.test.suite.flow import TestFlow

Expand Down Expand Up @@ -38,6 +40,7 @@ def test_hardsigmoid_f32_single_dim(self, flow: TestFlow) -> None:
def test_hardsigmoid_f32_multi_dim(self, flow: TestFlow) -> None:
self._test_op(Model(), (torch.randn(2, 3, 4, 5),), flow)

@unittest.skip("In place activations aren't properly defunctionalized yet.")
def test_hardsigmoid_f32_inplace(self, flow: TestFlow) -> None:
self._test_op(Model(inplace=True), (torch.randn(3, 4, 5),), flow)

Expand Down
3 changes: 3 additions & 0 deletions backends/test/suite/operators/test_hardswish.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
# pyre-unsafe


import unittest

import torch
from executorch.backends.test.suite.flow import TestFlow

Expand Down Expand Up @@ -38,6 +40,7 @@ def test_hardswish_f32_single_dim(self, flow: TestFlow) -> None:
def test_hardswish_f32_multi_dim(self, flow: TestFlow) -> None:
self._test_op(Model(), (torch.randn(2, 3, 4, 5),), flow)

@unittest.skip("In place activations aren't properly defunctionalized yet.")
def test_hardswish_f32_inplace(self, flow: TestFlow) -> None:
self._test_op(Model(inplace=True), (torch.randn(3, 4, 5),), flow)

Expand Down
3 changes: 3 additions & 0 deletions backends/test/suite/operators/test_hardtanh.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
# pyre-unsafe


import unittest

import torch
from executorch.backends.test.suite.flow import TestFlow

Expand Down Expand Up @@ -45,6 +47,7 @@ def test_hardtanh_f32_multi_dim(self, flow: TestFlow) -> None:
def test_hardtanh_f32_custom_range(self, flow: TestFlow) -> None:
self._test_op(Model(min_val=-2.0, max_val=2.0), (torch.randn(3, 4, 5),), flow)

@unittest.skip("In place activations aren't properly defunctionalized yet.")
def test_hardtanh_f32_inplace(self, flow: TestFlow) -> None:
self._test_op(Model(inplace=True), (torch.randn(3, 4, 5),), flow)

Expand Down
3 changes: 3 additions & 0 deletions backends/test/suite/operators/test_leaky_relu.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
# pyre-unsafe


import unittest

import torch
from executorch.backends.test.suite.flow import TestFlow

Expand Down Expand Up @@ -44,6 +46,7 @@ def test_leaky_relu_f32_multi_dim(self, flow: TestFlow) -> None:
def test_leaky_relu_f32_custom_slope(self, flow: TestFlow) -> None:
self._test_op(Model(negative_slope=0.1), (torch.randn(3, 4, 5),), flow)

@unittest.skip("In place activations aren't properly defunctionalized yet.")
def test_leaky_relu_f32_inplace(self, flow: TestFlow) -> None:
self._test_op(Model(inplace=True), (torch.randn(3, 4, 5),), flow)

Expand Down
3 changes: 3 additions & 0 deletions backends/test/suite/operators/test_log.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
# pyre-unsafe


import unittest

import torch
from executorch.backends.test.suite.flow import TestFlow

Expand Down Expand Up @@ -46,6 +48,7 @@ def test_log_shapes(self, flow: TestFlow) -> None:
# 3D tensor
self._test_op(LogModel(), (torch.rand(3, 4, 5) + 0.01,), flow)

@unittest.skip("NaN and Inf are not enforced for backends.")
def test_log_edge_cases(self, flow: TestFlow) -> None:
# Test edge cases
# Tensor with infinity
Expand Down
3 changes: 3 additions & 0 deletions backends/test/suite/operators/test_log10.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
# pyre-unsafe


import unittest

import torch
from executorch.backends.test.suite.flow import TestFlow

Expand Down Expand Up @@ -46,6 +48,7 @@ def test_log10_shapes(self, flow: TestFlow) -> None:
# 3D tensor
self._test_op(Log10Model(), (torch.rand(3, 4, 5) + 0.01,), flow)

@unittest.skip("NaN and Inf are not enforced for backends.")
def test_log10_edge_cases(self, flow: TestFlow) -> None:
# Test edge cases
# Tensor with infinity
Expand Down
Loading
Loading