|
10 | 10 | import pytest
|
11 | 11 | import torch
|
12 | 12 | from executorch.backends.arm.quantizer import arm_quantizer
|
| 13 | +from executorch.backends.arm.quantizer.arm_quantizer import ( |
| 14 | + get_symmetric_a16w8_quantization_config, |
| 15 | + TOSAQuantizer, |
| 16 | +) |
13 | 17 | from executorch.backends.arm.test import common, conftest
|
14 | 18 | from executorch.backends.arm.test.tester.test_pipeline import (
|
15 | 19 | EthosU55PipelineINT,
|
@@ -216,3 +220,46 @@ def test_add_tensor_vgf_INT(test_data: input_t1):
|
216 | 220 | tosa_version="TOSA-1.0+INT",
|
217 | 221 | )
|
218 | 222 | pipeline.run()
|
| 223 | + |
| 224 | + |
| 225 | +def get_symmetric_a16w8_add_quantizer(u55_config=False, per_channel_quantization=False): |
| 226 | + tosa_version = conftest.get_option("tosa_version") |
| 227 | + tosa_profiles = { |
| 228 | + "1.0": TosaSpecification.create_from_string("TOSA-1.0+INT+int16"), |
| 229 | + } |
| 230 | + |
| 231 | + quantizer = TOSAQuantizer(tosa_profiles[tosa_version]) |
| 232 | + quantizer.set_global( |
| 233 | + get_symmetric_a16w8_quantization_config(is_per_channel=per_channel_quantization) |
| 234 | + ) |
| 235 | + |
| 236 | + return Quantize( |
| 237 | + quantizer, |
| 238 | + get_symmetric_a16w8_quantization_config( |
| 239 | + is_per_channel=per_channel_quantization |
| 240 | + ), |
| 241 | + ) |
| 242 | + |
| 243 | + |
| 244 | +@common.parametrize("test_data", Add.test_data) |
| 245 | +def test_add_tensor_16a8w_tosa_INT(test_data: input_t1): |
| 246 | + """Test add operation with 16A8W quantization (16-bit activations, 8-bit weights)""" |
| 247 | + per_channel_quantization = False |
| 248 | + |
| 249 | + pipeline = TosaPipelineINT[input_t1]( |
| 250 | + Add(), |
| 251 | + test_data(), |
| 252 | + aten_op, |
| 253 | + exir_op=[], |
| 254 | + per_channel_quantization=per_channel_quantization, |
| 255 | + use_to_edge_transform_and_lower=True, |
| 256 | + tosa_extensions=["int16"], |
| 257 | + ) |
| 258 | + |
| 259 | + pipeline.change_args( |
| 260 | + "quantize", |
| 261 | + get_symmetric_a16w8_add_quantizer( |
| 262 | + per_channel_quantization=per_channel_quantization |
| 263 | + ), |
| 264 | + ) |
| 265 | + pipeline.run() |
0 commit comments