Skip to content

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

[GPU]: Bitwise shifts: Added support for uint16 and int16 data type (#26251)

Piotr Kowalczyke9eac15d73e3
diff --git a/src/plugins/intel_gpu/src/graph/impls/ocl/eltwise.cpp b/src/plugins/intel_gpu/src/graph/impls/ocl/eltwise.cpp
index 0e85aa7e294..c3772d922e3 100644
--- a/src/plugins/intel_gpu/src/graph/impls/ocl/eltwise.cpp
+++ b/src/plugins/intel_gpu/src/graph/impls/ocl/eltwise.cpp
@@ -170,6 +170,8 @@ attach_eltwise_impl::attach_eltwise_impl() {
data_types::f16,
data_types::i8,
data_types::u8,
+ data_types::i16,
+ data_types::u16,
data_types::i32,
data_types::u32,
data_types::i64
@@ -194,6 +196,8 @@ attach_eltwise_impl::attach_eltwise_impl() {
std::make_tuple(data_types::f16, format::yxfb),
std::make_tuple(data_types::i8, format::yxfb),
std::make_tuple(data_types::u8, format::yxfb),
+ std::make_tuple(data_types::i16, format::yxfb),
+ std::make_tuple(data_types::u16, format::yxfb),
std::make_tuple(data_types::u32, format::yxfb),
std::make_tuple(data_types::i32, format::yxfb),
std::make_tuple(data_types::i64, format::yxfb),
@@ -201,8 +205,10 @@ attach_eltwise_impl::attach_eltwise_impl() {
std::make_tuple(data_types::f32, format::bfyx),
std::make_tuple(data_types::f16, format::bfyx),
std::make_tuple(data_types::u8, format::bfyx),
- std::make_tuple(data_types::u32, format::bfyx),
std::make_tuple(data_types::i8, format::bfyx),
+ std::make_tuple(data_types::u16, format::bfyx),
+ std::make_tuple(data_types::i16, format::bfyx),
+ std::make_tuple(data_types::u32, format::bfyx),
std::make_tuple(data_types::i32, format::bfyx),
std::make_tuple(data_types::i64, format::bfyx),
@@ -210,6 +216,8 @@ attach_eltwise_impl::attach_eltwise_impl() {
std::make_tuple(data_types::f16, format::byxf),
std::make_tuple(data_types::i8, format::byxf),
std::make_tuple(data_types::u8, format::byxf),
+ std::make_tuple(data_types::i16, format::byxf),
+ std::make_tuple(data_types::u16, format::byxf),
std::make_tuple(data_types::u32, format::byxf),
std::make_tuple(data_types::i32, format::byxf),
std::make_tuple(data_types::i64, format::byxf),
@@ -223,6 +231,8 @@ attach_eltwise_impl::attach_eltwise_impl() {
std::make_tuple(data_types::f16, format::bfzyx),
std::make_tuple(data_types::i8, format::bfzyx),
std::make_tuple(data_types::u8, format::bfzyx),
+ std::make_tuple(data_types::i16, format::bfzyx),
+ std::make_tuple(data_types::u16, format::bfzyx),
std::make_tuple(data_types::u32, format::bfzyx),
std::make_tuple(data_types::i32, format::bfzyx),
std::make_tuple(data_types::i64, format::bfzyx),
@@ -231,6 +241,8 @@ attach_eltwise_impl::attach_eltwise_impl() {
std::make_tuple(data_types::f16, format::bfwzyx),
std::make_tuple(data_types::i8, format::bfwzyx),
std::make_tuple(data_types::u8, format::bfwzyx),
+ std::make_tuple(data_types::i16, format::bfwzyx),
+ std::make_tuple(data_types::u16, format::bfwzyx),
std::make_tuple(data_types::u32, format::bfwzyx),
std::make_tuple(data_types::i32, format::bfwzyx),
std::make_tuple(data_types::i64, format::bfwzyx),
@@ -239,6 +251,8 @@ attach_eltwise_impl::attach_eltwise_impl() {
std::make_tuple(data_types::f16, format::bfuwzyx),
std::make_tuple(data_types::i8, format::bfuwzyx),
std::make_tuple(data_types::u8, format::bfuwzyx),
+ std::make_tuple(data_types::i16, format::bfuwzyx),
+ std::make_tuple(data_types::u16, format::bfuwzyx),
std::make_tuple(data_types::u32, format::bfuwzyx),
std::make_tuple(data_types::i32, format::bfuwzyx),
std::make_tuple(data_types::i64, format::bfuwzyx),
@@ -247,6 +261,8 @@ attach_eltwise_impl::attach_eltwise_impl() {
std::make_tuple(data_types::f16, format::bfvuwzyx),
std::make_tuple(data_types::i8, format::bfvuwzyx),
std::make_tuple(data_types::u8, format::bfvuwzyx),
+ std::make_tuple(data_types::i16, format::bfvuwzyx),
+ std::make_tuple(data_types::u16, format::bfvuwzyx),
std::make_tuple(data_types::u32, format::bfvuwzyx),
std::make_tuple(data_types::i32, format::bfvuwzyx),
std::make_tuple(data_types::i64, format::bfvuwzyx),
diff --git a/src/plugins/intel_gpu/src/graph/impls/ocl/kernel_selector_helper.cpp b/src/plugins/intel_gpu/src/graph/impls/ocl/kernel_selector_helper.cpp
index 1e6d06755a7..6915da8b754 100644
--- a/src/plugins/intel_gpu/src/graph/impls/ocl/kernel_selector_helper.cpp
+++ b/src/plugins/intel_gpu/src/graph/impls/ocl/kernel_selector_helper.cpp
@@ -171,6 +171,10 @@ kernel_selector::data_type to_data_type(data_types dt) {
return kernel_selector::data_type::INT8;
case cldnn::data_types::u8:
return kernel_selector::data_type::UINT8;
+ case cldnn::data_types::i16:
+ return kernel_selector::data_type::INT16;
+ case cldnn::data_types::u16:
+ return kernel_selector::data_type::UINT16;
case cldnn::data_types::i32:
return kernel_selector::data_type::INT32;
case cldnn::data_types::u32:
@@ -198,6 +202,10 @@ data_types from_data_type(kernel_selector::data_type dt) {
return cldnn::data_types::i8;
case kernel_selector::data_type::UINT8:
return cldnn::data_types::u8;
+ case kernel_selector::data_type::INT16:
+ return cldnn::data_types::i16;
+ case kernel_selector::data_type::UINT16:
+ return cldnn::data_types::u16;
case kernel_selector::data_type::INT32:
return cldnn::data_types::i32;
case kernel_selector::data_type::UINT32:
diff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/eltwise/eltwise_kernel_base.cpp b/src/plugins/intel_gpu/src/kernel_selector/kernels/eltwise/eltwise_kernel_base.cpp
index da46e89002e..ef46ede8a9f 100644
--- a/src/plugins/intel_gpu/src/kernel_selector/kernels/eltwise/eltwise_kernel_base.cpp
+++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/eltwise/eltwise_kernel_base.cpp
@@ -80,6 +80,14 @@ ParamsKey eltwise_params::GetParamsKey() const {
}
Datatype EltwiseKernelBase::GetAccumulatorType(const eltwise_params &params) const {
+ // NOTE: Workaround for not promoting shift operations. Not sure what should happen
+ // if shift op is just one operation of other elementwise operations. My guess is that is should be promoted as
+ // well, but in reality more robust solution will be needed or (better) - assumption that types are not promoted. So
+ // probably this is a temporary solution.
+ if (params.operations[0].mode == EltwiseMode::RIGHT_SHIFT || params.operations[0].mode == EltwiseMode::LEFT_SHIFT) {
+ return params.inputs[0].GetDType();
+ }
+
if (params.int8_quantization)
return Datatype::INT32;
diff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/eltwise/eltwise_kernel_ref.cpp b/src/plugins/intel_gpu/src/kernel_selector/kernels/eltwise/eltwise_kernel_ref.cpp
index 71f72d68089..53873a41312 100644
--- a/src/plugins/intel_gpu/src/kernel_selector/kernels/eltwise/eltwise_kernel_ref.cpp
+++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/eltwise/eltwise_kernel_ref.cpp
@@ -13,6 +13,8 @@ ParamsKey EltwiseKernelRef::GetSupportedKey() const {
k.EnableInputDataType(Datatype::F32);
k.EnableInputDataType(Datatype::INT8);
k.EnableInputDataType(Datatype::UINT8);
+ k.EnableInputDataType(Datatype::INT16);
+ k.EnableInputDataType(Datatype::UINT16);
k.EnableInputDataType(Datatype::INT32);
k.EnableInputDataType(Datatype::UINT32);
k.EnableInputDataType(Datatype::INT64);
@@ -20,6 +22,8 @@ ParamsKey EltwiseKernelRef::GetSupportedKey() const {
k.EnableOutputDataType(Datatype::F32);
k.EnableOutputDataType(Datatype::INT8);
k.EnableOutputDataType(Datatype::UINT8);
+ k.EnableOutputDataType(Datatype::INT16);
+ k.EnableOutputDataType(Datatype::UINT16);
k.EnableOutputDataType(Datatype::INT32);
k.EnableOutputDataType(Datatype::UINT32);
k.EnableOutputDataType(Datatype::INT64);
diff --git a/src/plugins/intel_gpu/tests/functional/shared_tests_instances/single_layer_tests/eltwise.cpp b/src/plugins/intel_gpu/tests/functional/shared_tests_instances/single_layer_tests/eltwise.cpp
index c5447983ba9..3109daecb43 100644
--- a/src/plugins/intel_gpu/tests/functional/shared_tests_instances/single_layer_tests/eltwise.cpp
+++ b/src/plugins/intel_gpu/tests/functional/shared_tests_instances/single_layer_tests/eltwise.cpp
@@ -71,7 +71,8 @@ std::vector<EltwiseTypes> smoke_intOnly_eltwiseOpTypes = {
};
std::vector<ov::test::ElementType> intOnly_netPrecisions = {
- ov::element::i32
+ ov::element::i32,
+ ov::element::u16
};
ov::AnyMap additional_config = {};
diff --git a/src/plugins/intel_gpu/tests/unit/test_cases/eltwise_gpu_test.cpp b/src/plugins/intel_gpu/tests/unit/test_cases/eltwise_gpu_test.cpp
index 1ae82b70ff1..118691bb29c 100644
--- a/src/plugins/intel_gpu/tests/unit/test_cases/eltwise_gpu_test.cpp
+++ b/src/plugins/intel_gpu/tests/unit/test_cases/eltwise_gpu_test.cpp
@@ -347,6 +347,8 @@ void run_eltwise_int_shift_generic_test(cldnn::eltwise_mode mode) {
ELTWISE_INT_TEST_CASES(int8_t);
ELTWISE_INT_TEST_CASES(uint8_t);
+ ELTWISE_INT_TEST_CASES(int16_t);
+ ELTWISE_INT_TEST_CASES(uint16_t);
ELTWISE_INT_TEST_CASES(int32_t);
ELTWISE_INT_TEST_CASES(uint32_t);
ELTWISE_INT_TEST_CASES(int64_t);