From b98a00fca14e535ec8793ab15933bf0935f34c9b Mon Sep 17 00:00:00 2001 From: Kevin Gleason Date: Fri, 23 Aug 2024 15:31:08 -0400 Subject: [PATCH] Move exported files behind filegroups (#2504) 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. --- BUILD.bazel | 20 +++++++++++++++++--- stablehlo/integrations/c/StablehloApi.h | 13 +++++++------ 2 files changed, 24 insertions(+), 9 deletions(-) diff --git a/BUILD.bazel b/BUILD.bazel index 6014550f869..0fb1b7cd4c5 100644 --- a/BUILD.bazel +++ b/BUILD.bazel @@ -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( @@ -254,6 +252,13 @@ td_library( ], ) +filegroup( + name = "chlo_py_api_files", + srcs = [ + "stablehlo/integrations/python/ChloModule.cpp", + ], +) + cc_library( name = "chlo_ops", srcs = [ @@ -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 = [ diff --git a/stablehlo/integrations/c/StablehloApi.h b/stablehlo/integrations/c/StablehloApi.h index 77864d6b55a..4c5425081e1 100644 --- a/stablehlo/integrations/c/StablehloApi.h +++ b/stablehlo/integrations/c/StablehloApi.h @@ -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. @@ -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_