[Mlir-commits] [mlir] 9e863cd - [mlir][python][cmake] Allows for specifying `NB_DOMAIN` in `add_mlir_python_extension` (#122865)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Thu Jan 16 07:26:33 PST 2025
Author: erwei-xilinx
Date: 2025-01-16T10:26:29-05:00
New Revision: 9e863cd44945345f22a28cdd3ea12aaa7963345e
URL: https://github.com/llvm/llvm-project/commit/9e863cd44945345f22a28cdd3ea12aaa7963345e
DIFF: https://github.com/llvm/llvm-project/commit/9e863cd44945345f22a28cdd3ea12aaa7963345e.diff
LOG: [mlir][python][cmake] Allows for specifying `NB_DOMAIN` in `add_mlir_python_extension` (#122865)
This PR allows the users to specify the `NB_DOMAIN` for
`add_mlir_python_extension`. This allows users to avoid nanobind domain
conflicts, when python bindings from multiple `mlir` projects were
imported.
(https://nanobind.readthedocs.io/en/latest/faq.html#how-can-i-avoid-conflicts-with-other-projects-using-nanobind)
Added:
Modified:
mlir/CMakeLists.txt
mlir/cmake/modules/AddMLIRPython.cmake
Removed:
################################################################################
diff --git a/mlir/CMakeLists.txt b/mlir/CMakeLists.txt
index a888ac243b044b..9e786154a2b405 100644
--- a/mlir/CMakeLists.txt
+++ b/mlir/CMakeLists.txt
@@ -174,6 +174,8 @@ configure_file(
# disable all package setup and control it themselves.
#-------------------------------------------------------------------------------
+set(MLIR_BINDINGS_PYTHON_NB_DOMAIN "mlir"
+ CACHE STRING "nanobind domain for MLIR python bindings.")
set(MLIR_ENABLE_BINDINGS_PYTHON 0 CACHE BOOL
"Enables building of Python bindings.")
set(MLIR_DETECT_PYTHON_ENV_PRIME_SEARCH 1 CACHE BOOL
diff --git a/mlir/cmake/modules/AddMLIRPython.cmake b/mlir/cmake/modules/AddMLIRPython.cmake
index 0679db9cf93e19..815f65b106d945 100644
--- a/mlir/cmake/modules/AddMLIRPython.cmake
+++ b/mlir/cmake/modules/AddMLIRPython.cmake
@@ -667,7 +667,7 @@ function(add_mlir_python_extension libname extname)
)
elseif(ARG_PYTHON_BINDINGS_LIBRARY STREQUAL "nanobind")
nanobind_add_module(${libname}
- NB_DOMAIN mlir
+ NB_DOMAIN ${MLIR_BINDINGS_PYTHON_NB_DOMAIN}
FREE_THREADED
${ARG_SOURCES}
)
More information about the Mlir-commits
mailing list