Skip to content

Commit

Permalink
[GPU] Enabled uint8_t input for ArgMinMax ensuring TF test compliance (
Browse files Browse the repository at this point in the history
…openvinotoolkit#27971)

### 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 <[email protected]>
  • Loading branch information
arshadlab authored Dec 19, 2024
1 parent f5b85f1 commit a2b00ec
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/plugins/intel_gpu/src/graph/impls/ocl/arg_max_min.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ struct arg_max_min_impl : typed_primitive_impl_ocl<arg_max_min> {

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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
34 changes: 31 additions & 3 deletions src/plugins/intel_gpu/tests/unit/test_cases/arg_max_gpu_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
using namespace cldnn;
using namespace ::tests;


template <format::type layoutFormat, typename DataType>
struct arg_max_input_types {
static const auto format = layoutFormat;
Expand Down Expand Up @@ -56,10 +55,21 @@ using format_types = testing::Types<arg_max_input_types<format::bfyx, float>,
arg_max_input_types<format::bfyx, ov::float16>,
arg_max_input_types<format::bs_fs_yx_bsv32_fsv16, ov::float16>,
arg_max_input_types<format::bfyx, int8_t>,
arg_max_input_types<format::bs_fs_yx_bsv32_fsv16, int8_t>>;
arg_max_input_types<format::bs_fs_yx_bsv32_fsv16, int8_t>,
arg_max_input_types<format::bs_fs_yx_bsv32_fsv32, int8_t>,
arg_max_input_types<format::bfyx, uint8_t>,
arg_max_input_types<format::bs_fs_yx_bsv32_fsv16, uint8_t>,
arg_max_input_types<format::bs_fs_yx_bsv32_fsv32, uint8_t>>;

TYPED_TEST_SUITE(argmax_gpu_test, format_types);

// Helper trait to check for uint8_t input_type
template<typename T>
struct is_uint8_input : std::false_type {};

template<format::type Fmt>
struct is_uint8_input<arg_max_input_types<Fmt, uint8_t>> : 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;
Expand All @@ -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<float> 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<TypeParam>::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));

Expand Down
2 changes: 0 additions & 2 deletions tests/layer_tests/tensorflow_tests/test_tf_ArgMinMax.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 0 additions & 2 deletions tests/layer_tests/tensorflow_tests/test_tf_TopKV2.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]:
Expand Down

0 comments on commit a2b00ec

Please sign in to comment.