Skip to content

[GPU] Bugfix in resample_pil_ref#36549

Merged
isanghao merged 4 commits into
openvinotoolkit:masterfrom
byungilm:bugfix_resample_pil_ref
Jul 7, 2026
Merged

[GPU] Bugfix in resample_pil_ref#36549
isanghao merged 4 commits into
openvinotoolkit:masterfrom
byungilm:bugfix_resample_pil_ref

Conversation

@byungilm

@byungilm byungilm commented Jun 24, 2026

Copy link
Copy Markdown
Contributor
  • Bugfix for phase-2 of GPU offloading of image pre-processing
  • Resolved execution failure in resample_pil_ref

Description

Optimization of GPU offloading of image pre-processing caused execution failure. It is caused by assertion in resample kernel selection.

Detail

Pillow's CPU resample copies the input straight to the output when neither axis needs
resampling (input size == output size on both axes). The staged GPU pipeline derives the
number of passes from NeedHorizontalPass/NeedVerticalPass, so a true identity would emit
zero passes: the output is left unwritten and the primitive is built with zero kernels,
which crashes at execution. Force a single horizontal pass for the identity case; it runs
with scale==1 (identity) coefficients and copies the input to the output.

Tickets:

AI Assistance:

  • *AI assistance used: yes
  • *If yes, summarize how AI was used and what human validation was performed (build/tests/manual checks). Generated and test unit-tests

@github-actions github-actions Bot added the category: GPU OpenVINO GPU plugin label Jun 24, 2026
byungilm added 2 commits June 26, 2026 16:45
Signed-off-by: Min, Byungil <byungil.min@intel.com>
Signed-off-by: Min, Byungil <byungil.min@intel.com>
@byungilm byungilm force-pushed the bugfix_resample_pil_ref branch from 9368fec to d1d6884 Compare June 26, 2026 08:13
@byungilm byungilm marked this pull request as ready for review June 26, 2026 08:14
@byungilm byungilm requested review from a team as code owners June 26, 2026 08:14
@p-durandin p-durandin added this to the 2026.3 milestone Jun 26, 2026
@isanghao isanghao requested a review from Copilot June 26, 2026 08:55

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

Note

Copilot couldn't run its full agentic review because no GitHub Actions runner was available. Make sure your repository has a runner available to run Copilot's review, or add a copilot-setup-steps.yml file specifying one with the runs-on attribute. See the docs for more details.

Fixes a crash in the GPU “Pillow reference” resample path for identity resampling (input spatial size equals output spatial size), and adds a regression test to ensure the identity case executes and produces correct output.

Changes:

  • Force at least one resample pass (horizontal) when the operation is an identity resample to avoid constructing a primitive with zero kernels.
  • Add a unit test covering the identity case for BILINEAR_PILLOW and BICUBIC_PILLOW modes.

Reviewed changes

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

File Description
src/plugins/intel_gpu/src/kernel_selector/kernels/resample/resample_kernel_pil_ref.cpp Introduces identity detection and forces a horizontal pass to prevent zero-kernel execution crashes.
src/plugins/intel_gpu/tests/unit/test_cases/resample_gpu_test.cpp Adds a regression test validating identity resample doesn’t crash and preserves values for Pillow modes.

Comment thread src/plugins/intel_gpu/tests/unit/test_cases/resample_gpu_test.cpp
Comment thread src/plugins/intel_gpu/tests/unit/test_cases/resample_gpu_test.cpp Outdated
byungilm added 2 commits July 3, 2026 19:39
Signed-off-by: Min, Byungil <byungil.min@intel.com>
return ExtractDim(params.outputs[0], params.axes[eVertical]).v;
}

bool IsIdentityResample(const resample_params& params) {

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.

Not sure but this fix is acceptable as a short-term crash hotfix, but the correct long-term direction is to opt-out this kernel entirely for the identity case rather than forcing an unnecessary GPU kernel enqueue. Isn't it it?

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.

Agree with Hyunback. Maybe you can just skip the execution of the node. Dynamic quantization has similar bypass logic. It is implemented around should_skip_execution

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

You are right. I think there will be next optimization pr for precision of code_predictor sub-model. I will apply the opt-out scenario.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Currently, a target resample kernel is fused normalization case.
Following clamp+ subtract + multiply layers are fused to the resample_pil_ref kernel.
This case is generated by image pre-processing.
raw_frame(u8 NHWC) → Convert(f32) → Transpose(NCHW) → Interpolate BICUBIC_PILLOW(f32→f32, pads=0) → Clamp(0,255) → Subtract(mean) → Multiply(scale)

@hyunback hyunback 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.

LGTM

@isanghao isanghao 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.

lgtm

@isanghao isanghao added this pull request to the merge queue Jul 7, 2026
Merged via the queue into openvinotoolkit:master with commit f256a96 Jul 7, 2026
192 checks passed
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.

6 participants