}
static void bind(py::module &m) {
- auto cls = ClassTy(m, DerivedTy::pyClassName);
+ auto cls = ClassTy(m, DerivedTy::pyClassName, py::module_local());
cls.def(py::init<PyAffineExpr &>());
DerivedTy::bindDerived(cls);
}
bool isEq() { return mlirIntegerSetIsConstraintEq(set, pos); }
static void bind(py::module &m) {
- py::class_<PyIntegerSetConstraint>(m, "IntegerSetConstraint")
+ py::class_<PyIntegerSetConstraint>(m, "IntegerSetConstraint",
+ py::module_local())
.def_property_readonly("expr", &PyIntegerSetConstraint::getExpr)
.def_property_readonly("is_eq", &PyIntegerSetConstraint::isEq);
}
//----------------------------------------------------------------------------
// Mapping of PyAffineExpr and derived classes.
//----------------------------------------------------------------------------
- py::class_<PyAffineExpr>(m, "AffineExpr")
+ py::class_<PyAffineExpr>(m, "AffineExpr", py::module_local())
.def_property_readonly(MLIR_PYTHON_CAPI_PTR_ATTR,
&PyAffineExpr::getCapsule)
.def(MLIR_PYTHON_CAPI_FACTORY_ATTR, &PyAffineExpr::createFromCapsule)
//----------------------------------------------------------------------------
// Mapping of PyAffineMap.
//----------------------------------------------------------------------------
- py::class_<PyAffineMap>(m, "AffineMap")
+ py::class_<PyAffineMap>(m, "AffineMap", py::module_local())
.def_property_readonly(MLIR_PYTHON_CAPI_PTR_ATTR,
&PyAffineMap::getCapsule)
.def(MLIR_PYTHON_CAPI_FACTORY_ATTR, &PyAffineMap::createFromCapsule)
//----------------------------------------------------------------------------
// Mapping of PyIntegerSet.
//----------------------------------------------------------------------------
- py::class_<PyIntegerSet>(m, "IntegerSet")
+ py::class_<PyIntegerSet>(m, "IntegerSet", py::module_local())
.def_property_readonly(MLIR_PYTHON_CAPI_PTR_ATTR,
&PyIntegerSet::getCapsule)
.def(MLIR_PYTHON_CAPI_FACTORY_ATTR, &PyIntegerSet::createFromCapsule)
static void bind(py::module &m) {
// Debug flags.
- py::class_<PyGlobalDebugFlag>(m, "_GlobalDebug")
+ py::class_<PyGlobalDebugFlag>(m, "_GlobalDebug", py::module_local())
.def_property_static("flag", &PyGlobalDebugFlag::get,
&PyGlobalDebugFlag::set, "LLVM-wide debug flag");
}
}
static void bind(py::module &m) {
- py::class_<PyRegionIterator>(m, "RegionIterator")
+ py::class_<PyRegionIterator>(m, "RegionIterator", py::module_local())
.def("__iter__", &PyRegionIterator::dunderIter)
.def("__next__", &PyRegionIterator::dunderNext);
}
}
static void bind(py::module &m) {
- py::class_<PyRegionList>(m, "RegionSequence")
+ py::class_<PyRegionList>(m, "RegionSequence", py::module_local())
.def("__len__", &PyRegionList::dunderLen)
.def("__getitem__", &PyRegionList::dunderGetItem);
}
}
static void bind(py::module &m) {
- py::class_<PyBlockIterator>(m, "BlockIterator")
+ py::class_<PyBlockIterator>(m, "BlockIterator", py::module_local())
.def("__iter__", &PyBlockIterator::dunderIter)
.def("__next__", &PyBlockIterator::dunderNext);
}
}
static void bind(py::module &m) {
- py::class_<PyBlockList>(m, "BlockList")
+ py::class_<PyBlockList>(m, "BlockList", py::module_local())
.def("__getitem__", &PyBlockList::dunderGetItem)
.def("__iter__", &PyBlockList::dunderIter)
.def("__len__", &PyBlockList::dunderLen)
}
static void bind(py::module &m) {
- py::class_<PyOperationIterator>(m, "OperationIterator")
+ py::class_<PyOperationIterator>(m, "OperationIterator", py::module_local())
.def("__iter__", &PyOperationIterator::dunderIter)
.def("__next__", &PyOperationIterator::dunderNext);
}
}
static void bind(py::module &m) {
- py::class_<PyOperationList>(m, "OperationList")
+ py::class_<PyOperationList>(m, "OperationList", py::module_local())
.def("__getitem__", &PyOperationList::dunderGetItem)
.def("__iter__", &PyOperationList::dunderIter)
.def("__len__", &PyOperationList::dunderLen);
/// Binds the Python module objects to functions of this class.
static void bind(py::module &m) {
- auto cls = ClassTy(m, DerivedTy::pyClassName);
+ auto cls = ClassTy(m, DerivedTy::pyClassName, py::module_local());
cls.def(py::init<PyValue &>(), py::keep_alive<0, 1>());
DerivedTy::bindDerived(cls);
}
/// Defines a Python class in the bindings.
static void bind(py::module &m) {
- py::class_<PyBlockArgumentList>(m, "BlockArgumentList")
+ py::class_<PyBlockArgumentList>(m, "BlockArgumentList", py::module_local())
.def("__len__", &PyBlockArgumentList::dunderLen)
.def("__getitem__", &PyBlockArgumentList::dunderGetItem);
}
}
static void bind(py::module &m) {
- py::class_<PyOpAttributeMap>(m, "OpAttributeMap")
+ py::class_<PyOpAttributeMap>(m, "OpAttributeMap", py::module_local())
.def("__contains__", &PyOpAttributeMap::dunderContains)
.def("__len__", &PyOpAttributeMap::dunderLen)
.def("__getitem__", &PyOpAttributeMap::dunderGetItemNamed)
//----------------------------------------------------------------------------
// Mapping of MlirContext.
//----------------------------------------------------------------------------
- py::class_<PyMlirContext>(m, "Context")
+ py::class_<PyMlirContext>(m, "Context", py::module_local())
.def(py::init<>(&PyMlirContext::createNewContextForInit))
.def_static("_get_live_count", &PyMlirContext::getLiveCount)
.def("_get_context_again",
//----------------------------------------------------------------------------
// Mapping of PyDialectDescriptor
//----------------------------------------------------------------------------
- py::class_<PyDialectDescriptor>(m, "DialectDescriptor")
+ py::class_<PyDialectDescriptor>(m, "DialectDescriptor", py::module_local())
.def_property_readonly("namespace",
[](PyDialectDescriptor &self) {
MlirStringRef ns =
//----------------------------------------------------------------------------
// Mapping of PyDialects
//----------------------------------------------------------------------------
- py::class_<PyDialects>(m, "Dialects")
+ py::class_<PyDialects>(m, "Dialects", py::module_local())
.def("__getitem__",
[=](PyDialects &self, std::string keyName) {
MlirDialect dialect =
//----------------------------------------------------------------------------
// Mapping of PyDialect
//----------------------------------------------------------------------------
- py::class_<PyDialect>(m, "Dialect")
+ py::class_<PyDialect>(m, "Dialect", py::module_local())
.def(py::init<py::object>(), "descriptor")
.def_property_readonly(
"descriptor", [](PyDialect &self) { return self.getDescriptor(); })
//----------------------------------------------------------------------------
// Mapping of Location
//----------------------------------------------------------------------------
- py::class_<PyLocation>(m, "Location")
+ py::class_<PyLocation>(m, "Location", py::module_local())
.def_property_readonly(MLIR_PYTHON_CAPI_PTR_ATTR, &PyLocation::getCapsule)
.def(MLIR_PYTHON_CAPI_FACTORY_ATTR, &PyLocation::createFromCapsule)
.def("__enter__", &PyLocation::contextEnter)
//----------------------------------------------------------------------------
// Mapping of Module
//----------------------------------------------------------------------------
- py::class_<PyModule>(m, "Module")
+ py::class_<PyModule>(m, "Module", py::module_local())
.def_property_readonly(MLIR_PYTHON_CAPI_PTR_ATTR, &PyModule::getCapsule)
.def(MLIR_PYTHON_CAPI_FACTORY_ATTR, &PyModule::createFromCapsule)
.def_static(
//----------------------------------------------------------------------------
// Mapping of Operation.
//----------------------------------------------------------------------------
- py::class_<PyOperationBase>(m, "_OperationBase")
+ py::class_<PyOperationBase>(m, "_OperationBase", py::module_local())
.def("__eq__",
[](PyOperationBase &self, PyOperationBase &other) {
return &self.getOperation() == &other.getOperation();
"Verify the operation and return true if it passes, false if it "
"fails.");
- py::class_<PyOperation, PyOperationBase>(m, "Operation")
+ py::class_<PyOperation, PyOperationBase>(m, "Operation", py::module_local())
.def_static("create", &PyOperation::create, py::arg("name"),
py::arg("results") = py::none(),
py::arg("operands") = py::none(),
.def_property_readonly("opview", &PyOperation::createOpView);
auto opViewClass =
- py::class_<PyOpView, PyOperationBase>(m, "OpView")
+ py::class_<PyOpView, PyOperationBase>(m, "OpView", py::module_local())
.def(py::init<py::object>())
.def_property_readonly("operation", &PyOpView::getOperationObject)
.def_property_readonly(
//----------------------------------------------------------------------------
// Mapping of PyRegion.
//----------------------------------------------------------------------------
- py::class_<PyRegion>(m, "Region")
+ py::class_<PyRegion>(m, "Region", py::module_local())
.def_property_readonly(
"blocks",
[](PyRegion &self) {
//----------------------------------------------------------------------------
// Mapping of PyBlock.
//----------------------------------------------------------------------------
- py::class_<PyBlock>(m, "Block")
+ py::class_<PyBlock>(m, "Block", py::module_local())
.def_property_readonly(
"owner",
[](PyBlock &self) {
// Mapping of PyInsertionPoint.
//----------------------------------------------------------------------------
- py::class_<PyInsertionPoint>(m, "InsertionPoint")
+ py::class_<PyInsertionPoint>(m, "InsertionPoint", py::module_local())
.def(py::init<PyBlock &>(), py::arg("block"),
"Inserts after the last operation but still inside the block.")
.def("__enter__", &PyInsertionPoint::contextEnter)
//----------------------------------------------------------------------------
// Mapping of PyAttribute.
//----------------------------------------------------------------------------
- py::class_<PyAttribute>(m, "Attribute")
+ py::class_<PyAttribute>(m, "Attribute", py::module_local())
// Delegate to the PyAttribute copy constructor, which will also lifetime
// extend the backing context which owns the MlirAttribute.
.def(py::init<PyAttribute &>(), py::arg("cast_from_type"),
//----------------------------------------------------------------------------
// Mapping of PyNamedAttribute
//----------------------------------------------------------------------------
- py::class_<PyNamedAttribute>(m, "NamedAttribute")
+ py::class_<PyNamedAttribute>(m, "NamedAttribute", py::module_local())
.def("__repr__",
[](PyNamedAttribute &self) {
PyPrintAccumulator printAccum;
//----------------------------------------------------------------------------
// Mapping of PyType.
//----------------------------------------------------------------------------
- py::class_<PyType>(m, "Type")
+ py::class_<PyType>(m, "Type", py::module_local())
// Delegate to the PyType copy constructor, which will also lifetime
// extend the backing context which owns the MlirType.
.def(py::init<PyType &>(), py::arg("cast_from_type"),
//----------------------------------------------------------------------------
// Mapping of Value.
//----------------------------------------------------------------------------
- py::class_<PyValue>(m, "Value")
+ py::class_<PyValue>(m, "Value", py::module_local())
.def_property_readonly(MLIR_PYTHON_CAPI_PTR_ATTR, &PyValue::getCapsule)
.def(MLIR_PYTHON_CAPI_FACTORY_ATTR, &PyValue::createFromCapsule)
.def_property_readonly(