From a12a82d00b35d63166613373833c4aaf29947161 Mon Sep 17 00:00:00 2001 From: Arshad Mehmood Date: Mon, 9 Dec 2024 07:58:02 +0800 Subject: [PATCH] [GPU] Enabled uint8_t input for ArgMinMax ensuring TF test compliance Details: This update introduces support for the uint8_t data type in the argminmax implementation on the cldnn path, which was previously lacking. Specifically, for the TopKV2 test case, the OpenVino IR optimization reduced the model to an argminmax primitive that did not support uint8_t inputs, causing failures. With the new uint8_t support for argminmax and the addition of a kernel, the test now passes. An OpenVino unit test has been added to verify uint8_t data type handling, with test inputs consisting of non-negative values. Tickets: - CVS-153078 - CVS-156587 Signed-off-by: Arshad Mehmood --- .../src/graph/impls/ocl/arg_max_min.cpp | 2 +- .../arg_max_min/arg_max_min_kernel_axis.cpp | 1 + .../arg_max_min_kernel_gpu_ref.cpp | 1 + .../arg_max_min/arg_max_min_kernel_opt.cpp | 1 + .../unit/test_cases/arg_max_gpu_test.cpp | 34 +++++++++++++++++-- .../tensorflow_tests/test_tf_ArgMinMax.py | 2 -- .../tensorflow_tests/test_tf_TopKV2.py | 2 -- 7 files changed, 35 insertions(+), 8 deletions(-) diff --git a/src/plugins/intel_gpu/src/graph/impls/ocl/arg_max_min.cpp b/src/plugins/intel_gpu/src/graph/impls/ocl/arg_max_min.cpp index dd1e8d256860d7..496d38d9b44210 100644 --- a/src/plugins/intel_gpu/src/graph/impls/ocl/arg_max_min.cpp +++ b/src/plugins/intel_gpu/src/graph/impls/ocl/arg_max_min.cpp @@ -131,7 +131,7 @@ struct arg_max_min_impl : typed_primitive_impl_ocl { namespace detail { attach_arg_max_min_impl::attach_arg_max_min_impl() { - auto types = {data_types::f16, data_types::f32, data_types::i8, data_types::i32}; + auto types = {data_types::f16, data_types::f32, data_types::i8, data_types::i32, data_types::u8}; auto formats = { format::bfyx, diff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/arg_max_min/arg_max_min_kernel_axis.cpp b/src/plugins/intel_gpu/src/kernel_selector/kernels/arg_max_min/arg_max_min_kernel_axis.cpp index ecb6be6f17020d..4cedb9a3c7b6c7 100644 --- a/src/plugins/intel_gpu/src/kernel_selector/kernels/arg_max_min/arg_max_min_kernel_axis.cpp +++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/arg_max_min/arg_max_min_kernel_axis.cpp @@ -52,6 +52,7 @@ ParamsKey ArgMaxMinKernelAxis::GetSupportedKey() const { k.EnableInputDataType(Datatype::F16); k.EnableInputDataType(Datatype::F32); k.EnableInputDataType(Datatype::INT8); + k.EnableInputDataType(Datatype::UINT8); k.EnableInputDataType(Datatype::INT32); k.EnableAllOutputDataType(); k.EnableInputLayout(DataLayout::bfyx); diff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/arg_max_min/arg_max_min_kernel_gpu_ref.cpp b/src/plugins/intel_gpu/src/kernel_selector/kernels/arg_max_min/arg_max_min_kernel_gpu_ref.cpp index 991edfcf093383..26b45f220968b2 100644 --- a/src/plugins/intel_gpu/src/kernel_selector/kernels/arg_max_min/arg_max_min_kernel_gpu_ref.cpp +++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/arg_max_min/arg_max_min_kernel_gpu_ref.cpp @@ -10,6 +10,7 @@ ParamsKey ArgMaxMinKernelGPURef::GetSupportedKey() const { k.EnableInputDataType(Datatype::F16); k.EnableInputDataType(Datatype::F32); k.EnableInputDataType(Datatype::INT8); + k.EnableInputDataType(Datatype::UINT8); k.EnableAllOutputDataType(); k.EnableInputLayout(DataLayout::bfyx); k.EnableInputLayout(DataLayout::yxfb); diff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/arg_max_min/arg_max_min_kernel_opt.cpp b/src/plugins/intel_gpu/src/kernel_selector/kernels/arg_max_min/arg_max_min_kernel_opt.cpp index 5f31efdd089b7c..5216a9f53de7e8 100644 --- a/src/plugins/intel_gpu/src/kernel_selector/kernels/arg_max_min/arg_max_min_kernel_opt.cpp +++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/arg_max_min/arg_max_min_kernel_opt.cpp @@ -10,6 +10,7 @@ ParamsKey ArgMaxMinKernelOpt::GetSupportedKey() const { k.EnableInputDataType(Datatype::F16); k.EnableInputDataType(Datatype::F32); k.EnableInputDataType(Datatype::INT8); + k.EnableInputDataType(Datatype::UINT8); k.EnableOutputDataType(Datatype::F32); k.EnableInputLayout(DataLayout::bfyx); k.EnableOutputLayout(DataLayout::bfyx); diff --git a/src/plugins/intel_gpu/tests/unit/test_cases/arg_max_gpu_test.cpp b/src/plugins/intel_gpu/tests/unit/test_cases/arg_max_gpu_test.cpp index eb532b2357f1da..ea65a864020e73 100644 --- a/src/plugins/intel_gpu/tests/unit/test_cases/arg_max_gpu_test.cpp +++ b/src/plugins/intel_gpu/tests/unit/test_cases/arg_max_gpu_test.cpp @@ -16,7 +16,6 @@ using namespace cldnn; using namespace ::tests; - template struct arg_max_input_types { static const auto format = layoutFormat; @@ -56,10 +55,21 @@ using format_types = testing::Types, arg_max_input_types, arg_max_input_types, arg_max_input_types, - arg_max_input_types>; + arg_max_input_types, + arg_max_input_types, + arg_max_input_types, + arg_max_input_types, + arg_max_input_types>; TYPED_TEST_SUITE(argmax_gpu_test, format_types); +// Helper trait to check for uint8_t input_type +template +struct is_uint8_input : std::false_type {}; + +template +struct is_uint8_input> : std::true_type {}; + TYPED_TEST(argmax_gpu_test, base) { // Input : 2x4x2x2 static const int32_t x_size = 2, y_size = 2, feature_num = 4, batch_num = 2; @@ -82,7 +92,25 @@ TYPED_TEST(argmax_gpu_test, base) { /*b1f1*/ 4.f, 0.5f, 8.f, 8.2f, /*b1f2*/ 0.2f, 0.2f, -10.f, 5.2f, /*b1f3*/ 4.f, 0.5f, 8.f, 8.2f}; - set_values(input, this->getTypedVector(input_vec)); + + // Positive values for u8 input type test + std::vector input_vec_u8 = {// y0x0 y0x1 y1x0 y1x1 + /*b0f0*/ 0.1f, 0.1f, 0.9f, 1.5f, + /*b0f1*/ 0.2f, 0.2f, 0.1f, 5.2f, + /*b0f2*/ 0.2f, 0.2f, 0.1f, 5.2f, + /*b0f3*/ 0.2f, 0.2f, 0.1f, 4.2f, + + /*b1f0*/ 3.f, 0.5f, 7.f, 10.f, + /*b1f1*/ 4.f, 0.5f, 8.f, 8.2f, + /*b1f2*/ 0.2f, 0.2f, 0.1f, 5.2f, + /*b1f3*/ 4.f, 0.5f, 8.f, 8.2f}; + + // If format is of type u8 then use non negative values as input. + if (is_uint8_input::value) { + set_values(input, this->getTypedVector(input_vec_u8)); + } else { + set_values(input, this->getTypedVector(input_vec)); + } network network(engine, topology, get_test_default_config(engine)); diff --git a/tests/layer_tests/tensorflow_tests/test_tf_ArgMinMax.py b/tests/layer_tests/tensorflow_tests/test_tf_ArgMinMax.py index 785ef72a60f3a1..5ea8b8e65086a3 100644 --- a/tests/layer_tests/tensorflow_tests/test_tf_ArgMinMax.py +++ b/tests/layer_tests/tensorflow_tests/test_tf_ArgMinMax.py @@ -69,8 +69,6 @@ def test_argmin_max_net(self, input_shape, dimension, input_type, output_type, o ie_device, precision, ir_version, temp_dir, use_legacy_frontend): if platform.machine() in ['aarch64', 'arm64', 'ARM64']: pytest.skip('153077: Segmentation fault on ARM') - if ie_device == 'GPU' and input_type == np.uint8: - pytest.skip('153078: No layout format available for topk') if ie_device == 'GPU' and input_type == np.float32 and input_shape == [10, 15, 20]: pytest.skip('153079: Accuracy error on GPU') self._test(*self.create_argmin_max_net(input_shape=input_shape, dimension=dimension, diff --git a/tests/layer_tests/tensorflow_tests/test_tf_TopKV2.py b/tests/layer_tests/tensorflow_tests/test_tf_TopKV2.py index 23d5c6bf2c23fe..65efbe7c6b8bd2 100644 --- a/tests/layer_tests/tensorflow_tests/test_tf_TopKV2.py +++ b/tests/layer_tests/tensorflow_tests/test_tf_TopKV2.py @@ -55,8 +55,6 @@ def create_topk_v2_net(self, input_shape, input_type, k, k_type, sorted, index_t def test_topk_v2(self, input_shape, input_type, k, k_type, sorted, index_type, ie_device, precision, ir_version, temp_dir, use_legacy_frontend): - if ie_device == 'GPU' and input_type == np.uint8: - pytest.skip('156587: Check correct_layout_selected failed for input uint8 on GPU') if platform.machine() in ['arm', 'armv7l', 'aarch64', 'arm64', 'ARM64'] and \ input_type in [np.int32, np.uint8, np.int16, np.int8, np.int64, np.uint16, np.uint32, np.uint64]: