MLIR
17.0.0git
|
#include <Python.h>
#include "mlir-c/AffineExpr.h"
#include "mlir-c/AffineMap.h"
#include "mlir-c/ExecutionEngine.h"
#include "mlir-c/IR.h"
#include "mlir-c/IntegerSet.h"
#include "mlir-c/Pass.h"
Go to the source code of this file.
Functions | |
static PyObject * | mlirPythonAffineExprToCapsule (MlirAffineExpr expr) |
Creates a capsule object encapsulating the raw C-API MlirAffineExpr. More... | |
static MlirAffineExpr | mlirPythonCapsuleToAffineExpr (PyObject *capsule) |
Extracts an MlirAffineExpr from a capsule as produced from mlirPythonAffineExprToCapsule. More... | |
static PyObject * | mlirPythonAttributeToCapsule (MlirAttribute attribute) |
Creates a capsule object encapsulating the raw C-API MlirAttribute. More... | |
static MlirAttribute | mlirPythonCapsuleToAttribute (PyObject *capsule) |
Extracts an MlirAttribute from a capsule as produced from mlirPythonAttributeToCapsule. More... | |
static PyObject * | mlirPythonContextToCapsule (MlirContext context) |
Creates a capsule object encapsulating the raw C-API MlirContext. More... | |
static MlirContext | mlirPythonCapsuleToContext (PyObject *capsule) |
Extracts a MlirContext from a capsule as produced from mlirPythonContextToCapsule. More... | |
static PyObject * | mlirPythonDialectRegistryToCapsule (MlirDialectRegistry registry) |
Creates a capsule object encapsulating the raw C-API MlirDialectRegistry. More... | |
static MlirDialectRegistry | mlirPythonCapsuleToDialectRegistry (PyObject *capsule) |
Extracts an MlirDialectRegistry from a capsule as produced from mlirPythonDialectRegistryToCapsule. More... | |
static PyObject * | mlirPythonLocationToCapsule (MlirLocation loc) |
Creates a capsule object encapsulating the raw C-API MlirLocation. More... | |
static MlirLocation | mlirPythonCapsuleToLocation (PyObject *capsule) |
Extracts an MlirLocation from a capsule as produced from mlirPythonLocationToCapsule. More... | |
static PyObject * | mlirPythonModuleToCapsule (MlirModule module) |
Creates a capsule object encapsulating the raw C-API MlirModule. More... | |
static MlirModule | mlirPythonCapsuleToModule (PyObject *capsule) |
Extracts an MlirModule from a capsule as produced from mlirPythonModuleToCapsule. More... | |
static PyObject * | mlirPythonPassManagerToCapsule (MlirPassManager pm) |
Creates a capsule object encapsulating the raw C-API MlirPassManager. More... | |
static MlirPassManager | mlirPythonCapsuleToPassManager (PyObject *capsule) |
Extracts an MlirPassManager from a capsule as produced from mlirPythonPassManagerToCapsule. More... | |
static PyObject * | mlirPythonOperationToCapsule (MlirOperation operation) |
Creates a capsule object encapsulating the raw C-API MlirOperation. More... | |
static MlirOperation | mlirPythonCapsuleToOperation (PyObject *capsule) |
Extracts an MlirOperations from a capsule as produced from mlirPythonOperationToCapsule. More... | |
static PyObject * | mlirPythonTypeToCapsule (MlirType type) |
Creates a capsule object encapsulating the raw C-API MlirType. More... | |
static MlirType | mlirPythonCapsuleToType (PyObject *capsule) |
Extracts an MlirType from a capsule as produced from mlirPythonTypeToCapsule. More... | |
static PyObject * | mlirPythonAffineMapToCapsule (MlirAffineMap affineMap) |
Creates a capsule object encapsulating the raw C-API MlirAffineMap. More... | |
static MlirAffineMap | mlirPythonCapsuleToAffineMap (PyObject *capsule) |
Extracts an MlirAffineMap from a capsule as produced from mlirPythonAffineMapToCapsule. More... | |
static PyObject * | mlirPythonIntegerSetToCapsule (MlirIntegerSet integerSet) |
Creates a capsule object encapsulating the raw C-API MlirIntegerSet. More... | |
static MlirIntegerSet | mlirPythonCapsuleToIntegerSet (PyObject *capsule) |
Extracts an MlirIntegerSet from a capsule as produced from mlirPythonIntegerSetToCapsule. More... | |
static PyObject * | mlirPythonExecutionEngineToCapsule (MlirExecutionEngine jit) |
Creates a capsule object encapsulating the raw C-API MlirExecutionEngine. More... | |
static MlirExecutionEngine | mlirPythonCapsuleToExecutionEngine (PyObject *capsule) |
Extracts an MlirExecutionEngine from a capsule as produced from mlirPythonIntegerSetToCapsule. More... | |
static PyObject * | mlirPythonValueToCapsule (MlirValue value) |
Creates a capsule object encapsulating the raw C-API MlirValue. More... | |
static MlirValue | mlirPythonCapsuleToValue (PyObject *capsule) |
Extracts an MlirValue from a capsule as produced from mlirPythonValueToCapsule. More... | |
#define MAKE_MLIR_PYTHON_QUALNAME | ( | local | ) | MLIR_PYTHON_STRINGIZE_ARG(MLIR_PYTHON_PACKAGE_PREFIX) local |
#define MLIR_PYTHON_CAPI_FACTORY_ATTR "_CAPICreate" |
Attribute on MLIR Python objects that exposes a factory function for constructing the corresponding Python object from a type-specific capsule wrapping the C-API pointer.
The signature of the function is: def _CAPICreate(capsule) -> object Calling such a function implies a transfer of ownership of the object the capsule wraps: after such a call, the capsule should be considered invalid, and its wrapped pointer must not be destroyed.
Only a very small number of Python objects can be created in such a fashion (i.e. top-level types such as Context where the lifetime can be cleanly delineated).
#define MLIR_PYTHON_CAPI_PTR_ATTR "_CAPIPtr" |
Attribute on MLIR Python objects that expose their C-API pointer.
This will be a type-specific capsule created as per one of the helpers below.
Ownership is not transferred by acquiring a capsule in this way: the validity of the pointer wrapped by the capsule will be bounded by the lifetime of the Python object that produced it. Only the name and pointer of the capsule are set. The caller is free to set a destructor and context as needed to manage anything further.
#define MLIR_PYTHON_CAPSULE_AFFINE_EXPR MAKE_MLIR_PYTHON_QUALNAME("ir.AffineExpr._CAPIPtr") |
#define MLIR_PYTHON_CAPSULE_AFFINE_MAP MAKE_MLIR_PYTHON_QUALNAME("ir.AffineMap._CAPIPtr") |
#define MLIR_PYTHON_CAPSULE_ATTRIBUTE MAKE_MLIR_PYTHON_QUALNAME("ir.Attribute._CAPIPtr") |
#define MLIR_PYTHON_CAPSULE_CONTEXT MAKE_MLIR_PYTHON_QUALNAME("ir.Context._CAPIPtr") |
#define MLIR_PYTHON_CAPSULE_DIALECT_REGISTRY MAKE_MLIR_PYTHON_QUALNAME("ir.DialectRegistry._CAPIPtr") |
#define MLIR_PYTHON_CAPSULE_EXECUTION_ENGINE MAKE_MLIR_PYTHON_QUALNAME("execution_engine.ExecutionEngine._CAPIPtr") |
#define MLIR_PYTHON_CAPSULE_INTEGER_SET MAKE_MLIR_PYTHON_QUALNAME("ir.IntegerSet._CAPIPtr") |
#define MLIR_PYTHON_CAPSULE_LOCATION MAKE_MLIR_PYTHON_QUALNAME("ir.Location._CAPIPtr") |
#define MLIR_PYTHON_CAPSULE_MODULE MAKE_MLIR_PYTHON_QUALNAME("ir.Module._CAPIPtr") |
#define MLIR_PYTHON_CAPSULE_OPERATION MAKE_MLIR_PYTHON_QUALNAME("ir.Operation._CAPIPtr") |
#define MLIR_PYTHON_CAPSULE_PASS_MANAGER MAKE_MLIR_PYTHON_QUALNAME("passmanager.PassManager._CAPIPtr") |
#define MLIR_PYTHON_CAPSULE_TYPE MAKE_MLIR_PYTHON_QUALNAME("ir.Type._CAPIPtr") |
#define MLIR_PYTHON_CAPSULE_VALUE MAKE_MLIR_PYTHON_QUALNAME("ir.Value._CAPIPtr") |
#define MLIR_PYTHON_GET_WRAPPED_POINTER | ( | object | ) | (void *)(object.ptr) |
#define MLIR_PYTHON_STRINGIZE_ARG | ( | arg | ) | MLIR_PYTHON_STRINGIZE(arg) |
|
inlinestatic |
Creates a capsule object encapsulating the raw C-API MlirAffineExpr.
The returned capsule does not extend or affect ownership of any Python objects that reference the expression in any way.
Definition at line 125 of file Interop.h.
References MLIR_PYTHON_CAPSULE_AFFINE_EXPR, and MLIR_PYTHON_GET_WRAPPED_POINTER.
Referenced by mlir::python::PyAffineExpr::getCapsule().
|
inlinestatic |
Creates a capsule object encapsulating the raw C-API MlirAffineMap.
The returned capsule does not extend or affect ownership of any Python objects that reference the type in any way.
Definition at line 294 of file Interop.h.
References MLIR_PYTHON_CAPSULE_AFFINE_MAP, and MLIR_PYTHON_GET_WRAPPED_POINTER.
Referenced by pybind11::detail::type_caster< MlirAffineMap >::cast(), and mlir::python::PyAffineMap::getCapsule().
|
inlinestatic |
Creates a capsule object encapsulating the raw C-API MlirAttribute.
The returned capsule does not extend or affect ownership of any Python objects that reference the attribute in any way.
Definition at line 144 of file Interop.h.
References MLIR_PYTHON_CAPSULE_ATTRIBUTE, and MLIR_PYTHON_GET_WRAPPED_POINTER.
Referenced by pybind11::detail::type_caster< MlirAttribute >::cast(), and mlir::python::PyAttribute::getCapsule().
|
inlinestatic |
Extracts an MlirAffineExpr from a capsule as produced from mlirPythonAffineExprToCapsule.
If the capsule is not of the right type, then a null expression is returned (as checked via mlirAffineExprIsNull). In such a case, the Python APIs will have already set an error.
Definition at line 134 of file Interop.h.
References MLIR_PYTHON_CAPSULE_AFFINE_EXPR.
Referenced by mlir::python::PyAffineExpr::createFromCapsule().
|
inlinestatic |
Extracts an MlirAffineMap from a capsule as produced from mlirPythonAffineMapToCapsule.
If the capsule is not of the right type, then a null type is returned (as checked via mlirAffineMapIsNull). In such a case, the Python APIs will have already set an error.
Definition at line 303 of file Interop.h.
References MLIR_PYTHON_CAPSULE_AFFINE_MAP.
Referenced by mlir::python::PyAffineMap::createFromCapsule(), and pybind11::detail::type_caster< MlirAffineMap >::load().
|
inlinestatic |
Extracts an MlirAttribute from a capsule as produced from mlirPythonAttributeToCapsule.
If the capsule is not of the right type, then a null attribute is returned (as checked via mlirAttributeIsNull). In such a case, the Python APIs will have already set an error.
Definition at line 153 of file Interop.h.
References MLIR_PYTHON_CAPSULE_ATTRIBUTE.
Referenced by mlir::python::PyAttribute::createFromCapsule(), and pybind11::detail::type_caster< MlirAttribute >::load().
|
inlinestatic |
Extracts a MlirContext from a capsule as produced from mlirPythonContextToCapsule.
If the capsule is not of the right type, then a null context is returned (as checked via mlirContextIsNull). In such a case, the Python APIs will have already set an error.
Definition at line 171 of file Interop.h.
References MLIR_PYTHON_CAPSULE_CONTEXT.
Referenced by mlir::python::PyMlirContext::createFromCapsule(), and pybind11::detail::type_caster< MlirContext >::load().
|
inlinestatic |
Extracts an MlirDialectRegistry from a capsule as produced from mlirPythonDialectRegistryToCapsule.
If the capsule is not of the right type, then a null context is returned (as checked via mlirContextIsNull). In such a case, the Python APIs will have already set an error.
Definition at line 192 of file Interop.h.
References MLIR_PYTHON_CAPSULE_DIALECT_REGISTRY.
Referenced by mlir::python::PyDialectRegistry::createFromCapsule(), and pybind11::detail::type_caster< MlirDialectRegistry >::load().
|
inlinestatic |
Extracts an MlirExecutionEngine from a capsule as produced from mlirPythonIntegerSetToCapsule.
If the capsule is not of the right type, then a null set is returned (as checked via mlirExecutionEngineIsNull). In such a case, the Python APIs will have already set an error.
Definition at line 342 of file Interop.h.
References MLIR_PYTHON_CAPSULE_EXECUTION_ENGINE.
|
inlinestatic |
Extracts an MlirIntegerSet from a capsule as produced from mlirPythonIntegerSetToCapsule.
If the capsule is not of the right type, then a null set is returned (as checked via mlirIntegerSetIsNull). In such a case, the Python APIs will have already set an error.
Definition at line 322 of file Interop.h.
References MLIR_PYTHON_CAPSULE_INTEGER_SET.
Referenced by mlir::python::PyIntegerSet::createFromCapsule().
|
inlinestatic |
Extracts an MlirLocation from a capsule as produced from mlirPythonLocationToCapsule.
If the capsule is not of the right type, then a null module is returned (as checked via mlirLocationIsNull). In such a case, the Python APIs will have already set an error.
Definition at line 211 of file Interop.h.
References MLIR_PYTHON_CAPSULE_LOCATION.
Referenced by mlir::python::PyLocation::createFromCapsule(), and pybind11::detail::type_caster< MlirLocation >::load().
|
inlinestatic |
Extracts an MlirModule from a capsule as produced from mlirPythonModuleToCapsule.
If the capsule is not of the right type, then a null module is returned (as checked via mlirModuleIsNull). In such a case, the Python APIs will have already set an error.
Definition at line 229 of file Interop.h.
References MLIR_PYTHON_CAPSULE_MODULE.
Referenced by mlir::python::PyModule::createFromCapsule(), and pybind11::detail::type_caster< MlirModule >::load().
|
inlinestatic |
Extracts an MlirOperations from a capsule as produced from mlirPythonOperationToCapsule.
If the capsule is not of the right type, then a null type is returned (as checked via mlirOperationIsNull). In such a case, the Python APIs will have already set an error.
Definition at line 265 of file Interop.h.
References MLIR_PYTHON_CAPSULE_OPERATION.
Referenced by mlir::python::PyOperation::createFromCapsule(), and pybind11::detail::type_caster< MlirOperation >::load().
|
inlinestatic |
Extracts an MlirPassManager from a capsule as produced from mlirPythonPassManagerToCapsule.
If the capsule is not of the right type, then a null pass manager is returned (as checked via mlirPassManagerIsNull).
Definition at line 247 of file Interop.h.
References MLIR_PYTHON_CAPSULE_PASS_MANAGER.
Referenced by pybind11::detail::type_caster< MlirPassManager >::load().
|
inlinestatic |
Extracts an MlirType from a capsule as produced from mlirPythonTypeToCapsule.
If the capsule is not of the right type, then a null type is returned (as checked via mlirTypeIsNull). In such a case, the Python APIs will have already set an error.
Definition at line 284 of file Interop.h.
References MLIR_PYTHON_CAPSULE_TYPE.
Referenced by mlir::python::PyType::createFromCapsule(), and pybind11::detail::type_caster< MlirType >::load().
|
inlinestatic |
Extracts an MlirValue from a capsule as produced from mlirPythonValueToCapsule.
If the capsule is not of the right type, then a null type is returned (as checked via mlirValueIsNull). In such a case, the Python APIs will have already set an error.
Definition at line 362 of file Interop.h.
References MLIR_PYTHON_CAPSULE_VALUE.
Referenced by mlir::python::PyValue::createFromCapsule(), and pybind11::detail::type_caster< MlirValue >::load().
|
inlinestatic |
Creates a capsule object encapsulating the raw C-API MlirContext.
The returned capsule does not extend or affect ownership of any Python objects that reference the context in any way.
Definition at line 163 of file Interop.h.
References MLIR_PYTHON_CAPSULE_CONTEXT.
Referenced by mlir::python::PyMlirContext::getCapsule().
|
inlinestatic |
Creates a capsule object encapsulating the raw C-API MlirDialectRegistry.
The returned capsule does not extend or affect ownership of any Python objects that reference the context in any way.
Definition at line 182 of file Interop.h.
References MLIR_PYTHON_CAPSULE_DIALECT_REGISTRY.
Referenced by pybind11::detail::type_caster< MlirDialectRegistry >::cast(), and mlir::python::PyDialectRegistry::getCapsule().
|
inlinestatic |
Creates a capsule object encapsulating the raw C-API MlirExecutionEngine.
The returned capsule does not extend or affect ownership of any Python objects that reference the set in any way.
Definition at line 332 of file Interop.h.
References MLIR_PYTHON_CAPSULE_EXECUTION_ENGINE, and MLIR_PYTHON_GET_WRAPPED_POINTER.
|
inlinestatic |
Creates a capsule object encapsulating the raw C-API MlirIntegerSet.
The returned capsule does not extend or affect ownership of any Python objects that reference the set in any way.
Definition at line 313 of file Interop.h.
References MLIR_PYTHON_CAPSULE_INTEGER_SET, and MLIR_PYTHON_GET_WRAPPED_POINTER.
Referenced by mlir::python::PyIntegerSet::getCapsule().
|
inlinestatic |
Creates a capsule object encapsulating the raw C-API MlirLocation.
The returned capsule does not extend or affect ownership of any Python objects that reference the location in any way.
Definition at line 202 of file Interop.h.
References MLIR_PYTHON_CAPSULE_LOCATION, and MLIR_PYTHON_GET_WRAPPED_POINTER.
Referenced by pybind11::detail::type_caster< MlirLocation >::cast(), and mlir::python::PyLocation::getCapsule().
|
inlinestatic |
Creates a capsule object encapsulating the raw C-API MlirModule.
The returned capsule does not extend or affect ownership of any Python objects that reference the module in any way.
Definition at line 220 of file Interop.h.
References MLIR_PYTHON_CAPSULE_MODULE, and MLIR_PYTHON_GET_WRAPPED_POINTER.
Referenced by pybind11::detail::type_caster< MlirModule >::cast(), and mlir::python::PyModule::getCapsule().
|
inlinestatic |
Creates a capsule object encapsulating the raw C-API MlirOperation.
The returned capsule does not extend or affect ownership of any Python objects that reference the operation in any way.
Definition at line 257 of file Interop.h.
References MLIR_PYTHON_CAPSULE_OPERATION.
Referenced by pybind11::detail::type_caster< MlirOperation >::cast(), and mlir::python::PyOperation::getCapsule().
|
inlinestatic |
Creates a capsule object encapsulating the raw C-API MlirPassManager.
The returned capsule does not extend or affect ownership of any Python objects that reference the module in any way.
Definition at line 238 of file Interop.h.
References MLIR_PYTHON_CAPSULE_PASS_MANAGER, and MLIR_PYTHON_GET_WRAPPED_POINTER.
|
inlinestatic |
Creates a capsule object encapsulating the raw C-API MlirType.
The returned capsule does not extend or affect ownership of any Python objects that reference the type in any way.
Definition at line 275 of file Interop.h.
References MLIR_PYTHON_CAPSULE_TYPE, and MLIR_PYTHON_GET_WRAPPED_POINTER.
Referenced by pybind11::detail::type_caster< MlirType >::cast(), and mlir::python::PyType::getCapsule().
|
inlinestatic |
Creates a capsule object encapsulating the raw C-API MlirValue.
The returned capsule does not extend or affect ownership of any Python objects that reference the operation in any way.
Definition at line 353 of file Interop.h.
References MLIR_PYTHON_CAPSULE_VALUE, and MLIR_PYTHON_GET_WRAPPED_POINTER.
Referenced by pybind11::detail::type_caster< MlirValue >::cast(), and mlir::python::PyValue::getCapsule().