-
-
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
fix and then specialize sparse broadcast!(f, C, A), strengthen tests #19986
Conversation
@test broadcast!(sin, copy(A), A) == sparse(broadcast!(sin, copy(fA), fA)) | ||
# The two following tests are from #19895, and check the absence of an ambiguity | ||
# between a pair of specializations, but #19895 removed both of those specializations, | ||
# so perhaps these tests should be nixed? |
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.
@martinholters @pabloferz, thoughts? Thanks!
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 few months down the road, someone decides to add specializations for the common x .= y
case to be faster...
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.
On that note, perhaps we should add tests for #19895 (comment). Will add a commit. Thanks!
# We first divide the cases into two groups: those in which the input argument does not | ||
# expand vertically, and those in which the input argument expands vertically. | ||
# | ||
# Cases without version expansion |
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.
vertical?
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.
Good catch. Fixed on push. Thanks!
# if fofAx is zero, then either A's jth column is empty, or A's jth column | ||
# contains a nonzero value x but f(Ax) is nonetheless zero, so we need store | ||
# nothing in C's jth column. if to the contrary fofAx is nonzero, then we must | ||
# densely populate C's jth column wiht fofAx. |
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.
with misspelled
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.
Yesterday was not a good day for spelling. Fixed on push. Thanks!
_densestructure!(C) | ||
# Populate values | ||
fill!(storedvals(C), fillvalue) | ||
# Cases without version expansion |
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.
vertical
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.
Fixed on push. Thanks!
# above. here we simply lightly exercise the relevant broadcast[!] entry points. | ||
@testset "broadcast implementation specialized for a single (input) sparse vector/matrix" begin | ||
# broadcast for a single (input) sparse vector/matrix falls back to map, tested | ||
# extensively above. hre we simply lightly exercise the relevant broadcast entry |
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" misspelled
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.
Fixed on push. Thanks!
934939c
to
bec0c0d
Compare
Added a commit strengthening |
Absent objections or requests for time, I plan to merge this Thursday morning PST. Best! |
…rengthen associated tests.
…-preserving and tighten related tests.
…uction of erroneous or ambiguous specializations.
bec0c0d
to
5fcc60e
Compare
LGTM |
Thanks for reviewing / merging! |
In #19895 (comment), @martinholters (thanks!) noticed that the existing sparse
broadcast!(f, C, A)
specialization does not handle cases where the shapes of destinationC
and sourceA
differ.This pull request's first commit removes the incorrect sparse
broadcast!(f, C, A)
specialization (falling back to the argument-number-generic sparsebroadcast!
code, which does not suffer from the above issue) and strengthens associated tests. The argument-number-generic code leaves some performance on the table, so the second commit provides a corrected sparsebroadcast!(f, C, A)
specialization for zero-preservingf
, and the third commit likewise for not-zero-preservingf
.While writing this pull request I realized that the sparse
broadcast!(f, C, A, B)
specializations suffer from the same issue. A fix for that code is in the works. Best!