Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
33 changes: 11 additions & 22 deletions backends/arm/test/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import shutil
import subprocess
import sys
from enum import auto, Enum
from typing import Any

import pytest
Expand All @@ -22,30 +21,24 @@
"""


class arm_test_options(Enum):
quantize_io = auto()
corstone_fvp = auto()
fast_fvp = auto()


_test_options: dict[arm_test_options, Any] = {}

# ==== Pytest hooks ====


def pytest_configure(config):
pytest._test_options = {}

if config.option.arm_quantize_io:
_load_libquantized_ops_aot_lib()
_test_options[arm_test_options.quantize_io] = True
pytest._test_options["quantize_io"] = True
if config.option.arm_run_corstoneFVP:
corstone300_exists = shutil.which("FVP_Corstone_SSE-300_Ethos-U55")
corstone320_exists = shutil.which("FVP_Corstone_SSE-320")
if not (corstone300_exists and corstone320_exists):
raise RuntimeError(
"Tests are run with --arm_run_corstoneFVP but corstone FVP is not installed."
)
_test_options[arm_test_options.corstone_fvp] = True
_test_options[arm_test_options.fast_fvp] = config.option.fast_fvp
pytest._test_options["corstone_fvp"] = True
pytest._test_options["fast_fvp"] = config.option.fast_fvp
logging.basicConfig(level=logging.INFO, stream=sys.stdout)


Expand Down Expand Up @@ -131,9 +124,7 @@ def expectedFailureOnFVP(test_item):
# ==== End of Custom Pytest decorators =====


def is_option_enabled(
option: str | arm_test_options, fail_if_not_enabled: bool = False
) -> bool:
def is_option_enabled(option: str, fail_if_not_enabled: bool = False) -> bool:
"""
Returns whether an option is successfully enabled, i.e. if the flag was
given to pytest and the necessary requirements are available.
Expand All @@ -144,10 +135,8 @@ def is_option_enabled(
The optional parameter 'fail_if_not_enabled' makes the function raise
a RuntimeError instead of returning False.
"""
if isinstance(option, str):
option = arm_test_options[option.lower()]

if option in _test_options and _test_options[option]:
if option in pytest._test_options and pytest._test_options[option]:
return True
else:
if fail_if_not_enabled:
Expand All @@ -156,15 +145,15 @@ def is_option_enabled(
return False


def get_option(option: arm_test_options) -> Any | None:
def get_option(option: str) -> Any | None:
"""
Returns the value of an pytest option if it is set, otherwise None.

Args:
option (arm_test_options): The option to check for.
option (str): The option to check for.
"""
if option in _test_options:
return _test_options[option]
if option in pytest._test_options:
return pytest._test_options[option]
return None


Expand Down
13 changes: 7 additions & 6 deletions backends/arm/test/ops/test_depthwise_conv.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,14 +156,11 @@
("two_dw_conv2d", two_dw_conv2d),
]

testsuite_conv2d_u85 = [
testsuite_conv2d_u85_xfails = [
("2x2_1x6x4x4_gp6_st1", dw_conv2d_2x2_1x6x4x4_gp6_st1),
("3x3_1x3x256x256_gp3_st1", dw_conv2d_3x3_1x3x256x256_gp3_st1),
("3x3_1x4x256x256_gp4_st1", dw_conv2d_3x3_1x4x256x256_gp4_st1),
("3x3_1x4x256x256_gp4_nobias", dw_conv2d_3x3_1x4x256x256_gp4_nobias),
]

testsuite_conv2d_u85_xfails = [
("3x3_2x8x198x198_gp8_st3", dw_conv2d_3x3_2x8x198x198_gp8_st3),
("two_dw_conv2d", two_dw_conv2d),
]
Expand Down Expand Up @@ -287,7 +284,7 @@ def test_dw_conv1d_u55_BI(
model.get_inputs(),
)

@parameterized.expand(testsuite_conv1d + testsuite_conv2d_u85)
@parameterized.expand(testsuite_conv1d[2:])
def test_dw_conv_u85_BI(
self, test_name: str, model: torch.nn.Module, set_quantize_io: bool = False
):
Expand All @@ -299,8 +296,12 @@ def test_dw_conv_u85_BI(
model.get_inputs(),
)

testsuite_conv2d_u85_xfails.remove(
("3x3_1x3x256x256_gp3_st1", dw_conv2d_3x3_1x3x256x256_gp3_st1)
) # Works

# All test cases except 3x3_1x3x256x256_gp3_st1 have numerical issues on FVP. MLETORCH-520
@parameterized.expand(testsuite_conv2d_u85_xfails)
@parameterized.expand(testsuite_conv2d_u85_xfails + testsuite_conv1d[:2])
@conftest.expectedFailureOnFVP
def test_dw_conv_u85_BI_xfails(
self, test_name: str, model: torch.nn.Module, set_quantize_io: bool = False
Expand Down
30 changes: 2 additions & 28 deletions backends/arm/test/ops/test_div.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,21 +183,8 @@ def test_div_tosa_BI(
test_data = (input_, other_)
self._test_div_tosa_BI_pipeline(self.Div(), test_data)

@parameterized.expand(test_data_suite[:2])
def test_div_u55_BI(
self,
test_name: str,
input_: Union[torch.Tensor, torch.types.Number],
other_: Union[torch.Tensor, torch.types.Number],
rounding_mode: Optional[str] = None,
):
test_data = (input_, other_)
self._test_div_ethos_BI_pipeline(
self.Div(), common.get_u55_compile_spec(), test_data
)

# Numerical issues on FVP likely due to mul op, MLETORCH-521
@parameterized.expand(test_data_suite[2:])
@parameterized.expand(test_data_suite)
@conftest.expectedFailureOnFVP
def test_div_u55_BI_xfails(
self,
Expand All @@ -211,21 +198,8 @@ def test_div_u55_BI_xfails(
self.Div(), common.get_u55_compile_spec(), test_data
)

@parameterized.expand(test_data_suite[:2])
def test_div_u85_BI(
self,
test_name: str,
input_: Union[torch.Tensor, torch.types.Number],
other_: Union[torch.Tensor, torch.types.Number],
rounding_mode: Optional[str] = None,
):
test_data = (input_, other_)
self._test_div_ethos_BI_pipeline(
self.Div(), common.get_u85_compile_spec(), test_data
)

# Numerical issues on FVP likely due to mul op, MLETORCH-521
@parameterized.expand(test_data_suite[2:])
@parameterized.expand(test_data_suite)
@conftest.expectedFailureOnFVP
def test_div_u85_BI_xfails(
self,
Expand Down
7 changes: 6 additions & 1 deletion backends/arm/test/ops/test_mul.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,9 @@ def test_mul_tosa_BI(
test_data = (input_, other_)
self._test_mul_tosa_BI_pipeline(self.Mul(), test_data)

# Numerical issues on FVP, MLETORCH-521
@parameterized.expand(test_data_sute)
@conftest.expectedFailureOnFVP
def test_mul_u55_BI(
self,
test_name: str,
Expand All @@ -164,7 +166,10 @@ def test_mul_u55_BI(
common.get_u55_compile_spec(), self.Mul(), test_data
)

@parameterized.expand(test_data_sute)
# Numerical issues on FVP, MLETORCH-521
# test_data_sute[0] works on U85
@parameterized.expand(test_data_sute[1:])
@conftest.expectedFailureOnFVP
def test_mul_u85_BI(
self,
test_name: str,
Expand Down
4 changes: 2 additions & 2 deletions backends/arm/test/runner_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import numpy as np
import torch

from executorch.backends.arm.test.conftest import arm_test_options, is_option_enabled
from executorch.backends.arm.test.conftest import is_option_enabled

from torch.export import ExportedProgram
from torch.fx.node import Node
Expand Down Expand Up @@ -251,7 +251,7 @@ def run_corstone(
cmd_line += f" -i {input_path}"

ethos_u_extra_args = ""
if is_option_enabled(arm_test_options.fast_fvp):
if is_option_enabled("fast_fvp"):
ethos_u_extra_args = ethos_u_extra_args + "--fast"

command_args = {
Expand Down