-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
5-arg mul! bug fixes #32901
5-arg mul! bug fixes #32901
Conversation
I ran the "full test" on 9da77a4 by commenting out this line julia/stdlib/LinearAlgebra/test/addmul.jl Line 121 in 9da77a4
All tests passed (after more than 6 hours...). As a side note, I find |
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.
LGTM except for the rending issue
@@ -277,81 +277,83 @@ function rmul!(A::AbstractMatrix, transB::Transpose{<:Any,<:Diagonal}) | |||
end | |||
|
|||
# Elements of `out` may not be defined (e.g., for `BigFloat`). To make | |||
# `mul!(out, A, B)` work for such cases, `_scaledout` short-circuits | |||
# `mul!(out, A, B)` work for such cases, `out .*ₛ beta` short-circuits |
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.
This doesn't render for me. Which character are you using here?
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.
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.
We can also use normal function like mulsc
. The code would look like:
mulsc.(A.diag .* in, alpha) .+ mulsc.(out, beta)
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.
According to wikipedia ⊙ is sometimes used for element-wise product.
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.
⊙
is indeed the notation that my profs used for element-wise product.
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.
We need a non-standard binary operator and directly define the broadcasted behavior of it. (The usecase here is to hijack the broadcasted behavior to implement short-circuiting at the level of vector-vector multiplication.)
So using ⊙
would mean to write .⊙
which looks a bit strange as it sounds like doing "doubly" element-wise operation on nested objects.
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.
We can worry about the choice of operator later, to get these fixes in. |
On one of my machines, the Of course, it might also be a good compiler benchmark, maybe worth investigating. |
Part of the answer: julia> m = only(methods(LinearAlgebra._generic_matmatmul!))
_generic_matmatmul!(C::AbstractVecOrMat{R}, tA, tB, A::AbstractVecOrMat{T}, B::AbstractVecOrMat{S}, _add::LinearAlgebra.MulAddMul) where {T, S, R} in LinearAlgebra at /home/tim/src/julia-branch2/usr/share/julia/stdlib/v1.9/LinearAlgebra/src/matmul.jl:850
julia> length(filter(mi -> mi !== nothing, collect(m.specializations)))
5272 😆 |
Another followup of #29634: