Skip to content

Commit

Permalink
Move exported files behind filegroups (#2504)
Browse files Browse the repository at this point in the history
It is problematic to include StableHLO source files from non-StableHLO
projects. It makes renaming files and dependencies much more difficult.

Hiding file names behind a target that lives in StableHLO should help
with the file renames case. There isn't a good way to keep a dependency
list in StableHLO, but the only dependency of python bindings should be
CAPI so that shouldn't be too problematic.
  • Loading branch information
GleasonK authored Aug 23, 2024
1 parent 13bf01c commit b98a00f
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 9 deletions.
20 changes: 17 additions & 3 deletions BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,9 @@ package(

exports_files([
"LICENSE",
"stablehlo/integrations/python/ChloModule.cpp",
# Export to be used by MLIR-free python binding impls
"stablehlo/integrations/python/StablehloApi.cpp",
"stablehlo/integrations/python/StablehloApi.h",
"stablehlo/integrations/python/StablehloModule.cpp",
"stablehlo/integrations/python/VhloModule.cpp",
])

filegroup(
Expand Down Expand Up @@ -254,6 +252,13 @@ td_library(
],
)

filegroup(
name = "chlo_py_api_files",
srcs = [
"stablehlo/integrations/python/ChloModule.cpp",
],
)

cc_library(
name = "chlo_ops",
srcs = [
Expand Down Expand Up @@ -1021,6 +1026,15 @@ gentbl_filegroup(
],
)

filegroup(
name = "stablehlo_py_api_files",
srcs = [
"stablehlo/integrations/python/StablehloApi.cpp",
"stablehlo/integrations/python/StablehloApi.h",
"stablehlo/integrations/python/StablehloModule.cpp",
],
)

td_library(
name = "stablehlo_ops_td_files",
srcs = [
Expand Down
13 changes: 7 additions & 6 deletions stablehlo/integrations/c/StablehloApi.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,9 @@ MLIR_CAPI_EXPORTED void stablehloGetMinimumVersion(MlirStringCallback callback,

// For two given version strings, return the smaller version.
// Returns failure if either version is not a valid version string.
MlirLogicalResult stablehloGetSmallerVersion(MlirStringRef version1,
MlirStringRef version2,
MlirStringCallback callback,
void* userData);
MLIR_CAPI_EXPORTED MlirLogicalResult
stablehloGetSmallerVersion(MlirStringRef version1, MlirStringRef version2,
MlirStringCallback callback, void* userData);

// Write a StableHLO program expressed as a string (either prettyprinted MLIR
// module or MLIR bytecode) to a portable artifact.
Expand Down Expand Up @@ -116,7 +115,9 @@ MLIR_CAPI_EXPORTED MlirModule stablehloDeserializePortableArtifact(
// Entrypoint for calling the StableHLO reference interpreter.
// Returns an array attribute of dense element attributes for results.
// Sets error code to non-zero on failure.
MlirAttribute stablehloEvalModule(MlirModule module, int nArgs,
MlirAttribute const* args, int* errorCode);
MLIR_CAPI_EXPORTED MlirAttribute stablehloEvalModule(MlirModule module,
int nArgs,
MlirAttribute const* args,
int* errorCode);

#endif // STABLEHLO_INTEGRATIONS_C_STABLEHLOAPI_H_

0 comments on commit b98a00f

Please sign in to comment.