|
MLIR 23.0.0git
|
CRTP base class for Python classes representing MLIR Op interfaces. More...
#include "mlir/Bindings/Python/IRInterfaces.h"
Public Member Functions | |
| PyConcreteOpInterface (nanobind::object object, DefaultingPyMlirContext context) | |
| Constructs an interface instance from an object that is either an operation or a subclass of OpView. | |
| bool | isStatic () |
| Returns true if this object was constructed from a subclass of OpView rather than from an operation instance. | |
| nanobind::typed< nanobind::object, PyOperation > | getOperationObject () |
| Returns the operation instance from which this object was constructed. | |
| nanobind::typed< nanobind::object, PyOpView > | getOpView () |
| Returns the opview of the operation instance from which this object was constructed. | |
| const std::string & | getOpName () |
| Returns the canonical name of the operation this interface is constructed from. | |
Static Public Member Functions | |
| static void | bind (nanobind::module_ &m) |
| Creates the Python bindings for this class in the given module. | |
| static void | bindDerived (ClassTy &cls) |
| Hook for derived classes to add class-specific bindings. | |
Protected Types | |
| using | ClassTy = nanobind::class_<ConcreteIface> |
| using | GetTypeIDFunctionTy = MlirTypeID (*)() |
CRTP base class for Python classes representing MLIR Op interfaces.
Interface hierarchies are flat so no base class is expected here. The derived class is expected to define the following static fields:
An interface class may be constructed from either an Operation/OpView object or from a subclass of OpView. In the latter case, only the static interface methods are available, similarly to calling ConcereteOp::staticMethod on the C++ side. Implementations of concrete interfaces can use the isStatic method to check whether the interface object was constructed from a class or an operation/opview instance. The getOpName always succeeds and returns a canonical name of the operation suitable for lookups.
Definition at line 40 of file IRInterfaces.h.
|
protected |
Definition at line 42 of file IRInterfaces.h.
|
protected |
Definition at line 43 of file IRInterfaces.h.
|
inline |
Constructs an interface instance from an object that is either an operation or a subclass of OpView.
In the latter case, only the static methods of the interface are accessible to the caller.
Definition at line 49 of file IRInterfaces.h.
References MlirStringRef::data, mlir::python::MLIR_BINDINGS_PYTHON_DOMAIN::PyMlirContext::get(), mlir::python::MLIR_BINDINGS_PYTHON_DOMAIN::PyOpView::getOperation(), MlirStringRef::length, mlirIdentifierStr(), mlirOperationGetName(), mlirOperationImplementsInterface(), mlirOperationImplementsInterfaceStatic(), mlirStringRefCreate(), and mlir::python::MLIR_BINDINGS_PYTHON_DOMAIN::DefaultingPyMlirContext::resolve().
|
inlinestatic |
Creates the Python bindings for this class in the given module.
Definition at line 84 of file IRInterfaces.h.
References getOperationObject(), and getOpView().
|
inlinestatic |
Hook for derived classes to add class-specific bindings.
Definition at line 102 of file IRInterfaces.h.
|
inline |
Returns the operation instance from which this object was constructed.
Throws a type error if this object was constructed from a subclass of OpView.
Definition at line 111 of file IRInterfaces.h.
Referenced by bind().
|
inline |
Returns the canonical name of the operation this interface is constructed from.
Definition at line 130 of file IRInterfaces.h.
|
inline |
Returns the opview of the operation instance from which this object was constructed.
Throws a type error if this object was constructed form a subclass of OpView.
Definition at line 121 of file IRInterfaces.h.
Referenced by bind().
|
inline |
Returns true if this object was constructed from a subclass of OpView rather than from an operation instance.
Definition at line 106 of file IRInterfaces.h.