Skip to content

Fix rocJpeg decoder#459

Open
fiona-gladwin wants to merge 21 commits intoROCm:developfrom
fiona-gladwin:fg/rocjpeg_acc_fix
Open

Fix rocJpeg decoder#459
fiona-gladwin wants to merge 21 commits intoROCm:developfrom
fiona-gladwin:fg/rocjpeg_acc_fix

Conversation

@fiona-gladwin
Copy link
Contributor

@fiona-gladwin fiona-gladwin commented Feb 24, 2026

Motivation

Fixes the accuracy issue with Resnet50 trainings when using rocJpeg decoder.
Fixes the ROI updation for rocJpeg fused crop decoder and also modifies the resize kernel in rocJpeg decoder to resize only the images that exceed the max decoded width and height.

Technical Details

  1. Replaces fixed scaling factors with aspect-ratio preserving resize logic that properly fits images within max dimensions
  2. Optimizes batch decoding to skip resize for images that don't exceed max dimensions, decoding them directly to output
  3. Update ROI for rocJpeg fused crop decoder's output after updating with crop params.

Test Plan

All rocAL tests must pass

Test Result

Submission Checklist

Copy link
Contributor

Copilot AI left a comment

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 accuracy/ROI issues when using the rocJpeg-based decoders by improving resize behavior (aspect-ratio preserving and skipping resize for images already within limits) and ensuring the fused-crop decoder reports updated ROI dimensions after applying crop parameters.

Changes:

  • Replaced fixed scaling-factor downscaling with aspect-ratio-preserving fit-to-max logic in the rocJpeg decoder.
  • Optimized batch decode to resize only the subset of images that exceed max dimensions (others decode directly into the output tensor).
  • Updated fused-crop decoder to track and report ROI width/height after bbox/crop updates; updated resize kernel API to support subset->batch index mapping.

Reviewed changes

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

Show a summary per file
File Description
rocAL/source/decoders/image/rocjpeg_fused_crop_decoder.cpp Tracks per-image ROI after crop updates and uses it to fill actual_decoded_width/height in decode_batch().
rocAL/source/decoders/image/rocjpeg_decoder.cpp Adds aspect-ratio fit resize logic; decodes non-resized images directly to output; resizes only needed images via updated HIP kernel.
rocAL/rocAL_hip/rocal_hip_kernels.h Updates resize kernel interface to accept dst_img_idx mapping for subset resize.
rocAL/rocAL_hip/rocal_hip_kernels.cpp Updates resize kernels to write into the correct output image via dst_img_idx, and adds safe tail handling for RGB widths.
rocAL/include/decoders/image/rocjpeg_fused_crop_decoder.h Adds ROI tracking state and initializes members defensively.
rocAL/include/decoders/image/rocjpeg_decoder.h Removes scaling-factor table and adds subset index mapping buffer member.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@LakshmiKumar23 LakshmiKumar23 self-requested a review February 24, 2026 19:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants