Recurse into some arrays of arrays?
- Dominant language
- Julia
- Stars
- 120
- Forks
- 29
- Avg merge
- 1d 18h
- Merged PRs (30d)
- 1
Description
I wonder whether `adapt` should treat an Array of Arrays as a container, like a Tuple, rather than storage to be converted. Convert the innermost Array, not the outermost:
```julia
julia> (rand(1,1), rand(1,1)) |> cu |> first
1×1 CuArray{Float32, 2, CUDA.Mem.DeviceBuffer}:
0.37755206
julia> [rand(1,1), rand(1,1)] |> cu # should perhaps work as above
ERROR: CuArray only supports element types that are allocated inline.
Matrix{Float64} is a mutable type
julia> [1:2, 3:4] |> cu # should not change
2-element CuArray{UnitRange{Int64}, 1, CUDA.Mem.DeviceBuffer}:
1:2
3:4
julia> [SA[1,2.], SA[3,4.]] |> cu
2-element CuArray{SVector{2, Float64}, 1, CUDA.Mem.DeviceBuffer}:
[1.0, 2.0]
[3.0, 4.0]
julia> Any[1:2, 3:4] |> cu
ERROR: CuArray only supports element types that are allocated inline.
```
I'm not exactly sure what the rule would be, perhaps something like `isbitstype(eltype(x))` is enough?
This came up in https://github.com/JuliaGPU/CUDA.jl/pull/1769, where CuIterator at present produces a `Vector{CuArray}`.
Contributor guide
No contributing guide indexed for this repository
Research direction
The issue centers on Adapt.adapt for nested Julia Arrays and references CUDA.jl's CuIterator; start by tracing that adaptation entry point and compare the tuple, typed-range, StaticArrays, and Any examples. Define the supported recursion rule and verify each example's resulting behavior, including the failure cases.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- julia
- Domain
- backend
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100