Skip to content

Handle avg_pool2d with padding == 0 as no padding #10697

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 8, 2025
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
5 changes: 4 additions & 1 deletion backends/arm/operator_support/pool_2d_support.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,11 @@ def is_node_tosa_supported(self, node: fx.Node, tosa_spec: TosaSpecification):
kernel = cast(tuple[int, int], node.args[1])
stride = cast(tuple[int, int], node.args[2])
if len(node.args) > 3:
padding = cast(tuple[int, int], node.args[3])
# Padding case
if not all(1 <= k <= 8 for k in kernel):
if not all(1 <= k <= 8 for k in kernel) and not all(
v == 0 for v in padding
):
self.reporter.report_reject(
node, f"Avgpool2d with padding needs kernel dims < 8, got {kernel}"
)
Expand Down
25 changes: 19 additions & 6 deletions backends/arm/test/ops/test_avg_pool2d.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@

from typing import Tuple

import pytest

import torch

from executorch.backends.arm.test import common
from executorch.backends.arm.test import common, conftest

from executorch.backends.arm.test.tester.test_pipeline import (
EthosU55PipelineBI,
Expand Down Expand Up @@ -64,15 +66,24 @@ def forward(self, x):


@common.parametrize("test_module", test_modules)
@pytest.mark.tosa_ref_model
def test_avgpool2d_tosa_MI(test_module):
model, input_tensor = test_module

pipeline = TosaPipelineMI[input_t](model, input_tensor, aten_op, exir_op)
pipeline.change_args("run_method_and_compare_outputs", qtol=1, atol=1, rtol=1)
pipeline.run()
pipeline = TosaPipelineMI[input_t](
model,
input_tensor,
aten_op,
exir_op,
run_on_tosa_ref_model=conftest.is_option_enabled("tosa_ref_model"),
)
if conftest.is_option_enabled("tosa_ref_model"):
pipeline.change_args("run_method_and_compare_outputs", qtol=1, atol=1, rtol=1)
pipeline.run()


@common.parametrize("test_module", test_modules)
@pytest.mark.tosa_ref_model
def test_avgpool2d_tosa_BI(test_module):
model, input_tensor = test_module

Expand All @@ -82,9 +93,11 @@ def test_avgpool2d_tosa_BI(test_module):
aten_op,
exir_op,
symmetric_io_quantization=True,
run_on_tosa_ref_model=conftest.is_option_enabled("tosa_ref_model"),
)
pipeline.change_args("run_method_and_compare_outputs", qtol=1, atol=1, rtol=1)
pipeline.run()
if conftest.is_option_enabled("tosa_ref_model"):
pipeline.change_args("run_method_and_compare_outputs", qtol=1, atol=1, rtol=1)
pipeline.run()


@common.parametrize("test_module", test_modules)
Expand Down
1 change: 1 addition & 0 deletions backends/arm/test/targets.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ def define_arm_tests():

# Operators
test_files += [
"ops/test_avg_pool2d.py",
"ops/test_linear.py",
"ops/test_slice.py",
"ops/test_sigmoid.py",
Expand Down
Loading