Skip to content

Fix OpenCL Build Failure for int16/uint16 Fused Activations#36407

Open
peterchen-intel wants to merge 8 commits into
openvinotoolkit:masterfrom
peterchen-intel:CVS-188408/fixing
Open

Fix OpenCL Build Failure for int16/uint16 Fused Activations#36407
peterchen-intel wants to merge 8 commits into
openvinotoolkit:masterfrom
peterchen-intel:CVS-188408/fixing

Conversation

@peterchen-intel

@peterchen-intel peterchen-intel commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

Details:

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.

Tickets:

AI Assistance:

  • AI assistance used: yes
  • If yes, summarize how AI was used and what human validation was performed (build/tests/manual checks). AI does all the build/tests/verification

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 <peter.chen@intel.com>
@peterchen-intel peterchen-intel requested review from a team as code owners June 15, 2026 08:45
@github-actions github-actions Bot added the category: GPU OpenVINO GPU plugin label Jun 15, 2026
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 <peter.chen@intel.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR addresses an OpenCL JIT compilation failure in the Intel GPU plugin when fusing activations onto 16-bit integer primitives (e.g., reorder -> abs), by extending datatype handling so integer-specific activation codegen is selected instead of floating-point (fabs) paths.

Changes:

  • Extend kernel-selector datatype support to include INT16/UINT16 in unit-type deduction and activation kernel capability keys.
  • Broaden OpenCL activation implementation type filtering to allow i16/u16.
  • Add a unit test covering an i16 reorder + Abs fusion path to prevent regressions.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

File Description
src/plugins/intel_gpu/src/kernel_selector/kernel_base.cpp Adds INT16/UINT16 to unit-type selection and emits new JIT constants.
src/plugins/intel_gpu/src/kernel_selector/kernels/activation/activation_kernel_ref.cpp Enables INT16/UINT16 input/output in the reference activation kernel supported key.
src/plugins/intel_gpu/src/graph/impls/ocl/activation.cpp Allows i16/u16 types for selecting the OCL activation implementation.
src/plugins/intel_gpu/tests/unit/fusions/activation_fusion_test.cpp Adds a regression test for reorder(i16) -> abs -> reorder(f32) execution.

Comment thread src/plugins/intel_gpu/src/kernel_selector/kernel_base.cpp Outdated
Comment thread src/plugins/intel_gpu/src/kernel_selector/kernel_base.cpp Outdated
Comment thread src/plugins/intel_gpu/tests/unit/fusions/activation_fusion_test.cpp Outdated
Comment thread src/plugins/intel_gpu/src/kernel_selector/kernel_base.cpp Outdated
peterchen-intel and others added 2 commits June 24, 2026 23:06
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Chen Peter <peter.chen@intel.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

Comment thread src/plugins/intel_gpu/tests/unit/fusions/activation_fusion_test.cpp
Comment thread src/plugins/intel_gpu/src/kernel_selector/kernel_base.cpp

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

Comment thread src/plugins/intel_gpu/tests/unit/fusions/activation_fusion_test.cpp
Comment thread src/plugins/intel_gpu/src/kernel_selector/kernel_base.cpp
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

Comments suppressed due to low confidence (1)

src/plugins/intel_gpu/src/kernel_selector/kernel_base.cpp:69

  • The PR description mentions adding INT16_UNIT_USED / UINT16_UNIT_USED JIT variables in MakeBaseParamsJitConstants(), but the current code only defines INT8/INT32/INT64/UINT8/UINT32 unit-used flags. Since GetUnitType() now explicitly prioritizes INT16/UINT16, it’s reasonable to also expose corresponding *_UNIT_USED constants (or update the PR description if they’re intentionally omitted).
        {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))
            return type;

Comment on lines +360 to +371
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)";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

category: GPU OpenVINO GPU plugin

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants