-
Notifications
You must be signed in to change notification settings - Fork 128
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
Expose a StableHLO Dialect CAPI that doesn't requires building upstream dialects #2705
Conversation
This looks mostly good! And definitely a good first step. I think the part 2 of this (can be separate and I can try my hand at it) would be splitting the dialect API passes from Or maybe the overhead of this dep isn't too bad in which case we don't need to do this... Have you done any analysis on the library size to compare before/after?
Thank you so much for this. This tends to be the trickier part of these CAPI / Python binding changes :) Also RE lint failure: |
@GleasonK tbh I'm pretty OK with keeping the other passes, as long as they don't pull other dialects (or perhaps, LinAlg only). For instance, CHLO -> StableHLO. Or perhaps you count them as serialization passes too ? |
Let's keep the passes. I was thinking if we should split into a hypothetical "framework_passes" and "plugin_passes" looking at the things in passes this may not be a big deal:
This shouldn't pull in many new MLIR dialects, maybe linalg by the sound of it but maybe not even(?). Happy to defer that decision, can prototype and see if the binary size changes much. |
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, will need a rebase, and there's a buildifier lint error
@GleasonK Should be good ! Many thanks for the review. |
Not sure what happened... Buildified again. |
Thanks! Also I've sent you an OpenXLA org invite so your future PRs won't need approval to run CI |
This is an attempt PR to address #2593
This PR introduces 2 seperate targets:
stablehlo_dialect_capi
which embeds StableHLO + Serialization.stablehlo_unified_capi
which embedsstablehlo_dialect_capi
as well as transformation passes (incl linalg) and reference interpreter.Note:
I kept CHLO C API as a separate target as it was. I could include it in
stablehlo_dialect_capi
but since it was already exposed as a separate target and not included in the formerstablehlo_capi
I didn't do it just yet.stablehlo_passes
is still included indialect_capi
because it's needed by serialisation.I kept an alias
stablehlo_capi
onstablehlo_unified_capi
just so that downstreams don't have to rename the target they depend on. Let me know if this is un-needed.I had to extract a small type conversion delcared in
linagl_passes
but used instablehlo_passes
which forcedstablehlo_passes
to depend onlinagl_passes
.I named this extracted target
stablehlo_type_conversions
and put it understablehlo/transforms/conversions
. Let me know if this is not the right location.Dependency Graph
stablehlo_dialect_capi
stablehlo_unified_capi
Finally I tested integration in XLA and JAX as well as python bindings to validate that it links correctly.
Let me know what you think and if you see further changes to add to this PR :)