-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Dispatch more cases to BLAS.gemm! #33229
Conversation
@inline function mul!(C::StridedMatrix{T}, A::StridedVecOrMat{T}, B::StridedVecOrMat{T}, | ||
alpha′::Number, beta′::Number) where {T<:BlasFloat} | ||
alpha, beta = promote(alpha′, beta′, zero(T)) | ||
if alpha isa T && beta isa T |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not use a separate method for this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you suggesting to write
@inline function mul!(C::StridedMatrix{T}, A::StridedVecOrMat{T}, B::StridedVecOrMat{T},
alpha::$TA, beta::$TB) where {T<:BlasFloat}
...
with some expressions $TA
and $TB
? Is it possible? We need to express "alpha and beta would be promoted to T
" in the type domain. I don't know how to do it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't see the accents. So no, it's not possible.
@andreasnoack Maybe I started to think using |
Can it be backported to 1.3? I think this is a bit dangerous performance pitfall and the patch does not seem to be very destructive. |
I've added the triage label. They'll decide if it's okay to try backporting. |
I'd say this is clearly a bugfix. It's very hard to imagine that anybody would have relied on the specific behavior (same result with less speed) in code written in the past month or so... |
* Dispatch more cases to BLAS.gemm! * Use α and β instead of alpha′ and beta′ (cherry picked from commit 51b3227)
* Dispatch more cases to BLAS.gemm! * Use α and β instead of alpha′ and beta′ (cherry picked from commit 51b3227)
This PR tweaks dispatch of
mul!
so that more combinations of types can useBLAS.gemm!
. Namely, alpha and beta does not have to beBlasFloat
anymore.After:
Before:
@fredrikekre pointed it out in JuliaLang/LinearAlgebra.jl#663