[Mlir-commits] [mlir] 8b134d0 - [mlir][transform][python] Add AnyValueType to bindings.

Ingo Müller llvmlistbot at llvm.org
Fri Aug 11 04:26:28 PDT 2023


Author: Ingo Müller
Date: 2023-08-11T11:26:23Z
New Revision: 8b134d0b3593a511bff3046d89d35a7d09c469bd

URL: https://github.com/llvm/llvm-project/commit/8b134d0b3593a511bff3046d89d35a7d09c469bd
DIFF: https://github.com/llvm/llvm-project/commit/8b134d0b3593a511bff3046d89d35a7d09c469bd.diff

LOG: [mlir][transform][python] Add AnyValueType to bindings.

This patch adds the MLIR C bindings and the corresponding Python bindings of the AnyValueType of the transform dialect.

Reviewed By: springerm

Differential Revision: https://reviews.llvm.org/D157638

Added: 
    

Modified: 
    mlir/include/mlir-c/Dialect/Transform.h
    mlir/lib/Bindings/Python/DialectTransform.cpp
    mlir/lib/CAPI/Dialect/Transform.cpp

Removed: 
    


################################################################################
diff  --git a/mlir/include/mlir-c/Dialect/Transform.h b/mlir/include/mlir-c/Dialect/Transform.h
index 0409890b214062..954575925cc5c4 100644
--- a/mlir/include/mlir-c/Dialect/Transform.h
+++ b/mlir/include/mlir-c/Dialect/Transform.h
@@ -27,6 +27,14 @@ MLIR_CAPI_EXPORTED bool mlirTypeIsATransformAnyOpType(MlirType type);
 
 MLIR_CAPI_EXPORTED MlirType mlirTransformAnyOpTypeGet(MlirContext ctx);
 
+//===---------------------------------------------------------------------===//
+// AnyValueType
+//===---------------------------------------------------------------------===//
+
+MLIR_CAPI_EXPORTED bool mlirTypeIsATransformAnyValueType(MlirType type);
+
+MLIR_CAPI_EXPORTED MlirType mlirTransformAnyValueTypeGet(MlirContext ctx);
+
 //===---------------------------------------------------------------------===//
 // OperationType
 //===---------------------------------------------------------------------===//

diff  --git a/mlir/lib/Bindings/Python/DialectTransform.cpp b/mlir/lib/Bindings/Python/DialectTransform.cpp
index e4b8cee73ef163..932e40220057c1 100644
--- a/mlir/lib/Bindings/Python/DialectTransform.cpp
+++ b/mlir/lib/Bindings/Python/DialectTransform.cpp
@@ -31,6 +31,20 @@ void populateDialectTransformSubmodule(const pybind11::module &m) {
       "Get an instance of AnyOpType in the given context.", py::arg("cls"),
       py::arg("context") = py::none());
 
+  //===-------------------------------------------------------------------===//
+  // AnyValueType
+  //===-------------------------------------------------------------------===//
+
+  auto anyValueType =
+      mlir_type_subclass(m, "AnyValueType", mlirTypeIsATransformAnyValueType);
+  anyValueType.def_classmethod(
+      "get",
+      [](py::object cls, MlirContext ctx) {
+        return cls(mlirTransformAnyValueTypeGet(ctx));
+      },
+      "Get an instance of AnyValueType in the given context.", py::arg("cls"),
+      py::arg("context") = py::none());
+
   //===-------------------------------------------------------------------===//
   // OperationType
   //===-------------------------------------------------------------------===//

diff  --git a/mlir/lib/CAPI/Dialect/Transform.cpp b/mlir/lib/CAPI/Dialect/Transform.cpp
index d3cd4e3d0bb289..5841f6783ad5f1 100644
--- a/mlir/lib/CAPI/Dialect/Transform.cpp
+++ b/mlir/lib/CAPI/Dialect/Transform.cpp
@@ -29,6 +29,18 @@ MlirType mlirTransformAnyOpTypeGet(MlirContext ctx) {
   return wrap(transform::AnyOpType::get(unwrap(ctx)));
 }
 
+//===---------------------------------------------------------------------===//
+// AnyValueType
+//===---------------------------------------------------------------------===//
+
+bool mlirTypeIsATransformAnyValueType(MlirType type) {
+  return isa<transform::AnyValueType>(unwrap(type));
+}
+
+MlirType mlirTransformAnyValueTypeGet(MlirContext ctx) {
+  return wrap(transform::AnyValueType::get(unwrap(ctx)));
+}
+
 //===---------------------------------------------------------------------===//
 // OperationType
 //===---------------------------------------------------------------------===//


        


More information about the Mlir-commits mailing list