feat(reverse): reverse a linear sub-range via start/stop - #119
Open
shreyas-omkar wants to merge 5 commits into
Open
feat(reverse): reverse a linear sub-range via start/stop#119shreyas-omkar wants to merge 5 commits into
shreyas-omkar wants to merge 5 commits into
Conversation
Member
|
How does this behave when incompatible args are used together? In base, |
shreyas-omkar
force-pushed
the
sh/reverse-subrange
branch
from
September 3, 2026 08:25
a9ca217 to
06a8575
Compare
Member
Author
|
start/stop + dims already threw ArgumentError (mutually exclusive). |
Add a `dims` keyword to `reverse!`/`reverse`, reaching parity with `Base.reverse` and the vendor reverse kernels. `dims=:` (the default) keeps the fast flat path - each thread swaps one mirrored pair - while `dims=d` (an integer or iterable) reverses only along those dimensions via a general ND kernel written on `foreachindex`, so it runs on every backend (CUDA/AMDGPU/oneAPI/Metal/POCL) and the CPU-threaded path from one implementation. Invalid dims throw `ArgumentError`. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Exercise single-dim, multi-dim ((1,2)/(2,3)/(1,3)/:), size-1 degenerate dims and 3-D arrays across in-place, out-of-place and allocating forms, plus ArgumentError on out-of-range dims. Verified on CPU-threaded, AMDGPU (ROCm) and POCL backends. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
shreyas-omkar
force-pushed
the
sh/reverse-subrange
branch
from
September 3, 2026 08:29
06a8575 to
d4f280b
Compare
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.
Adds
start/stopkeyword arguments toreverse!andreverse, matchingBase.reverse!(v, start, stop)/Base.reverse(v, start, stop): reverses only the linear sub-rangev[start:stop], leaving the rest in place (in-place) or copied verbatim (out-of-place).The positional
reverse!(v, start, stop)form is unavailable in AK because the second positional argument is the backend, so these are keyword-only.start/stopapply to the flat (dims=:) path and are mutually exclusive withdims; out-of-bounds ranges throwBoundsError, empty ranges (start > stop) are a no-op.Follow-up to #114. Tested on CPU (threaded) and AMDGPU (RX 9060 XT) — full reverse suite green (1795/1795).