|
5 | 5 |
|
6 | 6 | from typing import Tuple
|
7 | 7 |
|
| 8 | +import pytest |
8 | 9 | import torch
|
| 10 | +from executorch.backends.arm.quantizer.arm_quantizer import ( |
| 11 | + get_symmetric_a16w8_quantization_config, |
| 12 | + TOSAQuantizer, |
| 13 | +) |
9 | 14 |
|
10 |
| -from executorch.backends.arm.test import common |
| 15 | +from executorch.backends.arm.test import common, conftest |
11 | 16 | from executorch.backends.arm.test.tester.test_pipeline import (
|
12 | 17 | EthosU55PipelineINT,
|
13 | 18 | EthosU85PipelineINT,
|
14 | 19 | TosaPipelineFP,
|
15 | 20 | TosaPipelineINT,
|
16 | 21 | VgfPipeline,
|
17 | 22 | )
|
| 23 | +from executorch.backends.arm.tosa_specification import TosaSpecification |
| 24 | +from executorch.backends.xnnpack.test.tester import Quantize |
18 | 25 |
|
19 | 26 | aten_op = "torch.ops.aten.addmm.default"
|
20 | 27 |
|
@@ -182,3 +189,102 @@ def test_addmm_vgf_INT(test_data: input_t1):
|
182 | 189 | tosa_version="TOSA-1.0+INT",
|
183 | 190 | )
|
184 | 191 | pipeline.run()
|
| 192 | + |
| 193 | + |
| 194 | +def get_symmetric_a16w8_addmm_quantizer(per_channel_quantization=False): |
| 195 | + tosa_version = conftest.get_option("tosa_version") |
| 196 | + tosa_profiles = { |
| 197 | + "1.0": TosaSpecification.create_from_string("TOSA-1.0+INT+int16"), |
| 198 | + } |
| 199 | + |
| 200 | + quantizer = TOSAQuantizer(tosa_profiles[tosa_version]) |
| 201 | + quantizer.set_global( |
| 202 | + get_symmetric_a16w8_quantization_config(is_per_channel=per_channel_quantization) |
| 203 | + ) |
| 204 | + |
| 205 | + return Quantize( |
| 206 | + quantizer, |
| 207 | + get_symmetric_a16w8_quantization_config( |
| 208 | + is_per_channel=per_channel_quantization |
| 209 | + ), |
| 210 | + ) |
| 211 | + |
| 212 | + |
| 213 | +@common.parametrize("test_data", test_data_suite) |
| 214 | +def test_addmm_16a8w_tosa_INT(test_data: input_t1): |
| 215 | + """Test addmm (FC layer) operation with 16A8W quantization (16-bit activations, 8-bit weights)""" |
| 216 | + per_channel_quantization = False |
| 217 | + |
| 218 | + pipeline = TosaPipelineINT[input_t1]( |
| 219 | + Addmm(), |
| 220 | + (*test_data,), |
| 221 | + aten_op=[], |
| 222 | + exir_op=[], |
| 223 | + per_channel_quantization=per_channel_quantization, |
| 224 | + use_to_edge_transform_and_lower=True, |
| 225 | + tosa_extensions=["int16"], |
| 226 | + ) |
| 227 | + |
| 228 | + pipeline.change_args( |
| 229 | + "quantize", |
| 230 | + get_symmetric_a16w8_addmm_quantizer( |
| 231 | + per_channel_quantization=per_channel_quantization |
| 232 | + ), |
| 233 | + ) |
| 234 | + pipeline.run() |
| 235 | + |
| 236 | + |
| 237 | +@common.parametrize("test_data", test_data_suite) |
| 238 | +@common.XfailIfNoCorstone300 |
| 239 | +@pytest.mark.xfail( |
| 240 | + reason="Vela compilation fails with 'Invalid arguments' for int16 addmm operations" |
| 241 | +) |
| 242 | +def test_addmm_16a8w_u55_INT16(test_data: input_t1): |
| 243 | + """Test addmm (FC layer) operation with 16A8W quantization on U55 (16-bit activations, 8-bit weights)""" |
| 244 | + per_channel_quantization = False |
| 245 | + |
| 246 | + pipeline = EthosU55PipelineINT[input_t1]( |
| 247 | + Addmm(), |
| 248 | + (*test_data,), |
| 249 | + aten_ops=[], |
| 250 | + exir_ops=[], |
| 251 | + per_channel_quantization=per_channel_quantization, |
| 252 | + use_to_edge_transform_and_lower=True, |
| 253 | + run_on_fvp=True, |
| 254 | + ) |
| 255 | + |
| 256 | + pipeline.change_args( |
| 257 | + "quantize", |
| 258 | + get_symmetric_a16w8_addmm_quantizer( |
| 259 | + per_channel_quantization=per_channel_quantization |
| 260 | + ), |
| 261 | + ) |
| 262 | + pipeline.run() |
| 263 | + |
| 264 | + |
| 265 | +@common.parametrize("test_data", test_data_suite) |
| 266 | +@common.XfailIfNoCorstone320 |
| 267 | +@pytest.mark.xfail( |
| 268 | + reason="Vela compilation fails with 'Invalid arguments' for int16 addmm operations" |
| 269 | +) |
| 270 | +def test_addmm_16a8w_u85_INT16(test_data: input_t1): |
| 271 | + """Test addmm (FC layer) operation with 16A8W quantization on U85 (16-bit activations, 8-bit weights)""" |
| 272 | + per_channel_quantization = False |
| 273 | + |
| 274 | + pipeline = EthosU85PipelineINT[input_t1]( |
| 275 | + Addmm(), |
| 276 | + (*test_data,), |
| 277 | + aten_ops=[], |
| 278 | + exir_ops=[], |
| 279 | + per_channel_quantization=per_channel_quantization, |
| 280 | + use_to_edge_transform_and_lower=True, |
| 281 | + run_on_fvp=True, |
| 282 | + ) |
| 283 | + |
| 284 | + pipeline.change_args( |
| 285 | + "quantize", |
| 286 | + get_symmetric_a16w8_addmm_quantizer( |
| 287 | + per_channel_quantization=per_channel_quantization |
| 288 | + ), |
| 289 | + ) |
| 290 | + pipeline.run() |
0 commit comments