Skip to content

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

[GPU] Revert convolution fsv16 kernel changes because of OCL perf drop (#36406)

Mikolaj Roszczyka2b32c99821a
diff --git a/src/plugins/intel_gpu/src/kernel_selector/cl_kernels/convolution_gpu_bfyx_f16.cl b/src/plugins/intel_gpu/src/kernel_selector/cl_kernels/convolution_gpu_bfyx_f16.cl
index 9779e5c63e8..c5b63fecdf1 100644
--- a/src/plugins/intel_gpu/src/kernel_selector/cl_kernels/convolution_gpu_bfyx_f16.cl
+++ b/src/plugins/intel_gpu/src/kernel_selector/cl_kernels/convolution_gpu_bfyx_f16.cl
@@ -60,7 +60,6 @@ KERNEL(convolution_bfyx_f16)(
const int xy = get_global_id(0);
const int x = (xy % X_BLOCKS) * OUTPUT_X_BLOCK_SIZE;
const int y = (xy / X_BLOCKS);
- const int input_spatial_size_x = INPUT0_SIZE_X;
const int lid1 = (int)get_local_id(1);
const int feature_per_wg = (int)get_local_size(1) / SLM_DIV_FACTOR;
@@ -188,8 +187,7 @@ KERNEL(convolution_bfyx_f16)(
{
for (int xb = 0; xb < INPUT_LINE_SIZE; xb++)
{
- const int in_x = input_x + xb;
- if (icb * FEATURE_SLICE_SIZE + sglid >= FILTER_IFM_NUM || in_x < 0 || in_x >= input_spatial_size_x)
+ if (icb * FEATURE_SLICE_SIZE + sglid >= FILTER_IFM_NUM)
line_cache[xb] = 0;
else
line_cache[xb] = input[grouped_input_offset +
@@ -202,54 +200,38 @@ KERNEL(convolution_bfyx_f16)(
else
#endif // INPUT_LEFTOVERS
{
- int valid_start = max(0, -input_x);
- int valid_end = min(INPUT_LINE_SIZE, input_spatial_size_x - input_x);
-
- if (valid_start <= 0 && valid_end >= INPUT_LINE_SIZE) {
- int xb = 0;
- for (; xb + 8 <= INPUT_LINE_SIZE; xb += 8) {
- INPUT_TYPE8 vv = DT_INPUT_BLOCK_READ8(input, grouped_input_offset +
- icb * input_fs_pitch +
- kh * DILATION_SIZE_Y * input_y_pitch +
- xb * input_x_pitch);
-
- line_cache[xb + 0] = vv[0];
- line_cache[xb + 1] = vv[1];
- line_cache[xb + 2] = vv[2];
- line_cache[xb + 3] = vv[3];
- line_cache[xb + 4] = vv[4];
- line_cache[xb + 5] = vv[5];
- line_cache[xb + 6] = vv[6];
- line_cache[xb + 7] = vv[7];
- }
- for (; xb + 4 <= INPUT_LINE_SIZE; xb += 4) {
- INPUT_TYPE4 vv = DT_INPUT_BLOCK_READ4(input, grouped_input_offset +
- icb * input_fs_pitch +
- kh * DILATION_SIZE_Y * input_y_pitch +
- xb * input_x_pitch);
-
- line_cache[xb + 0] = vv[0];
- line_cache[xb + 1] = vv[1];
- line_cache[xb + 2] = vv[2];
- line_cache[xb + 3] = vv[3];
- }
- for (; xb < INPUT_LINE_SIZE; xb++) {
- line_cache[xb] = DT_INPUT_BLOCK_READ(input, grouped_input_offset +
- icb * input_fs_pitch +
- kh * DILATION_SIZE_Y * input_y_pitch +
- xb * input_x_pitch);
- }
- } else {
- for (int xb = 0; xb < INPUT_LINE_SIZE; xb++) {
- if (xb < valid_start || xb >= valid_end) {
- line_cache[xb] = 0;
- } else {
- line_cache[xb] = DT_INPUT_BLOCK_READ(input, grouped_input_offset +
- icb * input_fs_pitch +
- kh * DILATION_SIZE_Y * input_y_pitch +
- xb * input_x_pitch);
- }
- }
+ int xb = 0;
+ for (; xb + 8 <= INPUT_LINE_SIZE; xb += 8) {
+ INPUT_TYPE8 vv = DT_INPUT_BLOCK_READ8(input, grouped_input_offset +
+ icb * input_fs_pitch +
+ kh * DILATION_SIZE_Y * input_y_pitch +
+ xb * input_x_pitch);
+
+ line_cache[xb + 0] = vv[0];
+ line_cache[xb + 1] = vv[1];
+ line_cache[xb + 2] = vv[2];
+ line_cache[xb + 3] = vv[3];
+ line_cache[xb + 4] = vv[4];
+ line_cache[xb + 5] = vv[5];
+ line_cache[xb + 6] = vv[6];
+ line_cache[xb + 7] = vv[7];
+ }
+ for (; xb + 4 <= INPUT_LINE_SIZE; xb += 4) {
+ INPUT_TYPE4 vv = DT_INPUT_BLOCK_READ4(input, grouped_input_offset +
+ icb * input_fs_pitch +
+ kh * DILATION_SIZE_Y * input_y_pitch +
+ xb * input_x_pitch);
+
+ line_cache[xb + 0] = vv[0];
+ line_cache[xb + 1] = vv[1];
+ line_cache[xb + 2] = vv[2];
+ line_cache[xb + 3] = vv[3];
+ }
+ for (; xb < INPUT_LINE_SIZE; xb++) {
+ line_cache[xb] = DT_INPUT_BLOCK_READ(input, grouped_input_offset +
+ icb * input_fs_pitch +
+ kh * DILATION_SIZE_Y * input_y_pitch +
+ xb * input_x_pitch);
}
}
@@ -494,4 +476,4 @@ KERNEL(convolution_bfyx_f16)(
# undef OUTPUTVTYPE
# undef TO_OUTPUTVTYPE
# undef VSTORE
-#endif // OUTPUT_FORMAT_BFYX
+#endif // OUTPUT_FORMAT_BFYX
\ No newline at end of file
diff --git a/src/plugins/intel_gpu/src/kernel_selector/cl_kernels/convolution_gpu_bfyx_f16_1x1.cl b/src/plugins/intel_gpu/src/kernel_selector/cl_kernels/convolution_gpu_bfyx_f16_1x1.cl
index 107f1839b4f..f1a5da9b9ea 100644
--- a/src/plugins/intel_gpu/src/kernel_selector/cl_kernels/convolution_gpu_bfyx_f16_1x1.cl
+++ b/src/plugins/intel_gpu/src/kernel_selector/cl_kernels/convolution_gpu_bfyx_f16_1x1.cl
@@ -41,9 +41,6 @@ KERNEL(convolution_b_fs_yx_fsv16_1x1)(
const uint xy = (int)get_global_id(0);
const uint x = (xy * X_BLOCK_SIZE) % OUTPUT_SIZE_X;
const uint y = (xy * X_BLOCK_SIZE) / OUTPUT_SIZE_X;
- const uint spatial_base = xy * X_BLOCK_SIZE;
- const uint input_spatial_size = INPUT0_SIZE_X * INPUT0_SIZE_Y;
- const uint full_spatial_block = (spatial_base + X_BLOCK_SIZE) <= input_spatial_size;
const uint input_x = x;
const uint input_y = y;
@@ -134,16 +131,11 @@ KERNEL(convolution_b_fs_yx_fsv16_1x1)(
__attribute__((opencl_unroll_hint(X_BLOCK_SIZE)))
for (int i = 0; i < X_BLOCK_SIZE; i++)
{
- const uint spatial_idx = spatial_base + i;
- if (spatial_idx < input_spatial_size) {
- const uint xb = spatial_idx % INPUT0_SIZE_X;
- const uint yb = spatial_idx / INPUT0_SIZE_X;
- const uint input_idx = input_offset + k * input_fs_pitch + yb * input_y_pitch + xb * input_x_pitch;
-
- src[i] = input[input_idx + sglid];
- } else {
- src[i] = UNIT_VAL_ZERO;
- }
+ const uint xb = (x + i) % INPUT0_SIZE_X;
+ const uint yb = y + (x + i) / INPUT0_SIZE_X;
+ const uint input_idx = input_offset + k * input_fs_pitch + yb * input_y_pitch + xb * input_x_pitch;
+
+ src[i] = input[input_idx + sglid];
}
#else
src = input[input_offset + k * input_fs_pitch + sglid];
@@ -154,31 +146,14 @@ KERNEL(convolution_b_fs_yx_fsv16_1x1)(
{
#if PADDED_INPUT
#if X_BLOCK_SIZE > 1
- if (full_spatial_block) {
- __attribute__((opencl_unroll_hint(X_BLOCK_SIZE)))
- for (int i = 0; i < X_BLOCK_SIZE; i++)
- {
- const uint xb = (x + i) % INPUT0_SIZE_X;
- const uint yb = y + (x + i) / INPUT0_SIZE_X;
- const uint input_idx = input_offset + k * input_fs_pitch + yb * input_y_pitch + xb * input_x_pitch;
+ __attribute__((opencl_unroll_hint(X_BLOCK_SIZE)))
+ for (int i = 0; i < X_BLOCK_SIZE; i++)
+ {
+ const uint xb = (x + i) % INPUT0_SIZE_X;
+ const uint yb = y + (x + i) / INPUT0_SIZE_X;
+ const uint input_idx = input_offset + k * input_fs_pitch + yb * input_y_pitch + xb * input_x_pitch;
- src[i] = UNIT_BLOCK_READ(input, input_idx);
- }
- } else {
- __attribute__((opencl_unroll_hint(X_BLOCK_SIZE)))
- for (int i = 0; i < X_BLOCK_SIZE; i++)
- {
- const uint spatial_idx = spatial_base + i;
- if (spatial_idx < input_spatial_size) {
- const uint xb = spatial_idx % INPUT0_SIZE_X;
- const uint yb = spatial_idx / INPUT0_SIZE_X;
- const uint input_idx = input_offset + k * input_fs_pitch + yb * input_y_pitch + xb * input_x_pitch;
-
- src[i] = UNIT_BLOCK_READ(input, input_idx);
- } else {
- src[i] = UNIT_VAL_ZERO;
- }
- }
+ src[i] = UNIT_BLOCK_READ(input, input_idx);
}
#else
src = UNIT_BLOCK_READ(input, input_offset + k * input_fs_pitch);
@@ -187,24 +162,7 @@ KERNEL(convolution_b_fs_yx_fsv16_1x1)(
#else // PADDED_INPUT
#if X_BLOCK_SIZE > 1
- if (full_spatial_block) {
- src = UNIT_BLOCK_READ_VEC(input, input_offset + k * input_fs_pitch + input_y * input_y_pitch + input_x * input_x_pitch);
- } else {
- __attribute__((opencl_unroll_hint(X_BLOCK_SIZE)))
- for (int i = 0; i < X_BLOCK_SIZE; i++)
- {
- const uint spatial_idx = spatial_base + i;
- if (spatial_idx < input_spatial_size) {
- const uint xb = spatial_idx % INPUT0_SIZE_X;
- const uint yb = spatial_idx / INPUT0_SIZE_X;
- const uint input_idx = input_offset + k * input_fs_pitch + yb * input_y_pitch + xb * input_x_pitch;
-
- src[i] = UNIT_BLOCK_READ(input, input_idx);
- } else {
- src[i] = UNIT_VAL_ZERO;
- }
- }
- }
+ src = UNIT_BLOCK_READ_VEC(input, input_offset + k * input_fs_pitch + input_y * input_y_pitch + input_x * input_x_pitch);
#else
src = UNIT_BLOCK_READ(input, input_offset + k * input_fs_pitch);
#endif // X_BLOCK_SIZE > 1
@@ -340,4 +298,4 @@ KERNEL(convolution_b_fs_yx_fsv16_1x1)(
#undef GET_SRC
#undef FEATURE_SLICE_SIZE
#undef UNIT_BLOCK_READ_VEC
-#undef UNIT_BLOCK_WRITE_VEC
+#undef UNIT_BLOCK_WRITE_VEC
\ No newline at end of file