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 uses of Rebroadcast by SpecifyShape #915
Replace uses of Rebroadcast by SpecifyShape #915
Conversation
f8211eb
to
72094d1
Compare
Sounds like this is the core of our work: finding these dependencies and addressing them directly. |
a865f2d
to
cb0eba7
Compare
The last places that seem to make explicit use of "unbroadcasting" are these: aesara/aesara/tensor/basic_opt.py Lines 156 to 165 in 6cca25e
Lines 750 to 758 in 6cca25e
Lines 878 to 885 in 6cca25e
Lines 1012 to 1017 in 6cca25e
|
8a4b5a9
to
794801e
Compare
aesara/scan/basic.py
Outdated
@@ -751,7 +751,7 @@ def wrap_into_list(x): | |||
# defined in scan utils | |||
sit_sot_scan_inputs.append( | |||
expand_empty( | |||
at.unbroadcast(shape_padleft(actual_arg), 0), | |||
mask_broadcastable(shape_padleft(actual_arg), 0), |
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.
The issue here seems to be creating an EmptyAlloc that does not have a fixed shape of 1 on the leftmost dimension. I didn't dig to find out why/whether this is actually needed
Codecov Report
@@ Coverage Diff @@
## main #915 +/- ##
==========================================
- Coverage 79.27% 79.24% -0.03%
==========================================
Files 152 152
Lines 47965 47848 -117
Branches 10923 10902 -21
==========================================
- Hits 38023 37919 -104
+ Misses 7438 7423 -15
- Partials 2504 2506 +2
|
Tests are passing! |
e021750
to
6d2a42b
Compare
637827f
to
953d410
Compare
2cb7222
to
d93f915
Compare
09de773
to
217f985
Compare
I pushed a commit that removes the use of "unbroadcasting" in In that same commit, several If "unbroadcasting" is not necessary in |
217f985
to
1e26263
Compare
Let's remove it from |
a31c9b0
to
d3e2275
Compare
4cfaaa5
to
dab821b
Compare
All the tests passed without the use of unbroadcast in |
dab821b
to
fb3a880
Compare
Renamed MaskBroadcastable to Unbroadcast |
This rewrite predated partial shape specification in SpecifyShape, and as such ignored possible shape refinement over consecutive SpecifyShapes. It now merges information across consecutive SpecifyShape. Unlike the original, preference is given to the outer SpecifyShape, similar to what local_rebroadcast_lift does.
Adds condition in convert_variable_test which would fail before this change
The behavior was already accounted by filter_variable which is called directly on as a fallback by the optimizer routines
This change was introduced in 9a45333 and did not include specific tests. It was likely introduced to cope with the old restrictions regarding rewrite substitution of variables with different static broadcastable shape information, which was alleviated in aesara-devs#711
fb3a880
to
8a6a871
Compare
This was/is a big improvement! |
This one is not as straightforward as I was hoping, mainly because of the current dependency on the ability to "unbroadcast" variables (i.e., to mask known broadcastable dimensions). This was done via
unbroadcast
andpatternbroadcast
which combined bothunbroadcast
andaddbroadcast
"Unbroadcasting" is still used explicitly in
Scan
andbroadcast_like
.Changes
For now explicit "unbroadcasting" goes through the more limited
MaskBroadcastable
Op
, adapted from the oldRebroadcast
. Everything else that used to rely onRebroadcast
usesSpecifyShape
or the new thin wrapperspecify_broadcastable
.Addresses part of #748 and #917
Closes #955