[Mlir-commits] [mlir] [MLIR][Standalone] don't register everything	(PR #157688)
    Maksim Levental 
    llvmlistbot at llvm.org
       
    Tue Sep  9 08:59:08 PDT 2025
    
    
  
https://github.com/makslevental updated https://github.com/llvm/llvm-project/pull/157688
>From 0ab91593df8a9ca5df6ccd7b9e25c7f087603cdb Mon Sep 17 00:00:00 2001
From: Maksim Levental <maksim.levental at gmail.com>
Date: Tue, 9 Sep 2025 10:09:44 -0500
Subject: [PATCH 1/3] [MLIR][Standalone] don't register everything
We only need to register `builtin`.
---
 mlir/examples/standalone/python/CMakeLists.txt | 6 ------
 1 file changed, 6 deletions(-)
diff --git a/mlir/examples/standalone/python/CMakeLists.txt b/mlir/examples/standalone/python/CMakeLists.txt
index cb10518e94e33..33e2640300043 100644
--- a/mlir/examples/standalone/python/CMakeLists.txt
+++ b/mlir/examples/standalone/python/CMakeLists.txt
@@ -54,9 +54,6 @@ add_mlir_python_common_capi_library(StandalonePythonCAPI
   RELATIVE_INSTALL_ROOT "../../../.."
   DECLARED_SOURCES
     StandalonePythonSources
-    # TODO: Remove this in favor of showing fine grained registration once
-    # available.
-    MLIRPythonExtension.RegisterEverything
     MLIRPythonSources.Core
     MLIRPythonSources.Dialects.builtin
 )
@@ -70,9 +67,6 @@ add_mlir_python_modules(StandalonePythonModules
   INSTALL_PREFIX "${MLIR_BINDINGS_PYTHON_INSTALL_PREFIX}"
   DECLARED_SOURCES
     StandalonePythonSources
-    # TODO: Remove this in favor of showing fine grained registration once
-    # available.
-    MLIRPythonExtension.RegisterEverything
     MLIRPythonSources.Core
     MLIRPythonSources.Dialects.builtin
   COMMON_CAPI_LINK_LIBS
>From ef55a39efe518b05b543cf905c576ef3eeb9e143 Mon Sep 17 00:00:00 2001
From: Maksim Levental <maksim.levental at gmail.com>
Date: Tue, 9 Sep 2025 08:21:19 -0700
Subject: [PATCH 2/3] Update CMakeLists.txt
---
 mlir/examples/standalone/python/CMakeLists.txt | 2 ++
 1 file changed, 2 insertions(+)
diff --git a/mlir/examples/standalone/python/CMakeLists.txt b/mlir/examples/standalone/python/CMakeLists.txt
index 33e2640300043..2c6a2ffde10b7 100644
--- a/mlir/examples/standalone/python/CMakeLists.txt
+++ b/mlir/examples/standalone/python/CMakeLists.txt
@@ -28,6 +28,7 @@ declare_mlir_python_extension(StandalonePythonSources.Pybind11Extension
     StandaloneExtensionPybind11.cpp
   EMBED_CAPI_LINK_LIBS
     StandaloneCAPI
+    MLIRCAPITransforms
   PYTHON_BINDINGS_LIBRARY pybind11
 )
 
@@ -38,6 +39,7 @@ declare_mlir_python_extension(StandalonePythonSources.NanobindExtension
     StandaloneExtensionNanobind.cpp
   EMBED_CAPI_LINK_LIBS
     StandaloneCAPI
+    MLIRCAPITransforms
   PYTHON_BINDINGS_LIBRARY nanobind
   GENERATE_TYPE_STUBS
 )
>From a9af4175818437564c599d1cf201e5e261cb8c69 Mon Sep 17 00:00:00 2001
From: Maksim Levental <maksim.levental at gmail.com>
Date: Tue, 9 Sep 2025 08:58:59 -0700
Subject: [PATCH 3/3] Update StandaloneExtensionNanobind.cpp
---
 .../standalone/python/StandaloneExtensionNanobind.cpp       | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/mlir/examples/standalone/python/StandaloneExtensionNanobind.cpp b/mlir/examples/standalone/python/StandaloneExtensionNanobind.cpp
index 189ebac368bf5..aad44dc7f2137 100644
--- a/mlir/examples/standalone/python/StandaloneExtensionNanobind.cpp
+++ b/mlir/examples/standalone/python/StandaloneExtensionNanobind.cpp
@@ -12,6 +12,7 @@
 #include "Standalone-c/Dialects.h"
 #include "mlir/Bindings/Python/Nanobind.h"
 #include "mlir/Bindings/Python/NanobindAdaptors.h"
+#include "mlir-c/Dialect/Arith.h
 
 namespace nb = nanobind;
 
@@ -22,9 +23,10 @@ NB_MODULE(_standaloneDialectsNanobind, m) {
   auto standaloneM = m.def_submodule("standalone");
 
   standaloneM.def(
-      "register_dialect",
+      "register_dialects",
       [](MlirContext context, bool load) {
-        MlirDialectHandle handle = mlirGetDialectHandle__standalone__();
+        MlirDialectHandle standaloneHandle = mlirGetDialectHandle__standalone__();
+        MlirDialectHandle arithHandle = mlirGetDialectHandle__arith__();
         mlirDialectHandleRegisterDialect(handle, context);
         if (load) {
           mlirDialectHandleLoadDialect(handle, context);
    
    
More information about the Mlir-commits
mailing list