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
13 changes: 8 additions & 5 deletions backends/arm/test/ops/test_avg_pool.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@

test_data_suite = [
# (test_name, test_data, [kernel_size, stride, padding])
("zeros", torch.zeros(20, 16, 50, 32), [4, 2, 0]),
("ones", torch.zeros(20, 16, 50, 32), [4, 2, 0]),
("rand", torch.rand(20, 16, 50, 32), [4, 2, 0]),
("randn", torch.randn(20, 16, 50, 32), [4, 2, 0]),
("zeros", torch.zeros(1, 16, 50, 32), [4, 2, 0]),
("ones", torch.zeros(1, 16, 50, 32), [4, 2, 0]),
("rand", torch.rand(1, 16, 50, 32), [4, 2, 0]),
("randn", torch.randn(1, 16, 50, 32), [4, 2, 0]),
]


Expand Down Expand Up @@ -101,7 +101,7 @@ def _test_avgpool2d_tosa_ethos_BI_pipeline(
test_data: Tuple[torch.tensor],
):
quantizer = ArmQuantizer().set_io(get_symmetric_quantization_config())
(
tester = (
ArmTester(
module,
example_inputs=test_data,
Expand All @@ -116,7 +116,10 @@ def _test_avgpool2d_tosa_ethos_BI_pipeline(
.check_not(["executorch_exir_dialects_edge__ops_aten_avg_pool2d_default"])
.check_count({"torch.ops.higher_order.executorch_call_delegate": 1})
.to_executorch()
.serialize()
)
if common.is_option_enabled("corstone300"):
tester.run_method_and_compare_outputs(qtol=1, inputs=test_data)

@parameterized.expand(test_data_suite)
def test_avgpool2d_tosa_MI(
Expand Down
22 changes: 19 additions & 3 deletions backends/arm/test/ops/test_bmm.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def forward(self, x, y):
class BMMSingleInput(torch.nn.Module):
test_parameters = [
(torch.rand(20, 3, 3),),
(torch.ones(2, 128, 128),),
(torch.rand(2, 128, 128),),
(10000 * torch.randn(4, 25, 25),),
(5 + 5 * torch.randn(3, 64, 64),),
]
Expand Down Expand Up @@ -96,7 +96,7 @@ def _test_bmm_ethosu_BI_pipeline(
compile_spec: CompileSpec,
test_data: Tuple[torch.Tensor, ...],
):
(
tester = (
ArmTester(
module,
example_inputs=test_data,
Expand All @@ -110,7 +110,10 @@ def _test_bmm_ethosu_BI_pipeline(
.partition()
.check_count({"torch.ops.higher_order.executorch_call_delegate": 1})
.to_executorch()
.serialize()
)
if common.is_option_enabled("corstone300"):
tester.run_method_and_compare_outputs(inputs=test_data, qtol=1)

@parameterized.expand(BMM.test_parameters)
def test_bmm_tosa_MI(self, operand1: torch.Tensor, operand2: torch.Tensor):
Expand Down Expand Up @@ -143,9 +146,20 @@ def test_bmm_single_input_tosa_BI(self, operand1: torch.Tensor):
self._test_bmm_tosa_BI_pipeline(self.BMMSingleInput(), test_data)

@parameterized.expand(BMM.test_parameters)
@unittest.expectedFailure
def test_bmm_u55_BI(self, operand1: torch.Tensor, operand2: torch.Tensor):
test_data = (operand1, operand2)
self._test_bmm_tosa_BI_pipeline(self.BMM(), test_data)
self._test_bmm_ethosu_BI_pipeline(
self.BMM(), common.get_u55_compile_spec(), test_data
)

@parameterized.expand(BMM.test_parameters)
@common.expectedFailureOnFVP
def test_bmm_u85_BI(self, operand1: torch.Tensor, operand2: torch.Tensor):
test_data = (operand1, operand2)
self._test_bmm_ethosu_BI_pipeline(
self.BMM(), common.get_u85_compile_spec(), test_data
)

# Expected to fail with error: Warning, unsupported fusing of TOSA Rescale previous operator is of type: Memcpy
@parameterized.expand(BMMSingleInput.test_parameters)
Expand All @@ -156,7 +170,9 @@ def test_bmm_single_input_u55_BI(self, operand1: torch.Tensor):
self.BMMSingleInput(), common.get_u55_compile_spec(), test_data
)

# Numerical issues on FVP, MLETORCH 534
@parameterized.expand(BMMSingleInput.test_parameters)
@common.expectedFailureOnFVP
def test_bmm_single_input_u85_BI(self, operand1: torch.Tensor):
test_data = (operand1,)
self._test_bmm_ethosu_BI_pipeline(
Expand Down
10 changes: 9 additions & 1 deletion backends/arm/test/ops/test_cat.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ def _test_cat_ethosu_BI_pipeline(
compile_spec: CompileSpec,
test_data: Tuple[tuple[torch.Tensor, ...], int],
):
(
tester = (
ArmTester(
module,
example_inputs=test_data,
Expand All @@ -108,10 +108,14 @@ def _test_cat_ethosu_BI_pipeline(
.check(["torch.ops.quantized_decomposed"])
.to_edge()
.partition()
.dump_artifact()
.check_not(["executorch_exir_dialects_edge__ops_aten_cat_default"])
.check_count({"torch.ops.higher_order.executorch_call_delegate": 1})
.to_executorch()
.serialize()
)
if common.is_option_enabled("corstone300"):
tester.run_method_and_compare_outputs(inputs=test_data)

@parameterized.expand(Cat.test_parameters)
def test_cat_tosa_MI(self, operands: tuple[torch.Tensor, ...], dim: int):
Expand All @@ -129,14 +133,18 @@ def test_cat_tosa_BI(self, operands: tuple[torch.Tensor, ...], dim: int):
test_data = (operands, dim)
self._test_cat_tosa_BI_pipeline(self.Cat(), test_data)

# Mismatch in provided number of inputs and model signature, MLETORCH 519
@parameterized.expand(Cat.test_parameters)
@common.expectedFailureOnFVP
def test_cat_u55_BI(self, operands: tuple[torch.Tensor, ...], dim: int):
test_data = (operands, dim)
self._test_cat_ethosu_BI_pipeline(
self.Cat(), common.get_u55_compile_spec(), test_data
)

# Mismatch in provided number of inputs and model signature, MLETORCH 519
@parameterized.expand(Cat.test_parameters)
@common.expectedFailureOnFVP
def test_cat_u85_BI(self, operands: tuple[torch.Tensor, ...], dim: int):
test_data = (operands, dim)
self._test_cat_ethosu_BI_pipeline(
Expand Down
5 changes: 4 additions & 1 deletion backends/arm/test/ops/test_clone.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def _test_clone_tosa_ethos_pipeline(
test_data: Tuple[torch.Tensor],
):
quantizer = ArmQuantizer().set_io(get_symmetric_quantization_config())
(
tester = (
ArmTester(module, example_inputs=test_data, compile_spec=compile_spec)
.quantize(Quantize(quantizer, get_symmetric_quantization_config()))
.export()
Expand All @@ -94,7 +94,10 @@ def _test_clone_tosa_ethos_pipeline(
.partition()
.check_count({"torch.ops.higher_order.executorch_call_delegate": 1})
.to_executorch()
.serialize()
)
if common.is_option_enabled("corstone300"):
tester.run_method_and_compare_outputs(qtol=1, inputs=test_data)

def _test_clone_tosa_u55_pipeline(
self, module: torch.nn.Module, test_data: Tuple[torch.Tensor]
Expand Down
8 changes: 7 additions & 1 deletion backends/arm/test/ops/test_conv1d.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ def _test_conv1d_ethosu_BI_pipeline(
compile_spec: CompileSpec,
test_data: Tuple[torch.Tensor],
):
(
tester = (
ArmTester(module, example_inputs=test_data, compile_spec=compile_spec)
.quantize()
.export()
Expand All @@ -277,7 +277,10 @@ def _test_conv1d_ethosu_BI_pipeline(
.check_count({"torch.ops.higher_order.executorch_call_delegate": 1})
.check_not(["executorch_exir_dialects_edge__ops_aten_convolution_default"])
.to_executorch()
.serialize()
)
if common.is_option_enabled("corstone300"):
tester.run_method_and_compare_outputs(qtol=1, inputs=test_data)

@parameterized.expand(testsuite)
def test_conv1d_tosa_MI(self, test_name, model):
Expand All @@ -295,6 +298,9 @@ def test_conv1d_u55_BI(self, test_name, model):
model, common.get_u55_compile_spec(), model.get_inputs()
)

# This specific test case has numerical errors on FVP, MLETORCH-520.
testsuite.remove(("5_3x2x128_st1", conv1d_5_3x2x128_st1))

@parameterized.expand(testsuite)
def test_conv1d_u85_BI(self, test_name, model):
self._test_conv1d_ethosu_BI_pipeline(
Expand Down
9 changes: 8 additions & 1 deletion backends/arm/test/ops/test_conv2d.py
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ def _test_conv2d_ethosu_BI_pipeline(
module: torch.nn.Module,
test_data: Tuple[torch.Tensor],
):
(
tester = (
ArmTester(
module,
example_inputs=test_data,
Expand All @@ -308,7 +308,10 @@ def _test_conv2d_ethosu_BI_pipeline(
.check_count({"torch.ops.higher_order.executorch_call_delegate": 1})
.check_not(["executorch_exir_dialects_edge__ops_aten_convolution_default"])
.to_executorch()
.serialize()
)
if common.is_option_enabled("corstone300"):
tester.run_method_and_compare_outputs(qtol=1, inputs=test_data)

@parameterized.expand(testsuite)
def test_conv2d_tosa_MI(self, test_name, model):
Expand All @@ -318,6 +321,10 @@ def test_conv2d_tosa_MI(self, test_name, model):
def test_conv2d_tosa_BI(self, test_name, model):
self._test_conv2d_tosa_BI_pipeline(model, model.get_inputs())

# These cases have numerical issues on FVP, MLETORCH-520
testsuite.remove(("2x2_3x2x40x40_nobias", conv2d_2x2_3x2x40x40_nobias))
testsuite.remove(("5x5_3x2x128x128_st1", conv2d_5x5_3x2x128x128_st1))

@parameterized.expand(testsuite)
def test_conv2d_u55_BI(self, test_name, model):
self._test_conv2d_ethosu_BI_pipeline(
Expand Down
7 changes: 6 additions & 1 deletion backends/arm/test/ops/test_conv_combos.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ def _test_conv_combo_ethos_BI_pipeline(
compile_spec: CompileSpec,
test_data: Tuple[torch.Tensor],
):
(
tester = (
ArmTester(
module,
example_inputs=test_data,
Expand All @@ -251,7 +251,10 @@ def _test_conv_combo_ethos_BI_pipeline(
.check_count({"torch.ops.higher_order.executorch_call_delegate": 1})
.check_not(list(module.edge_op_list))
.to_executorch()
.serialize()
)
if common.is_option_enabled("corstone300"):
tester.run_method_and_compare_outputs(qtol=1, inputs=test_data)

####################
## Conv + meandim ##
Expand All @@ -272,6 +275,8 @@ def test_conv_meandim_u55_BI(self):
model.get_inputs(),
)

# Numerical Issues on FVP, MLETORCH-520
@common.expectedFailureOnFVP
def test_conv_meandim_u85_BI(self):
model = ComboConv2dMeandim()
self._test_conv_combo_ethos_BI_pipeline(
Expand Down
31 changes: 25 additions & 6 deletions backends/arm/test/ops/test_depthwise_conv.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@

from typing import Tuple

import pytest

import torch
from executorch.backends.arm.test import common
from executorch.backends.arm.test.ops.test_conv1d import Conv1d
Expand Down Expand Up @@ -160,8 +158,8 @@

testsuite_conv1d = [
("2_1x6x4_gp6_st1", dw_conv1d_2_1x6x4_gp6_st1),
("3_1x3x256_gp3_st1", dw_conv1d_3_1x3x256_gp3_st1),
("two_dw_conv1d", two_dw_conv1d),
("3_1x3x256_gp3_st1", dw_conv1d_3_1x3x256_gp3_st1),
("3_1x3x14_gp3_st1", dw_conv1d_3_1x3x14_gp3_st1),
]

Expand Down Expand Up @@ -217,7 +215,7 @@ def _test_dw_conv_ethos_BI_pipeline(
compile_spec: CompileSpec,
test_data: Tuple[torch.Tensor],
):
(
tester = (
ArmTester(
module,
example_inputs=test_data,
Expand All @@ -230,19 +228,26 @@ def _test_dw_conv_ethos_BI_pipeline(
.check_not(["executorch_exir_dialects_edge__ops_aten_convolution_default"])
.check_count({"torch.ops.higher_order.executorch_call_delegate": 1})
.to_executorch()
.serialize()
)
if common.is_option_enabled("corstone300"):
tester.run_method_and_compare_outputs(qtol=1, inputs=test_data)

@parameterized.expand(testsuite_conv1d + testsuite_conv2d)
def test_dw_conv_tosa_MI(self, test_name: str, model: torch.nn.Module):
self._test_dw_conv_tosa_MI_pipeline(model, model.get_inputs())

# TODO: Investigate flakyness (MLTORCH-307)
@parameterized.expand(testsuite_conv1d + testsuite_conv2d)
@pytest.mark.flaky(reruns=3)
def test_dw_conv_tosa_BI(self, test_name: str, model: torch.nn.Module):
self._test_dw_conv_tosa_BI_pipeline(model, model.get_inputs())

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

@parameterized.expand(testsuite_conv2d, skip_on_empty=True)
@common.expectedFailureOnFVP
def test_dw_conv2d_u55_BI(
self, test_name: str, model: torch.nn.Module, set_quantize_io: bool = False
):
Expand All @@ -269,7 +274,21 @@ def test_dw_conv1d_u55_BI(
model.get_inputs(),
)

@parameterized.expand(testsuite_conv1d + testsuite_conv2d)
# All test cases except 3x3_1x3x256x256_gp3_st1 have numerical issues on FVP. MLETORCH-520
@parameterized.expand(testsuite_conv1d[:-2] + testsuite_conv2d)
@common.expectedFailureOnFVP
def test_dw_conv_u85_BI_xfails(
self, test_name: str, model: torch.nn.Module, set_quantize_io: bool = False
):
self._test_dw_conv_ethos_BI_pipeline(
model,
common.get_u85_compile_spec(
permute_memory_to_nhwc=True, quantize_io=set_quantize_io
),
model.get_inputs(),
)

@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 Down
30 changes: 26 additions & 4 deletions backends/arm/test/ops/test_div.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,10 +136,10 @@ def _test_div_tosa_BI_pipeline(
.run_method_and_compare_outputs(inputs=test_data, atol=1, rtol=0.1)
)

def _test_div_u55_BI_pipeline(
self, module: torch.nn.Module, test_data: Tuple[torch.Tensor]
def _test_div_ethos_BI_pipeline(
self, module: torch.nn.Module, compile_spec, test_data: Tuple[torch.Tensor]
):
(
tester = (
ArmTester(
module,
example_inputs=test_data,
Expand All @@ -155,7 +155,10 @@ def _test_div_u55_BI_pipeline(
.partition()
.check_count({"torch.ops.higher_order.executorch_call_delegate": 1})
.to_executorch()
.serialize()
)
if common.is_option_enabled("corstone300"):
tester.run_method_and_compare_outputs(qtol=1, inputs=test_data)

@parameterized.expand(test_data_suite)
def test_div_tosa_MI(
Expand All @@ -180,7 +183,9 @@ def test_div_tosa_BI(
test_data = (input_, other_)
self._test_div_tosa_BI_pipeline(self.Div(), test_data)

# Numerical issues on FVP likely due to mul op, MLETORCH-521
@parameterized.expand(test_data_suite)
@common.expectedFailureOnFVP
def test_div_u55_BI(
self,
test_name: str,
Expand All @@ -189,4 +194,21 @@ def test_div_u55_BI(
rounding_mode: Optional[str] = None,
):
test_data = (input_, other_)
self._test_div_u55_BI_pipeline(self.Div(), test_data)
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)
@common.expectedFailureOnFVP
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
)
Loading
Loading