Skip to content

Conversation

@shreyas-omkar
Copy link

@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.

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