You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently CAPI builds linalg and arith, etc -- but most users of CAPI (frameworks) only want StableHLO+CHLO+Serialization. Would be great to offer a stablehlo_dialect_capi which only has core APIs.
One possible separation direction:
stablehlo_dialect_capi: Just StableHLO+CHLO+Serialization APIs, these are the things useful for PJRT frameworks.
stablehlo_unified_capi: A separate target which builds the dialect CAPI along with the transformation passes / reference interpreter / other useful APIs, likely will be the target used for StableHLO python bindings
I'm having a go at this and am nearly ready to submit a draft PR.
Before submitting anything, I would love your thoughts on a few points:
1. API Export vs Re-export
Basically, either:
stablehlo_unified_capi target exports StablehloDialectApi.h as well as StablehloUnifiedApi.h (in the hdrs attribute) (but then downstreams users like python bindings have to import the 2 of them)
StablehloUnifiedApi.h re-exports StablehloDialectApi.h which becomes the only header to import.
2. Common deps between new StablehloUnifiedApi and StablehloDialectApi
Currently, stablehlo_capi compiles StablehloAttributes, StablehloDialect and StablehloTypes and exports their respective headers which will likely needed by users of the new stablehlo_dialect_capi.
I have several options:
Split those further into multiple targets and depend on them on both stablehlo_unified_capi and stablehlo_dialect_capi targets. (But then both targets need to either re-rexports the headers or exports them for manual inclusion downstream).
Have stablehlo_dialect_capi depend on them and stablehlo_unified_capi depend on stablehlo_dialect_capi.
Have both stablehlo_unified_capi and stablehlo_dialect_capi compile those files and exports their headers.
3. Backward compat for target names
Should I expose aliases so that stablehlo_capi points to stablehlo_unified_capi to preserve backward compat ?
If confusing, I can go ahead and submit what I have and we start from there ?
Request description
Currently CAPI builds linalg and arith, etc -- but most users of CAPI (frameworks) only want StableHLO+CHLO+Serialization. Would be great to offer a
stablehlo_dialect_capi
which only has core APIs.One possible separation direction:
stablehlo_dialect_capi
: Just StableHLO+CHLO+Serialization APIs, these are the things useful for PJRT frameworks.stablehlo_unified_capi
: A separate target which builds the dialect CAPI along with the transformation passes / reference interpreter / other useful APIs, likely will be the target used for StableHLO python bindingsThis will probably require splitting the serialization APIs into a separate file
StablehloDialectApi.h
andStablehloUnifiedApi.h
. The following functions should go into the dialect API: https://github.com/openxla/stablehlo/blob/main/stablehlo/integrations/c/StablehloApi.h#L23-L117The reference API and pass registration should go into the unified API target:
https://source.corp.google.com/piper///depot/google3/third_party/stablehlo/stablehlo/integrations/c/StablehloPasses.h
Looking at the CAPI deps today, I'm surprised that this requires upstream dialects, so definitely something to look into.
(Noted by @steeve at recent OpenXLA community meeting)
The text was updated successfully, but these errors were encountered: