|
MLIR 23.0.0git
|
Globals that are always accessible once the extension has been initialized. More...
#include "mlir/Bindings/Python/Globals.h"
Classes | |
| class | TracebackLoc |
| class | TypeIDAllocator |
Public Member Functions | |
| PyGlobals () | |
| ~PyGlobals () | |
| std::vector< std::string > | getDialectSearchPrefixes () |
| Get and set the list of parent modules to search for dialect implementation classes. | |
| void | setDialectSearchPrefixes (std::vector< std::string > newValues) |
| void | addDialectSearchPrefix (std::string value) |
| bool | loadDialectModule (std::string_view dialectNamespace) |
| Loads a python module corresponding to the given dialect namespace. | |
| void | registerAttributeBuilder (const std::string &attributeKind, nanobind::callable pyFunc, bool replace=false) |
| Adds a user-friendly Attribute builder. | |
| void | registerTypeCaster (MlirTypeID mlirTypeID, nanobind::callable typeCaster, bool replace=false) |
| Adds a user-friendly type caster. | |
| void | registerValueCaster (MlirTypeID mlirTypeID, nanobind::callable valueCaster, bool replace=false) |
| Adds a user-friendly value caster. | |
| void | registerDialectImpl (const std::string &dialectNamespace, nanobind::object pyClass) |
| Adds a concrete implementation dialect class. | |
| void | registerOperationImpl (const std::string &operationName, nanobind::object pyClass, bool replace=false) |
| Adds a concrete implementation operation class. | |
| void | registerOpAdaptorImpl (const std::string &operationName, nanobind::object pyClass, bool replace=false) |
| Adds an operation adaptor class. | |
| std::optional< nanobind::callable > | lookupAttributeBuilder (const std::string &attributeKind) |
| Returns the custom Attribute builder for Attribute kind. | |
| std::optional< nanobind::callable > | lookupTypeCaster (MlirTypeID mlirTypeID, MlirDialect dialect) |
| Returns the custom type caster for MlirTypeID mlirTypeID. | |
| std::optional< nanobind::callable > | lookupValueCaster (MlirTypeID mlirTypeID, MlirDialect dialect) |
| Returns the custom value caster for MlirTypeID mlirTypeID. | |
| std::optional< nanobind::object > | lookupDialectClass (const std::string &dialectNamespace) |
| Looks up a registered dialect class by namespace. | |
| std::optional< nanobind::object > | lookupOperationClass (std::string_view operationName) |
| Looks up a registered operation class (deriving from OpView) by operation name. | |
| std::optional< nanobind::object > | lookupOpAdaptorClass (std::string_view operationName) |
| Looks up a registered operation adaptor class by operation name. | |
| TracebackLoc & | getTracebackLoc () |
| MlirTypeID | allocateTypeID () |
Static Public Member Functions | |
| static PyGlobals & | get () |
| Most code should get the globals via this static accessor. | |
Globals that are always accessible once the extension has been initialized.
Methods of this class are thread-safe.
| mlir::python::MLIR_BINDINGS_PYTHON_DOMAIN::PyGlobals::PyGlobals | ( | ) |
Definition at line 49 of file Globals.cpp.
References MAKE_MLIR_PYTHON_QUALNAME.
Referenced by get().
| mlir::python::MLIR_BINDINGS_PYTHON_DOMAIN::PyGlobals::~PyGlobals | ( | ) |
Definition at line 57 of file Globals.cpp.
|
inline |
Definition at line 47 of file Globals.h.
Referenced by mlir::python::MLIR_BINDINGS_PYTHON_DOMAIN::populateRoot().
|
inline |
Definition at line 181 of file Globals.h.
Referenced by mlir::python::MLIR_BINDINGS_PYTHON_DOMAIN::populatePassManagerSubmodule().
|
static |
Most code should get the globals via this static accessor.
Definition at line 59 of file Globals.cpp.
References PyGlobals().
Referenced by mlir::python::MLIR_BINDINGS_PYTHON_DOMAIN::PyRewritePatternSet::addConversion(), mlir::python::MLIR_BINDINGS_PYTHON_DOMAIN::PyConcreteAttribute< DerivedTy, BaseTy >::bind(), mlir::python::MLIR_BINDINGS_PYTHON_DOMAIN::PyConcreteType< DerivedTy, BaseTy >::bind(), mlir::python::MLIR_BINDINGS_PYTHON_DOMAIN::PyConcreteValue< DerivedTy >::bind(), createCustomDialectWrapper(), mlir::python::MLIR_BINDINGS_PYTHON_DOMAIN::PyAttrBuilderMap::dunderContains(), mlir::python::MLIR_BINDINGS_PYTHON_DOMAIN::PyAttrBuilderMap::dunderGetItemNamed(), mlir::python::MLIR_BINDINGS_PYTHON_DOMAIN::PyAttrBuilderMap::dunderSetItemNamed(), mlir::python::MLIR_BINDINGS_PYTHON_DOMAIN::populateIRAttributes(), mlir::python::MLIR_BINDINGS_PYTHON_DOMAIN::populatePassManagerSubmodule(), and mlir::python::MLIR_BINDINGS_PYTHON_DOMAIN::populateRoot().
|
inline |
Get and set the list of parent modules to search for dialect implementation classes.
Definition at line 39 of file Globals.h.
Referenced by mlir::python::MLIR_BINDINGS_PYTHON_DOMAIN::populateRoot().
|
inline |
Definition at line 158 of file Globals.h.
Referenced by mlir::python::MLIR_BINDINGS_PYTHON_DOMAIN::populateRoot().
| bool mlir::python::MLIR_BINDINGS_PYTHON_DOMAIN::PyGlobals::loadDialectModule | ( | std::string_view | dialectNamespace | ) |
Loads a python module corresponding to the given dialect namespace.
No-ops if the module has already been loaded or is not found. Raises an error on any evaluation issues. Note that this returns void because it is expected that the module contains calls to decorators and helpers that register the salient entities. Returns true if dialect is successfully loaded.
Definition at line 64 of file Globals.cpp.
Referenced by lookupDialectClass(), lookupOpAdaptorClass(), lookupOperationClass(), lookupTypeCaster(), lookupValueCaster(), and mlir::python::MLIR_BINDINGS_PYTHON_DOMAIN::populateRoot().
| std::optional< nb::callable > mlir::python::MLIR_BINDINGS_PYTHON_DOMAIN::PyGlobals::lookupAttributeBuilder | ( | const std::string & | attributeKind | ) |
Returns the custom Attribute builder for Attribute kind.
Definition at line 166 of file Globals.cpp.
Referenced by mlir::python::MLIR_BINDINGS_PYTHON_DOMAIN::PyAttrBuilderMap::dunderContains(), and mlir::python::MLIR_BINDINGS_PYTHON_DOMAIN::PyAttrBuilderMap::dunderGetItemNamed().
| std::optional< nb::object > mlir::python::MLIR_BINDINGS_PYTHON_DOMAIN::PyGlobals::lookupDialectClass | ( | const std::string & | dialectNamespace | ) |
Looks up a registered dialect class by namespace.
Note that this may trigger loading of the defining module and can arbitrarily re-enter.
Definition at line 205 of file Globals.cpp.
References loadDialectModule().
Referenced by createCustomDialectWrapper().
| std::optional< nb::object > mlir::python::MLIR_BINDINGS_PYTHON_DOMAIN::PyGlobals::lookupOpAdaptorClass | ( | std::string_view | operationName | ) |
Looks up a registered operation adaptor class by operation name.
Note that this may trigger a load of the dialect, which can arbitrarily re-enter.
Definition at line 238 of file Globals.cpp.
References loadDialectModule().
Referenced by mlir::python::MLIR_BINDINGS_PYTHON_DOMAIN::PyRewritePatternSet::addConversion().
| std::optional< nb::object > mlir::python::MLIR_BINDINGS_PYTHON_DOMAIN::PyGlobals::lookupOperationClass | ( | std::string_view | operationName | ) |
Looks up a registered operation class (deriving from OpView) by operation name.
Note that this may trigger a load of the dialect, which can arbitrarily re-enter.
Definition at line 220 of file Globals.cpp.
References loadDialectModule().
| std::optional< nb::callable > mlir::python::MLIR_BINDINGS_PYTHON_DOMAIN::PyGlobals::lookupTypeCaster | ( | MlirTypeID | mlirTypeID, |
| MlirDialect | dialect ) |
Returns the custom type caster for MlirTypeID mlirTypeID.
Definition at line 176 of file Globals.cpp.
References MlirStringRef::data, MlirStringRef::length, loadDialectModule(), and mlirDialectGetNamespace().
| std::optional< nb::callable > mlir::python::MLIR_BINDINGS_PYTHON_DOMAIN::PyGlobals::lookupValueCaster | ( | MlirTypeID | mlirTypeID, |
| MlirDialect | dialect ) |
Returns the custom value caster for MlirTypeID mlirTypeID.
Definition at line 190 of file Globals.cpp.
References MlirStringRef::data, MlirStringRef::length, loadDialectModule(), and mlirDialectGetNamespace().
| void mlir::python::MLIR_BINDINGS_PYTHON_DOMAIN::PyGlobals::registerAttributeBuilder | ( | const std::string & | attributeKind, |
| nanobind::callable | pyFunc, | ||
| bool | replace = false ) |
Adds a user-friendly Attribute builder.
Raises an exception if the mapping already exists and replace == false. This is intended to be called by implementation code.
Definition at line 99 of file Globals.cpp.
References nanobind::detail::join().
Referenced by mlir::python::MLIR_BINDINGS_PYTHON_DOMAIN::PyAttrBuilderMap::dunderSetItemNamed().
| void mlir::python::MLIR_BINDINGS_PYTHON_DOMAIN::PyGlobals::registerDialectImpl | ( | const std::string & | dialectNamespace, |
| nanobind::object | pyClass ) |
Adds a concrete implementation dialect class.
Raises an exception if the mapping already exists. This is intended to be called by implementation code.
Definition at line 132 of file Globals.cpp.
References nanobind::detail::join().
Referenced by mlir::python::MLIR_BINDINGS_PYTHON_DOMAIN::populateRoot().
| void mlir::python::MLIR_BINDINGS_PYTHON_DOMAIN::PyGlobals::registerOpAdaptorImpl | ( | const std::string & | operationName, |
| nanobind::object | pyClass, | ||
| bool | replace = false ) |
Adds an operation adaptor class.
Raises an exception if the mapping already exists and replace == false. This is intended to be called by implementation code.
Definition at line 154 of file Globals.cpp.
References nanobind::detail::join().
Referenced by mlir::python::MLIR_BINDINGS_PYTHON_DOMAIN::populateRoot().
| void mlir::python::MLIR_BINDINGS_PYTHON_DOMAIN::PyGlobals::registerOperationImpl | ( | const std::string & | operationName, |
| nanobind::object | pyClass, | ||
| bool | replace = false ) |
Adds a concrete implementation operation class.
Raises an exception if the mapping already exists and replace == false. This is intended to be called by implementation code.
Definition at line 143 of file Globals.cpp.
References nanobind::detail::join().
Referenced by mlir::python::MLIR_BINDINGS_PYTHON_DOMAIN::populateRoot().
| void mlir::python::MLIR_BINDINGS_PYTHON_DOMAIN::PyGlobals::registerTypeCaster | ( | MlirTypeID | mlirTypeID, |
| nanobind::callable | typeCaster, | ||
| bool | replace = false ) |
Adds a user-friendly type caster.
Raises an exception if the mapping already exists and replace == false. This is intended to be called by implementation code.
Definition at line 112 of file Globals.cpp.
Referenced by mlir::python::MLIR_BINDINGS_PYTHON_DOMAIN::populateIRAttributes(), and mlir::python::MLIR_BINDINGS_PYTHON_DOMAIN::populateRoot().
| void mlir::python::MLIR_BINDINGS_PYTHON_DOMAIN::PyGlobals::registerValueCaster | ( | MlirTypeID | mlirTypeID, |
| nanobind::callable | valueCaster, | ||
| bool | replace = false ) |
Adds a user-friendly value caster.
Raises an exception if the mapping already exists and replace == false. This is intended to be called by implementation code.
Definition at line 122 of file Globals.cpp.
Referenced by mlir::python::MLIR_BINDINGS_PYTHON_DOMAIN::populateRoot().
|
inline |
Definition at line 43 of file Globals.h.
Referenced by mlir::python::MLIR_BINDINGS_PYTHON_DOMAIN::populateRoot().