Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This pull request provides (1) a
map
/map!
implementation specialized for a single (input) sparse matrix, (2) amap
/map!
implementation specialized for a pair of (input) sparse matrices, and (3) a generalmap
/map!
implementation capable of efficiently handling an arbitrary number of sparse matrices (within compiler limits).broadcast
/broadcast!
over a single (input) sparse matrix being identical tomap
/map!
over the same, this pull request also reimplementsbroadcast
/broadcast!
over a single (input) sparse matrix as short children ofmap
/map!
.The semantics of these
map!
/broadcast!
methods are those discussed in #19372. Notably thesemap!
/broadcast!
methods only allocate when strictly necessary, so for exampleAdditionally, where these
map!
/broadcast!
methods do allocate, they do so less pessimistically than the existingbroadcast!
methods.The specialized
map
/map!
methods achieve performance similar to corresponding existingbroadcast
/broadcast!
methods (despite performing slightly more work to enable the more precise allocation behavior). The former win in some cases and the latter in others, with runtime differences usually ~10% or less in (hopefully realistic) tests.The general
map
/map!
methods achieve performance not too far behind the methods specialized for pairs of (input) sparse matrices. The latter typically best the former by only 10-35% runtime, though in some cases they're on par and in others the gap stretches to 45%.Fixes (the
SparseMatrixCSC
part of) #19363. Also relevant to #16285 and friends as a step in the sparsebroadcast
/broadcast!
overhaul. Best!(Realized this PR lacks a
map!(f, A)
method. Punting to a followup PR.)