You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Sanity checks (read this first, then remove this section)
I don't know if this works by accident for normal arrays, but I did find it quite useful.
Describe the bug
Trying to index an array with an empty index array produces an error.
To Reproduce
The Minimal Working Example (MWE) for this bug:
julia> aa =randn(3,3);
julia> aa[Int[],1:3]
0×3 Array{Float64,2}
julia>cu(aa)[Int[],1:3]
ERROR: DivideError: integer division error
Stacktrace:
[1] div at .\int.jl:230 [inlined]
[2] div at .\div.jl:215 [inlined]
[3] div at .\div.jl:270 [inlined]
[4] cld at .\div.jl:227 [inlined]
[5] configurator at E:\Programs\julia\.julia\packages\CuArrays\e8PLr\src\gpuarrays.jl:27 [inlined]
[6] #cudacall#216 at E:\Programs\julia\.julia\packages\CUDAnative\ierw8\src\execution.jl:259 [inlined]
[7] macro expansion at E:\Programs\julia\.julia\packages\CUDAnative\ierw8\src\execution.jl:242 [inlined]
[8] call(::CUDAnative.HostKernel{GPUArrays.index_kernel,Tuple{CuArrays.CuKernelContext,CUDAnative.CuDeviceArray{Float32,2,CUDAnative.AS.Global},CUDAnative.CuDeviceArray{Float32,2,CUDAnative.AS.Global},Tuple{Int64,Int64},Tuple{CUDAnative.CuDeviceArray{Int64,1,CUDAnative.AS.Global},UnitRange{Int64}}}}, ::CuArrays.CuKernelContext, ::CUDAnative.CuDeviceArray{Float32,2,CUDAnative.AS.Global}, ::CUDAnative.CuDeviceArray{Float32,2,CUDAnative.AS.Global}, ::Tuple{Int64,Int64}, ::Tuple{CUDAnative.CuDeviceArray{Int64,1,CUDAnative.AS.Global},UnitRange{Int64}}; call_kwargs::Base.Iterators.Pairs{Symbol,CuArrays.var"#configurator#50"{Int64},Tuple{Symbol},NamedTuple{(:config,),Tuple{CuArrays.var"#configurator#50"{Int64}}}}) at E:\Programs\julia\.julia\packages\CUDAnative\ierw8\src\execution.jl:219
[9] (::CUDAnative.HostKernel{GPUArrays.index_kernel,Tuple{CuArrays.CuKernelContext,CUDAnative.CuDeviceArray{Float32,2,CUDAnative.AS.Global},CUDAnative.CuDeviceArray{Float32,2,CUDAnative.AS.Global},Tuple{Int64,Int64},Tuple{CUDAnative.CuDeviceArray{Int64,1,CUDAnative.AS.Global},UnitRange{Int64}}}})(::CuArrays.CuKernelContext, ::Vararg{Any,N}where N; kwargs::Base.Iterators.Pairs{Symbol,CuArrays.var"#configurator#50"{Int64},Tuple{Symbol},NamedTuple{(:config,),Tuple{CuArrays.var"#configurator#50"{Int64}}}}) at E:\Programs\julia\.julia\packages\CUDAnative\ierw8\src\execution.jl:472
[10] macro expansion at E:\Programs\julia\.julia\packages\CUDAnative\ierw8\src\execution.jl:158 [inlined]
[11] gpu_call(::CuArrays.CuArrayBackend, ::Function, ::Tuple{CuArray{Float32,2,Nothing},CuArray{Float32,2,Nothing},Tuple{Int64,Int64},Tuple{CuArray{Int64,1,Nothing},UnitRange{Int64}}}, ::Int64; name::Nothing) at E:\Programs\julia\.julia\packages\CuArrays\e8PLr\src\gpuarrays.jl:32
[12] #gpu_call#1 at E:\Programs\julia\.julia\packages\GPUArrays\QDGmr\src\device\execution.jl:60 [inlined]
[13] gpu_call at E:\Programs\julia\.julia\packages\GPUArrays\QDGmr\src\device\execution.jl:46 [inlined]
[14] _unsafe_getindex! at E:\Programs\julia\.julia\packages\GPUArrays\QDGmr\src\host\indexing.jl:125 [inlined]
[15] _unsafe_getindex(::IndexLinear, ::CuArray{Float32,2,Nothing}, ::Array{Int64,1}, ::UnitRange{Int64}) at .\multidimensional.jl:741
[16] _getindex at .\multidimensional.jl:727 [inlined]
[17] getindex(::CuArray{Float32,2,Nothing}, ::Array{Int64,1}, ::UnitRange{Int64}) at .\abstractarray.jl:980
[18] top-level scope at none:0
Expected behavior
Same behaviour as for the normal array: An empty array with the "correct" dimensions.
Build log
# post the output of Pkg.build()
# make sure the error still reproduces after that.
julia> Pkg.build()
Building NNlib → `E:\Programs\julia\.julia\packages\NNlib\FAI3o\deps\build.log`
julia> aa = randn(3,3);
julia> cu(aa)[Int[],1:3]
ERROR: DivideError: integer division error
...
Environment details (please complete this section)
Details on Julia:
# please post the output of:
julia> versioninfo()
Julia Version 1.4.0
Commit b8e9a9ecc6 (2020-03-21 16:36 UTC)
Platform Info:
OS: Windows (x86_64-w64-mingw32)
CPU: Intel(R) Core(TM) i7-5820K CPU @ 3.30GHz
WORD_SIZE: 64
LIBM: libopenlibm
LLVM: libLLVM-8.0.1 (ORCJIT, haswell)
Julia packages:
CuArrays.jl:
CUDAnative.jl:
...
CUDA: toolkit and driver version
Additional context
If the right solution is to just add something like any(isempty, indices) && return CuArray(length(indices)...) (I know this example does not work as is) in e.g. ´_unsafe_getindex` I can probably contribute with that :)
The text was updated successfully, but these errors were encountered:
Sanity checks (read this first, then remove this section)
I don't know if this works by accident for normal arrays, but I did find it quite useful.
Describe the bug
Trying to index an array with an empty index array produces an error.
To Reproduce
The Minimal Working Example (MWE) for this bug:
Expected behavior
Same behaviour as for the normal array: An empty array with the "correct" dimensions.
Build log
Environment details (please complete this section)
Details on Julia:
Julia packages:
CUDA: toolkit and driver version
Additional context
If the right solution is to just add something like
any(isempty, indices) && return CuArray(length(indices)...)
(I know this example does not work as is) in e.g. ´_unsafe_getindex` I can probably contribute with that :)The text was updated successfully, but these errors were encountered: