Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

multiplication fails with discontinuous view #460

Open
CarloLucibello opened this issue Oct 16, 2024 · 1 comment
Open

multiplication fails with discontinuous view #460

CarloLucibello opened this issue Oct 16, 2024 · 1 comment

Comments

@CarloLucibello
Copy link

Found the following problem with multiplication of a discontinuous view by a matrix

x = ones(Float32,2,2) |> MtlArray
y = ones(Float32,4,2) |> MtlArray
yv = view(y, 1:2, :)
x * yv
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 should be avoided.

If you want to allow scalar iteration, use `allowscalar` or `@allowscalar`
to enable scalar iteration globally or for the operations in question.
Stacktrace:
  [1] error(s::String)
    @ Base ./error.jl:35
  [2] errorscalar(op::String)
    @ GPUArraysCore ~/.julia/packages/GPUArraysCore/GMsgk/src/GPUArraysCore.jl:155
  [3] _assertscalar(op::String, behavior::GPUArraysCore.ScalarIndexing)
    @ GPUArraysCore ~/.julia/packages/GPUArraysCore/GMsgk/src/GPUArraysCore.jl:128
  [4] assertscalar(op::String)
    @ GPUArraysCore ~/.julia/packages/GPUArraysCore/GMsgk/src/GPUArraysCore.jl:116
  [5] getindex
    @ ~/.julia/packages/GPUArrays/qt4ax/src/host/indexing.jl:50 [inlined]
  [6] scalar_getindex
    @ ~/.julia/packages/GPUArrays/qt4ax/src/host/indexing.jl:36 [inlined]
  [7] _getindex
    @ ~/.julia/packages/GPUArrays/qt4ax/src/host/indexing.jl:19 [inlined]
  [8] getindex
    @ ~/.julia/packages/GPUArrays/qt4ax/src/host/indexing.jl:17 [inlined]
  [9] matmul2x2!(C::MtlMatrix{…}, tA::Char, tB::Char, A::MtlMatrix{…}, B::SubArray{…}, _add::LinearAlgebra.MulAddMul{…})
    @ LinearAlgebra ~/.julia/juliaup/julia-1.11.0+0.aarch64.apple.darwin14/share/julia/stdlib/v1.11/LinearAlgebra/src/matmul.jl:943
 [10] gemm_wrapper!(C::MtlMatrix{…}, tA::Char, tB::Char, A::MtlMatrix{…}, B::SubArray{…}, _add::LinearAlgebra.MulAddMul{…})
    @ LinearAlgebra ~/.julia/juliaup/julia-1.11.0+0.aarch64.apple.darwin14/share/julia/stdlib/v1.11/LinearAlgebra/src/matmul.jl:644
 [11] generic_matmatmul!
    @ ~/.julia/juliaup/julia-1.11.0+0.aarch64.apple.darwin14/share/julia/stdlib/v1.11/LinearAlgebra/src/matmul.jl:381 [inlined]
 [12] _mul!
    @ ~/.julia/juliaup/julia-1.11.0+0.aarch64.apple.darwin14/share/julia/stdlib/v1.11/LinearAlgebra/src/matmul.jl:287 [inlined]
 [13] mul!
    @ ~/.julia/juliaup/julia-1.11.0+0.aarch64.apple.darwin14/share/julia/stdlib/v1.11/LinearAlgebra/src/matmul.jl:285 [inlined]
 [14] mul!
    @ ~/.julia/juliaup/julia-1.11.0+0.aarch64.apple.darwin14/share/julia/stdlib/v1.11/LinearAlgebra/src/matmul.jl:253 [inlined]
 [15] *(A::MtlMatrix{Float32, Metal.PrivateStorage}, B::SubArray{Float32, 2, MtlMatrix{…}, Tuple{…}, false})
    @ LinearAlgebra ~/.julia/juliaup/julia-1.11.0+0.aarch64.apple.darwin14/share/julia/stdlib/v1.11/LinearAlgebra/src/matmul.jl:124
 [16] top-level scope
    @ ~/.julia/dev/Flux/prova.jl:24
Some type information was truncated. Use `show(err)` to see complete types.
julia> Metal.versioninfo()
macOS 14.6.1, Darwin 23.6.0

Toolchain:
- Julia: 1.11.0
- LLVM: 16.0.6

Julia packages: 
- Metal.jl: 1.4.1
- GPUArrays: 10.3.1
- GPUCompiler: 0.27.8
- KernelAbstractions: 0.9.28
- ObjectiveC: 3.1.0
- LLVM: 9.1.2
- LLVMDowngrader_jll: 0.3.0+1

1 device:
- Apple M1 Pro (640.000 KiB allocated)
@jonas4climate
Copy link

jonas4climate commented Oct 28, 2024

I'm new here but I believe this is something that cannot be adressed (i.e. remains unsupported as the error message indicates), until GPUArrays.jl provides functionality for such operations.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants