OpenVINO™ is an open source toolkit for optimizing and deploying AI inference
C++ aicomputer-visiondeep-learningdeploy-aidiffusion-modelsgenerative-aigood-first-issueinferencellm-inferencenatural-language-processingnlpopenvinooptimize-aiperformance-boostrecommendation-systemspeech-recognitionstable-diffusiontransformersyolo
[GPU] Fix StridedSlice NEW_AXIS input indexing (#36688)
Michal Miotk0c0ed6eae1aa
diff --git a/src/plugins/intel_gpu/src/kernel_selector/cl_kernels/strided_slice_ref.cl b/src/plugins/intel_gpu/src/kernel_selector/cl_kernels/strided_slice_ref.clindex 1344eb973f4..eba022fdfbb 100644--- a/src/plugins/intel_gpu/src/kernel_selector/cl_kernels/strided_slice_ref.cl+++ b/src/plugins/intel_gpu/src/kernel_selector/cl_kernels/strided_slice_ref.cl@@ -289,39 +289,43 @@ KERNEL(strided_slice_ref)(OPTIONAL_SHAPE_INFO_ARG#if NEW_AXIS_MODE// If NEW_AXIS_MODE that just copy input to output+ const uint out_feature_gws = (uint)OUTPUT_FEATURE_NUM;+ const uint out_spatial_gws = (uint)(OUTPUT_SIZE_W * OUTPUT_SIZE_Z * OUTPUT_SIZE_Y * OUTPUT_SIZE_X);+ const uint linear_pos = (batch * out_feature_gws + feature) * out_spatial_gws + (uint)get_global_id(2);+ const uint spatial_size = INPUT0_SIZE_W * INPUT0_SIZE_Z *INPUT0_SIZE_Y * INPUT0_SIZE_X;+ const uint b_input = linear_pos / (INPUT0_FEATURE_NUM * spatial_size);+ const uint fwzyx_pos = linear_pos % (INPUT0_FEATURE_NUM * spatial_size);+ const uint f_input = fwzyx_pos / spatial_size;#ifdef INPUT0_LAYOUT_BFYX- const uint index_in_batch = (feature * (uint)get_global_size(2) + (uint)get_global_id(2)) % (OUTPUT_SIZE_X * OUTPUT_SIZE_Y);- const uint input_feature_id = (feature * (uint)get_global_size(2) + (uint)get_global_id(2)) / (OUTPUT_SIZE_X * OUTPUT_SIZE_Y);const uint w_input = 0;const uint z_input = 0;- const uint y_input = index_in_batch / OUTPUT_SIZE_X;- const uint x_input = index_in_batch % OUTPUT_SIZE_X;+ const uint yx_pos = fwzyx_pos % spatial_size;+ const uint y_input = yx_pos / INPUT0_SIZE_X;+ const uint x_input = yx_pos % INPUT0_SIZE_X;#elif INPUT0_LAYOUT_BFZYX- const uint index_in_batch = (feature * (uint)get_global_size(2) + (uint)get_global_id(2)) % (OUTPUT_SIZE_X * OUTPUT_SIZE_Y * OUTPUT_SIZE_Z);- const uint input_feature_id = (feature * (uint)get_global_size(2) + (uint)get_global_id(2)) / (OUTPUT_SIZE_X * OUTPUT_SIZE_Y * OUTPUT_SIZE_Z);const uint w_input = 0;- const uint yx_input = index_in_batch % (OUTPUT_SIZE_X * OUTPUT_SIZE_Y);- const uint z_input = index_in_batch / (OUTPUT_SIZE_X * OUTPUT_SIZE_Y);- const uint y_input = yx_input / OUTPUT_SIZE_X;- const uint x_input = yx_input % OUTPUT_SIZE_X;+ const uint zyx_pos = fwzyx_pos % spatial_size;+ const uint z_input = zyx_pos / (INPUT0_SIZE_X * INPUT0_SIZE_Y);+ const uint yx_pos = zyx_pos % (INPUT0_SIZE_X * INPUT0_SIZE_Y);+ const uint y_input = yx_pos / INPUT0_SIZE_X;+ const uint x_input = yx_pos % INPUT0_SIZE_X;#elif INPUT0_LAYOUT_BFWZYX- const uint index_in_batch = (feature * (uint)get_global_size(2) + (uint)get_global_id(2)) % (OUTPUT_SIZE_X * OUTPUT_SIZE_Y * OUTPUT_SIZE_Z * OUTPUT_SIZE_W);- const uint input_feature_id = (feature * (uint)get_global_size(2) + (uint)get_global_id(2)) / (OUTPUT_SIZE_X * OUTPUT_SIZE_Y * OUTPUT_SIZE_Z * OUTPUT_SIZE_W);- const uint zyx_input = index_in_batch % (OUTPUT_SIZE_X * OUTPUT_SIZE_Y * OUTPUT_SIZE_Z);- const uint w_input = index_in_batch / (OUTPUT_SIZE_X * OUTPUT_SIZE_Y * OUTPUT_SIZE_Z);- const uint z_input = zyx_input / (OUTPUT_SIZE_X * OUTPUT_SIZE_Y);- const uint yx_input = zyx_input % (OUTPUT_SIZE_X * OUTPUT_SIZE_Y);- const uint y_input = yx_input / OUTPUT_SIZE_X;- const uint x_input = yx_input % OUTPUT_SIZE_X;+ const uint wzyx_pos = fwzyx_pos % spatial_size;+ const uint w_input = wzyx_pos / (INPUT0_SIZE_Z * INPUT0_SIZE_Y * INPUT0_SIZE_X);+ const uint zyx_pos = wzyx_pos % (INPUT0_SIZE_Z * INPUT0_SIZE_Y * INPUT0_SIZE_X );+ const uint z_input = zyx_pos / (INPUT0_SIZE_Y * INPUT0_SIZE_X);+ const uint yx_pos = zyx_pos % (INPUT0_SIZE_Y * INPUT0_SIZE_X);+ const uint y_input = yx_pos / INPUT0_SIZE_X;+ const uint x_input = yx_pos % INPUT0_SIZE_X;#endifconst uint input_index = INPUT0_OFFSET +- batch * INPUT0_BATCH_PITCH +- input_feature_id * INPUT0_FEATURE_PITCH +- w_input * OUTPUT_W_PITCH +- z_input * OUTPUT_Z_PITCH +- y_input * OUTPUT_Y_PITCH +- x_input * OUTPUT_X_PITCH;+ b_input * INPUT0_BATCH_PITCH ++ f_input * INPUT0_FEATURE_PITCH ++ w_input * INPUT0_W_PITCH ++ z_input * INPUT0_Z_PITCH ++ y_input * INPUT0_Y_PITCH ++ x_input * INPUT0_X_PITCH;#ifdef OUTPUT_LAYOUT_BFYXconst uint y = (uint)get_global_id(2) / OUTPUT_SIZE_X;diff --git a/src/plugins/intel_gpu/tests/functional/shared_tests_instances/single_layer_tests/strided_slice.cpp b/src/plugins/intel_gpu/tests/functional/shared_tests_instances/single_layer_tests/strided_slice.cppindex 2d0e85fa10a..9064659c5bf 100644--- a/src/plugins/intel_gpu/tests/functional/shared_tests_instances/single_layer_tests/strided_slice.cpp+++ b/src/plugins/intel_gpu/tests/functional/shared_tests_instances/single_layer_tests/strided_slice.cpp@@ -146,7 +146,7 @@ std::vector<StridedSliceSpecificParams> ss_only_test_cases_fp32 = {{ 0, 0, 0, 0 }, { 0, 1, 0, 1 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 } },StridedSliceSpecificParams{ ov::test::static_shapes_to_test_representation(std::vector<ov::Shape>({{ 2, 2, 4, 1 }})),- { 0, 0, 0, 0 }, { 2, 2, 4, 1 }, { 1, 1, 1, 1 },+ { 0, 0, 0, 0 }, { 1, 2, 2, 4}, { 1, 1, 1, 1 },{ 0 }, { 0 }, { 1 }, { 0 }, {0 } },StridedSliceSpecificParams{ ov::test::static_shapes_to_test_representation(std::vector<ov::Shape>({{ 128, 1, 1024 }})),diff --git a/src/plugins/intel_gpu/tests/functional/single_layer_tests/dynamic/strided_slice.cpp b/src/plugins/intel_gpu/tests/functional/single_layer_tests/dynamic/strided_slice.cppindex 72849ae5e5f..f798c401ebf 100644--- a/src/plugins/intel_gpu/tests/functional/single_layer_tests/dynamic/strided_slice.cpp+++ b/src/plugins/intel_gpu/tests/functional/single_layer_tests/dynamic/strided_slice.cpp@@ -472,3 +472,19 @@ INSTANTIATE_TEST_SUITE_P(smoke_CompareWithRefs_new_axis_3D, StridedSliceLayerRes::testing::ValuesIn(model_types),::testing::Values(rest_input_types[0])),StridedSliceLayerGPUTest::getTestCaseName);++const std::vector<InputShape> inputShapesDynamic3D_new_axis_linear = {+ {{-1, -1, -1},+ {{ 160, 256, 3 }}},+};+const std::vector<StridedSliceParams> params3D_new_axis_linear = {+ StridedSliceParams{ { 0, 0, 0 }, { 1, 160, 256 }, { 1, 1, 1 }, { 0, 0, 0 }, { 0, 0, 0 }, { 1, 0, 0 }, { }, { } },+};++INSTANTIATE_TEST_SUITE_P(smoke_CompareWithRefs_new_axis_3D_linear_order, StridedSliceLayerGPUTest,+ ::testing::Combine(+ ::testing::ValuesIn(inputShapesDynamic3D_new_axis_linear),+ ::testing::ValuesIn(params3D_new_axis_linear),+ ::testing::ValuesIn(model_types),+ ::testing::Values(rest_input_types[0])),+ StridedSliceLayerGPUTest::getTestCaseName);