Skip to content
Open
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
74 changes: 72 additions & 2 deletions backends/arm/test/ops/test_sum.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# Copyright 2024-2026 Arm Limited and/or its affiliates.
#
# This source code is licensed under the BSD-style license found in the
Expand All @@ -5,6 +5,8 @@

from typing import Callable, Tuple

import pytest

import torch
from executorch.backends.arm.test import common

Expand Down Expand Up @@ -96,7 +98,18 @@
pipeline.run()


@common.parametrize("test_data", Sum.test_parameters)
# dim=None cases skipped: executorch.devtools.bundled_program.config rejects
# None as a model input (cannot be serialized into the bundled program).
_DIM_NONE_SKIP_REASON = (
"bundled_program cannot serialize None as a model input"
)
Comment on lines +101 to +105
_dim_none_skips = {
"dim_None": _DIM_NONE_SKIP_REASON,
"dim_None_4d_tensor": _DIM_NONE_SKIP_REASON,
}


@common.parametrize("test_data", Sum.test_parameters, skips=_dim_none_skips)
@common.XfailIfNoCorstone300
def test_sum_u55_INT_1_0(test_data: Tuple):
pipeline = EthosU55PipelineINT[input_t1](
Expand All @@ -108,7 +121,7 @@
pipeline.run()


@common.parametrize("test_data", Sum.test_parameters)
@common.parametrize("test_data", Sum.test_parameters, skips=_dim_none_skips)
@common.XfailIfNoCorstone320
def test_sum_u85_INT_1_0(test_data: Tuple):
pipeline = EthosU85PipelineINT[input_t1](
Expand Down Expand Up @@ -220,3 +233,60 @@
def test_sum_tosa_INT(test_data: Callable[[], input_t2]):
pipeline = TosaPipelineINT[input_t1](SumDefault(), test_data(), SumDefault.aten_op)
pipeline.run()


# a16w8 (int16 IO + int8 weights) coverage for sum.dim_IntList. Surfaces the
# Ethos-U85 int16 ReduceSum silent-zero issue tracked upstream at
# https://gitlab.arm.com/artificial-intelligence/ethos-u/ethos-u-vela/-/issues/23.


class SumLastDim(torch.nn.Module):
"""Reduce the last dim with keepdim=True."""

def forward(self, x: torch.Tensor) -> torch.Tensor:
return x.sum(dim=-1, keepdim=True)


a16w8_sum_test_parameters = {
"rank1_16": lambda: (torch.rand(16),),
"rank3_8x1x16": lambda: (torch.rand(8, 1, 16),),
"rank3_4x4x16": lambda: (torch.rand(4, 4, 16),),
}


@common.parametrize("test_data", a16w8_sum_test_parameters)
@common.XfailIfNoCorstone300
def test_sum_dim_intlist_a16w8_u55_INT(test_data: Callable[[], input_t1]):
pipeline = EthosU55PipelineINT[input_t1](
Comment thread
Ninja91 marked this conversation as resolved.
SumLastDim(),
test_data(),
aten_op,
exir_ops=[],
a16w8_quantization=True,
symmetric_io_quantization=True,
qtol=128,
epsilon=2**-16,
)
pipeline.run()


# All cases hit upstream Vela issue #23 (linked above). strict=False so the
# test target stays green both on stock Vela 5.0 (cases XFAIL) and once the
# Vela fix is in tree (cases XPASS).
@common.parametrize("test_data", a16w8_sum_test_parameters)
@common.XfailIfNoCorstone320
@pytest.mark.xfail(
reason="Ethos-U85 int16 ReduceSum returns zero (vela#23)", strict=False
)
Comment thread
Ninja91 marked this conversation as resolved.
def test_sum_dim_intlist_a16w8_u85_INT(test_data: Callable[[], input_t1]):
pipeline = EthosU85PipelineINT[input_t1](
SumLastDim(),
test_data(),
aten_op,
exir_ops=[],
a16w8_quantization=True,
symmetric_io_quantization=True,
qtol=128,
epsilon=2**-16,
)
pipeline.run()
1 change: 1 addition & 0 deletions backends/arm/test/targets.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ def define_arm_tests():
"ops/test_slice.py",
"ops/test_sigmoid.py",
"ops/test_sub.py",
"ops/test_sum.py",
"ops/test_tanh.py",
"ops/test_view.py",
"ops/test_cos.py",
Comment thread
Ninja91 marked this conversation as resolved.
Expand Down
Loading