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
1 change: 1 addition & 0 deletions backends/arm/_passes/arm_pass_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -451,6 +451,7 @@ def transform_for_annotation_pipeline(self, graph_module: GraphModule):
DecomposeLeakyReLUPass(tfa_pass=True),
DecomposeLinalgVectorNormPass(tfa_pass=True),
DecomposeSqrtPass(tfa_pass=True),
DecomposeAdaptiveAvgPool2dPass(tfa_pass=True),
DecomposeAvgPool2dPass(tfa_pass=True),
DecomposeSoftmaxUnstablePass(tfa_pass=True),
DecomposeSoftmaxPass(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class DecomposeAdaptiveAvgPool2dPass(ArmPass):
_passes_required_after: Set[Type[ExportPass]] = {DecomposeAvgPool2dPass}

def call_operator(self, op, args, kwargs, meta, updated=False):
if op not in (edge_ops + aten_ops):
if op not in (edge_ops + aten_ops) or not self.allowed_to_transform(meta):
return super().call_operator(op, args, kwargs, meta, updated)

avg_pool2d_op, slice_op, cat_op = _get_decomposition(op)
Expand Down
2 changes: 1 addition & 1 deletion backends/arm/ethosu/backend.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2025 Arm Limited and/or its affiliates.
# Copyright 2025-2026 Arm Limited and/or its affiliates.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.
Expand Down
6 changes: 4 additions & 2 deletions backends/arm/test/models/test_mobilenet_v2_arm.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,10 @@ def test_mv2_tosa_INT(per_channel_quantization):
@common.XfailIfNoCorstone300
@common.parametrize("per_channel_quantization", quant_test_data)
def test_mv2_u55_INT(per_channel_quantization):
input_tensor = model_inputs[0].to(memory_format=torch.channels_last)
pipeline = EthosU55PipelineINT[input_t](
mv2,
model_inputs,
(input_tensor,),
aten_ops=[],
exir_ops=[],
use_to_edge_transform_and_lower=True,
Expand All @@ -122,9 +123,10 @@ def test_mv2_u55_INT(per_channel_quantization):
@common.XfailIfNoCorstone320
@common.parametrize("per_channel_quantization", quant_test_data)
def test_mv2_u85_INT(per_channel_quantization):
input_tensor = model_inputs[0].to(memory_format=torch.channels_last)
pipeline = EthosU85PipelineINT[input_t](
mv2,
model_inputs,
(input_tensor,),
aten_ops=[],
exir_ops=[],
use_to_edge_transform_and_lower=True,
Expand Down
8 changes: 5 additions & 3 deletions backends/arm/test/ops/test_avg_pool2d.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,11 @@ def forward(self, x: torch.Tensor):
AvgPool2d(3, (1, 3), 1, count_include_pad=False),
(torch.rand(1, 16, 54, 54),),
),
"becomes_mean_rank3": lambda: (BecomesMeanInToEdge(), (torch.rand(2, 8, 8),)),
"becomes_mean_rank4": lambda: (BecomesMeanInToEdge(), (torch.rand(2, 2, 8, 8),)),
"becomes_mean_rank5": lambda: (BecomesMeanInToEdge(), (torch.rand(2, 2, 8, 8),)),
"becomes_mean_rank4": lambda: (BecomesMeanInToEdge(), (torch.rand(1, 2, 8, 8),)),
"channels_last_adaptive_avg_pool": lambda: (
BecomesMeanInToEdge(),
(torch.randn(1, 1280, 7, 7).to(memory_format=torch.channels_last),),
),
}

test_modules_bf16 = {
Expand Down
16 changes: 8 additions & 8 deletions backends/arm/test/ops/test_mean_dim.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ def test_adaptive_avg_pool2d_tosa_INT(test_data):
TosaPipelineINT[input_t](
AdaptiveAveragePool2d(),
test_data(),
AdaptiveAveragePool2d.aten_op,
AdaptiveAveragePool2d.exir_op,
[],
[],
symmetric_io_quantization=True,
).run()

Expand All @@ -65,8 +65,8 @@ def test_adaptive_avg_pool2d_u55_INT(test_data):
EthosU55PipelineINT[input_t](
AdaptiveAveragePool2d(),
test_data(),
AdaptiveAveragePool2d.aten_op,
AdaptiveAveragePool2d.exir_op,
[],
[],
symmetric_io_quantization=True,
).run()

Expand All @@ -77,8 +77,8 @@ def test_adaptive_avg_pool2d_u85_INT(test_data):
EthosU85PipelineINT[input_t](
AdaptiveAveragePool2d(),
test_data(),
AdaptiveAveragePool2d.aten_op,
AdaptiveAveragePool2d.exir_op,
[],
[],
symmetric_io_quantization=True,
).run()

Expand All @@ -102,8 +102,8 @@ def test_adaptive_avg_pool2d_vgf_quant(test_data):
pipeline = VgfPipeline[input_t](
AdaptiveAveragePool2d(),
test_data(),
AdaptiveAveragePool2d.aten_op,
AdaptiveAveragePool2d.exir_op,
[],
[],
symmetric_io_quantization=True,
quantize=True,
)
Expand Down
9 changes: 4 additions & 5 deletions backends/arm/test/quantizer/test_selective_quantization.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2025 Arm Limited and/or its affiliates.
# Copyright 2025-2026 Arm Limited and/or its affiliates.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.
Expand Down Expand Up @@ -172,8 +172,8 @@ def test_mv3_selective_quant_float32_tosa_INT():
inputs = (normalize(torch.randn(1, 3, 224, 224)),)

quantization_annotations = {
"aten.adaptive_avg_pool2d.default": {
None: 1,
"aten.conv2d.default": {
None: 14,
},
}

Expand All @@ -182,12 +182,11 @@ def test_mv3_selective_quant_float32_tosa_INT():
inputs,
quantizer=get_selective_quantizer_by_module_name(
{
"features.11.block.2.avgpool": None,
"conv2d_3": None,
}
),
qspecs=quantization_annotations,
)

pipeline.run()


Expand Down
Loading