Vectorize Resize#4967
Open
pfultz2 wants to merge 10 commits into
Open
Conversation
Regressions detected 🔴 |
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #4967 +/- ##
========================================
Coverage 92.73% 92.73%
========================================
Files 594 594
Lines 31340 31340
========================================
Hits 29063 29063
Misses 2277 2277 🚀 New features to boost your workflow:
|
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates the GPU resize JIT path to enable vectorized stores on the output (and conditionally vectorized loads on the input when the fastest axis is a true pass-through), aiming to improve kernel performance for common layouts like NHWC.
Changes:
- Refactors the device-side resize kernels to run through a shared
resize_applywrapper that supports mixed (scalar vs vectorized) input/output handling. - Updates the GPU JIT resize kernel template to apply
vectorize<N, Axis>()transformers toout(and toinputwhen safe), and adjusts launch sizing to operate on vectorized output elements. - Adds host-side logic to decide when input vectorization is safe based on stride/scale/coordinate transform constraints.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/targets/gpu/kernels/include/migraphx/kernels/resize.hpp | Adds vectorization support via a new resize_apply wrapper and updates nearest/linear/cubic implementations to use it. |
| src/targets/gpu/jit/resize.cpp | Applies vectorize transformers in the generated kernel, selects vectorization parameters, and updates launch sizing and input-vectorization eligibility logic. |
Comment on lines
+209
to
+214
| template <index_int Axis, class Input, class Output, class Outv, class Compute> | ||
| __device__ void resize_apply(Input input, Output out, Outv outv, Compute compute) | ||
| { | ||
| auto idx = make_index(); | ||
| auto in_shape = input.get_shape(); | ||
| auto out_shape = output.get_shape(); | ||
|
|
||
| idx.global_stride(out_shape.elements(), [&](auto out_idx) { | ||
| auto in_idx = compute_nearest_idx<CoordOp, NearestOp>(in_shape, out_shape, out_idx, scales); | ||
| output[out_idx] = input[in_idx]; | ||
| }); | ||
| auto idx = make_index(); | ||
| constexpr index_int ivn = tensor_vec_size<Input>(); // >= 2 only for a pass-through fast axis | ||
| constexpr index_int ovn = tensor_vec_size<Outv>(); |
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
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.
Motivation
Enable vectorization for resize which help improve the performance of the kernel.
Technical Details
Since the input and output are different sizes the
vectorizearg transformer cannot be applied across all tensors. Instead, we vectorize the output and input differently. Ouput vectorization can be easily applied for most cases but input vectorization can only be applied when its not resizing the fastest axis. So it mainly helps for cases like NHWC.Changelog Category
Add a
CHANGELOG.mdentry for any option other thanNot Applicable