Skip to content

gather is not friendly with matrix of size 0 on GPU #411

Open
@YichengDWu

Description

@YichengDWu
using NNlib, CUDA
julia>  NNlib.gather(rand(0,32),[2,3,4]) #on CPU
0×3 Matrix{Float64} 


julia> a = rand(0,32)|>gpu
0×32 CuArray{Float32, 2, CUDA.Mem.DeviceBuffer}

julia> idx = cu[2,4,6]
3-element CuArray{Int64, 1, CUDA.Mem.DeviceBuffer}:
 2
 4
 6

julia>  NNlib.gather(a,idx)
ERROR: DivideError: integer division error
Stacktrace:
 [1] div
   @ .\int.jl:284 [inlined]
 [2] div
   @ .\div.jl:257 [inlined]
 [3] div
   @ .\div.jl:312 [inlined]
 [4] cld
   @ .\div.jl:269 [inlined]
 [5] gather!(dst::CuArray{Float32, 2, CUDA.Mem.DeviceBuffer}, src::CuArray{Float32, 2, CUDA.Mem.DeviceBuffer}, idx::CuArray{Int64, 1, CUDA.Mem.DeviceBuffer})
   @ NNlibCUDA C:\Users\Luffy\.julia\packages\NNlibCUDA\vECff\src\gather.jl:62
 [6] gather(src::CuArray{Float32, 2, CUDA.Mem.DeviceBuffer}, idx::CuArray{Int64, 1, CUDA.Mem.DeviceBuffer})
   @ NNlib C:\Users\Luffy\.julia\packages\NNlib\hydo3\src\gather.jl:77
 [7] top-level scope
   @ REPL[135]:1
 [8] top-level scope
   @ C:\Users\Luffy\.julia\packages\CUDA\qAl31\src\initialization.jl:52

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions