[all-commits] [llvm/llvm-project] afe75b: [mlir python] Add nanobind support for standalone ...
Peter Hawkins via All-commits
all-commits at lists.llvm.org
Tue Dec 3 09:13:57 PST 2024
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: afe75b4d5fcebd6fdd292ca1797de1b35cb687b0
https://github.com/llvm/llvm-project/commit/afe75b4d5fcebd6fdd292ca1797de1b35cb687b0
Author: Peter Hawkins <phawkins at google.com>
Date: 2024-12-03 (Tue, 03 Dec 2024)
Changed paths:
M mlir/cmake/modules/AddMLIRPython.cmake
M mlir/cmake/modules/MLIRDetectPythonEnv.cmake
M mlir/docs/Bindings/Python.md
M mlir/examples/standalone/python/CMakeLists.txt
R mlir/examples/standalone/python/StandaloneExtension.cpp
A mlir/examples/standalone/python/StandaloneExtensionNanobind.cpp
A mlir/examples/standalone/python/StandaloneExtensionPybind11.cpp
R mlir/examples/standalone/python/mlir_standalone/dialects/standalone.py
A mlir/examples/standalone/python/mlir_standalone/dialects/standalone_nanobind.py
A mlir/examples/standalone/python/mlir_standalone/dialects/standalone_pybind11.py
M mlir/examples/standalone/test/python/smoketest.py
A mlir/include/mlir/Bindings/Python/Diagnostics.h
A mlir/include/mlir/Bindings/Python/NanobindAdaptors.h
M mlir/include/mlir/Bindings/Python/PybindAdaptors.h
M mlir/lib/Bindings/Python/DialectLLVM.cpp
M mlir/lib/Bindings/Python/TransformInterpreter.cpp
M mlir/python/CMakeLists.txt
M mlir/python/mlir/dialects/python_test.py
M mlir/python/requirements.txt
M mlir/test/python/dialects/python_test.py
M mlir/test/python/lib/CMakeLists.txt
R mlir/test/python/lib/PythonTestModule.cpp
A mlir/test/python/lib/PythonTestModuleNanobind.cpp
A mlir/test/python/lib/PythonTestModulePybind11.cpp
M utils/bazel/WORKSPACE
M utils/bazel/llvm-project-overlay/mlir/BUILD.bazel
A utils/bazel/third_party_build/nanobind.BUILD
A utils/bazel/third_party_build/robin_map.BUILD
Log Message:
-----------
[mlir python] Add nanobind support for standalone dialects. (#117922)
This PR allows out-of-tree dialects to write Python dialect modules
using nanobind instead of pybind11.
It may make sense to migrate in-tree dialects and some of the ODS Python
infrastructure to nanobind, but that is a topic for a future change.
This PR makes the following changes:
* adds nanobind to the CMake and Bazel build systems. We also add
robin_map to the Bazel build, which is a dependency of nanobind.
* adds a PYTHON_BINDING_LIBRARY option to various CMake functions, such
as declare_mlir_python_extension, allowing users to select a Python
binding library.
* creates a fork of mlir/include/mlir/Bindings/Python/PybindAdaptors.h
named NanobindAdaptors.h. This plays the same role, using nanobind
instead of pybind11.
* splits CollectDiagnosticsToStringScope out of PybindAdaptors.h and
into a new header mlir/include/mlir/Bindings/Python/Diagnostics.h, since
it is code that is no way related to pybind11 or for that matter,
Python.
* changed the standalone Python extension example to have both pybind11
and nanobind variants.
* changed mlir/python/mlir/dialects/python_test.py to have both pybind11
and nanobind variants.
Notes:
* A slightly unfortunate thing that I needed to do in the CMake
integration was to use FindPython in addition to FindPython3, since
nanobind's CMake integration expects the Python_ names for variables.
Perhaps there's a better way to do this.
To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications
More information about the All-commits
mailing list