Skip to content

Fix sub_materialize for GPU arrays #261

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

mtfishman
Copy link

@mtfishman mtfishman commented Jul 3, 2025

Currently, sub_materialize (through sub_materialize_axes) falls back to materializing on CPU. This PR generalizes that logic by determining the output destination with similar, which helps to support non-Array types like GPU arrays. As a stand-in for other GPU arrays, I test this using JLArrays.JLArray, which is a reference implementation for the GPUArrays.jl interface that runs on CPU.

An alternative design would be to define memory layouts for GPU arrays (i.e. #9), which would allow more customizability for GPU array backends, however I think it is helpful to have fallbacks that "just work" if reasonable parts of the Base AbstractArray interface are implemented.

I hit this issue because I was testing out BlockArrays.BlockedArray wrapping a GPU array and noticed that calling A[Block(1, 1)] to access a block instantiated the block on CPU, this PR fixes that issue.

Copy link

codecov bot commented Jul 3, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 89.51%. Comparing base (b9b424e) to head (5f4db5b).
Report is 2 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #261      +/-   ##
==========================================
- Coverage   89.52%   89.51%   -0.01%     
==========================================
  Files          11       11              
  Lines        1938     1937       -1     
==========================================
- Hits         1735     1734       -1     
  Misses        203      203              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants