JuliaGPU / GPUArrays.jl

Reusable array functionality for Julia's various GPU backends.
MIT License
313 stars 74 forks source link

JLArrays is missing `resize!` function #541

Closed kmp5VT closed 1 week ago

kmp5VT commented 2 weeks ago

Hello,

I am trying to use JLArrays for testing GPUArrays on CPU but am running into an issue when using the append! function. It looks like there is no defined resize! function for this struct

julia> a = JLArray{Float32}(undef, 0)
0-element JLArray{Float32, 1}

julia> append!(a, Vector{Float32}(undef, 4))
ERROR: MethodError: no method matching resize!(::JLArray{Float32, 1}, ::Int64)

Closest candidates are:
  resize!(::BitVector, ::Integer)
   @ Base bitarray.jl:814
  resize!(::Vector, ::Integer)
   @ Base array.jl:1312
  resize!(::NDTensors.SmallVectors.MSmallVector, ::Integer)
   @ NDTensors ~/.julia/dev/ITensors/NDTensors/src/lib/SmallVectors/src/msmallvector/msmallvector.jl:69
  ...

Stacktrace:
 [1] append!(a::JLArray{Float32, 1}, items::Vector{Float32})
   @ GPUArrays ~/.julia/packages/GPUArrays/HjWFN/src/host/abstractarray.jl:326
 [2] top-level scope
   @ REPL[12]:1
maleadt commented 1 week ago

The function exists, we just forgot to tag JLArrays.

maleadt commented 1 week ago

https://github.com/JuliaRegistries/General/pull/109848