Skip to content

Scalar indexing with CuArray * ReshapedArray{SubArray{CuArray}}} #2009

Closed
@vpuri3

Description

@vpuri3

MWE:

julia> CUDA.allowscalar(false)                                                                                                                                                                          [0/1467]
                                                                                                                                                                                                                
julia> CUDA.ones(5, 4) * reshape(view(CUDA.ones(10, 10, 10), 1:4, :, :), 4, 100)                                                                                                                                
ERROR: Scalar indexing is disallowed.                                                                                                                                                                           
Invocation of getindex resulted in scalar indexing of a GPU array.                                                                                                                                              
This is typically caused by calling an iterating implementation of a method.                                                                                                                                    
Such implementations *do not* execute on the GPU, but very slowly on the CPU,                                                                                                                                   
and therefore are only permitted from the REPL for prototyping purposes.                                                                                                                                        
If you did intend to index this array, annotate the caller with @allowscalar.                                                                                                                                   
Stacktrace:                                                                                                                                                                                                     
  [1] error(s::String)                                                                                                                                                                                          
    @ Base ./error.jl:35                                                                                                                                                                                        
  [2] assertscalar(op::String)                                                                                                                                                                                  
    @ GPUArraysCore ~/.julia/packages/GPUArraysCore/uOYfN/src/GPUArraysCore.jl:103                                                                                                                              
  [3] getindex(::CuArray{Float32, 2, CUDA.Mem.DeviceBuffer}, ::Int64, ::Int64)                                                                                                                                  
    @ GPUArrays ~/.julia/packages/GPUArrays/5XhED/src/host/indexing.jl:9     
  [4] _generic_matmatmul!(C::CuArray{Float32, 2, CUDA.Mem.DeviceBuffer}, tA::Char, tB::Char, A::CuArray{Float32, 2, CUDA.Mem.DeviceBuffer}, B::Base.ReshapedArray{Float32, 2, SubArray{Float32, 3, CuArray{Float
32, 3, CUDA.Mem.DeviceBuffer}, Tuple{UnitRange{Int64}, Base.Slice{Base.OneTo{Int64}}, Base.Slice{Base.OneTo{Int64}}}, false}, Tuple{Base.MultiplicativeInverses.SignedMultiplicativeInverse{Int64}, Base.Multipl
icativeInverses.SignedMultiplicativeInverse{Int64}}}, _add::LinearAlgebra.MulAddMul{true, true, Bool, Bool})                                                                                                    
    @ LinearAlgebra ~/.julia/juliaup/julia-1.9.2+0.x64.linux.gnu/share/julia/stdlib/v1.9/LinearAlgebra/src/matmul.jl:876
  [5] generic_matmatmul!(C::CuArray{Float32, 2, CUDA.Mem.DeviceBuffer}, tA::Char, tB::Char, A::CuArray{Float32, 2, CUDA.Mem.DeviceBuffer}, B::Base.ReshapedArray{Float32, 2, SubArray{Float32, 3, CuArray{Float3
2, 3, CUDA.Mem.DeviceBuffer}, Tuple{UnitRange{Int64}, Base.Slice{Base.OneTo{Int64}}, Base.Slice{Base.OneTo{Int64}}}, false}, Tuple{Base.MultiplicativeInverses.SignedMultiplicativeInverse{Int64}, Base.Multipli
cativeInverses.SignedMultiplicativeInverse{Int64}}}, _add::LinearAlgebra.MulAddMul{true, true, Bool, Bool})
    @ LinearAlgebra ~/.julia/juliaup/julia-1.9.2+0.x64.linux.gnu/share/julia/stdlib/v1.9/LinearAlgebra/src/matmul.jl:844
  [6] mul!                                                                                              
    @ ~/.julia/juliaup/julia-1.9.2+0.x64.linux.gnu/share/julia/stdlib/v1.9/LinearAlgebra/src/matmul.jl:303 [inlined]                                                                                            
  [7] mul!                                                                                                                                                                                                      
    @ ~/.julia/juliaup/julia-1.9.2+0.x64.linux.gnu/share/julia/stdlib/v1.9/LinearAlgebra/src/matmul.jl:276 [inlined]
  [8] *(A::CuArray{Float32, 2, CUDA.Mem.DeviceBuffer}, B::Base.ReshapedArray{Float32, 2, SubArray{Float32, 3, CuArray{Float32, 3, CUDA.Mem.DeviceBuffer}, Tuple{UnitRange{Int64}, Base.Slice{Base.OneTo{Int64}},
 Base.Slice{Base.OneTo{Int64}}}, false}, Tuple{Base.MultiplicativeInverses.SignedMultiplicativeInverse{Int64}, Base.MultiplicativeInverses.SignedMultiplicativeInverse{Int64}}})
    @ LinearAlgebra ~/.julia/juliaup/julia-1.9.2+0.x64.linux.gnu/share/julia/stdlib/v1.9/LinearAlgebra/src/matmul.jl:141
  [9] top-level scope
    @ REPL[8]:1
 [10] top-level scope
    @ ~/.julia/packages/CUDA/tVtYo/src/initialization.jl:185

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions