-
-
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
RFC: Add allocation free matrix multiplication and solving #4595
Conversation
I'm a little bit confused here...there's a lot of work on allocation-free multiplication, but we already had that. What's different? (What do you mean by "the BLAS way of updating"?) |
The idea was to have functions of the type |
@andreasnoackjensen There is a problem in the logic of using
where the result of multiplying a 40 by 60 sparse matrix by a vector of length 60 was a vector of length 60, not 40 as it should be. You will need to back off the y <- αAx+βy form for non-square I would say this is an urgent fix as the current version produces incorrect answers. Let me know if I can help. |
@dmbates, is this just in the pull request or on master? Do you have the exact code that produced the error? |
I don't think we need to back off |
I agree that there isn't a fundamental problem. I recognize it's like |
I have psuhed a fix to master. @timholy BLAS has |
Didn't know that, thanks for explaining. This makes more sense to me now. I was worried that we were basically forcing extra operations on users in circumstances where they might most often choose |
@StefanKarpinski I should have made it clear that the problem was on master but @andreasnoackjensen has fixed it now. |
@andreasnoackjensen I suggest changing the (*){TA,S,Tx}(A::SparseMatrixCSC{TA,S}, x::AbstractVector{Tx}) = A_mul_B!(1, A, x, 0, zeros(promote_type(TA,Tx), A.m)) to |
@timholy For the @dmbates I have now changed the functions to use |
Just to clarify the 2.0 considerations related to this request. This should not break anything exported or documented as far as I can see, but it breaks the API for allocation free multiplication which is not exported and documented. |
On a different note, I really do not like the proliferation of these |
That doesn't really make much sense. The non-mutating versions need to exist in Base since At_mul_B(A,B) = At_mul_B!(allocate_output(),A,B) |
Most of the code would need to be copied to the package. I have no idea about the things @JeffBezanson is planning on allocation and gc, but my guess is that the function bodies would need to be something like this request. Then the header could be changed to something more elegant than |
Here are the allocation free versions of the dense matrix algebra. I have tried to make all the versions use the BLAS way of updating. It is a major rewrite of
matmul
so this should wait for after 2.0, I think. Thegeneric_matmatmul!
is a little fancy so I am not sure I got it right, so please review it.This was motivated by some work on iterative methods for solving linear systems where it was useful to have a common name and API for the allocation free multiplication. I hope that find an API such that you are free to define a type and
A_mul_B!
and then you can start solving linear systems and eigensystems efficiently.