Skip to content

RPP JPEG Compression Distortion HOST#531

Merged
kiritigowda merged 46 commits intoROCm:developfrom
r-abishek:ar/opt_jpeg_distortion_host
May 30, 2025
Merged

RPP JPEG Compression Distortion HOST#531
kiritigowda merged 46 commits intoROCm:developfrom
r-abishek:ar/opt_jpeg_distortion_host

Conversation

@r-abishek
Copy link
Copy Markdown
Member

  • Adds JPEG Compression Distortion augmentation for HOST on U8/F32/F16/I8.
  • Adds relevant unit/perf/QA tests.

@kiritigowda kiritigowda self-assigned this Mar 26, 2025
@kiritigowda kiritigowda requested a review from Copilot April 1, 2025 04:18
@kiritigowda kiritigowda requested review from Copilot and rrawther April 19, 2025 17:45
Copy link
Copy Markdown
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 introduces a new JPEG Compression Distortion augmentation for the HOST backend, including support for U8, F32, F16, and I8 data types, along with corresponding unit, performance, and QA tests.

  • Added new augmentation mappings and enum entries across header and source files.
  • Implemented the jpeg_compression_distortion functions for various data types in tensor geometric augmentation modules.
  • Updated test suites and API documentation to integrate and validate the new augmentation.

Reviewed Changes

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

Show a summary per file
File Description
utilities/test_suite/rpp_test_suite_image.h Added mapping entry and enum for JPEG Compression Distortion.
utilities/test_suite/common.py Updated augmentation map with the new JPEG compression case.
utilities/test_suite/HOST/runImageTests.py Adjusted the test range to include the new augmentation.
utilities/test_suite/HOST/Tensor_image_host.cpp Introduced a new test case branch for JPEG Compression Distortion.
src/modules/tensor/rppt_tensor_geometric_augmentations.cpp Added the main JPEG compression distortion function for HOST.
src/include/tensor/host_tensor_executors.hpp Declared new function prototypes for the augmentation methods.
src/include/common/cpu/rpp_cpu_simd_math.hpp Added a helper function for rounding away from zero.
src/include/common/cpu/rpp_cpu_simd_load_store.hpp Included new load/store functions handling larger packed data blocks.
api/rppt_tensor_geometric_augmentations.h Provided API documentation for the new augmentation function.
CHANGELOG.md Updated the changelog to include JPEG Compression Distortion.

Copy link
Copy Markdown
Contributor

@rrawther rrawther left a comment

Choose a reason for hiding this comment

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

I have added few comments. Let's discuss the rest over a call

HazarathKumarM and others added 2 commits April 21, 2025 19:11
RPP JPEG Compression distortion HOST - review comments resolution
@codecov
Copy link
Copy Markdown

codecov bot commented Apr 23, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop     #531      +/-   ##
===========================================
+ Coverage    54.82%   55.56%   +0.74%     
===========================================
  Files          293      294       +1     
  Lines       118516   120606    +2090     
===========================================
+ Hits         64972    67007    +2035     
- Misses       53544    53599      +55     
Files with missing lines Coverage Δ
src/include/common/cpu/rpp_cpu_simd_load_store.hpp 92.60% <100.00%> (+0.55%) ⬆️
.../tensor/cpu/kernel/jpeg_compression_distortion.cpp 95.88% <ø> (ø)
...les/tensor/rppt_tensor_geometric_augmentations.cpp 91.76% <100.00%> (+0.18%) ⬆️

... and 2 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

temp[6] = x[2] - x[5];
temp[7] = x[4] - x[3];

temp[8] = temp[0] + temp[3];
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.

please combine temp[0] and temp[3] computation here and use only T temp[4] like
temp[8] = x[0] + x[7] + x[3] + x[4];

if (row < colLimit && col < rowLimit)
{
Rpp32s idx = srcRowIdx + col * wStride;
if constexpr (std::is_same<T, Rpp32f>::value || std::is_same<T, Rpp16f>::value)
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.

I think if we have a way to combine this with the formula it is better code
mul_factor = 1.0 * mul_table(rgb_data_type) , then use it in line 354

Copy link
Copy Markdown
Contributor

@rrawther rrawther left a comment

Choose a reason for hiding this comment

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

Added few comments

r *= ONE_OVER_255;
g *= ONE_OVER_255;
b *= ONE_OVER_255;
dstPtrR[dstIdx] = static_cast<T>((r < 0.0f) ? 0.0f : (r > 1.0f) ? 1.0f : r);
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.

check if std::max std::min combo is better. Should use an inline clamp function

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.

Changed to an inline function, and computing the clamp function using conditional operators is faster than using the combination of std::min and std::max.

@kiritigowda
Copy link
Copy Markdown
Collaborator

@r-abishek - needs conflicts resolved

@r-abishek
Copy link
Copy Markdown
Member Author

@kiritigowda Resolved. Docs CI failing to pull commit.

Copy link
Copy Markdown
Contributor

@rrawther rrawther left a comment

Choose a reason for hiding this comment

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

Added few more comments

Rpp32f avgB = (b[id1] + b[id2] + b[id3] + b[id4]) / 4.0f;

// Convert to Cb/Cr and center around 0
Rpp32s chromaIdx = (row / 2) * 8 + (col / 2);
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.

please use ( >> 1) instead of /2

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.

Done

for (Rpp32s col = 0; col < 16; col += 2)
{
Rpp32s id1 = (row * 16) + col;
Rpp32s id2 = (row * 16) + col + 1;
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.

please change it to id2 = id1 + 1, also u can use in place in line#392 and get rid of id2. Same for id4

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.

Done

Rpp32s id3 = (row + 1) * 16 + col;
Rpp32s id4 = (row + 1) * 16 + col + 1;

Rpp32f avgR = (r[id1] + r[id2] + r[id3] + r[id4]) / 4.0f;
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.

change /4.0 to * 0.25

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.

changed


// Convert YCbCr to RGB
Rpp32f yVal = y[yIdx] + 128.0f;
yVal = clamp(yVal, 0.0f, 255.0f);
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.

why is this required. Please remove

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.

removed the clamp

Rpp32f r = yVal + 1.402f * currCr;
Rpp32f g = yVal - 0.344136f * currCb - 0.714136f * currCr;
Rpp32f b = yVal + 1.772f * currCb;

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.

I suggest clamping values here so it is int clamp between 0 and 255

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.

moved the all the clamps

r *= ONE_OVER_255;
g *= ONE_OVER_255;
b *= ONE_OVER_255;
dstPtrR[dstIdx] = static_cast<T>(clamp(r, 0.0f, 1.0f));
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.

remove clamp from here

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.

Done

r -= 128;
g -= 128;
b -= 128;
dstPtrR[dstIdx] = static_cast<T>(clamp(r, -128.0f, 127.0f));
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.

remove clamp from here

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.

Done

Copy link
Copy Markdown
Contributor

@rrawther rrawther left a comment

Choose a reason for hiding this comment

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

@HazarathKumarM : Are all the comments resolved for this PR?

@HazarathKumarM
Copy link
Copy Markdown
Contributor

@HazarathKumarM : Are all the comments resolved for this PR?

yes Rajy

@kiritigowda kiritigowda merged commit 4e65665 into ROCm:develop May 30, 2025
22 of 24 checks passed
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.

7 participants