-
Notifications
You must be signed in to change notification settings - Fork 42
Get rid of A*_mul_B! #97
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
Conversation
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.
Here are some more specific comments for anybody who wishes to review this. I'm still amazed how all this turned out to work without changing the tests (except for removing the stupid "4-arg mul!
test, which is inconsistent with LinearAlgebra
anyway).
Codecov Report
@@ Coverage Diff @@
## master #97 +/- ##
==========================================
+ Coverage 98.29% 99.33% +1.03%
==========================================
Files 12 12
Lines 822 904 +82
==========================================
+ Hits 808 898 +90
+ Misses 14 6 -8
Continue to review full report at Codecov.
|
d292899
to
fba9e2f
Compare
… into dk/makeallmul!
It may look like this is a major overhaul, but actually this only does a few distinct things, so instead of asking for a line-by-line code review, let me just tell you what is done here. Let me know if you disagree with something fundamentally, and I'll take care of adjusting the code. Besides the goal stated in the OP, I've also included the following things:
|
Ok, I think I'm done with this one. I'll leave it hanging for a little while, in case somebody wants to take a closer look. Passing tests and coverage at 100% - eps() look great, don't they? 😉 |
I'll try to give this a good look asap. Thanks for all this amazing work. |
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.
Looking great already. I've left a few comments, not all of them have to do with the current changes, some are also about older changes. I have not been giving this package sufficient attention :-).
The major comment is all the @propagate_inbounds
machinery, which I think is a bit abused for a purpose for which it was not intended. Typically, the dimension check does not matter in comparison to the actual multiplication, which is different for indexing, as I wrote in one of the comments.
However, because of the different nested levels of multiplication that a typical LinearMap
might have, I do understand that you want to disable checking proper dimensions at all levels over and over again. How about a design where there is a single entry point mul!(y::AbstractVecOrMat, L::LinearMap, x::AbstractVecOrMat)
(as well as the one with the scalar coefficients) which does the dimension check (without giving the user a possibility to disable it), and which then calls some internal method _unsafe_mul!
which does no check. All the current mul!
implementations for the different types of linear maps could become _unsafe_mul!
methods with all dimension checks removed.
When all of this is merged, I will probably go through the complete package code locally at my computer before we tag version 3. I've now skipped the parts I am less familiar with because you implemented it (blockmap, kronecker stuff). |
Thanks @Jutho for the thorough review and your comments. Perhaps I went overboard with the whole at-inbounds stuff. I agree that this is not crucial for performance, so I removed all of it. I thought a lot about the "single entry point" approach, especially in the context of leveraging the
Sure, that's a good opportunity now. |
Not saying that you have to, but if you would want to get rid of the extra dimension checkings due to the nested structure of
There was a discussion, or at least a post, about disconnecting method tables: Unfortunately no one responded yet, cause I am interested in this. Not for this package in particular, but for other packages where I am also facing issues with excessive compilation times. However, I am not sure that the premise made in that post is correct, and I will probably draft a response now. |
Aha, that proposal sounds clean and easy enough, I'll give that a try. I was thinking about such a redirection approach, but always tried to mix that with |
Argh, that doesn't help. Within the |
I am not sure I am following; though I haven't thought this through as much. Within the |
I forgot the fallback. 🤦 I'll try again. |
Alright, this has the acclaimed feature, plus the minimal size checking thanks to @Jutho's suggestion and is basically 100% tested. Soon, we will have a code coverage of 110%, at least! 🤣 I think I'll merge this and then @Jutho can take a fresh look at it, meanwhile I'll work on the custom map documentation and the show methods. |
But this time it works! I'll comment on the challenging parts directly in the code. This is BREAKING, because anybody with custom
LinearMap
types will have the action implemented inA[*]_mul_B!
s, which are no longer called from the code base here. So, after this, people would need to writemul!
methods instead, which I believe would be easier to communicate.