[Mlir-commits] [mlir] [MLIR][CAPI][python] expose the python binding for linalgOp.getIndexingMaps (PR #136054)

Maksim Levental llvmlistbot at llvm.org
Thu Apr 17 08:38:38 PDT 2025


================
@@ -121,10 +121,15 @@ static void populateDialectLinalgSubmodule(nb::module_ m) {
   m.def("infer_convolution_dimensions", &InferConvolutionDimensions,
         "Infers convolution dimensions", nb::arg("op"));
 
-  m.def("get_indexing_maps_attr", &mlirLinalgGetIndexingMapsAttribute,
-        "Returns the indexing_maps or memoized_indexing_maps attribute for a "
-        "Linalg op.",
-        nb::arg("op"));
+  m.def(
+      "get_indexing_maps_attr",
+      [](MlirOperation op) -> std::optional<MlirAttribute> {
+        MlirAttribute attr = mlirLinalgGetIndexingMapsAttribute(op);
+        if (mlirAttributeIsNull(attr))
+          return std::nullopt;
+        return attr;
+      },
+      "Returns the indexing_maps attribute for a linalg op.");
----------------
makslevental wrote:

but leaving `attribute` in the description is good 

https://github.com/llvm/llvm-project/pull/136054


More information about the Mlir-commits mailing list