MLIR
22.0.0git
|
#include "Bindings/Python/IRModule.h"
Public Member Functions | |
~PyOperation () override | |
PyOperation & | getOperation () override |
Each must provide access to the raw Operation. More... | |
void | detachFromParent () |
Detaches the operation from its parent block and updates its state accordingly. More... | |
operator MlirOperation () const | |
Gets the backing operation. More... | |
MlirOperation | get () const |
PyOperationRef | getRef () |
bool | isAttached () |
void | setAttached (const nanobind::object &parent=nanobind::object()) |
void | setDetached () |
void | checkValid () const |
PyBlock | getBlock () |
Gets the owning block or raises an exception if the operation has no owning block. More... | |
std::optional< PyOperationRef > | getParentOperation () |
Gets the parent operation or raises an exception if the operation has no parent. More... | |
nanobind::object | getCapsule () |
Gets a capsule wrapping the void* within the MlirOperation. More... | |
nanobind::object | createOpView () |
Creates an OpView suitable for this operation. More... | |
void | erase () |
Erases the underlying MlirOperation, removes its pointer from the parent context's live operations map, and sets the valid bit false. More... | |
void | setInvalid () |
Invalidate the operation. More... | |
nanobind::object | clone (const nanobind::object &ip) |
Clones this operation. More... | |
PyOperation (PyMlirContextRef contextRef, MlirOperation operation) | |
![]() | |
virtual | ~PyOperationBase ()=default |
void | print (std::optional< int64_t > largeElementsLimit, std::optional< int64_t > largeResourceLimit, bool enableDebugInfo, bool prettyDebugInfo, bool printGenericOpForm, bool useLocalScope, bool useNameLocAsPrefix, bool assumeVerified, nanobind::object fileObject, bool binary, bool skipRegions) |
Implements the bound 'print' method and helps with others. More... | |
void | print (PyAsmState &state, nanobind::object fileObject, bool binary) |
nanobind::object | getAsm (bool binary, std::optional< int64_t > largeElementsLimit, std::optional< int64_t > largeResourceLimit, bool enableDebugInfo, bool prettyDebugInfo, bool printGenericOpForm, bool useLocalScope, bool useNameLocAsPrefix, bool assumeVerified, bool skipRegions) |
void | writeBytecode (const nanobind::object &fileObject, std::optional< int64_t > bytecodeVersion) |
void | walk (std::function< MlirWalkResult(MlirOperation)> callback, MlirWalkOrder walkOrder) |
void | moveAfter (PyOperationBase &other) |
Moves the operation before or after the other operation. More... | |
void | moveBefore (PyOperationBase &other) |
bool | isBeforeInBlock (PyOperationBase &other) |
Given an operation 'other' that is within the same parent block, return whether the current operation is before 'other' in the operation list of the parent block. More... | |
bool | verify () |
Verify the operation. More... | |
![]() | |
BaseContextObject (PyMlirContextRef ref) | |
PyMlirContextRef & | getContext () |
Accesses the context reference. More... | |
Static Public Member Functions | |
static PyOperationRef | forOperation (PyMlirContextRef contextRef, MlirOperation operation, nanobind::object parentKeepAlive=nanobind::object()) |
Returns a PyOperation for the given MlirOperation, optionally associating it with a parentKeepAlive. More... | |
static PyOperationRef | createDetached (PyMlirContextRef contextRef, MlirOperation operation, nanobind::object parentKeepAlive=nanobind::object()) |
Creates a detached operation. More... | |
static PyOperationRef | parse (PyMlirContextRef contextRef, const std::string &sourceStr, const std::string &sourceName) |
Parses a source string (either text assembly or bytecode), creating a detached operation. More... | |
static nanobind::object | createFromCapsule (const nanobind::object &capsule) |
Creates a PyOperation from the MlirOperation wrapped by a capsule. More... | |
static nanobind::object | create (std::string_view name, std::optional< std::vector< PyType * >> results, llvm::ArrayRef< MlirValue > operands, std::optional< nanobind::dict > attributes, std::optional< std::vector< PyBlock * >> successors, int regions, PyLocation &location, const nanobind::object &ip, bool inferType) |
Creates an operation. See corresponding python docstring. More... | |
Friends | |
class | PyOperationBase |
class | PySymbolTable |
Definition at line 605 of file IRModule.h.
|
override |
Definition at line 1134 of file IRCore.cpp.
References erase(), isAttached(), and setInvalid().
PyOperation::PyOperation | ( | PyMlirContextRef | contextRef, |
MlirOperation | operation | ||
) |
Definition at line 1131 of file IRCore.cpp.
void PyOperation::checkValid | ( | ) | const |
Definition at line 1204 of file IRCore.cpp.
Referenced by mlir::python::PyRegion::checkValid(), mlir::python::PyBlock::checkValid(), mlir::python::PyValue::checkValid(), createOpView(), mlir::python::PySymbolTable::dunderGetItem(), erase(), mlir::python::PySymbolTable::erase(), get(), getBlock(), getCapsule(), getParentOperation(), mlir::python::PySymbolTable::getSymbolName(), mlir::python::PySymbolTable::getVisibility(), mlir::python::PySymbolTable::insert(), mlir::python::PyOperationBase::isBeforeInBlock(), mlir::python::PyOperationBase::moveAfter(), mlir::python::PyOperationBase::moveBefore(), mlir::python::PySymbolTable::replaceAllSymbolUses(), mlir::python::PySymbolTable::setSymbolName(), mlir::python::PySymbolTable::setVisibility(), mlir::python::PyOperationBase::walk(), mlir::python::PySymbolTable::walkSymbolTables(), and mlir::python::PyOperationBase::writeBytecode().
nb::object PyOperation::clone | ( | const nanobind::object & | ip | ) |
Clones this operation.
Definition at line 1537 of file IRCore.cpp.
References createDetached(), createOpView(), mlir::python::BaseContextObject::getContext(), maybeInsertOperation(), and mlirOperationClone().
|
static |
Creates an operation. See corresponding python docstring.
Definition at line 1422 of file IRCore.cpp.
Referenced by mlir::python::PyOpView::buildGeneric().
|
static |
Creates a detached operation.
The operation must not be associated with any existing live operation.
Definition at line 1183 of file IRCore.cpp.
|
static |
Creates a PyOperation from the MlirOperation wrapped by a capsule.
Ownership of the underlying MlirOperation is taken by calling this function.
Definition at line 1398 of file IRCore.cpp.
References mlir::python::PyMlirContext::forContext(), forOperation(), mlirOperationGetContext(), mlirOperationIsNull(), mlirPythonCapsuleToOperation(), and mlir::python::PyObjectRef< T >::releaseObject().
nb::object PyOperation::createOpView | ( | ) |
Creates an OpView suitable for this operation.
Definition at line 1546 of file IRCore.cpp.
References checkValid(), mlir::python::PyOpView::constructDerived(), MlirStringRef::data, mlir::python::PyGlobals::get(), get(), getRef(), MlirStringRef::length, mlir::python::PyGlobals::lookupOperationClass(), mlirIdentifierStr(), and mlirOperationGetName().
Referenced by clone(), mlir::python::PySymbolTable::dunderGetItem(), and mlir::python::PyConcreteOpInterface< ConcreteIface >::getOpView().
|
inline |
Detaches the operation from its parent block and updates its state accordingly.
Definition at line 630 of file IRModule.h.
References getOperation(), mlirOperationRemoveFromParent(), and setDetached().
void PyOperation::erase | ( | ) |
Erases the underlying MlirOperation, removes its pointer from the parent context's live operations map, and sets the valid bit false.
Definition at line 1557 of file IRCore.cpp.
References checkValid(), mlirOperationDestroy(), and setInvalid().
Referenced by ~PyOperation().
|
static |
Returns a PyOperation for the given MlirOperation, optionally associating it with a parentKeepAlive.
Definition at line 1176 of file IRCore.cpp.
Referenced by mlir::python::PyInsertionPoint::after(), mlir::python::PyInsertionPoint::atBlockBegin(), mlir::python::PyInsertionPoint::atBlockTerminator(), createFromCapsule(), mlir::python::PyValue::createFromCapsule(), mlir::python::PySymbolTable::dunderGetItem(), and getParentOperation().
|
inline |
Definition at line 638 of file IRModule.h.
References checkValid().
Referenced by createOpView(), mlir::python::PySymbolTable::erase(), getBlock(), getCapsule(), getOpResultOrValue(), getParentOperation(), mlir::python::PySymbolTable::getSymbolName(), mlir::python::PySymbolTable::getVisibility(), mlir::python::PySymbolTable::insert(), operator MlirOperation(), mlir::python::PyAsmState::PyAsmState(), mlir::python::PySymbolTable::PySymbolTable(), mlir::python::PySymbolTable::setSymbolName(), mlir::python::PySymbolTable::setVisibility(), mlir::python::PyOperationBase::verify(), and mlir::python::PySymbolTable::walkSymbolTables().
PyBlock PyOperation::getBlock | ( | ) |
Gets the owning block or raises an exception if the operation has no owning block.
Definition at line 1384 of file IRCore.cpp.
References checkValid(), get(), getParentOperation(), mlirBlockIsNull(), and mlirOperationGetBlock().
Referenced by mlir::python::PyInsertionPoint::after().
nb::object PyOperation::getCapsule | ( | ) |
Gets a capsule wrapping the void* within the MlirOperation.
Definition at line 1393 of file IRCore.cpp.
References checkValid(), get(), and mlirPythonOperationToCapsule().
|
inlineoverridevirtual |
Each must provide access to the raw Operation.
Implements mlir::python::PyOperationBase.
Definition at line 608 of file IRModule.h.
Referenced by detachFromParent(), and mlir::python::PyConcreteOpInterface< ConcreteIface >::PyConcreteOpInterface().
std::optional< PyOperationRef > PyOperation::getParentOperation | ( | ) |
Gets the parent operation or raises an exception if the operation has no parent.
Definition at line 1374 of file IRCore.cpp.
References checkValid(), forOperation(), get(), mlir::python::BaseContextObject::getContext(), isAttached(), mlirOperationGetParentOperation(), and mlirOperationIsNull().
Referenced by getBlock().
|
inline |
Definition at line 643 of file IRModule.h.
Referenced by createOpView(), and mlir::python::PyConcreteOpInterface< ConcreteIface >::getOperationObject().
|
inline |
Definition at line 647 of file IRModule.h.
Referenced by getParentOperation(), mlir::python::PyInsertionPoint::insert(), and ~PyOperation().
|
inline |
|
static |
Parses a source string (either text assembly or bytecode), creating a detached operation.
Definition at line 1192 of file IRCore.cpp.
References createDetached(), mlir::python::PyMlirContext::get(), mlirOperationCreateParse(), mlirOperationIsNull(), mlir::python::PyMlirContext::ErrorCapture::take(), and toMlirStringRef().
|
inline |
Definition at line 648 of file IRModule.h.
Referenced by mlir::python::PyInsertionPoint::insert().
|
inline |
Definition at line 652 of file IRModule.h.
Referenced by detachFromParent().
|
inline |
Invalidate the operation.
Definition at line 690 of file IRModule.h.
Referenced by erase(), and ~PyOperation().
|
friend |
Definition at line 714 of file IRModule.h.
|
friend |
Definition at line 715 of file IRModule.h.