Skip to content

Comments

fix: Specialized ReshapedArray dispatch to resolve setindex! ambiguities#680

Open
shreyas-omkar wants to merge 1 commit intoJuliaGPU:masterfrom
shreyas-omkar:Iss587
Open

fix: Specialized ReshapedArray dispatch to resolve setindex! ambiguities#680
shreyas-omkar wants to merge 1 commit intoJuliaGPU:masterfrom
shreyas-omkar:Iss587

Conversation

@shreyas-omkar
Copy link
Contributor

@shreyas-omkar shreyas-omkar commented Jan 20, 2026

Fix for #587

Summary

Resolves setindex! method ambiguities occurring when using ReshapedArray views of GPU-backed arrays.

Issue

The ambiguity was caused by a dispatch tie between the general WrappedGPUArray union method and the specialized ReshapedArray constructor. This PR breaks that tie by providing specialized _unsafe_setindex! methods for IndexLinear and IndexCartesian.

By specifying the concrete IndexStyle subtypes, these methods provide a narrower dispatch scope, ensuring Julia selects the correct vectorized path for reshaped views.

Changes

  • src/host/indexing.jl: Added specialized dispatch methods for ReshapedArray to resolve ambiguities.
  • test/testsuite/indexing.jl: Added a combinatorial test suite to verify the fix across various nested wrapper types (views, permutations, and reinterpreted arrays).

Verification

  • Confirmed fix resolves MethodError in the reported minimal working example.
  • Verified data parity between CPU and GPU results using compare().
  • Successfully ran the new indexing combinatorial test suite on ROCArray and JLArray.

@shreyas-omkar shreyas-omkar force-pushed the Iss587 branch 3 times, most recently from f336ab2 to 7cdbbae Compare January 25, 2026 07:58
@shreyas-omkar shreyas-omkar marked this pull request as draft January 25, 2026 08:52
@shreyas-omkar shreyas-omkar force-pushed the Iss587 branch 2 times, most recently from 0cf9660 to 7399f56 Compare January 25, 2026 11:20
@shreyas-omkar shreyas-omkar force-pushed the Iss587 branch 3 times, most recently from 266ee85 to 727957f Compare February 22, 2026 13:14
@shreyas-omkar shreyas-omkar marked this pull request as ready for review February 22, 2026 15:09
@github-actions
Copy link
Contributor

Your PR requires formatting changes to meet the project's style guidelines.
Please consider running Runic (git runic master) to apply these changes.

Click here to view the suggested changes.
diff --git a/test/testsuite/indexing.jl b/test/testsuite/indexing.jl
index aaae72b..9e4d600 100644
--- a/test/testsuite/indexing.jl
+++ b/test/testsuite/indexing.jl
@@ -353,4 +353,4 @@ end
             A
         end
     end
-end
\ No newline at end of file
+end

@shreyas-omkar
Copy link
Contributor Author

@maleadt @kshyatt Please review the changes.

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.

1 participant