Random Erase Dropout Augmentation on HOST and HIP#674
Random Erase Dropout Augmentation on HOST and HIP#674rrawther merged 78 commits intoROCm:developfrom
Conversation
r-abishek
commented
Feb 18, 2026
- 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
…all the bitdepths
…images in the docs
indentation modified
…ied QA for logic to implement random seed for non QA
* Add Box and Median Filter ROI fixes after minor corrections * Fix source index computation --------- Co-authored-by: Mukesh <mukesh.jayakodi@multicorewareinc.com> Co-authored-by: Kiriti Gowda <kiritigowda@gmail.com>
Random erase dropout kernel implementation
There was a problem hiding this comment.
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_eraseAPI entry and dispatch inrppt_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
255values instead ofRANDOM_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 isdocs/data/doxygenOutputs/effects_augmentation_random_erase_dropout_img150x150.png(missing thesinaugmentations). This will break the generated docs image. Rename the file or update the\image htmlreference 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()forcesx_start/y_startto be at least 1.0 even whenx_slack/y_slackis 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
RpptRoiLtrbuses inclusive right/bottom coordinates (seecompute_xywh_from_ltrb_host()which doesrb - lt + 1). Hererbis set tolt + boxW/boxH, which makes the box 1 pixel larger than intended and can overshoot the ROI. Consider settingrbtolt + 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 Report❌ Patch coverage is 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
🚀 New features to boost your workflow:
|
msiddaiah
left a comment
There was a problem hiding this comment.
- Either implement 1-channel NHWC support OR explicitly validate and return error
- Run full test suite to verify memory safety
- 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) |
There was a problem hiding this comment.
The anchor box coordinates from anchorBoxInfoTensor[id_z] are used directly without checking if they're within the destination image dimensions.
| 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) |
There was a problem hiding this comment.
The anchor box coordinates from anchorBoxInfoTensor[id_z] are used directly without checking if they're within the destination image dimensions.
Random Erase - Resolved copilot review comments
|
@r-abishek, Please resolve all review comments. |
Random Erase Dropout - Resolved review comments
…_erase_dropout
Merged - Random Erase Dropout