-
Notifications
You must be signed in to change notification settings - Fork 41
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
Offset matrix multiplication via generic_matmatmul!
#270
base: master
Are you sure you want to change the base?
Conversation
src/linearalgebra.jl
Outdated
if tA == 'N' | ||
if tB == 'N' | ||
mul!(C1, A1, B1, alpha, beta) | ||
elseif tB == 'T' | ||
mul!(C1, A1, transpose(B1), alpha, beta) | ||
elseif tB == 'C' | ||
mul!(C1, A1, adjoint(B1), alpha, 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.
A bigger change to LinearAlgebra.generic_matmatmul!
would be to make it keep adjoint
longer, before introducing 'C'
, etc. Then this nest of conditions could be removed.
It seems an odd design that MulAddMul pushes α,β
into the type domain (partly) at the same time that it moves transpose/adjoint to values from types. Perhaps JuliaLang/julia#43552 could fix both at the same time.
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.
816b928 (and JuliaLang/julia@aad0522) changes this. It removes the extra allocation above.
The downside is that these methods will not be called for mul!
with a version of Julia older than JuliaLang/julia#43552 .
Codecov Report
@@ Coverage Diff @@
## master #270 +/- ##
==========================================
- Coverage 96.52% 88.93% -7.59%
==========================================
Files 5 6 +1
Lines 460 488 +28
==========================================
- Hits 444 434 -10
- Misses 16 54 +38
Continue to review full report at Codecov.
|
generic_matmatmul!
This is meant to work with JuliaLang/julia#43552, although I think
mul!
might work without that.Alternative to #146. Since this does not overload
*
, I think it should not encounter the endless method ambiguities that tends to cause, against Adjoint matrices and other types. In fact I think other packages could overloadgeneric_matmul!
too in the same way, and each unwrap nicely, so long as they all only dispatch on the outputC
, which is created bysimilar
.This seems to cause one extra allocation and hence is slower than without offsets. I'm not so sure why, I thought
MulAddMul(α,β)
(whose type depends on the values of α,β) was the culprit, but in fact get similar times after avoiding that:Discussed briefly in this long discourse thread.