Skip to content

Commit 125d651

Browse files
Add a16w8 per-op test for mean_dim (pytorch#19594) (pytorch#19594)
Summary: Add int16 activation / int8 weight (a16w8) quantization tests for `aten.mean.dim` on Ethos-U55 and Ethos-U85. ## Changes - Add `a16w8_mean_test_parameters` dict with 11 test configurations covering keepdim/no-keepdim, positive/negative dims, dim=None, and ranks 1-4 - Add `test_mean_dim_a16w8_u55_INT` using `EthosU55PipelineINT` with `a16w8_quantization=True, symmetric_io_quantization=True` - Add `test_mean_dim_a16w8_u85_INT` using `EthosU85PipelineINT` with same kwargs - Register `ops/test_mean_dim.py` in `fbcode/` and `xplat/` `targets.bzl` Differential Revision: D104532361
1 parent e6bf149 commit 125d651

2 files changed

Lines changed: 67 additions & 0 deletions

File tree

backends/arm/test/ops/test_mean_dim.py

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
# LICENSE file in the root directory of this source tree.
77
from typing import Callable
88

9+
import pytest
910
import torch
1011
from executorch.backends.arm.test import common
1112
from executorch.backends.arm.test.tester.test_pipeline import (
@@ -393,3 +394,68 @@ def test_mean_tosa_INT(test_data):
393394
symmetric_io_quantization=True,
394395
)
395396
pipeline.run()
397+
398+
399+
a16w8_mean_test_parameters = {
400+
"rank_2_keepdim": lambda: (torch.rand(7, 3), (0, 1), True),
401+
"rank_3_keepdim": lambda: (torch.rand(5, 7, 3), (0, 1, 2), True),
402+
"rand_23_keepdim": lambda: (torch.rand(1, 5, 7, 3), (2, 3), True),
403+
"rand_0123_keepdim": lambda: (torch.rand(1, 5, 7, 3), (0, 1, 2, 3), True),
404+
"rand_none_keepdim": lambda: (torch.rand(1, 5, 7, 3), None, True),
405+
"rank_2": lambda: (torch.rand(5, 7), (-2, -1), False),
406+
"rand_123": lambda: (torch.rand(1, 5, 7, 3), (-3, -2, -1), False),
407+
}
408+
409+
a16w8_mean_test_parameters_u85_xfails = {
410+
"rank_1_keepdim": lambda: (torch.rand(7), 0, True),
411+
"rand_1_keepdim": lambda: (torch.rand(1, 5, 7, 3), (1), True),
412+
"rank_1": lambda: (torch.rand(7), (-1), False),
413+
"rand_3": lambda: (torch.rand(1, 5, 7, 3), (-1), False),
414+
}
415+
416+
417+
@common.parametrize(
418+
"test_data", {**a16w8_mean_test_parameters, **a16w8_mean_test_parameters_u85_xfails}
419+
)
420+
@common.XfailIfNoCorstone300
421+
def test_mean_dim_a16w8_u55_INT(test_data):
422+
test_data, dim, keep_dim = test_data()
423+
pipeline = EthosU55PipelineINT[input_t](
424+
MeanDim(dim, keep_dim),
425+
(test_data,),
426+
[],
427+
symmetric_io_quantization=True,
428+
a16w8_quantization=True,
429+
)
430+
pipeline.run()
431+
432+
433+
@common.parametrize("test_data", a16w8_mean_test_parameters)
434+
@common.XfailIfNoCorstone320
435+
def test_mean_dim_a16w8_u85_INT(test_data):
436+
test_data, dim, keep_dim = test_data()
437+
pipeline = EthosU85PipelineINT[input_t](
438+
MeanDim(dim, keep_dim),
439+
(test_data,),
440+
[],
441+
symmetric_io_quantization=True,
442+
a16w8_quantization=True,
443+
)
444+
pipeline.run()
445+
446+
447+
@common.parametrize("test_data", a16w8_mean_test_parameters_u85_xfails)
448+
@pytest.mark.xfail(
449+
reason="U85 mean_dim a16w8 produces all-zero output for single-dim reductions"
450+
)
451+
@common.XfailIfNoCorstone320
452+
def test_mean_dim_a16w8_u85_INT_xfail(test_data):
453+
test_data, dim, keep_dim = test_data()
454+
pipeline = EthosU85PipelineINT[input_t](
455+
MeanDim(dim, keep_dim),
456+
(test_data,),
457+
[],
458+
symmetric_io_quantization=True,
459+
a16w8_quantization=True,
460+
)
461+
pipeline.run()

backends/arm/test/targets.bzl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ def define_arm_tests():
3838
"ops/test_to_copy.py",
3939
"ops/test_exp.py",
4040
"ops/test_reciprocal.py",
41+
"ops/test_mean_dim.py",
4142
]
4243

4344
# Quantization

0 commit comments

Comments
 (0)