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

trimatmul Not Supported #534

Closed
tgymnich opened this issue Apr 18, 2024 · 1 comment · Fixed by #531
Closed

trimatmul Not Supported #534

tgymnich opened this issue Apr 18, 2024 · 1 comment · Fixed by #531

Comments

@tgymnich
Copy link
Member

tgymnich commented Apr 18, 2024

It seem like GPUArrays does not know how to handle a triangular matmul.

We should either add generic_trimatmul to GPUArrays or teach it to fall back to a normal matmul for those cases.

Falling back to matmul is faster in most cases than implementing a generic_trimatmul kernel since matmul often has a matrix matrix multiplication implementation, that is more performant than generic_trimatmul.

julia> A = UpperTriangular(MtlMatrix(rand(Float32, 1024, 1024)))
julia> x = mtl(rand(1024))
julia> A * x
ERROR: ArgumentError: cannot take the CPU address of a MtlMatrix{Float32, Private}
Stacktrace:
 [1] unsafe_convert(::Type{Ptr{Float32}}, x::MtlMatrix{Float32, Private})
   @ Metal ~/Developer/Metal.jl/src/array.jl:197
 [2] trmv!(uplo::Char, trans::Char, diag::Char, A::MtlMatrix{Float32, Private}, x::MtlVector{Float32, Private})
   @ LinearAlgebra.BLAS ~/.julia/juliaup/julia-1.10.2+0.aarch64.apple.darwin14/share/julia/stdlib/v1.10/LinearAlgebra/src/blas.jl:1315
 [3] generic_trimatmul!(c::MtlVector{…}, uploc::Char, isunitc::Char, tfun::Function, A::MtlMatrix{…}, b::MtlVector{…})
   @ LinearAlgebra ~/.julia/juliaup/julia-1.10.2+0.aarch64.apple.darwin14/share/julia/stdlib/v1.10/LinearAlgebra/src/triangular.jl:823
 [4] _trimul!(C::MtlVector{Float32, Private}, A::UpperTriangular{Float32, MtlMatrix{…}}, B::MtlVector{Float32, Private})
   @ LinearAlgebra ~/.julia/juliaup/julia-1.10.2+0.aarch64.apple.darwin14/share/julia/stdlib/v1.10/LinearAlgebra/src/triangular.jl:705
 [5] mul!(C::MtlVector{Float32, Private}, A::UpperTriangular{Float32, MtlMatrix{…}}, B::MtlVector{Float32, Private})
   @ LinearAlgebra ~/.julia/juliaup/julia-1.10.2+0.aarch64.apple.darwin14/share/julia/stdlib/v1.10/LinearAlgebra/src/triangular.jl:690
 [6] *(A::UpperTriangular{Float32, MtlMatrix{Float32, Private}}, B::MtlVector{Float32, Private})
   @ LinearAlgebra ~/.julia/juliaup/julia-1.10.2+0.aarch64.apple.darwin14/share/julia/stdlib/v1.10/LinearAlgebra/src/triangular.jl:1471
 [7] top-level scope
   @ REPL[18]:1
Some type information was truncated. Use `show(err)` to see complete types.
@tgymnich
Copy link
Member Author

#531

@maleadt maleadt transferred this issue from JuliaGPU/Metal.jl May 24, 2024
@maleadt maleadt linked a pull request May 24, 2024 that will close this issue
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

Successfully merging a pull request may close this issue.

1 participant