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
using CuArrays
CuArrays.allowscalar(false)
x =cu(rand(10));
ind =cu(rand(1:10, 20));
x[ind]
This gives an error, because checkbounds in base goes through the index array one by one:
ERROR: scalar getindex is disallowed
Stacktrace:
[1] error(::String) at ./error.jl:33
[2] assertscalar(::String) at /data/.julia/packages/GPUArrays/QDGmr/src/host/indexing.jl:41
[3] getindex(::CuArray{Int64,1,Nothing}, ::Int64) at /data/.julia/packages/GPUArrays/QDGmr/src/host/indexing.jl:86
[4] iterate at ./abstractarray.jl:914 [inlined]
[5] iterate at ./abstractarray.jl:912 [inlined]
[6] checkindex at ./abstractarray.jl:572 [inlined]
[7] checkbounds at ./abstractarray.jl:488 [inlined]
[8] checkbounds at ./abstractarray.jl:503 [inlined]
[9] _getindex at ./multidimensional.jl:669 [inlined]
[10] getindex(::CuArray{Float32,1,Nothing}, ::CuArray{Int64,1,Nothing}) at ./abstractarray.jl:981
[11] top-level scope at REPL[5]:1
Now, disable checkindex:
import Base.checkindex
checkindex(::Type{Bool}, inds::AbstractUnitRange, I::CuArray) =true
checkindex (generic function with 12 methods)
x[ind]
# prints the expected output
I presume, checkindex needs overriding to something meaningful for GPUArrays?
The text was updated successfully, but these errors were encountered:
I have stumbled upon this when playing around with FluxML/Flux.jl#1006
MWE:
This gives an error, because
checkbounds
in base goes through the index array one by one:Now, disable
checkindex
:I presume,
checkindex
needs overriding to something meaningful forGPUArrays
?The text was updated successfully, but these errors were encountered: