diff --git a/backends/arm/scripts/parse_test_names.py b/backends/arm/scripts/parse_test_names.py index e388d5b30cb..7dc2bfaef68 100644 --- a/backends/arm/scripts/parse_test_names.py +++ b/backends/arm/scripts/parse_test_names.py @@ -19,7 +19,9 @@ "multihead_attention.default", "adaptive_avg_pool2d.default", "bitwise_right_shift.Tensor", + "bitwise_right_shift.Scalar", "bitwise_left_shift.Tensor", + "bitwise_left_shift.Scalar", "native_group_norm.default", "silu.default", "sdpa.default", diff --git a/backends/arm/test/models/test_nn_functional.py b/backends/arm/test/models/test_nn_functional.py index e585e82ad9d..7d1ae64b63e 100644 --- a/backends/arm/test/models/test_nn_functional.py +++ b/backends/arm/test/models/test_nn_functional.py @@ -110,8 +110,10 @@ def test_nn_functional_INT(test_data): ) pipeline.pop_stage("check.aten") pipeline.pop_stage("check_count.exir") - pipeline.pop_stage("check.quant_nodes") - pipeline.pop_stage("check_not.quant_nodes") + if pipeline.has_stage("check.quant_nodes"): + pipeline.pop_stage("check.quant_nodes") + if pipeline.has_stage("check_not.quant_nodes"): + pipeline.pop_stage("check_not.quant_nodes") try: pipeline.run() except RuntimeError as e: diff --git a/backends/arm/test/models/test_nn_modules.py b/backends/arm/test/models/test_nn_modules.py index 8192ec6887b..a1e1f6431d9 100644 --- a/backends/arm/test/models/test_nn_modules.py +++ b/backends/arm/test/models/test_nn_modules.py @@ -147,8 +147,10 @@ def test_nn_Modules_INT(test_data): ) pipeline.pop_stage("check.aten") pipeline.pop_stage("check_count.exir") - pipeline.pop_stage("check.quant_nodes") - pipeline.pop_stage("check_not.quant_nodes") + if pipeline.has_stage("check.quant_nodes"): + pipeline.pop_stage("check.quant_nodes") + if pipeline.has_stage("check_not.quant_nodes"): + pipeline.pop_stage("check_not.quant_nodes") try: pipeline.run() except RuntimeError as e: diff --git a/backends/arm/test/ops/test_any.py b/backends/arm/test/ops/test_any.py index 3eccff0a64e..9d973a27d41 100644 --- a/backends/arm/test/ops/test_any.py +++ b/backends/arm/test/ops/test_any.py @@ -149,8 +149,6 @@ def test_any_tosa_INT(test_data: input_t1): rtol=0, qtol=0, ) - pipeline.pop_stage("quantize") - pipeline.pop_stage("check.quant_nodes") pipeline.run() @@ -181,8 +179,6 @@ def test_any_u85_INT(test_data: input_t1): rtol=0, qtol=0, ) - pipeline.pop_stage("quantize") - pipeline.pop_stage("check.quant_nodes") pipeline.run() @@ -211,6 +207,4 @@ def test_any_vgf_INT(test_data: input_t1): op.exir_op, tosa_version="TOSA-1.0+INT", ) - pipeline.pop_stage("quantize") - pipeline.pop_stage("check.quant_nodes") pipeline.run() diff --git a/backends/arm/test/ops/test_arange.py b/backends/arm/test/ops/test_arange.py index 33cca542922..3816db3a53c 100644 --- a/backends/arm/test/ops/test_arange.py +++ b/backends/arm/test/ops/test_arange.py @@ -98,7 +98,6 @@ def test_arange_start_step_tosa_INT(test_data: test_data_t): ArangeAdd.aten_op, ArangeAdd.exir_op, ) - pipeline.pop_stage("check.quant_nodes") pipeline.run() @@ -111,7 +110,6 @@ def test_arange_start_step_u55_INT(test_data: test_data_t): input_data(), ArangeAdd.aten_op, ) - pipeline.pop_stage("check.quant_nodes") pipeline.run() @@ -124,7 +122,6 @@ def test_arange_start_step_u85_INT(test_data: test_data_t): input_data(), ArangeAdd.aten_op, ) - pipeline.pop_stage("check.quant_nodes") pipeline.run() diff --git a/backends/arm/test/ops/test_bitwise.py b/backends/arm/test/ops/test_bitwise.py index f9b20e5dbdd..b80b87fdae5 100644 --- a/backends/arm/test/ops/test_bitwise.py +++ b/backends/arm/test/ops/test_bitwise.py @@ -109,8 +109,8 @@ def forward(self, tensor1: torch.Tensor, tensor2: torch.Tensor): class AndScalar(BitwiseBinaryScalar): - aten_op = "torch.ops.aten.bitwise_and.Scalar" # Tensor because it gets converted from Scalar -> Tensor in lowering + aten_op = "torch.ops.aten.bitwise_and.Tensor" exir_op = "executorch_exir_dialects_edge__ops_aten_bitwise_and_Tensor" exir_op_scalar = "executorch_exir_dialects_edge__ops_aten_bitwise_and_Scalar" @@ -119,8 +119,8 @@ def forward(self, tensor: torch.Tensor, scalar: int): class XorScalar(BitwiseBinaryScalar): - aten_op = "torch.ops.aten.bitwise_xor.Scalar" # Tensor because it gets converted from Scalar -> Tensor in lowering + aten_op = "torch.ops.aten.bitwise_xor.Tensor" exir_op = "executorch_exir_dialects_edge__ops_aten_bitwise_xor_Tensor" exir_op_scalar = "executorch_exir_dialects_edge__ops_aten_bitwise_xor_Scalar" @@ -129,8 +129,8 @@ def forward(self, tensor: torch.Tensor, scalar: int): class OrScalar(BitwiseBinaryScalar): - aten_op = "torch.ops.aten.bitwise_or.Scalar" # Tensor because it gets converted from Scalar -> Tensor in lowering + aten_op = "torch.ops.aten.bitwise_or.Tensor" exir_op = "executorch_exir_dialects_edge__ops_aten_bitwise_or_Tensor" exir_op_scalar = "executorch_exir_dialects_edge__ops_aten_bitwise_or_Scalar" @@ -174,8 +174,6 @@ def test_bitwise_and_tensor_tosa_INT(test_data: input_t2): rtol=0, qtol=0, ) - pipeline.pop_stage("quantize") - pipeline.pop_stage("check.quant_nodes") pipeline.run() @@ -190,8 +188,6 @@ def test_bitwise_and_scalar_tosa_INT(test_data: input_t2): rtol=0, qtol=0, ) - pipeline.pop_stage("quantize") - pipeline.pop_stage("check.quant_nodes") pipeline.run() @@ -239,8 +235,6 @@ def test_bitwise_and_scalar_u85_INT(test_data: input_t2): rtol=0, qtol=0, ) - pipeline.pop_stage("quantize") - pipeline.pop_stage("check.quant_nodes") pipeline.run() @@ -256,8 +250,6 @@ def test_bitwise_and_tensor_u85_INT(test_data: input_t2): rtol=0, qtol=0, ) - pipeline.pop_stage("quantize") - pipeline.pop_stage("check.quant_nodes") pipeline.run() @@ -296,8 +288,6 @@ def test_bitwise_and_tensor_vgf_INT(test_data: input_t2): qtol=0, tosa_version="TOSA-1.0+INT", ) - pipeline.pop_stage("quantize") - pipeline.pop_stage("check.quant_nodes") pipeline.run() @@ -314,8 +304,6 @@ def test_bitwise_and_scalar_vgf_INT(test_data: input_t2): qtol=0, tosa_version="TOSA-1.0+INT", ) - pipeline.pop_stage("quantize") - pipeline.pop_stage("check.quant_nodes") pipeline.run() @@ -355,8 +343,6 @@ def test_bitwise_xor_tensor_tosa_INT(test_data: input_t2): rtol=0, qtol=0, ) - pipeline.pop_stage("quantize") - pipeline.pop_stage("check.quant_nodes") pipeline.run() @@ -371,8 +357,6 @@ def test_bitwise_xor_scalar_tosa_INT(test_data: input_t2): rtol=0, qtol=0, ) - pipeline.pop_stage("quantize") - pipeline.pop_stage("check.quant_nodes") pipeline.run() @@ -420,8 +404,6 @@ def test_bitwise_xor_tensor_u85_INT(test_data: input_t2): rtol=0, qtol=0, ) - pipeline.pop_stage("quantize") - pipeline.pop_stage("check.quant_nodes") pipeline.run() @@ -437,8 +419,6 @@ def test_bitwise_xor_scalar_u85_INT(test_data: input_t2): rtol=0, qtol=0, ) - pipeline.pop_stage("quantize") - pipeline.pop_stage("check.quant_nodes") pipeline.run() @@ -477,8 +457,6 @@ def test_bitwise_xor_tensor_vgf_INT(test_data: input_t2): qtol=0, tosa_version="TOSA-1.0+INT", ) - pipeline.pop_stage("quantize") - pipeline.pop_stage("check.quant_nodes") pipeline.run() @@ -495,8 +473,6 @@ def test_bitwise_xor_scalar_vgf_INT(test_data: input_t2): qtol=0, tosa_version="TOSA-1.0+INT", ) - pipeline.pop_stage("quantize") - pipeline.pop_stage("check.quant_nodes") pipeline.run() @@ -536,8 +512,6 @@ def test_bitwise_or_tensor_tosa_INT(test_data: input_t2): rtol=0, qtol=0, ) - pipeline.pop_stage("quantize") - pipeline.pop_stage("check.quant_nodes") pipeline.run() @@ -552,8 +526,6 @@ def test_bitwise_or_scalar_tosa_INT(test_data: input_t2): rtol=0, qtol=0, ) - pipeline.pop_stage("quantize") - pipeline.pop_stage("check.quant_nodes") pipeline.run() @@ -601,8 +573,6 @@ def test_bitwise_or_tensor_u85_INT(test_data: input_t2): rtol=0, qtol=0, ) - pipeline.pop_stage("quantize") - pipeline.pop_stage("check.quant_nodes") pipeline.run() @@ -618,8 +588,6 @@ def test_bitwise_or_scalar_u85_INT(test_data: input_t2): rtol=0, qtol=0, ) - pipeline.pop_stage("quantize") - pipeline.pop_stage("check.quant_nodes") pipeline.run() @@ -658,8 +626,6 @@ def test_bitwise_or_tensor_vgf_INT(test_data: input_t2): qtol=0, tosa_version="TOSA-1.0+INT", ) - pipeline.pop_stage("quantize") - pipeline.pop_stage("check.quant_nodes") pipeline.run() @@ -676,8 +642,6 @@ def test_bitwise_or_scalar_vgf_INT(test_data: input_t2): qtol=0, tosa_version="TOSA-1.0+INT", ) - pipeline.pop_stage("quantize") - pipeline.pop_stage("check.quant_nodes") pipeline.run() diff --git a/backends/arm/test/ops/test_bitwise_not.py b/backends/arm/test/ops/test_bitwise_not.py index 4f48bc134ba..f9d743bdc8a 100644 --- a/backends/arm/test/ops/test_bitwise_not.py +++ b/backends/arm/test/ops/test_bitwise_not.py @@ -60,8 +60,6 @@ def test_bitwise_not_tosa_INT(test_data: Tuple): aten_op=aten_op, exir_op=exir_op, ) - pipeline.pop_stage("quantize") - pipeline.pop_stage("check.quant_nodes") pipeline.run() @@ -87,8 +85,6 @@ def test_bitwise_not_u85_INT(test_data: Tuple): aten_ops=aten_op, exir_ops=exir_op, ) - pipeline.pop_stage("quantize") - pipeline.pop_stage("check.quant_nodes") pipeline.run() @@ -115,6 +111,4 @@ def test_bitwise_not_vgf_INT(test_data: Tuple): exir_op, tosa_version="TOSA-1.0+INT", ) - pipeline.pop_stage("quantize") - pipeline.pop_stage("check.quant_nodes") pipeline.run() diff --git a/backends/arm/test/ops/test_eye.py b/backends/arm/test/ops/test_eye.py index 5c829acc145..f3ba4113db1 100644 --- a/backends/arm/test/ops/test_eye.py +++ b/backends/arm/test/ops/test_eye.py @@ -68,7 +68,8 @@ def test_eye_tosa_INT(test_data: test_data_t): input_data(), EyeAdd.aten_op, ) - pipeline.pop_stage("check.quant_nodes") + if pipeline.has_stage("check.quant_nodes"): + pipeline.pop_stage("check.quant_nodes") pipeline.run() @@ -82,7 +83,8 @@ def test_eye_u55_INT(test_data: test_data_t): EyeAdd.aten_op, use_to_edge_transform_and_lower=True, ) - pipeline.pop_stage("check.quant_nodes") + if pipeline.has_stage("check.quant_nodes"): + pipeline.pop_stage("check.quant_nodes") pipeline.run() @@ -96,7 +98,8 @@ def test_eye_u85_INT(test_data: test_data_t): EyeAdd.aten_op, use_to_edge_transform_and_lower=True, ) - pipeline.pop_stage("check.quant_nodes") + if pipeline.has_stage("check.quant_nodes"): + pipeline.pop_stage("check.quant_nodes") pipeline.run() @@ -132,7 +135,8 @@ def test_eye_vgf_INT(test_data: test_data_t): EyeAdd.aten_op, tosa_version="TOSA-1.0+INT", ) - pipeline.pop_stage("check.quant_nodes") + if pipeline.has_stage("check.quant_nodes"): + pipeline.pop_stage("check.quant_nodes") pipeline.run() diff --git a/backends/arm/test/ops/test_full.py b/backends/arm/test/ops/test_full.py index 8ab063e9957..d0cf162a232 100644 --- a/backends/arm/test/ops/test_full.py +++ b/backends/arm/test/ops/test_full.py @@ -117,7 +117,6 @@ def test_full_like_tosa_INT(test_data: Tuple): aten_op=[], exir_op=exir_op, ) - pipeline.pop_stage("check.quant_nodes") pipeline.run() diff --git a/backends/arm/test/ops/test_logical.py b/backends/arm/test/ops/test_logical.py index e772840e6e6..8c290c28908 100644 --- a/backends/arm/test/ops/test_logical.py +++ b/backends/arm/test/ops/test_logical.py @@ -111,8 +111,6 @@ def test_logical_and_tosa_INT(test_data: input_t2): rtol=0, qtol=0, ) - pipeline.pop_stage("quantize") - pipeline.pop_stage("check.quant_nodes") pipeline.run() @@ -141,8 +139,6 @@ def test_logical_and_u85_INT(test_data: input_t2): rtol=0, qtol=0, ) - pipeline.pop_stage("quantize") - pipeline.pop_stage("check.quant_nodes") pipeline.run() @@ -169,8 +165,6 @@ def test_logical_and_vgf_INT(test_data: input_t2): And().exir_op, tosa_version="TOSA-1.0+INT", ) - pipeline.pop_stage("quantize") - pipeline.pop_stage("check.quant_nodes") pipeline.run() @@ -204,8 +198,6 @@ def test_logical_xor_tosa_INT(test_data: input_t2): rtol=0, qtol=0, ) - pipeline.pop_stage("quantize") - pipeline.pop_stage("check.quant_nodes") pipeline.run() @@ -234,8 +226,6 @@ def test_logical_xor_u85_INT(test_data: input_t2): rtol=0, qtol=0, ) - pipeline.pop_stage("quantize") - pipeline.pop_stage("check.quant_nodes") pipeline.run() @@ -262,8 +252,6 @@ def test_logical_xor_vgf_INT(test_data: input_t2): Xor().exir_op, tosa_version="TOSA-1.0+INT", ) - pipeline.pop_stage("quantize") - pipeline.pop_stage("check.quant_nodes") pipeline.run() @@ -297,8 +285,6 @@ def test_logical_or_tosa_INT(test_data: input_t2): rtol=0, qtol=0, ) - pipeline.pop_stage("quantize") - pipeline.pop_stage("check.quant_nodes") pipeline.run() @@ -327,8 +313,6 @@ def test_logical_or_u85_INT(test_data: input_t2): rtol=0, qtol=0, ) - pipeline.pop_stage("quantize") - pipeline.pop_stage("check.quant_nodes") pipeline.run() @@ -355,8 +339,6 @@ def test_logical_or_vgf_INT(test_data: input_t2): Or().exir_op, tosa_version="TOSA-1.0+INT", ) - pipeline.pop_stage("quantize") - pipeline.pop_stage("check.quant_nodes") pipeline.run() @@ -390,8 +372,6 @@ def test_logical_not_tosa_INT(test_data: input_t2): rtol=0, qtol=0, ) - pipeline.pop_stage("quantize") - pipeline.pop_stage("check.quant_nodes") pipeline.run() @@ -420,8 +400,6 @@ def test_logical_not_u85_INT(test_data: input_t2): rtol=0, qtol=0, ) - pipeline.pop_stage("quantize") - pipeline.pop_stage("check.quant_nodes") pipeline.run() @@ -448,6 +426,4 @@ def test_logical_not_vgf_INT(test_data: input_t2): Not().exir_op, tosa_version="TOSA-1.0+INT", ) - pipeline.pop_stage("quantize") - pipeline.pop_stage("check.quant_nodes") pipeline.run() diff --git a/backends/arm/test/ops/test_lshift.py b/backends/arm/test/ops/test_lshift.py index 3af49cd4dc2..1d4224a8efe 100644 --- a/backends/arm/test/ops/test_lshift.py +++ b/backends/arm/test/ops/test_lshift.py @@ -91,7 +91,6 @@ def test_bitwise_left_shift_tensor_tosa_INT_scalar(test_data): LshiftScalar.torch_op_INT, LshiftScalar.exir_op, ) - pipeline.pop_stage("check.quant_nodes") pipeline.run() @@ -104,7 +103,6 @@ def test_bitwise_left_shift_tensor_u55_INT_scalar(test_data): LshiftScalar.torch_op_INT, LshiftScalar.exir_op, ) - pipeline.pop_stage("check.quant_nodes") pipeline.run() @@ -117,7 +115,6 @@ def test_bitwise_left_shift_tensor_u85_INT_scalar(test_data): LshiftScalar.torch_op_INT, LshiftScalar.exir_op, ) - pipeline.pop_stage("check.quant_nodes") pipeline.run() @@ -144,7 +141,6 @@ def test_bitwise_left_shift_tensor_vgf_INT_scalar(test_data: scalar_input_t): LshiftScalar.exir_op, tosa_version="TOSA-1.0+INT", ) - pipeline.pop_stage("check.quant_nodes") pipeline.run() @@ -171,7 +167,6 @@ def test_bitwise_left_shift_tensor_tosa_INT(test_data): LshiftTensor.torch_op, LshiftTensor.exir_op, ) - pipeline.pop_stage("check.quant_nodes") pipeline.run() @@ -184,7 +179,6 @@ def test_bitwise_left_shift_tensor_u55_INT(test_data): LshiftTensor.torch_op, LshiftTensor.exir_op, ) - pipeline.pop_stage("check.quant_nodes") pipeline.run() @@ -197,7 +191,6 @@ def test_bitwise_left_shift_tensor_u85_INT(test_data): LshiftTensor.torch_op, LshiftTensor.exir_op, ) - pipeline.pop_stage("check.quant_nodes") pipeline.run() @@ -224,5 +217,4 @@ def test_bitwise_left_shift_tensor_vgf_INT(test_data: tensor_input_t): LshiftTensor.exir_op, tosa_version="TOSA-1.0+INT", ) - pipeline.pop_stage("check.quant_nodes") pipeline.run() diff --git a/backends/arm/test/ops/test_mul.py b/backends/arm/test/ops/test_mul.py index 02447e40c4e..2e40a244983 100644 --- a/backends/arm/test/ops/test_mul.py +++ b/backends/arm/test/ops/test_mul.py @@ -187,7 +187,6 @@ def test_mul_tensor_tosa_INT_int32(test_data: torch.Tensor): aten_op, exir_op=[], ) - pipeline.pop_stage("check.quant_nodes") pipeline.run() @@ -224,7 +223,6 @@ def test_mul_tensor_u55_INT_int32(test_data: torch.Tensor): aten_op, exir_ops=[], ) - pipeline.pop_stage("check.quant_nodes") pipeline.run() @@ -237,7 +235,6 @@ def test_mul_tensor_u85_INT_int32(test_data: torch.Tensor): aten_op, exir_ops=[], ) - pipeline.pop_stage("check.quant_nodes") pipeline.run() @@ -285,7 +282,6 @@ def test_mul_tensor_vgf_INT_int32(test_data: torch.Tensor): exir_op=[], tosa_version="TOSA-1.0+INT", ) - pipeline.pop_stage("check.quant_nodes") pipeline.run() diff --git a/backends/arm/test/ops/test_ones.py b/backends/arm/test/ops/test_ones.py index f4dafca5e10..53351bfff53 100644 --- a/backends/arm/test/ops/test_ones.py +++ b/backends/arm/test/ops/test_ones.py @@ -65,7 +65,10 @@ def test_ones_tosa_INT(test_data: test_data_t): input_data(), OnesAdd.aten_op, ) - pipeline.pop_stage("check.quant_nodes") + # Pop the quantization check stage if it exists as no + # quantization nodes will be present for int + fp inputs. + if pipeline.has_stage("check.quant_nodes"): + pipeline.pop_stage("check.quant_nodes") pipeline.run() @@ -79,7 +82,10 @@ def test_ones_u55_INT(test_data: test_data_t): OnesAdd.aten_op, use_to_edge_transform_and_lower=True, ) - pipeline.pop_stage("check.quant_nodes") + # Pop the quantization check stage if it exists as no + # quantization nodes will be present for int + fp inputs. + if pipeline.has_stage("check.quant_nodes"): + pipeline.pop_stage("check.quant_nodes") pipeline.run() @@ -92,8 +98,11 @@ def test_ones_u85_INT(test_data: test_data_t): input_data(), OnesAdd.aten_op, use_to_edge_transform_and_lower=True, - ).dump_artifact("to_edge_transform_and_lower") - pipeline.pop_stage("check.quant_nodes") + ) + # Pop the quantization check stage if it exists as no + # quantization nodes will be present for int + fp inputs. + if pipeline.has_stage("check.quant_nodes"): + pipeline.pop_stage("check.quant_nodes") pipeline.run() @@ -133,5 +142,8 @@ def test_ones_vgf_INT(test_data: test_data_t): OnesAdd.aten_op, tosa_version="TOSA-1.0+INT", ) - pipeline.pop_stage("check.quant_nodes") + # Pop the quantization check stage if it exists as no + # quantization nodes will be present for int + fp inputs. + if pipeline.has_stage("check.quant_nodes"): + pipeline.pop_stage("check.quant_nodes") pipeline.run() diff --git a/backends/arm/test/ops/test_rshift.py b/backends/arm/test/ops/test_rshift.py index f7a821e3a63..40258907b1e 100644 --- a/backends/arm/test/ops/test_rshift.py +++ b/backends/arm/test/ops/test_rshift.py @@ -91,7 +91,6 @@ def test_bitwise_right_shift_tensor_tosa_INT_scalar(test_data): RshiftScalar.torch_op_INT, RshiftScalar.exir_op, ) - pipeline.pop_stage("check.quant_nodes") pipeline.run() @@ -104,7 +103,6 @@ def test_bitwise_right_shift_tensor_u55_INT_scalar(test_data): RshiftScalar.torch_op_INT, RshiftScalar.exir_op, ) - pipeline.pop_stage("check.quant_nodes") # Forced rounding in U55 HW causes off-by-one errors. pipeline.change_args("run_method_and_compare_outputs", inputs=test_data(), atol=1) @@ -120,7 +118,6 @@ def test_bitwise_right_shift_tensor_u85_INT_scalar(test_data): RshiftScalar.torch_op_INT, RshiftScalar.exir_op, ) - pipeline.pop_stage("check.quant_nodes") pipeline.run() @@ -147,7 +144,6 @@ def test_bitwise_right_shift_tensor_vgf_INT_scalar(test_data): RshiftScalar.exir_op, tosa_version="TOSA-1.0+INT", ) - pipeline.pop_stage("check.quant_nodes") pipeline.run() @@ -174,7 +170,6 @@ def test_bitwise_right_shift_tensor_tosa_INT(test_data): RshiftTensor.torch_op, RshiftTensor.exir_op, ) - pipeline.pop_stage("check.quant_nodes") pipeline.run() @@ -187,7 +182,6 @@ def test_bitwise_right_shift_tensor_u55_INT(test_data): RshiftTensor.torch_op, RshiftTensor.exir_op, ) - pipeline.pop_stage("check.quant_nodes") # Forced rounding in U55 HW causes off-by-one errors. pipeline.change_args("run_method_and_compare_outputs", inputs=test_data(), atol=1) @@ -203,7 +197,6 @@ def test_bitwise_right_shift_tensor_u85_INT(test_data): RshiftTensor.torch_op, RshiftTensor.exir_op, ) - pipeline.pop_stage("check.quant_nodes") pipeline.run() @@ -230,5 +223,4 @@ def test_bitwise_right_shift_tensor_vgf_INT(test_data): RshiftTensor.exir_op, tosa_version="TOSA-1.0+INT", ) - pipeline.pop_stage("check.quant_nodes") pipeline.run() diff --git a/backends/arm/test/ops/test_scalar_tensor.py b/backends/arm/test/ops/test_scalar_tensor.py index d5e5b365da1..356bcf508b7 100644 --- a/backends/arm/test/ops/test_scalar_tensor.py +++ b/backends/arm/test/ops/test_scalar_tensor.py @@ -73,7 +73,10 @@ def test_scalar_tensor_tosa_INT(test_data): tuple(data), ScalarTensor.aten_op, ) - pipeline.pop_stage("check.quant_nodes") + # Pop the quantization check stage if it exists as no + # quantization nodes will be present for int + fp inputs. + if pipeline.has_stage("check.quant_nodes"): + pipeline.pop_stage("check.quant_nodes") pipeline.run() @@ -112,7 +115,10 @@ def test_scalar_tensor_vgf_FP(test_data): pipeline.run() -@common.parametrize("test_data", int_test_data_suite) +@common.parametrize( + "test_data", + int_test_data_suite, +) @common.SkipIfNoModelConverter def test_scalar_tensor_vgf_INT(test_data): scalar, dtype, data = test_data() @@ -122,5 +128,8 @@ def test_scalar_tensor_vgf_INT(test_data): ScalarTensor.aten_op, tosa_version="TOSA-1.0+INT", ) - pipeline.pop_stage("check.quant_nodes") + # Pop the quantization check stage if it exists as no + # quantization nodes will be present for int + fp inputs. + if pipeline.has_stage("check.quant_nodes"): + pipeline.pop_stage("check.quant_nodes") pipeline.run() diff --git a/backends/arm/test/ops/test_scalars.py b/backends/arm/test/ops/test_scalars.py index c4f371a1a14..b3704c87fb6 100644 --- a/backends/arm/test/ops/test_scalars.py +++ b/backends/arm/test/ops/test_scalars.py @@ -435,5 +435,4 @@ def test_bitwise_right_shift_tensor_tosa_INT_inplace(): (torch.IntTensor(5),), aten_op="torch.ops.aten.bitwise_right_shift.Tensor", ) - pipeline.pop_stage("check.quant_nodes") pipeline.run() diff --git a/backends/arm/test/ops/test_to_copy.py b/backends/arm/test/ops/test_to_copy.py index 1fdc4619131..b3b7fab5318 100644 --- a/backends/arm/test/ops/test_to_copy.py +++ b/backends/arm/test/ops/test_to_copy.py @@ -226,7 +226,6 @@ def test_to_tosa_INT_REDUNDANT_CAST(test_data: Tuple): exir_op=[], ) pipeline.pop_stage("run_method_and_compare_outputs") - pipeline.pop_stage("check.quant_nodes") pipeline.run() diff --git a/backends/arm/test/ops/test_zeros.py b/backends/arm/test/ops/test_zeros.py index caee678282a..d9a885620d9 100644 --- a/backends/arm/test/ops/test_zeros.py +++ b/backends/arm/test/ops/test_zeros.py @@ -65,7 +65,10 @@ def test_zeros_tosa_INT(test_data: test_data_t): input_data(), ZerosAdd.aten_op, ) - pipeline.pop_stage("check.quant_nodes") + # Pop the quantization check stage if it exists as no + # quantization nodes will be present for int + fp inputs. + if pipeline.has_stage("check.quant_nodes"): + pipeline.pop_stage("check.quant_nodes") pipeline.run() @@ -79,7 +82,10 @@ def test_zeros_u55_INT(test_data: test_data_t): ZerosAdd.aten_op, use_to_edge_transform_and_lower=True, ) - pipeline.pop_stage("check.quant_nodes") + # Pop the quantization check stage if it exists as no + # quantization nodes will be present for int + fp inputs. + if pipeline.has_stage("check.quant_nodes"): + pipeline.pop_stage("check.quant_nodes") pipeline.run() @@ -92,8 +98,11 @@ def test_zeros_u85_INT(test_data: test_data_t): input_data(), ZerosAdd.aten_op, use_to_edge_transform_and_lower=True, - ).dump_artifact("to_edge_transform_and_lower") - pipeline.pop_stage("check.quant_nodes") + ) + # Pop the quantization check stage if it exists as no + # quantization nodes will be present for int + fp inputs. + if pipeline.has_stage("check.quant_nodes"): + pipeline.pop_stage("check.quant_nodes") pipeline.run() @@ -139,5 +148,8 @@ def test_zeros_vgf_INT(test_data: test_data_t): ZerosAdd.aten_op, tosa_version="TOSA-1.0+INT", ) - pipeline.pop_stage("check.quant_nodes") + # Pop the quantization check stage if it exists as no + # quantization nodes will be present for int + fp inputs. + if pipeline.has_stage("check.quant_nodes"): + pipeline.pop_stage("check.quant_nodes") pipeline.run() diff --git a/backends/arm/test/passes/test_convert_int64_const_ops_to_int32.py b/backends/arm/test/passes/test_convert_int64_const_ops_to_int32.py index 7c7ad984e4c..5366e5453c1 100644 --- a/backends/arm/test/passes/test_convert_int64_const_ops_to_int32.py +++ b/backends/arm/test/passes/test_convert_int64_const_ops_to_int32.py @@ -90,7 +90,6 @@ def test_convert_arange_default_int64_dtype_to_int32_pass_tosa_INT( aten_ops_checks, exir_ops_checks, ) - pipeline.pop_stage("check.quant_nodes") pipeline.run() @@ -152,7 +151,6 @@ def test_convert_arange_start_int64_dtype_to_int32_pass_tosa_INT( aten_ops_checks, exir_ops_checks, ) - pipeline.pop_stage("check.quant_nodes") pipeline.run() @@ -214,7 +212,6 @@ def test_convert_arange_start_step_int64_dtype_to_int32_pass_tosa_INT( aten_ops_checks, exir_ops_checks, ) - pipeline.pop_stage("check.quant_nodes") pipeline.run() @@ -387,7 +384,6 @@ def test_convert_full_int64_dtype_to_int32_pass_tosa_INT( aten_ops_checks, exir_ops_checks, ) - pipeline.pop_stage("check.quant_nodes") pipeline.run() diff --git a/backends/arm/test/tester/test_pipeline.py b/backends/arm/test/tester/test_pipeline.py index 059534a46ba..e77a2667eb9 100644 --- a/backends/arm/test/tester/test_pipeline.py +++ b/backends/arm/test/tester/test_pipeline.py @@ -53,6 +53,13 @@ def _require_tosa_version() -> str: return version +def _has_quantizable_inputs(test_data: T) -> bool: + for data in test_data: + if isinstance(data, torch.Tensor) and data.is_floating_point(): + return True + return False + + class PipelineStage: """Container for a pipeline stage (callable plus arguments).""" @@ -391,30 +398,32 @@ def __init__( ) self.add_stage(self.tester.quantize, quant_stage, pos=0) - self.add_stage_after( - "quantize", - self.tester.check, - [ - "torch.ops.quantized_decomposed.dequantize_per_tensor.default", - "torch.ops.quantized_decomposed.quantize_per_tensor.default", - ], - suffix="quant_nodes", - ) - remove_quant_nodes_stage = ( "to_edge_transform_and_lower" if use_to_edge_transform_and_lower else "partition" ) - self.add_stage_after( - remove_quant_nodes_stage, - self.tester.check_not, - [ - "torch.ops.quantized_decomposed.dequantize_per_tensor.default", - "torch.ops.quantized_decomposed.quantize_per_tensor.default", - ], - suffix="quant_nodes", - ) + + if _has_quantizable_inputs(test_data): + # only add stages if we have quantizable input + self.add_stage_after( + "quantize", + self.tester.check, + [ + "torch.ops.quantized_decomposed.dequantize_per_tensor.default", + "torch.ops.quantized_decomposed.quantize_per_tensor.default", + ], + suffix="quant_nodes", + ) + self.add_stage_after( + remove_quant_nodes_stage, + self.tester.check_not, + [ + "torch.ops.quantized_decomposed.dequantize_per_tensor.default", + "torch.ops.quantized_decomposed.quantize_per_tensor.default", + ], + suffix="quant_nodes", + ) if run_on_tosa_ref_model: self.add_stage( @@ -571,30 +580,32 @@ def __init__( self.add_stage(self.tester.quantize, quant_stage, pos=0) - self.add_stage_after( - "quantize", - self.tester.check, - [ - "torch.ops.quantized_decomposed.dequantize_per_tensor.default", - "torch.ops.quantized_decomposed.quantize_per_tensor.default", - ], - suffix="quant_nodes", - ) - remove_quant_nodes_stage = ( "to_edge_transform_and_lower" if use_to_edge_transform_and_lower else "partition" ) - self.add_stage_after( - remove_quant_nodes_stage, - self.tester.check_not, - [ - "torch.ops.quantized_decomposed.dequantize_per_tensor.default", - "torch.ops.quantized_decomposed.quantize_per_tensor.default", - ], - suffix="quant_nodes", - ) + + if _has_quantizable_inputs(test_data): + # only add stages if we have quantizable input + self.add_stage_after( + "quantize", + self.tester.check, + [ + "torch.ops.quantized_decomposed.dequantize_per_tensor.default", + "torch.ops.quantized_decomposed.quantize_per_tensor.default", + ], + suffix="quant_nodes", + ) + self.add_stage_after( + remove_quant_nodes_stage, + self.tester.check_not, + [ + "torch.ops.quantized_decomposed.dequantize_per_tensor.default", + "torch.ops.quantized_decomposed.quantize_per_tensor.default", + ], + suffix="quant_nodes", + ) if run_on_fvp: self.add_stage(self.tester.serialize) @@ -669,30 +680,32 @@ def __init__( self.add_stage(self.tester.quantize, quant_stage, pos=0) - self.add_stage_after( - "quantize", - self.tester.check, - [ - "torch.ops.quantized_decomposed.dequantize_per_tensor.default", - "torch.ops.quantized_decomposed.quantize_per_tensor.default", - ], - suffix="quant_nodes", - ) - remove_quant_nodes_stage = ( "to_edge_transform_and_lower" if use_to_edge_transform_and_lower else "partition" ) - self.add_stage_after( - remove_quant_nodes_stage, - self.tester.check_not, - [ - "torch.ops.quantized_decomposed.dequantize_per_tensor.default", - "torch.ops.quantized_decomposed.quantize_per_tensor.default", - ], - suffix="quant_nodes", - ) + + if _has_quantizable_inputs(test_data): + # only add stages if we have quantizable input + self.add_stage_after( + "quantize", + self.tester.check, + [ + "torch.ops.quantized_decomposed.dequantize_per_tensor.default", + "torch.ops.quantized_decomposed.quantize_per_tensor.default", + ], + suffix="quant_nodes", + ) + self.add_stage_after( + remove_quant_nodes_stage, + self.tester.check_not, + [ + "torch.ops.quantized_decomposed.dequantize_per_tensor.default", + "torch.ops.quantized_decomposed.quantize_per_tensor.default", + ], + suffix="quant_nodes", + ) if run_on_fvp: self.add_stage(self.tester.serialize) @@ -999,30 +1012,32 @@ def __init__( self.add_stage(self.tester.quantize, quant_stage, pos=0) - self.add_stage_after( - "quantize", - self.tester.check, - [ - "torch.ops.quantized_decomposed.dequantize_per_tensor.default", - "torch.ops.quantized_decomposed.quantize_per_tensor.default", - ], - suffix="quant_nodes", - ) - remove_quant_nodes_stage = ( "to_edge_transform_and_lower" if use_to_edge_transform_and_lower else "partition" ) - self.add_stage_after( - remove_quant_nodes_stage, - self.tester.check_not, - [ - "torch.ops.quantized_decomposed.dequantize_per_tensor.default", - "torch.ops.quantized_decomposed.quantize_per_tensor.default", - ], - suffix="quant_nodes", - ) + + if _has_quantizable_inputs(test_data): + # only add stages if we have quantizable input + self.add_stage_after( + "quantize", + self.tester.check, + [ + "torch.ops.quantized_decomposed.dequantize_per_tensor.default", + "torch.ops.quantized_decomposed.quantize_per_tensor.default", + ], + suffix="quant_nodes", + ) + self.add_stage_after( + remove_quant_nodes_stage, + self.tester.check_not, + [ + "torch.ops.quantized_decomposed.dequantize_per_tensor.default", + "torch.ops.quantized_decomposed.quantize_per_tensor.default", + ], + suffix="quant_nodes", + ) else: self.add_stage_after( "export",