Skip to content

Random Erase Dropout Augmentation on HOST and HIP#674

Merged
rrawther merged 78 commits intoROCm:developfrom
r-abishek:ar/dropout_random_erase
Mar 16, 2026
Merged

Random Erase Dropout Augmentation on HOST and HIP#674
rrawther merged 78 commits intoROCm:developfrom
r-abishek:ar/dropout_random_erase

Conversation

@r-abishek
Copy link
Copy Markdown
Member

  • Adds Random Erase Dropout augmentation on HOST and HIP
  • Adds support for U8/F16/F32/I8 and NCHW/NHWC variants
  • Adds relevant unit/perf/qa tests

snehaa8 and others added 30 commits August 22, 2025 07:39
…ied QA for logic to implement random seed for non QA
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

Adds a new tensor augmentation (rppt_random_erase) intended to run on both HOST and HIP backends, with test-suite wiring and documentation updates.

Changes:

  • Adds rppt_random_erase API entry and dispatch in rppt_tensor_effects_augmentations.cpp.
  • Introduces new HOST and HIP kernel implementations for random erase.
  • Extends the test suite augmentation maps and adds RANDOM_ERASE execution paths for HOST/HIP runners (plus docs asset + constant definition).

Reviewed changes

Copilot reviewed 11 out of 14 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
utilities/test_suite/rpp_test_suite_image.h Adds RANDOM_ERASE to augmentation enums/maps and introduces init_dropout_erase() helper for random erase test data setup.
utilities/test_suite/common.py Adds RANDOM_ERASE to Python-side augmentation map for test runner selection.
utilities/test_suite/HOST/Tensor_image_host.cpp Adds RANDOM_ERASE test-case execution path for HOST test runner.
utilities/test_suite/HIP/Tensor_image_hip.cpp Adds RANDOM_ERASE allocations/execution path and cleanup for HIP test runner.
src/modules/tensor/rppt_tensor_effects_augmentations.cpp Adds rppt_random_erase() public API implementation and backend dispatch.
src/modules/tensor/hip/kernel/random_erase.cpp New HIP kernel + executor for random erase.
src/modules/tensor/cpu/kernel/random_erase.cpp New HOST kernel implementation for random erase.
src/include/tensor/host_tensor_executors.hpp Declares random_erase_host_tensor() executor prototype.
src/include/tensor/hip_tensor_executors.hpp Declares hip_exec_random_erase_tensor() executor prototype.
api/rppt_tensor_effects_augmentations.h Adds public API declaration + Doxygen documentation for random erase.
api/rppdefs.h Adds RANDOM_ERASE_NOISE_BUFFER_SIDE constant.
docs/data/doxygenOutputs/effects_augmentation_random_erase_dropout_img150x150.png Adds sample output image asset for documentation.
Comments suppressed due to low confidence (4)

