-
-
Notifications
You must be signed in to change notification settings - Fork 151
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
Update Scan
optimizations and fix Scan
+ RandomVariable
shape inference issues
#635
Merged
brandonwillard
merged 15 commits into
aesara-devs:main
from
brandonwillard:fix-scalar-shape-cloning
Nov 18, 2021
Merged
Update Scan
optimizations and fix Scan
+ RandomVariable
shape inference issues
#635
brandonwillard
merged 15 commits into
aesara-devs:main
from
brandonwillard:fix-scalar-shape-cloning
Nov 18, 2021
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
brandonwillard
added
important
refactor
This issue involves refactoring
Scan
Involves the `Scan` `Op`
labels
Oct 28, 2021
Codecov Report
@@ Coverage Diff @@
## main #635 +/- ##
==========================================
- Coverage 77.16% 77.14% -0.02%
==========================================
Files 156 156
Lines 47007 47022 +15
Branches 10281 10282 +1
==========================================
+ Hits 36271 36277 +6
- Misses 8150 8157 +7
- Partials 2586 2588 +2
|
brandonwillard
force-pushed
the
fix-scalar-shape-cloning
branch
3 times, most recently
from
October 29, 2021 17:52
6c61870
to
3bc437e
Compare
brandonwillard
force-pushed
the
fix-scalar-shape-cloning
branch
2 times, most recently
from
November 15, 2021 19:39
dc58c1c
to
f540230
Compare
brandonwillard
force-pushed
the
fix-scalar-shape-cloning
branch
2 times, most recently
from
November 15, 2021 22:31
8c17336
to
306528a
Compare
brandonwillard
force-pushed
the
fix-scalar-shape-cloning
branch
from
November 15, 2021 22:40
306528a
to
e7f48be
Compare
brandonwillard
force-pushed
the
fix-scalar-shape-cloning
branch
from
November 16, 2021 03:07
e7f48be
to
eed637d
Compare
brandonwillard
changed the title
Update
Update Nov 16, 2021
Scan
optimizationsScan
optimizations and fix Scan
+ RandomVariable
shape inference issues
brandonwillard
force-pushed
the
fix-scalar-shape-cloning
branch
from
November 16, 2021 04:46
eed637d
to
afefb01
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
bug
Something isn't working
graph rewriting
important
refactor
This issue involves refactoring
Scan
Involves the `Scan` `Op`
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 PR refactors some of the
Scan
optimizations in order to fixScan
+RandomVariable
shape inference issues. These changes are a part of #584 and are a solution to #608.Replace use of
FunctionGraph.replace*
inadd_nitsot_outputs
This isn't directly related to Fix
PushOutNonSeqScan
+RandomVariable
shape inference error inScan
s #608, so it can be taken care of later.Use
SpecifyShape
with theRandomVariable
'ssize
parameterThis makes it possible for
Scan
's shape inference to track the shape of the cloned non-sequence variables it makes out ofRandomVariable
size
parameters.Add canonicalizations for
SpecifyShape
These are necessary for broadcastable inference in
RandomVariable
whenSpecifyShape
is used.Convert global
Scan
optimizations to local optimizations.It looks like the current
Scan
optimizations mutate theFunctionGraph
s in-place in different stages, and this might be leading to inconsistent intermediate graph states that fail when the shape inference optimization is performed.This seems to be the case for the MWE in Fix
PushOutNonSeqScan
+RandomVariable
shape inference error inScan
s #608, because shape inference errors occur when the clonedsize
parameter in theScan
's body (i.e. thesize
variable in the graph constructed by thescan_body
function) is encountered. It should be possible to assign the shape ofsize_at
to that variable in theShapeFeature
; however, the outersize_at
is nowhere to be found in theFunctionGraph
that's being optimized—implying that a validScan
isn't being used to replace the originalScan
, but that the originalScan
is possibly being changed in multipleFunctionGraph.replace*
steps.From inspection of
aesara.graph.opt
, it's clear that this is a distinct possibility, since most of the optimizations are global optimizations with multipleFunctionGraph.replace_all*
calls in a single optimization. This approach to graph rewriting is rather undesirable for the reasons mentioned above, so this PR will attempt to remedy the situation.