From 1210018f07231568399bde58b316958ae740ec6f Mon Sep 17 00:00:00 2001 From: Yufeng Shi Date: Thu, 10 Jul 2025 12:15:02 +0100 Subject: [PATCH] Arm backend: Extend and fix quantization bugs in VgfPipeline - Add support for passing transform_passes to VgfPipeline - Fix the vgf quantization - Enable Vgf quantization in ArmTester using VgfQuantizer. - Use tosa_version to distinguish between quantized and non-quantized paths instead of quant_stage, which may be None even under INT profile. Change-Id: Id289ecbde57556e749c0a281ce6c8a000bb6eece --- backends/arm/test/ops/test_add.py | 1 - backends/arm/test/tester/arm_tester.py | 3 +++ backends/arm/test/tester/test_pipeline.py | 12 +++++------- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/backends/arm/test/ops/test_add.py b/backends/arm/test/ops/test_add.py index 7fcd8622195..b8dbe8db771 100644 --- a/backends/arm/test/ops/test_add.py +++ b/backends/arm/test/ops/test_add.py @@ -205,6 +205,5 @@ def test_add_tensor_vgf_int(test_data: input_t1): aten_op, exir_op, tosa_version="TOSA-1.0+INT", - symmetric_io_quantization=True, ) pipeline.run() diff --git a/backends/arm/test/tester/arm_tester.py b/backends/arm/test/tester/arm_tester.py index 99d95a2bc8e..dffee8349d6 100644 --- a/backends/arm/test/tester/arm_tester.py +++ b/backends/arm/test/tester/arm_tester.py @@ -43,6 +43,7 @@ EthosUQuantizer, get_symmetric_quantization_config, TOSAQuantizer, + VgfQuantizer, ) from executorch.backends.arm.test.runner_utils import ( dbg_tosa_fb_to_json, @@ -332,6 +333,8 @@ def quantize( quantizer = TOSAQuantizer(tosa_spec) elif is_ethosu(self.compile_spec): quantizer = EthosUQuantizer(self.compile_spec) + elif is_vgf(self.compile_spec): + quantizer = VgfQuantizer(self.compile_spec) quantize_stage = tester.Quantize( quantizer, get_symmetric_quantization_config(), diff --git a/backends/arm/test/tester/test_pipeline.py b/backends/arm/test/tester/test_pipeline.py index 9af0d5c8621..88a84e2463c 100644 --- a/backends/arm/test/tester/test_pipeline.py +++ b/backends/arm/test/tester/test_pipeline.py @@ -861,18 +861,15 @@ def __init__( rtol: float = 1e-03, qtol: int = 1, dynamic_shapes: Optional[Tuple[Any]] = None, + transform_passes: Optional[ + Union[Sequence[PassType], Dict[str, Sequence[PassType]]] + ] = None, ): if ( symmetric_io_quantization or per_channel_quantization ) and tosa_version == "TOSA-1.0+FP": raise ValueError("Dont configure quantization with FP TOSA profile.") - if ( - symmetric_io_quantization is False - and per_channel_quantization is False - and tosa_version == "TOSA-1.0+INT" - ): - raise ValueError("Missing quantization options for INT TOSA profile.") tosa_profile = TosaSpecification.create_from_string(tosa_version) compile_spec = common.get_vgf_compile_spec( @@ -887,6 +884,7 @@ def __init__( exir_op, use_to_edge_transform_and_lower, dynamic_shapes, + transform_passes=transform_passes, ) if symmetric_io_quantization or per_channel_quantization: @@ -900,7 +898,7 @@ def __init__( else: quant_stage = None - if quant_stage: + if "INT" in tosa_version: self.add_stage(self.tester.quantize, quant_stage, pos=0) self.add_stage_after(