src/modules/tensor/cpu/kernel/random_erase.cpp:112

  • Noise indexing here uses hard-coded 255 values instead of RANDOM_ERASE_NOISE_BUFFER_SIDE, making the code inconsistent with the rest of the file and fragile if the constant ever changes. Use the macro consistently.
                Rpp32u noiseRowOffset = ((y1 + i + batchCount) % 255) * 255 * 3;
                for (int j = 0; j < boxWidth; j++)
                {
                    Rpp32u noiseIdx = noiseRowOffset + ((x1 + j) % 255 * 3);

api/rppt_tensor_effects_augmentations.h:510

  • The Doxygen image reference uses effects_augmentations_random_erase_dropout_img150x150.png, but the added file path is docs/data/doxygenOutputs/effects_augmentation_random_erase_dropout_img150x150.png (missing the s in augmentations). This will break the generated docs image. Rename the file or update the \image html reference to match.
 * \image html img150x150.png Sample Input
 * \image html effects_augmentations_random_erase_dropout_img150x150.png Sample Output
 * \param [in] srcPtr source tensor in HIP memory (for HIP backend) or HOST memory (for HOST backend)

utilities/test_suite/rpp_test_suite_image.h:1747

  • init_dropout_erase() forces x_start/y_start to be at least 1.0 even when x_slack/y_slack is 0 (box equals ROI size). This can push the box outside the ROI or make the erase region empty for small ROIs. Allow 0 start (and clamp to slack) so boxes can start at the ROI origin.
        const float x_slack = std::max(0.0f, roiW - boxW);
        const float y_slack = std::max(0.0f, roiH - boxH);

        const float x_start = std::max(1.0f, std::min(pos_ratio(rng) * x_slack, x_slack));
        const float y_start = std::max(1.0f, std::min(pos_ratio(rng) * y_slack, y_slack));

utilities/test_suite/rpp_test_suite_image.h:1753

  • RpptRoiLtrb uses inclusive right/bottom coordinates (see compute_xywh_from_ltrb_host() which does rb - lt + 1). Here rb is set to lt + boxW/boxH, which makes the box 1 pixel larger than intended and can overshoot the ROI. Consider setting rb to lt + boxW/boxH - 1 (after clamping).
        RpptRoiLtrb &box = anchorBoxInfoTensor[i * maxBoxesPerImage];
        box.lt.x = static_cast<Rpp32u>(roiX + x_start);
        box.lt.y = static_cast<Rpp32u>(roiY + y_start);
        box.rb.x = static_cast<Rpp32u>(roiX + x_start + boxW);
        box.rb.y = static_cast<Rpp32u>(roiY + y_start + boxH);

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

@codecov
Copy link
Copy Markdown

codecov bot commented Feb 19, 2026

Codecov Report

❌ Patch coverage is 97.27096% with 14 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
...dules/tensor/rppt_tensor_effects_augmentations.cpp 95.12% 6 Missing ⚠️
src/modules/tensor/cpu/kernel/random_erase.cpp 97.86% 5 Missing ⚠️
src/modules/tensor/hip/kernel/random_erase.cpp 98.06% 3 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop     #674      +/-   ##
===========================================
+ Coverage    92.46%   92.52%   +0.07%     
===========================================
  Files          198      200       +2     
  Lines        89139    89652     +513     
===========================================
+ Hits         82415    82950     +535     
+ Misses        6724     6702      -22     
Files with missing lines Coverage Δ
api/rppdefs.h 72.00% <100.00%> (+0.28%) ⬆️
src/modules/tensor/hip/kernel/random_erase.cpp 98.06% <98.06%> (ø)
src/modules/tensor/cpu/kernel/random_erase.cpp 97.86% <97.86%> (ø)
...dules/tensor/rppt_tensor_effects_augmentations.cpp 92.90% <95.12%> (+0.10%) ⬆️

... and 3 files with indirect coverage changes

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

Copy link
Copy Markdown

@msiddaiah msiddaiah left a comment

Choose a reason for hiding this comment

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

  1. Either implement 1-channel NHWC support OR explicitly validate and return error
  2. Run full test suite to verify memory safety
  3. Cover all my and copilot comments

int id_y = hipBlockIdx_y * hipBlockDim_y + hipThreadIdx_y;
int id_z = hipBlockIdx_z * hipBlockDim_z + hipThreadIdx_z;

if (id_x < anchorBoxInfoTensor[id_z].lt.x || id_x > anchorBoxInfoTensor[id_z].rb.x || id_y < anchorBoxInfoTensor[id_z].lt.y || id_y > anchorBoxInfoTensor[id_z].rb.y)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The anchor box coordinates from anchorBoxInfoTensor[id_z] are used directly without checking if they're within the destination image dimensions.

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.

Added checks

int id_y = hipBlockIdx_y * hipBlockDim_y + hipThreadIdx_y;
int id_z = hipBlockIdx_z * hipBlockDim_z + hipThreadIdx_z;

if (id_x < anchorBoxInfoTensor[id_z].lt.x || id_x > anchorBoxInfoTensor[id_z].rb.x || id_y < anchorBoxInfoTensor[id_z].lt.y || id_y > anchorBoxInfoTensor[id_z].rb.y)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The anchor box coordinates from anchorBoxInfoTensor[id_z] are used directly without checking if they're within the destination image dimensions.

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.

Added checks

@msiddaiah
Copy link
Copy Markdown

@r-abishek, Please resolve all review comments.

Copy link
Copy Markdown

@msiddaiah msiddaiah left a comment

Choose a reason for hiding this comment

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

LGTM

@rrawther rrawther merged commit e5f17fe into ROCm:develop Mar 16, 2026
6 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.

8 participants