Skip to content

feat(reverse): Add dims support to reverse - #114

Open
shreyas-omkar wants to merge 3 commits into
JuliaGPU:mainfrom
shreyas-omkar:sh/reverse-dims
Open

feat(reverse): Add dims support to reverse#114
shreyas-omkar wants to merge 3 commits into
JuliaGPU:mainfrom
shreyas-omkar:sh/reverse-dims

Conversation

@shreyas-omkar

Copy link
Copy Markdown
Member

No description provided.

shreyas-omkar and others added 2 commits August 21, 2026 18:04
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>
@shreyas-omkar
shreyas-omkar marked this pull request as ready for review August 24, 2026 09:03
@shreyas-omkar

Copy link
Copy Markdown
Member Author

@christiangnrd I have added dims support for reverse. Please check it out once.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@christiangnrd

Copy link
Copy Markdown
Member

I had Claude take a look and it added a few test cases.

Was you plan to finish the reverse interface to add reverse(v [, start=firstindex(v) [, stop=lastindex(v) ]] ) in this PR or were you planning on opening a follow-up after the fact?

@shreyas-omkar

Copy link
Copy Markdown
Member Author

I had Claude take a look and it added a few test cases.

Was you plan to finish the reverse interface to add reverse(v [, start=firstindex(v) [, stop=lastindex(v) ]] ) in this PR or were you planning on opening a follow-up after the fact?

I planned on making a follow up PR once this is merged. We can do it in this PR too. What would be ideal??

@christiangnrd

Copy link
Copy Markdown
Member

Separate is fine and should make them easier to merge

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants