From 67ea06f39b33b5d1b7bb7760ed9304fa825a10e1 Mon Sep 17 00:00:00 2001 From: Chen Peter Date: Mon, 15 Jun 2026 16:42:42 +0800 Subject: [PATCH 1/4] Fix OpenCL Build Failure for int16/uint16 Fused Activations Root Cause A bug in the OpenVINO Intel GPU plugin's JIT kernel generator caused it to emit invalid OpenCL code when fusing activations onto 16-bit integer primitives (e.g., i16 -> reorder -> abs). The KernelBase::GetUnitType() function, which deduces the primary datatype to use for JIT macros, iterated over a types_prioritized list that was missing Datatype::INT16 and Datatype::UINT16. Consequently, the type deduction fell back to Datatype::F32. This mismatch caused the activation generator to incorrectly emit floating-point math macros for integer kernels. For example, it generated fabs(short) instead of abs(short). The Intel OpenCL compiler rejected this with error: call to 'fabs' is ambiguous since fabs is only overloaded for float and half, resulting in a -11 CL_BUILD_PROGRAM_FAILURE exception at runtime. Changes Made src/plugins/intel_gpu/src/kernel_selector/kernel_base.cpp: Added Datatype::INT16 and Datatype::UINT16 to the types_prioritized list in GetUnitType(). Added INT16_UNIT_USED and UINT16_UNIT_USED variables to MakeBaseParamsJitConstants() to ensure proper downstream macro generation for 16-bit integers. src/plugins/intel_gpu/tests/unit/fusions/activation_fusion_test.cpp: Added TEST_F(ActivationFusingTest, reorder_activation_i16) to explicitly cover the compilation and accuracy of an i16 -> Reorder -> Abs fusion chain, guaranteeing no regressions. Signed-off-by: Chen Peter --- .../src/kernel_selector/kernel_base.cpp | 4 ++- .../unit/fusions/activation_fusion_test.cpp | 29 +++++++++++++++++++ 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/src/plugins/intel_gpu/src/kernel_selector/kernel_base.cpp b/src/plugins/intel_gpu/src/kernel_selector/kernel_base.cpp index 83ab51f0a5ab..56104b19caad 100644 --- a/src/plugins/intel_gpu/src/kernel_selector/kernel_base.cpp +++ b/src/plugins/intel_gpu/src/kernel_selector/kernel_base.cpp @@ -62,7 +62,7 @@ static bool IsTypeUsedIn(Datatype type, const base_params& params) { Datatype KernelBase::GetUnitType(const base_params& params) const { Datatype types_prioritized[] = - {Datatype::INT8, Datatype::F16, Datatype::INT32, Datatype::INT64, Datatype::UINT8, Datatype::UINT32}; + {Datatype::INT8, Datatype::F16, Datatype::INT32, Datatype::INT64, Datatype::UINT8, Datatype::UINT32, Datatype::INT16, Datatype::UINT16}; for (Datatype type : types_prioritized) if (IsTypeUsedIn(type, params)) @@ -86,6 +86,8 @@ JitConstants KernelBase::MakeBaseParamsJitConstants(const base_params& params, b MakeJitConstant("INT64_UNIT_USED", IsTypeUsedIn(Datatype::INT64, params)), MakeJitConstant("UINT8_UNIT_USED", IsTypeUsedIn(Datatype::UINT8, params)), MakeJitConstant("UINT32_UNIT_USED", IsTypeUsedIn(Datatype::UINT32, params)), + MakeJitConstant("INT16_UNIT_USED", IsTypeUsedIn(Datatype::INT16, params)), + MakeJitConstant("UINT16_UNIT_USED", IsTypeUsedIn(Datatype::UINT16, params)), }; // for activation function diff --git a/src/plugins/intel_gpu/tests/unit/fusions/activation_fusion_test.cpp b/src/plugins/intel_gpu/tests/unit/fusions/activation_fusion_test.cpp index 072a17827457..224b7565819b 100644 --- a/src/plugins/intel_gpu/tests/unit/fusions/activation_fusion_test.cpp +++ b/src/plugins/intel_gpu/tests/unit/fusions/activation_fusion_test.cpp @@ -337,3 +337,32 @@ INSTANTIATE_TEST_SUITE_P(DISABLED_fusings_gpu, activation_eltwise_activation, :: activation_test_params{ CASE_ACTIVATION_3D_F32_4, 2, 4, "activation_ref" }, // FIXME - accuracy bug activation_test_params{ CASE_ACTIVATION_3D_F32_5, 2, 4, "activation_ref" }, // FIXME - accuracy bug })); + +TEST_F(ActivationFusingTest, reorder_activation_i16) { + // This tests CVS-188408: Ensure int16 Reorder -> Abs activation compiles cleanly + // Prior to fix, this would fail with CL_BUILD_PROGRAM_FAILURE due to "fabs" macro ambiguity. + auto& engine = get_test_engine(); + ov::PartialShape input_shape = { 1, 4 }; + layout in_layout{ input_shape, data_types::f32, format::bfyx }; + + topology topology( + input_layout("input", in_layout), + reorder("reorder", input_info("input"), format::bfyx, data_types::i16), + activation("abs", input_info("reorder"), activation_func::abs), + reorder("reorder_out", input_info("abs"), format::bfyx, data_types::f32) + ); + + ExecutionConfig config = get_test_default_config(engine); + config.set_property(ov::intel_gpu::allow_new_shape_infer(true)); + config.set_property(ov::intel_gpu::optimize_data(true)); + network network(engine, topology, config); + + auto input_mem = engine.allocate_memory(in_layout); + set_values(input_mem, { -5.0f, 10.0f, -15.0f, 20.0f }); + network.set_input_data("input", input_mem); + auto outputs = network.execute(); + auto out_mem = outputs.at("reorder_out").get_memory(); + cldnn::mem_lock out_ptr(out_mem, get_test_stream()); + std::vector expected_output = { 5.0f, 10.0f, 15.0f, 20.0f }; + for (size_t i = 0; i < expected_output.size(); ++i) { EXPECT_EQ(out_ptr[i], expected_output[i]); } +} From 74a7df121b002cd56bbb17f59246ea7034c1219b Mon Sep 17 00:00:00 2001 From: Chen Peter Date: Tue, 16 Jun 2026 16:28:38 +0800 Subject: [PATCH 2/4] GPU: Fix missing INT16/UINT16 in standalone activation nodes Add i16/u16 layout formats and kernel selector datatype registration for ActivationKernelRef. This fixes the CL_BUILD_PROGRAM_FAILURE fallback for GPU architectures that do not support post-op fusion of i16 activations into preceding reorder nodes. Signed-off-by: Chen Peter --- src/plugins/intel_gpu/src/graph/impls/ocl/activation.cpp | 2 ++ .../kernels/activation/activation_kernel_ref.cpp | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/src/plugins/intel_gpu/src/graph/impls/ocl/activation.cpp b/src/plugins/intel_gpu/src/graph/impls/ocl/activation.cpp index 0f73af1e67fa..c7fbba04c675 100644 --- a/src/plugins/intel_gpu/src/graph/impls/ocl/activation.cpp +++ b/src/plugins/intel_gpu/src/graph/impls/ocl/activation.cpp @@ -89,6 +89,8 @@ attach_activation_impl::attach_activation_impl() { auto types = { data_types::f32, data_types::f16, + data_types::i16, + data_types::u16, data_types::i8, data_types::u8, data_types::i32 diff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/activation/activation_kernel_ref.cpp b/src/plugins/intel_gpu/src/kernel_selector/kernels/activation/activation_kernel_ref.cpp index 17aeee0d118f..c6c7d013fb56 100644 --- a/src/plugins/intel_gpu/src/kernel_selector/kernels/activation/activation_kernel_ref.cpp +++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/activation/activation_kernel_ref.cpp @@ -13,11 +13,15 @@ ParamsKey ActivationKernelRef::GetSupportedKey() const { k.EnableInputDataType(Datatype::INT8); k.EnableInputDataType(Datatype::UINT8); k.EnableInputDataType(Datatype::INT32); + k.EnableInputDataType(Datatype::INT16); + k.EnableInputDataType(Datatype::UINT16); k.EnableInputDataType(Datatype::F16); k.EnableInputDataType(Datatype::F32); k.EnableOutputDataType(Datatype::INT8); k.EnableOutputDataType(Datatype::INT32); k.EnableOutputDataType(Datatype::UINT8); + k.EnableOutputDataType(Datatype::INT16); + k.EnableOutputDataType(Datatype::UINT16); k.EnableOutputDataType(Datatype::F16); k.EnableOutputDataType(Datatype::F32); k.EnableDifferentTypes(); From 85abc5b14d01ddc3587ccc742af63a1f4394da13 Mon Sep 17 00:00:00 2001 From: Chen Peter Date: Wed, 24 Jun 2026 23:06:59 +0800 Subject: [PATCH 3/4] Update per review comments Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> Co-authored-by: Chen Peter --- src/plugins/intel_gpu/src/kernel_selector/kernel_base.cpp | 4 +--- .../intel_gpu/tests/unit/fusions/activation_fusion_test.cpp | 2 +- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/src/plugins/intel_gpu/src/kernel_selector/kernel_base.cpp b/src/plugins/intel_gpu/src/kernel_selector/kernel_base.cpp index 56104b19caad..2bcef5d6d247 100644 --- a/src/plugins/intel_gpu/src/kernel_selector/kernel_base.cpp +++ b/src/plugins/intel_gpu/src/kernel_selector/kernel_base.cpp @@ -62,7 +62,7 @@ static bool IsTypeUsedIn(Datatype type, const base_params& params) { Datatype KernelBase::GetUnitType(const base_params& params) const { Datatype types_prioritized[] = - {Datatype::INT8, Datatype::F16, Datatype::INT32, Datatype::INT64, Datatype::UINT8, Datatype::UINT32, Datatype::INT16, Datatype::UINT16}; + {Datatype::INT8, Datatype::INT16, Datatype::UINT16, Datatype::F16, Datatype::INT32, Datatype::INT64, Datatype::UINT8, Datatype::UINT32}; for (Datatype type : types_prioritized) if (IsTypeUsedIn(type, params)) @@ -86,8 +86,6 @@ JitConstants KernelBase::MakeBaseParamsJitConstants(const base_params& params, b MakeJitConstant("INT64_UNIT_USED", IsTypeUsedIn(Datatype::INT64, params)), MakeJitConstant("UINT8_UNIT_USED", IsTypeUsedIn(Datatype::UINT8, params)), MakeJitConstant("UINT32_UNIT_USED", IsTypeUsedIn(Datatype::UINT32, params)), - MakeJitConstant("INT16_UNIT_USED", IsTypeUsedIn(Datatype::INT16, params)), - MakeJitConstant("UINT16_UNIT_USED", IsTypeUsedIn(Datatype::UINT16, params)), }; // for activation function diff --git a/src/plugins/intel_gpu/tests/unit/fusions/activation_fusion_test.cpp b/src/plugins/intel_gpu/tests/unit/fusions/activation_fusion_test.cpp index 224b7565819b..913b4e15c02c 100644 --- a/src/plugins/intel_gpu/tests/unit/fusions/activation_fusion_test.cpp +++ b/src/plugins/intel_gpu/tests/unit/fusions/activation_fusion_test.cpp @@ -342,7 +342,7 @@ TEST_F(ActivationFusingTest, reorder_activation_i16) { // This tests CVS-188408: Ensure int16 Reorder -> Abs activation compiles cleanly // Prior to fix, this would fail with CL_BUILD_PROGRAM_FAILURE due to "fabs" macro ambiguity. auto& engine = get_test_engine(); - ov::PartialShape input_shape = { 1, 4 }; + ov::PartialShape input_shape = { 1, 4, 1, 1 }; layout in_layout{ input_shape, data_types::f32, format::bfyx }; topology topology( From 676a7fdb3e766e6f3b966a0b53ca4657a1b911a7 Mon Sep 17 00:00:00 2001 From: Chen Peter Date: Sun, 5 Jul 2026 21:08:50 +0800 Subject: [PATCH 4/4] Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> --- .../tests/unit/fusions/activation_fusion_test.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/plugins/intel_gpu/tests/unit/fusions/activation_fusion_test.cpp b/src/plugins/intel_gpu/tests/unit/fusions/activation_fusion_test.cpp index 913b4e15c02c..2b9120ee8aac 100644 --- a/src/plugins/intel_gpu/tests/unit/fusions/activation_fusion_test.cpp +++ b/src/plugins/intel_gpu/tests/unit/fusions/activation_fusion_test.cpp @@ -357,6 +357,19 @@ TEST_F(ActivationFusingTest, reorder_activation_i16) { config.set_property(ov::intel_gpu::optimize_data(true)); network network(engine, topology, config); + bool abs_fused = false; + for (const auto& pi : network.get_primitives_info()) { + for (const auto& fused_id : pi.c_fused_ids) { + if (fused_id == "abs") { + abs_fused = true; + break; + } + } + if (abs_fused) + break; + } + EXPECT_TRUE(abs_fused) << "Expected 'abs' to be fused when optimize_data(true)"; + auto input_mem = engine.allocate_memory(in_layout); set_values(input_mem, { -5.0f, 10.0f, -15.0f, 20.0f }); network.set_input_data("input", input_mem);