Converting/Reshaping a vector of ArrayPartition to an Array on the gpu

I have a vector ArrayPartition that looks like this:

5-element Vector{ArrayPartition{Float32, Tuple{CuArray{Float32, 2, CUDA.Mem.DeviceBuffer}, CuArray{Float32, 2, CUDA.Mem.DeviceBuffer}}}}

I want to reshape this into an CuArray that I can pass to the next layer or compute the loss on.

using:

reduce(vcat, v)

results in:

GPU compilation of MethodInstance for GPUArrays.setindex_kernel(::CUDA.CuKernelContext, ::CuDeviceVector{Float32, 1}, ::ArrayPartition{Float32, Tuple{CuArray{Float32, 2, CUDA.Mem.DeviceBuffer}, CuArray{Float32, 2, CUDA.Mem.DeviceBuffer}}}, ::Tuple{Int64}, ::Int64, ::UnitRange{Int64}) failed KernelError: passing and using non-bitstype argument Argument 4 to your kernel function is of type ArrayPartition{Float32, Tuple{CuArray{Float32, 2, CUDA.Mem.DeviceBuffer}, CuArray{Float32, 2, CUDA.Mem.DeviceBuffer}}}, which is not isbits: .x is of type Tuple{CuArray{Float32, 2, CUDA.Mem.DeviceBuffer}, CuArray{Float32, 2, CUDA.Mem.DeviceBuffer}} which is not isbits. .1 is of type CuArray{Float32, 2, CUDA.Mem.DeviceBuffer} which is not isbits. .data is of type GPUArrays.DataRef{CUDA.Mem.DeviceBuffer} which is not isbits. .rc is of type GPUArrays.RefCounted{CUDA.Mem.DeviceBuffer} which is not isbits. .obj is of type CUDA.Mem.DeviceBuffer which is not isbits. .ctx is of type CuContext which is not isbits. .finalizer is of type Any which is not isbits. .count is of type Base.Threads.Atomic{Int64} which is not isbits. .2 is of type CuArray{Float32, 2, CUDA.Mem.DeviceBuffer} which is not isbits. .data is of type GPUArrays.DataRef{CUDA.Mem.DeviceBuffer} which is not isbits. .rc is of type GPUArrays.RefCounted{CUDA.Mem.DeviceBuffer} which is not isbits. .obj is of type CUDA.Mem.DeviceBuffer which is not isbits. .ctx is of type CuContext which is not isbits. .finalizer is of type Any which is not isbits. .count is of type Base.Threads.Atomic{Int64} which is not isbits. Stacktrace: [1] check_invocation(job::GPUCompiler.CompilerJob) @ GPUCompiler ~/.julia/packages/GPUCompiler/U36Ed/src/validation.jl:92
@ Base ./abstractarray.jl:1629 [26] reduce(::typeof(vcat), A::Vector{ArrayPartition{Float32, Tuple{CuArray{Float32, 2, CUDA.Mem.DeviceBuffer}, CuArray{Float32, 2, CUDA.Mem.DeviceBuffer}}}}) @ Base ./abstractarray.jl:1715 [27] top-level scope @ In[18]:1

I am not sure how to proceed. This vector is the solution of a differential equation where the state is an ArrayPartition.

Try converting it to a VectorOfArray first? Or try using Adapt.jl.

Open an issue and we can figure this one out.