-
-
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
Optimizing some structured matrix multiply methods #32521
Conversation
attn: @ViralBShah This is the new version of #28345. |
Let's get this thing merged this time! |
I resolved the ambiguities by restricting the left side to be |
Did you try with |
@andreasnoack Yes, that seems more appropriate. Thanks. |
Fixed merge conflicts. |
Looks like something broke |
Seems like I accidentally deleted the relevant code. Should be fixed now. |
Thanks. One concern here is that |
@andreasnoack Yes, I have noticed this is several places with structured matrices. Would you be ok with a warning instead of an error ( |
I.e. dense output with a warning? |
I had thought Sparse output with a warning (which I guess is still breaking, but better than interrupting execution). |
The problem is that sparse output with a warning would introduce the dependency. We'd need to make a general decision if we can allow LinearAlgebra to depend on SparseArrays |
I had it backwards, I thought LinearAlgebra already had a dependency on SparseArrays, but it is the other way around. In this case, is it best to throw an error and move the method definition to SparseArrays? |
I guess we could also continue to return a dense array? |
I kind of agree that, if the result type is none of But, I need to admit that I'm confused. In a fresh Julia session: using LinearAlgebra
B = Bidiagonal(rand(4), rand(3), 'U')
@which similar(B, Float64, (3,3)) returns similar(B::Bidiagonal, ::Type{T}, dims::Union{Tuple{Int64}, Tuple{Int64,Int64}}) where T in SparseArrays at /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.3/SparseArrays/src/SparseArrays.jl:50 I couldn't find where we import this |
Is there any update on this? Or could I help in moving this PR forward? |
Yeah this sort of stalled. Happy to keep working on it, perhaps with @ranocha if there is interest. |
julia/stdlib/SparseArrays/src/SparseArrays.jl Lines 58 to 61 in ab04170
I don't understand how this is "known" to Julia without declaring |
Type piracy in combination with that SparseArrays exists in the sysimage. |
Seems all of these optimizations have been added in other PRs so I will close this one. |
This PR addresses #28345 and JuliaLang/LinearAlgebra.jl#525 as well as some missed optimizations from #28883.
A summary of the changes:
SparseMatrixCSC
)Bidiagonal
xTridiagonal
,SymTridiagonal
xSymTridiagonal
, and others outputSparseMatrixCSC
(not Dense). These changes were mentioned in [WIP] Optimizing {+,-,*} for structured matrices #28883, but apparently I missed them in that PR.Bidiagonal
xBidiagonal
outputsTridiagonal
orSparseMatrixCSC
depending on ifA.uplo == B.uplo
. Before it outputSparseMatrixCSC
or Dense.(EDIT: Closes JuliaLang/LinearAlgebra.jl#741, closes JuliaLang/LinearAlgebra.jl#525.)
Below are some benchmarks as well as the input/output types:
Before:
This PR: