Skip to content

Fix Broadcast.broadcast_shape inference#313

Open
charleskawczynski wants to merge 2 commits intoJuliaArrays:masterfrom
charleskawczynski:ck/310_alternative
Open

Fix Broadcast.broadcast_shape inference#313
charleskawczynski wants to merge 2 commits intoJuliaArrays:masterfrom
charleskawczynski:ck/310_alternative

Conversation

@charleskawczynski
Copy link
Copy Markdown

@charleskawczynski charleskawczynski commented Sep 21, 2023

This is an alternative to #312.

I noticed that, in the case when the union combines both entries, the result should still be correct (that's what the existing code is doing afterall). If we make tuples always combine entries then we have the benefit of Base.Broadcast.broadcast_shape both being stack allocated and fully type inferred. This fixes my upstream issue (and I would prefer this solution over #312).

@jishnub, does this look okay?

Closes #310.

@codecov
Copy link
Copy Markdown

codecov bot commented Sep 22, 2023

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.48%. Comparing base (cf7c29c) to head (549a1e1).
⚠️ Report is 123 commits behind head on master.

Additional details and impacted files
@@             Coverage Diff             @@
##           master     #313       +/-   ##
===========================================
+ Coverage    0.00%   92.48%   +92.48%     
===========================================
  Files          16       16               
  Lines        1469     1491       +22     
===========================================
+ Hits            0     1379     +1379     
+ Misses       1469      112     -1357     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@jishnub
Copy link
Copy Markdown
Member

jishnub commented Sep 22, 2023

This appears to be breaking. Could you look into the failing tests?

@charleskawczynski
Copy link
Copy Markdown
Author

This appears to be breaking. Could you look into the failing tests?

Ah, sorry, I didn't realize there were downstream tests, I only checked the unit tests locally. How can I run the downstream tests? It looks like I need to clone the downstream and dev this branch?

@jishnub
Copy link
Copy Markdown
Member

jishnub commented Sep 22, 2023

Yes, that's the way

@dlfivefifty
Copy link
Copy Markdown
Member

I guess this is only inferrable for vector broadcasting? I think that's fine

@charleskawczynski
Copy link
Copy Markdown
Author

I guess this is only inferrable for vector broadcasting? I think that's fine

It's not clear to me that vector broadcasting is the only thing impacted, but I'm not super familiar with this package's internals. This is only overloading cases when BlockedUnitRange's last entries are Tuples, so that it's stack-allocated / fully inferred. The tests that are added in this PR fail on the master branch (see #310).


# sortedunion can assume inputs are already sorted so this could be improved
sortedunion(a,b) = sort!(union(a,b))
sortedunion_tuple(a::Tuple, b::Tuple) = (a..., b...)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't this not really a union since it doesn't remove elements that a and b might have in common?

Could call it disjointsortedunion_tuple or something like that to clarify the inputs should also be disjoint.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed. Also, I'm not sure how I can fix the issues that come from this change..

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the only "solution" might be to somehow avoid this codepath, which I've not had enough time to try

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Broadcast.broadcast_shape for BlockedUnitRanges fails inference

4 participants