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

batched_mul doesn't work with MtlArrays #581

Open
forrestlaine opened this issue May 11, 2024 · 1 comment · May be fixed by #614
Open

batched_mul doesn't work with MtlArrays #581

forrestlaine opened this issue May 11, 2024 · 1 comment · May be fixed by #614

Comments

@forrestlaine
Copy link

Using Julia 1.10.3
Metal v1.1.0
NNlib v0.9.14

julia> using Metal, NNlib
julia> A = randn(Float32, 3,4,5);
julia> B = randn(Float32, 4,6,5);
julia> Ag = MtlArray(A);
julia> Bg = MtlArray(B);
julia> NNlib.batched_mul(A,B); # works no prob
julia> NNlib.batched_mul(Ag, Bg)
ERROR: MethodError: no method matching _batched_gemm!(::Type{MtlArray{Float32, 3, Private}}, ::Char, ::Char, ::Float32, ::MtlArray{Float32, 3, Private}, ::MtlArray{Float32, 3, Private}, ::Float32, ::MtlArray{Float32, 3, Private})

Closest candidates are:
  _batched_gemm!(::Type{<:Array}, ::Char, ::Char, ::Number, ::Any, ::Any, ::Number, ::Any)
   @ NNlib ~/.julia/packages/NNlib/c3RdJ/src/batched/batchedmul.jl:262

Stacktrace:
 [1] _batched_try_gemm!(::Type{MtlArray{Float32, 3, Private}}, C::MtlArray{Float32, 3, Private}, A::MtlArray{Float32, 3, Private}, B::MtlArray{Float32, 3, Private}, α::Float32, β::Float32)
   @ NNlib ~/.julia/packages/NNlib/c3RdJ/src/batched/batchedmul.jl:258
 [2] _batched_mul!(::Type{MtlArray{Float32, 3, Private}}, C::MtlArray{Float32, 3, Private}, A::MtlArray{Float32, 3, Private}, B::MtlArray{Float32, 3, Private}, α::Float32, β::Float32)
   @ NNlib ~/.julia/packages/NNlib/c3RdJ/src/batched/batchedmul.jl:222
 [3] batched_mul!(C::MtlArray{Float32, 3, Private}, A::MtlArray{Float32, 3, Private}, B::MtlArray{Float32, 3, Private}, α::Float32, β::Float32)
   @ NNlib ~/.julia/packages/NNlib/c3RdJ/src/batched/batchedmul.jl:216
 [4] batched_mul!(C::MtlArray{Float32, 3, Private}, A::MtlArray{Float32, 3, Private}, B::MtlArray{Float32, 3, Private})
   @ NNlib ~/.julia/packages/NNlib/c3RdJ/src/batched/batchedmul.jl:216
 [5] _batched_mul(::Type{MtlArray{Float32, 3, Private}}, A::MtlArray{Float32, 3, Private}, B::MtlArray{Float32, 3, Private})
   @ NNlib ~/.julia/packages/NNlib/c3RdJ/src/batched/batchedmul.jl:72
 [6] batched_mul(A::MtlArray{Float32, 3, Private}, B::MtlArray{Float32, 3, Private})
   @ NNlib ~/.julia/packages/NNlib/c3RdJ/src/batched/batchedmul.jl:59
 [7] top-level scope
   @ REPL[24]:1
 [8] top-level scope
   @ ~/.julia/packages/Metal/q9oGt/src/initialization.jl:57
@murrellb
Copy link

This was my fix: https://github.com/MurrellGroup/Jjama3.jl/blob/main/ext/MetalExt.jl

@mcabbott mcabbott linked a pull request Nov 15, 2024 that will close this issue
2 tasks
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.

2 participants