Skip to content

Commit db30c66

Browse files
Add a16w8 per-op test for mean_dim
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, qtol=128, epsilon=2**-16` - Add `test_mean_dim_a16w8_u85_INT` using `EthosU85PipelineINT` with same kwargs - Register `ops/test_mean_dim.py` in `fbcode/` and `xplat/` `targets.bzl` bypass-pytorch-oss-checks Differential Revision: D104532361
1 parent a9deed0 commit db30c66

2 files changed

Lines changed: 48 additions & 0 deletions

File tree

backends/arm/test/ops/test_mean_dim.py

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -393,3 +393,50 @@ def test_mean_tosa_INT(test_data):
393393
symmetric_io_quantization=True,
394394
)
395395
pipeline.run()
396+
397+
398+
a16w8_mean_test_parameters = {
399+
"rank_1_keepdim": lambda: (torch.rand(7), 0, True),
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_1_keepdim": lambda: (torch.rand(1, 5, 7, 3), (1), True),
403+
"rand_23_keepdim": lambda: (torch.rand(1, 5, 7, 3), (2, 3), True),
404+
"rand_0123_keepdim": lambda: (torch.rand(1, 5, 7, 3), (0, 1, 2, 3), True),
405+
"rand_none_keepdim": lambda: (torch.rand(1, 5, 7, 3), None, True),
406+
"rank_1": lambda: (torch.rand(7), (-1), False),
407+
"rank_2": lambda: (torch.rand(5, 7), (-2, -1), False),
408+
"rand_3": lambda: (torch.rand(1, 5, 7, 3), (-1), False),
409+
"rand_123": lambda: (torch.rand(1, 5, 7, 3), (-3, -2, -1), False),
410+
}
411+
412+
413+
@common.parametrize("test_data", a16w8_mean_test_parameters)
414+
@common.XfailIfNoCorstone300
415+
def test_mean_dim_a16w8_u55_INT(test_data):
416+
test_data, dim, keep_dim = test_data()
417+
pipeline = EthosU55PipelineINT[input_t](
418+
MeanDim(dim, keep_dim),
419+
(test_data,),
420+
[],
421+
symmetric_io_quantization=True,
422+
a16w8_quantization=True,
423+
qtol=128,
424+
epsilon=2**-16,
425+
)
426+
pipeline.run()
427+
428+
429+
@common.parametrize("test_data", a16w8_mean_test_parameters)
430+
@common.XfailIfNoCorstone320
431+
def test_mean_dim_a16w8_u85_INT(test_data):
432+
test_data, dim, keep_dim = test_data()
433+
pipeline = EthosU85PipelineINT[input_t](
434+
MeanDim(dim, keep_dim),
435+
(test_data,),
436+
[],
437+
symmetric_io_quantization=True,
438+
a16w8_quantization=True,
439+
qtol=128,
440+
epsilon=2**-16,
441+
)
442+
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)