From e7d94ba02018a9973bba7012c32267cba97cd9f1 Mon Sep 17 00:00:00 2001 From: Eddy Kim Date: Wed, 10 May 2023 15:56:43 +0900 Subject: [PATCH] [GPU] fix adaptive pooling kernel (#17429) * fixed not to use ceil * added an unit test --- .../cl_kernels/adaptive_pooling_gpu_ref.cl | 9 ++++++--- .../unit/test_cases/adaptive_avg_pooling_gpu_test.cpp | 2 +- .../unit/test_cases/adaptive_max_pooling_gpu_test.cpp | 2 +- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/plugins/intel_gpu/src/kernel_selector/cl_kernels/adaptive_pooling_gpu_ref.cl b/src/plugins/intel_gpu/src/kernel_selector/cl_kernels/adaptive_pooling_gpu_ref.cl index 85b44df0cf7..f3eaa90f6e5 100644 --- a/src/plugins/intel_gpu/src/kernel_selector/cl_kernels/adaptive_pooling_gpu_ref.cl +++ b/src/plugins/intel_gpu/src/kernel_selector/cl_kernels/adaptive_pooling_gpu_ref.cl @@ -45,12 +45,15 @@ KERNEL(adaptive_pooling_gpu)( #if OUTPUT_DIMS == 5 uint z_start = z * INPUT0_SIZE_Z / OUTPUT_SIZE_Z; - uint z_end = ceil((float)((z + 1) * INPUT0_SIZE_Z) / OUTPUT_SIZE_Z); + uint z_end = ((z + 1) * INPUT0_SIZE_Z) / OUTPUT_SIZE_Z; + z_end += (((z + 1) * INPUT0_SIZE_Z) - OUTPUT_SIZE_Z * z_end != 0) ? 1 : 0; #endif uint y_start = y * INPUT0_SIZE_Y / OUTPUT_SIZE_Y; - uint y_end = ceil((float)((y + 1) * INPUT0_SIZE_Y) / OUTPUT_SIZE_Y); + uint y_end = ((y + 1) * INPUT0_SIZE_Y) / OUTPUT_SIZE_Y; + y_end += (((y + 1) * INPUT0_SIZE_Y) - OUTPUT_SIZE_Y * y_end != 0) ? 1 : 0; uint x_start = x * INPUT0_SIZE_X / OUTPUT_SIZE_X; - uint x_end = ceil((float)((x + 1) * INPUT0_SIZE_X) / OUTPUT_SIZE_X); + uint x_end = ((x + 1) * INPUT0_SIZE_X) / OUTPUT_SIZE_X; + x_end += (((x + 1) * INPUT0_SIZE_X) - OUTPUT_SIZE_X * x_end != 0) ? 1 : 0; #if OUTPUT_DIMS == 5 diff --git a/src/plugins/intel_gpu/tests/unit/test_cases/adaptive_avg_pooling_gpu_test.cpp b/src/plugins/intel_gpu/tests/unit/test_cases/adaptive_avg_pooling_gpu_test.cpp index 094b7d5e0f7..11f7c601aa7 100644 --- a/src/plugins/intel_gpu/tests/unit/test_cases/adaptive_avg_pooling_gpu_test.cpp +++ b/src/plugins/intel_gpu/tests/unit/test_cases/adaptive_avg_pooling_gpu_test.cpp @@ -171,7 +171,7 @@ INSTANTIATE_TEST_SUITE_P(smoke_adaptive_avg_pooling_test_f32_2d, ::testing::ValuesIn(std::vector{ { tensor(1, 2, 7, 3), tensor(1, 2, 3, 3) }, { tensor(2, 3, 7, 3), tensor(2, 3, 3, 3) }, - { tensor(1, 3, 16, 16), tensor(1, 3, 16, 16) }, + { tensor(1, 3, 7, 7), tensor(1, 3, 7, 7) }, }), ::testing::Values(format::bfyx), ::testing::Values(format::bfyx), diff --git a/src/plugins/intel_gpu/tests/unit/test_cases/adaptive_max_pooling_gpu_test.cpp b/src/plugins/intel_gpu/tests/unit/test_cases/adaptive_max_pooling_gpu_test.cpp index faa9520af55..b1cb0e7329f 100644 --- a/src/plugins/intel_gpu/tests/unit/test_cases/adaptive_max_pooling_gpu_test.cpp +++ b/src/plugins/intel_gpu/tests/unit/test_cases/adaptive_max_pooling_gpu_test.cpp @@ -69,7 +69,7 @@ ov::Shape tensorToShape(const tensor& t, const format f) template void generateTestData(const AdaptiveMaxPoolingParams& p, const format fmt, std::vector& inputs, std::vector& outputs, std::vector& indices) { - const auto in = generate_random_1d(p.inputTensor.count(), -127, 127, 1); + const auto in = generate_random_1d(p.inputTensor.count(), -127, 127, 8); std::vector out(p.outputTensor.count()); std::vector ind(p.outputTensor.count());