Skip to content

Commit 838ccc3

Browse files
Add a16w8 per-op test for reciprocal (pytorch#19592)
Summary: Add int16 activation / int8 weight (a16w8) quantization tests for `aten.reciprocal` on Ethos-U55 and Ethos-U85. ## Changes - Add `a16w8_reciprocal_test_parameters` dict with 3 test configurations covering rank-1, rank-2, and rank-3 tensors (all shifted by +0.1 to avoid division near zero) - Add `test_reciprocal_a16w8_u55_INT` using `EthosU55PipelineINT` with `a16w8_quantization=True, symmetric_io_quantization=True, qtol=128, epsilon=2**-16` - Add `test_reciprocal_a16w8_u85_INT` using `EthosU85PipelineINT` with same kwargs - Register `ops/test_reciprocal.py` in `fbcode/` and `xplat/` `targets.bzl` bypass-pytorch-oss-checks Differential Revision: D104532357
1 parent 77603b2 commit 838ccc3

2 files changed

Lines changed: 40 additions & 0 deletions

File tree

backends/arm/test/ops/test_reciprocal.py

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,3 +123,42 @@ def test_reciprocal_vgf_quant(test_data: torch.Tensor):
123123
quantize=True,
124124
)
125125
pipeline.run()
126+
127+
128+
a16w8_reciprocal_test_parameters = {
129+
"rank1": lambda: torch.rand(10) + 0.5,
130+
"rank2": lambda: torch.rand(5, 10) + 0.5,
131+
"rank3": lambda: torch.rand(2, 5, 10) + 0.5,
132+
}
133+
134+
135+
@common.parametrize("test_data", a16w8_reciprocal_test_parameters)
136+
@common.XfailIfNoCorstone300
137+
def test_reciprocal_a16w8_u55_INT(test_data: torch.Tensor):
138+
pipeline = EthosU55PipelineINT[input_t1](
139+
Reciprocal(),
140+
(test_data(),),
141+
aten_op,
142+
exir_ops=[],
143+
a16w8_quantization=True,
144+
symmetric_io_quantization=True,
145+
qtol=128,
146+
epsilon=2**-16,
147+
)
148+
pipeline.run()
149+
150+
151+
@common.parametrize("test_data", a16w8_reciprocal_test_parameters)
152+
@common.XfailIfNoCorstone320
153+
def test_reciprocal_a16w8_u85_INT(test_data: torch.Tensor):
154+
pipeline = EthosU85PipelineINT[input_t1](
155+
Reciprocal(),
156+
(test_data(),),
157+
aten_op,
158+
exir_ops=[],
159+
a16w8_quantization=True,
160+
symmetric_io_quantization=True,
161+
qtol=128,
162+
epsilon=2**-16,
163+
)
164+
pipeline.run()

backends/arm/test/targets.bzl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ def define_arm_tests():
3737
"ops/test_cos.py",
3838
"ops/test_to_copy.py",
3939
"ops/test_exp.py",
40+
"ops/test_reciprocal.py",
4041
]
4142

4243
# Quantization

0 commit comments

Comments
 (0)