Skip to content
This repository was archived by the owner on Oct 11, 2025. It is now read-only.

Commit 417f29c

Browse files
authored
[MLIR][Python] Python binding support for IntegerSet attribute (#107640)
Support IntegerSet attribute python binding.
1 parent 221f9cb commit 417f29c

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

mlir/lib/Bindings/Python/IRAttributes.cpp

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,26 @@ class PyAffineMapAttribute : public PyConcreteAttribute<PyAffineMapAttribute> {
147147
}
148148
};
149149

150+
class PyIntegerSetAttribute
151+
: public PyConcreteAttribute<PyIntegerSetAttribute> {
152+
public:
153+
static constexpr IsAFunctionTy isaFunction = mlirAttributeIsAIntegerSet;
154+
static constexpr const char *pyClassName = "IntegerSetAttr";
155+
using PyConcreteAttribute::PyConcreteAttribute;
156+
static constexpr GetTypeIDFunctionTy getTypeIdFunction =
157+
mlirIntegerSetAttrGetTypeID;
158+
159+
static void bindDerived(ClassTy &c) {
160+
c.def_static(
161+
"get",
162+
[](PyIntegerSet &integerSet) {
163+
MlirAttribute attr = mlirIntegerSetAttrGet(integerSet.get());
164+
return PyIntegerSetAttribute(integerSet.getContext(), attr);
165+
},
166+
py::arg("integer_set"), "Gets an attribute wrapping an IntegerSet.");
167+
}
168+
};
169+
150170
template <typename T>
151171
static T pyTryCast(py::handle object) {
152172
try {
@@ -1426,7 +1446,6 @@ py::object symbolRefOrFlatSymbolRefAttributeCaster(PyAttribute &pyAttribute) {
14261446

14271447
void mlir::python::populateIRAttributes(py::module &m) {
14281448
PyAffineMapAttribute::bind(m);
1429-
14301449
PyDenseBoolArrayAttribute::bind(m);
14311450
PyDenseBoolArrayAttribute::PyDenseArrayIterator::bind(m);
14321451
PyDenseI8ArrayAttribute::bind(m);
@@ -1466,6 +1485,7 @@ void mlir::python::populateIRAttributes(py::module &m) {
14661485
PyOpaqueAttribute::bind(m);
14671486
PyFloatAttribute::bind(m);
14681487
PyIntegerAttribute::bind(m);
1488+
PyIntegerSetAttribute::bind(m);
14691489
PyStringAttribute::bind(m);
14701490
PyTypeAttribute::bind(m);
14711491
PyGlobals::get().registerTypeCaster(

0 commit comments

Comments
 (0)