-
Notifications
You must be signed in to change notification settings - Fork 29
Refactor compile
and test buffer donation
#126
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
Merged
Merged
Conversation
This file contains hidden or 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
Closed
6d71f10
to
f40a263
Compare
Benchmark Results
Benchmark PlotsA plot of the benchmark results have been uploaded as an artifact to the workflow run for this PR. |
f40a263
to
af7955b
Compare
wsmoses
reviewed
Sep 26, 2024
wsmoses
reviewed
Sep 26, 2024
wsmoses
reviewed
Sep 26, 2024
wsmoses
approved these changes
Sep 26, 2024
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.
LGTM just ome minor nits
Segfaults if MLIR has not been correctly generated
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 refactors
compile
in a series of smaller functions that makes it easier to test different parts of it. In particular, we use it to test buffer donation but could be used to test other parts as well.The new functions are:
compile_mlir
This is the oldcompile_to_module!
but added a new method such that it creates and activates the MLIR context by itself and returns the MLIR module.code_hlo
andcompile
) with slight variations.CompiledModule
).compile
... so this just activates the context where is needed.compile_xla
Calls tocompile_mlir
and passes the result to XLA for compilation.codegen_flatten
Generates the Julia code that unwraps the input arguments into the XLA buffers (i.e. the linearization)._flatten
suffix is a reference to theflatten
function passed toregister_pytree_node
in JAX, which has a similar functionality.codegen_unflatten
Generates the Julia code that rewraps the processed XLA buffers into the result datatypes (i.e. the delinearization)._unflatten
suffix is a reference to theunflatten
function passed toregister_pytree_node
in JAX, which has a similar functionality.codegen_xla_call
Generates the Julia code that calls the XLA-generated executable.This way, buffer donation can be checked just using
compile_mlir
and then checking manually against the returnedlinear_args
andpreserved_args
.The refactor of
compile
is due to the fact that I had to debug it many times, and it's hard to follow without more structure.I'm trying to rebase #123 since it changed some stuff on
compile
.