[Optimization] Improve border/interpolation wrapper implementations#147
Open
zacharyvincze wants to merge 13 commits intoROCm:developfrom
Open
[Optimization] Improve border/interpolation wrapper implementations#147zacharyvincze wants to merge 13 commits intoROCm:developfrom
zacharyvincze wants to merge 13 commits intoROCm:developfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR refactors the affine warp path to use a dedicated WarpAffine kernel (instead of delegating to WarpPerspective) and optimizes border/interpolation wrappers with new shared sampling helpers to reduce overhead on common in-bounds sampling cases.
Changes:
- Added dedicated GPU/CPU WarpAffine kernels and updated
WarpAffine::operator()to dispatch directly by dtype/channels/border/interp. - Optimized
InterpolationWrapper(bilinear/cubic) with in-bounds fast paths to bypass border handling when neighborhoods are fully in-range. - Refactored border coordinate math and interpolation index conversion into a new
sampling_helpers.hpphelper header.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/op_warp_affine.cpp | Replaces WarpPerspective reuse with dedicated WarpAffine dispatch and kernel launches. |
| include/op_warp_affine.hpp | Removes WarpPerspective member dependency; keeps WarpAffine API unchanged. |
| include/kernels/host/warp_affine_host.hpp | Adds host-side affine warp kernel implementation. |
| include/kernels/device/warp_affine_device.hpp | Adds device-side affine warp kernel implementation. |
| include/core/wrappers/interpolation_wrapper.hpp | Adds in-bounds fast paths and refactors nearest/bilinear/cubic sampling math. |
| include/core/wrappers/border_wrapper.hpp | Refactors border coordinate mapping with new helper functions and adds at_inbounds(). |
| include/core/detail/sampling_helpers.hpp | New shared host/device helpers for modulo/clamp/abs and interpolation index conversion. |
💡 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 #147 +/- ##
===========================================
- Coverage 74.40% 73.92% -0.48%
===========================================
Files 79 81 +2
Lines 3355 3520 +165
Branches 738 764 +26
===========================================
+ Hits 2496 2602 +106
- Misses 378 416 +38
- Partials 481 502 +21
🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR offers improvements to the interpolation, border paths as well as adding a dedicated WarpAffine kernel over using the WarpPerspective operator.
Optimizations to these paths improve geometric transformations which make use of border modes and interpolation (Rotate, Resize, WarpAffine, WarpPerspective, CopyMakeBorder).
Technical Details