Skip to content
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

replace broadcast with map in sparse binary op definitions #19527

Merged
merged 2 commits into from
Dec 19, 2016

Conversation

Sacha0
Copy link
Member

@Sacha0 Sacha0 commented Dec 7, 2016

A few elementwise operations over pairs of sparse matrices (e.g. +, min) are implemented as short children of broadcast preceded by a (same-)shape check. This pull request reimplements those operations in terms of map. Best!

Note: This pull request should not pass CI prior to rebasing on #19518.

@kshyatt kshyatt added domain:arrays:sparse Sparse arrays domain:broadcast Applying a function over a collection labels Dec 7, 2016
@Sacha0
Copy link
Member Author

Sacha0 commented Dec 13, 2016

Rebased with #19518 in. Should be in shape if CI approves. Best!

@Sacha0
Copy link
Member Author

Sacha0 commented Dec 17, 2016

Absent objections or requests for time, I plan to merge this PR Sunday morning PST. Best!

@tkelman
Copy link
Contributor

tkelman commented Dec 17, 2016

are mismatched-shape cases covered by existing tests?

@Sacha0
Copy link
Member Author

Sacha0 commented Dec 17, 2016

are mismatched-shape cases covered by existing tests?

The checks/throws in map and broadcast are. But from a brief look at test/sparse/sparse.jl, those checks/throws are not exercised via the operations touched in this pull request. Updating with tests. Thanks!

@Sacha0
Copy link
Member Author

Sacha0 commented Dec 17, 2016

Now with tests of shape checks. Thanks!

@tkelman
Copy link
Contributor

tkelman commented Dec 17, 2016

lgtm. the sparse broadcast tests have some loops that go through the special cases for 1-by-n and n-by-1, right? those might also be good places to throw in some test_throws to make sure we don't unintentionally change anything unexpected

@Sacha0
Copy link
Member Author

Sacha0 commented Dec 17, 2016

the sparse broadcast tests have some loops that go through the special cases for 1-by-n and n-by-1, right? those might also be good places to throw in some test_throws to make sure we don't unintentionally change anything unexpected

Do you mean adding tests along the lines of these tests for the generic code to e.g. these tests for the binary-specialized code? If so, absolutely, though in a separate PR? Thanks!

@tkelman
Copy link
Contributor

tkelman commented Dec 17, 2016

sure, as long as it doesn't get forgotten. if these operations mistakenly went through the broadcast code path I don't think mismatched size square inputs would be enough to tell the difference between broadcast and map, since both would throw an error.

@Sacha0
Copy link
Member Author

Sacha0 commented Dec 18, 2016

Ah, I see your concern now. Will update with sharper tests. Thanks!

@Sacha0
Copy link
Member Author

Sacha0 commented Dec 18, 2016

The revised tests should differentiate between implementing these operations as map versus broadcast. (map should throw and pass, broadcast should not.)

Realization re. the more general sparse broadcast shape check testing discussion above: I condensed the entry points for sparse broadcast into two methods (in which lie the shape checks) in #19518. The tests for the generic code linked above exercise those methods' shape checks, thereby covering the shape check code for all sparse broadcast cases. Sufficient, or should we do more? Thanks!

@tkelman
Copy link
Contributor

tkelman commented Dec 19, 2016

mac travis freeze unrelated, the added tests passed there

@tkelman tkelman merged commit c604d05 into JuliaLang:master Dec 19, 2016
@Sacha0
Copy link
Member Author

Sacha0 commented Dec 19, 2016

Thanks for reviewing / merging!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
domain:arrays:sparse Sparse arrays domain:broadcast Applying a function over a collection
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants