-
-
Notifications
You must be signed in to change notification settings - Fork 156
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
Use flat AST-generated functions for JAX FunctionGraph
conversion
#371
Merged
brandonwillard
merged 5 commits into
aesara-devs:master
from
brandonwillard:ast-jax-linker
Apr 14, 2021
Merged
Use flat AST-generated functions for JAX FunctionGraph
conversion
#371
brandonwillard
merged 5 commits into
aesara-devs:master
from
brandonwillard:ast-jax-linker
Apr 14, 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
FunctionGraph
conversion
8716f02
to
fcd4515
Compare
9b0bcb4
to
b861c01
Compare
Codecov Report
@@ Coverage Diff @@
## master #371 +/- ##
==========================================
+ Coverage 71.91% 71.94% +0.02%
==========================================
Files 166 168 +2
Lines 54736 54753 +17
==========================================
+ Hits 39365 39390 +25
+ Misses 15371 15363 -8
|
2cb9f0a
to
15526e8
Compare
FunctionGraph
conversionFunctionGraph
conversion
0acded9
to
a4bffbd
Compare
4788268
to
9472eaf
Compare
9472eaf
to
c5bb6e3
Compare
Closed
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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 changes the JAX translation process so that it converts
FunctionGraph
s into flattened AST-generated functions instead of nested functions. The resulting code and JAXified functions are much simpler than the previous implementation's.Here's an example:
This implementation uses the same basic idea as the prototype in #365, with the key differences being that it is very streamlined, requires minimal changes to be used with a simple
Linker
base class, and it generates the source first then the AST from that. Because of this, it requires no external libraries and produces easily debuggable functions.This change addresses concerns over potential recomputation of outputs that are referenced more than once in a graph, or that are one of many outputs of a single
Apply
node. A test has also been added to this PR that directly confirms such outputs are always reused and never recomputed (in both cases).Local tests replacing theThis PR now contains a commit that usesElemwise
JAXification withjax.vmap
also appear to work, so, now, we should seriously consider usingjax.vmap
in at least some cases (e.g. forComposite
functions).jax.numpy.vectorize
forElemwise
Op
s withComposite
scalarOp
s.