From 248c841e8580809739dd15e261bde8dea4d431b4 Mon Sep 17 00:00:00 2001 From: Sergey Shlyapnikov Date: Tue, 21 May 2024 16:10:27 +0400 Subject: [PATCH] [GPU] Fix U8 weights identification as a quantization case (#24488) ### Details: - Fix the issue where `conv_params.quantization` was not correctly identified as a quantization case when using U8 weights data (which is allowed by ConvertConvolutionToInternal transformation pass) ### Tickets: - 139740 --- .../src/graph/impls/ocl/convolution.cpp | 3 +- .../convolution_qdq_transformation.cpp | 54 +++++++++++++++++++ 2 files changed, 56 insertions(+), 1 deletion(-) diff --git a/src/plugins/intel_gpu/src/graph/impls/ocl/convolution.cpp b/src/plugins/intel_gpu/src/graph/impls/ocl/convolution.cpp index 9fbe7bd7e6cd21..ff35d9da49dc6a 100644 --- a/src/plugins/intel_gpu/src/graph/impls/ocl/convolution.cpp +++ b/src/plugins/intel_gpu/src/graph/impls/ocl/convolution.cpp @@ -137,7 +137,8 @@ struct convolution_impl : typed_primitive_impl_ocl { if ((impl_param.input_layouts[0].data_type == data_types::u8 || impl_param.input_layouts[0].data_type == data_types::i8) && - impl_param.input_layouts[1].data_type == data_types::i8) { + (impl_param.input_layouts[1].data_type == data_types::i8 || + impl_param.input_layouts[1].data_type == data_types::u8)) { if (!primitive->weights_zero_points.empty() && !primitive->activations_zero_points.empty()) { conv_params.quantization = kernel_selector::QuantizationType::ASYMMETRIC_DATA_AND_WEIGHTS; } else if (!primitive->weights_zero_points.empty()) { diff --git a/src/plugins/intel_gpu/tests/functional/shared_tests_instances/low_precision_transformations/convolution_qdq_transformation.cpp b/src/plugins/intel_gpu/tests/functional/shared_tests_instances/low_precision_transformations/convolution_qdq_transformation.cpp index 552a42d3eaec1d..dee07d8e9d00de 100644 --- a/src/plugins/intel_gpu/tests/functional/shared_tests_instances/low_precision_transformations/convolution_qdq_transformation.cpp +++ b/src/plugins/intel_gpu/tests/functional/shared_tests_instances/low_precision_transformations/convolution_qdq_transformation.cpp @@ -76,6 +76,60 @@ const std::vector para ov::element::u8.get_type_name() }, + // Actual: + // + // Constant + // | Constant Constant Constant Constant + // | /FP32 /FP32 /FP32 /FP32 + // FakeQuantize FakeQuantize + // |FP32 |FP32 + // | | + // Convert Constant Convert + // |U8 |U8 |U8 + // | | | + // Convert Convert Convert Constant + // \FP32 /FP32 |FP32 /U8 + // \ / | / + // Subtract Constant Subtract Constant + // \FP32 /FP32 |FP32 /FP32 + // \ / | / + // Multiply Multiply + // \FP32 /FP32 + // \ / + // Convolution + // + // Transformed: + // + // Parameter Constant Constant + // \U8 /U8 /U8 + // \ / / + // Subtract Subtract + // \FP32 /FP32 + // \ / + // Convolution Constant + // \FP32 /FP32 + // \ / + // Multiply + { + { 256ul, {{ 1, 1, 1, 1 }}, { -12.8f }, { 12.7f }, { 0.f }, { 255.f }, ov::element::f32 }, + { ov::element::u8, false }, + { + {ov::element::f32}, + { {128.f}, ov::element::f32, {}, false, 1ul, ov::element::u8, true }, + { {0.1f}, ov::element::f32, {}, false } + }, + { std::vector{ 15.f }, ov::element::f32}, + { 256ul, ov::Shape({ 1, 1, 1, 1 }), { 0.f }, { 25.5f }, { 0.f }, { 255.f }, ov::element::f32 }, + { ov::element::u8, false }, + { + { ov::element::f32, false }, + { {0.3f}, ov::element::f32, {}, false, 1ul, ov::element::u8, true }, + { {0.2f}, ov::element::f32, {}, false } + }, + "Convolution", + ov::element::u8.get_type_name() + }, + // Actual: // // Constant