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
4 changes: 2 additions & 2 deletions backends/arm/_passes/decompose_sum_pass.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ def call_operator(self, op, args, kwargs, meta):
case _:
raise ValueError(f"Invalid number of arguments ({len(args)}) provided.")

# If dims is None, sum over all dimensions
if dims is None:
# If dims evaluates to False (None or []), sum over all dimensions
if not dims:
shape = input_node.data.size()
dims = list(range(len(shape)))

Expand Down
1 change: 1 addition & 0 deletions backends/arm/quantizer/quantization_annotator.py
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,7 @@ def _match_pattern(
torch.ops.aten.sin.default,
torch.ops.aten.tanh.default,
torch.ops.aten.sum.dim_IntList,
torch.ops.aten.sum.default,
torch.ops.aten.hardsigmoid.default,
torch.ops.aten.hardswish.default,
torch.ops.aten.hardswish_.default,
Expand Down
1 change: 1 addition & 0 deletions backends/arm/scripts/parse_test_names.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"native_group_norm.default",
"silu.default",
"sdpa.default",
"sum.default",
"unbind.int",
"unflatten.int",
"_native_batch_norm_legit_no_training.default",
Expand Down
30 changes: 28 additions & 2 deletions backends/arm/test/ops/test_sum.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.

from typing import Tuple
from typing import Callable, Tuple

import torch
from executorch.backends.arm.test import common
Expand Down Expand Up @@ -61,7 +61,6 @@ def test_sum_dim_intlist_tosa_INT(test_data: input_t1):
aten_op,
exir_op=[],
)
pipeline.dump_artifact("export")
pipeline.run()


Expand Down Expand Up @@ -133,3 +132,30 @@ def test_view_u55_INT_failure_set(test_data: Tuple):
)
pipeline.pop_stage("check_count.exir")
pipeline.run()


input_t2 = tuple[torch.Tensor]


class SumDefault(torch.nn.Module):
test_parameters = {
"rank1": lambda: (torch.rand(10),),
"rank2": lambda: (torch.rand(10, 1, 10),),
"rank4": lambda: (torch.rand(1, 1, 5, 8),),
}
aten_op = "torch.ops.aten.sum.default"

def forward(self, x: torch.Tensor):
return x.sum()


@common.parametrize("test_data", SumDefault.test_parameters)
def test_sum_tosa_FP(test_data: Callable[[], input_t2]):
pipeline = TosaPipelineFP[input_t2](SumDefault(), test_data(), SumDefault.aten_op)
pipeline.run()


@common.parametrize("test_data", SumDefault.test_parameters)
def test_sum_tosa_INT(test_data: Callable[[], input_t2]):
pipeline = TosaPipelineINT[input_t1](SumDefault(), test_data(), SumDefault.aten_op)
pipeline.run()
Loading