-
Notifications
You must be signed in to change notification settings - Fork 170
[MLIR] Add C API for Enzyme dialect (MLIRCAPIEnzyme) #2859
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
Open
agarret7
wants to merge
6
commits into
EnzymeAD:main
Choose a base branch
from
agarret7:mlir-c-api
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 4 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
6ddddf9
[MLIR] Add C API for Enzyme dialect (MLIRCAPIEnzyme)
agarret7 ece264d
fix roundtrip test: avoid greedy %{{.*}} consuming attributes
agarret7 9dc699c
remove redundant test
agarret7 ff91852
[MLIR] add pass creation fns, batch op constructor, MLIR_CAPI_EXPORTE…
agarret7 aac41cf
[MLIR] simplify enzymeActivityAttrGet
agarret7 69e50d7
Merge branch 'main' into mlir-c-api
agarret7 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| add_subdirectory(c) |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| add_mlir_public_c_api_library(MLIRCAPIEnzyme | ||
| EnzymeMLIR.cpp | ||
|
|
||
| DEPENDS | ||
| MLIRImpulseEnumsIncGen | ||
| MLIRImpulseAttributesIncGen | ||
|
|
||
| LINK_LIBS PUBLIC | ||
| MLIRIR | ||
| MLIRCAPIIR | ||
|
|
||
| LINK_LIBS PRIVATE | ||
| MLIREnzyme | ||
| MLIRImpulse | ||
| MLIREnzymeTransforms | ||
| MLIREnzymeAnalysis | ||
| MLIREnzymeAutoDiffInterface | ||
| MLIREnzymeImplementations | ||
| ) |
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
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
Oops, something went wrong.
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.
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.
@agarret7 this can be simplified, see https://github.com/EnzymeAD/Reactant.jl/blob/a1092b113c9568b14eafad4eceaa89837eeae64a/deps/ReactantExtra/API.cpp#L390
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.
Thank you for the feedback! Will simplify
enzymeActivityAttrGet. Also wondering if we shouldn't removeenzymeAutoDiffOpCreate,enzymeForwardDiffOpCreate,enzymeJacobianOpCreate,enzymeBatchOpCreate, andactivityArrayAttrfrom this PR (the rest could be built downstream). What do you think, worth keeping?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.
ditto for
enzymeRegisterPassesThere 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.
for Op creation, at least in Reactant.jl, we always use
mlirOperationCreate, so they are clearly not required.enzymeRegisterPassesmight be required though because AFAIK there's no other way to create a pass without calling the C++ API right?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.
even if not required I'm okay with keeping it, if it makes your or other downstream folks life easier
Uh oh!
There was an error while loading. Please reload this page.
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.
enzymeRegisterPassesalso isn't strictly needed today. Pass constructors return the pass directly, so you can add to a localPassManagerwithout the global registry (unsafety can be wrapped):The registry does matter for MLIR string parsing (
mlir-opt --pass-pipeline=...), which melior already exposes throughparse_pass_pipeline.Given that, I suggest:
enzymeCreate*Passconstructors as it's needed to append toPassManagerdirectlyenzymeRegisterPassesfor themlir-optpipeline.*Op-construction helpers, since both should be expressible with the help of melior's existing builders (OperationBuilder+enzymeActivityAttrGet).Curious what you think.
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.
I'd go for keeping them, if it may make folks lives easier longer term [not just the work we're doing in julia or rust right now]