Skip to content

OpenVINO™ is an open source toolkit for optimizing and deploying AI inference

[GPU] Fixed missing check in quantize_gpu_ref kernel. (#36594)

Nikolay Proshunin72dd54002041
diff --git a/src/plugins/intel_gpu/src/kernel_selector/cl_kernels/quantize_gpu_ref.cl b/src/plugins/intel_gpu/src/kernel_selector/cl_kernels/quantize_gpu_ref.cl
index 4baeb7dd51c..95944e7cefd 100644
--- a/src/plugins/intel_gpu/src/kernel_selector/cl_kernels/quantize_gpu_ref.cl
+++ b/src/plugins/intel_gpu/src/kernel_selector/cl_kernels/quantize_gpu_ref.cl
@@ -52,6 +52,26 @@ KERNEL(quantize_ref)(
const int v = ((vuwzyx / OUTPUT_SIZE_X) / OUTPUT_SIZE_Y) / OUTPUT_SIZE_Z / OUTPUT_SIZE_W / OUTPUT_SIZE_U;
#endif
+#if OUTPUT_LAYOUT_B_FS_YX_FSV16
+ if (of >= OUTPUT_FEATURE_NUM)
+ return;
+#else
+ if (x >= OUTPUT_SIZE_X || y >= OUTPUT_SIZE_Y || z >= OUTPUT_SIZE_Z)
+ return;
+#if OUTPUT_DIMS >= 6
+ if (w >= OUTPUT_SIZE_W)
+ return;
+#endif
+#if OUTPUT_DIMS >= 7
+ if (u >= OUTPUT_SIZE_U)
+ return;
+#endif
+#if OUTPUT_DIMS >= 8
+ if (v >= OUTPUT_SIZE_V)
+ return;
+#endif
+#endif
+
#if INPUT0_DIMS == 8
const int input_offset = INPUT0_GET_INDEX(b, of, v, u, w, z, y, x);
#elif INPUT0_DIMS == 7
@@ -126,14 +146,6 @@ KERNEL(quantize_ref)(
INPUT0_TYPE val = input[input_offset];
-#if OUTPUT_LAYOUT_B_FS_YX_FSV16
- if (of >= OUTPUT_FEATURE_NUM)
- return;
-#else
- if (x >= OUTPUT_SIZE_X || y >= OUTPUT_SIZE_Y || z >= OUTPUT_SIZE_Z)
- return;
-#endif
-
INPUT0_TYPE input_low_val = input_low[input_low_offset];
INPUT0_TYPE input_high_val = input_high[input_high_offset];
INPUT0_TYPE output_low_val = output_low[output_low_offset];