Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Add constructor for GPUArrays #166

Merged
merged 5 commits into from
Oct 6, 2022

Conversation

ldeso
Copy link
Contributor

@ldeso ldeso commented Oct 5, 2022

Currently constructing ComponentArrays on the GPU with for example ComponentArray(a=CUDA.ones(2,3), b=CUDA.ones(4,5)) fails with an error.

ERROR: CuArray only supports element types that are stored inline

This fails because constructing the ComponentArray causes the creation of an array of arrays, which is not possible on the GPU. This happens in the pushcat! call at line 179 in componentarray.jl:

function make_idx(data, x::AbstractArray, last_val)
pushcat!(data, x)
out = last_index(last_val) .+ (1:length(x))
return (data, ViewAxis(out, ShapedAxis(size(x))))
end

This pull request fixes the issue by constructing the ComponentArray on the CPU and moving it back to the GPU afterwards.

Fixes #158. Needed for SciML/NeuralPDE.jl#594.

@codecov-commenter
Copy link

codecov-commenter commented Oct 6, 2022

Codecov Report

Merging #166 (61801da) into master (a7d6f7d) will decrease coverage by 0.62%.
The diff coverage is 0.00%.

@@            Coverage Diff             @@
##           master     #166      +/-   ##
==========================================
- Coverage   77.13%   76.50%   -0.63%     
==========================================
  Files          20       20              
  Lines         608      613       +5     
==========================================
  Hits          469      469              
- Misses        139      144       +5     
Impacted Files Coverage Δ
src/compat/gpuarrays.jl 65.78% <0.00%> (-9.97%) ⬇️

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@jonniedie jonniedie merged commit e991612 into jonniedie:master Oct 6, 2022
@jonniedie
Copy link
Owner

Cool, thanks!

@ldeso ldeso deleted the add-constructor-for-gpuarrays branch October 9, 2022 12:24
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.

Fix constructor for GPU arrays
3 participants