MLIR
20.0.0git
|
CRTP base class for Python classes representing MLIR Op interfaces. More...
Public Member Functions | |
PyConcreteOpInterface (py::object object, DefaultingPyMlirContext context) | |
Constructs an interface instance from an object that is either an operation or a subclass of OpView. More... | |
bool | isStatic () |
Returns true if this object was constructed from a subclass of OpView rather than from an operation instance. More... | |
py::object | getOperationObject () |
Returns the operation instance from which this object was constructed. More... | |
py::object | getOpView () |
Returns the opview of the operation instance from which this object was constructed. More... | |
const std::string & | getOpName () |
Returns the canonical name of the operation this interface is constructed from. More... | |
Static Public Member Functions | |
static void | bind (py::module &m) |
Creates the Python bindings for this class in the given module. More... | |
static void | bindDerived (ClassTy &cls) |
Hook for derived classes to add class-specific bindings. More... | |
Protected Types | |
using | ClassTy = py::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:
const char *pyClassName
- the name of the Python class to create;GetTypeIDFunctionTy getInterfaceID
- the function producing the TypeID of the interface. Derived classes may redefine the bindDerived(ClassTy &)
method to bind interface-specific methods.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 145 of file IRInterfaces.cpp.
|
protected |
Definition at line 147 of file IRInterfaces.cpp.
|
protected |
Definition at line 148 of file IRInterfaces.cpp.
|
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 154 of file IRInterfaces.cpp.
References MlirStringRef::data, mlir::python::PyMlirContext::get(), mlir::python::PyOperation::getOperation(), MlirStringRef::length, mlirIdentifierStr(), mlirOperationGetName(), mlirOperationImplementsInterface(), mlirOperationImplementsInterfaceStatic(), mlirStringRefCreate(), and mlir::python::DefaultingPyMlirContext::resolve().
|
inlinestatic |
Creates the Python bindings for this class in the given module.
Definition at line 196 of file IRInterfaces.cpp.
|
inlinestatic |
Hook for derived classes to add class-specific bindings.
Definition at line 210 of file IRInterfaces.cpp.
|
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 219 of file IRInterfaces.cpp.
References mlir::python::PyOperation::getRef(), and mlir::python::PyObjectRef< T >::releaseObject().
|
inline |
Returns the canonical name of the operation this interface is constructed from.
Definition at line 240 of file IRInterfaces.cpp.
|
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 230 of file IRInterfaces.cpp.
References mlir::python::PyOperation::createOpView().
|
inline |
Returns true
if this object was constructed from a subclass of OpView rather than from an operation instance.
Definition at line 214 of file IRInterfaces.cpp.