Fix OpenCL Build Failure for int16/uint16 Fused Activations#36407
Open
peterchen-intel wants to merge 8 commits into
Open
Fix OpenCL Build Failure for int16/uint16 Fused Activations#36407peterchen-intel wants to merge 8 commits into
peterchen-intel wants to merge 8 commits into
Conversation
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>
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>
Contributor
There was a problem hiding this comment.
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/UINT16in unit-type deduction and activation kernel capability keys. - Broaden OpenCL activation implementation type filtering to allow i16/u16.
- Add a unit test covering an
i16reorder +Absfusion 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. |
peterchen-intel
commented
Jun 24, 2026
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> Co-authored-by: Chen Peter <peter.chen@intel.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
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_USEDJIT variables inMakeBaseParamsJitConstants(), but the current code only defines INT8/INT32/INT64/UINT8/UINT32 unit-used flags. SinceGetUnitType()now explicitly prioritizes INT16/UINT16, it’s reasonable to also expose corresponding*_UNIT_USEDconstants (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)"; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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: