MLIR 22.0.0git
mlir::python::MLIR_BINDINGS_PYTHON_DOMAIN::PyOperation Class Reference

#include "mlir/Bindings/Python/IRCore.h"

Inheritance diagram for mlir::python::MLIR_BINDINGS_PYTHON_DOMAIN::PyOperation:

Public Member Functions

 ~PyOperation () override
PyOperationgetOperation () override
 Each must provide access to the raw Operation.
void detachFromParent ()
 Detaches the operation from its parent block and updates its state accordingly.
 operator MlirOperation () const
 Gets the backing operation.
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.
std::optional< PyOperationRefgetParentOperation ()
 Gets the parent operation or raises an exception if the operation has no parent.
nanobind::object getCapsule ()
 Gets a capsule wrapping the void* within the MlirOperation.
nanobind::object createOpView ()
 Creates an OpView suitable for this operation.
void erase ()
 Erases the underlying MlirOperation, removes its pointer from the parent context's live operations map, and sets the valid bit false.
void setInvalid ()
 Invalidate the operation.
nanobind::object clone (const nanobind::object &ip)
 Clones this operation.
 PyOperation (PyMlirContextRef contextRef, MlirOperation operation)
Public Member Functions inherited from mlir::python::MLIR_BINDINGS_PYTHON_DOMAIN::PyOperationBase
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.
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< PyWalkResult(MlirOperation)> callback, PyWalkOrder walkOrder)
void moveAfter (PyOperationBase &other)
 Moves the operation before or after the other operation.
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.
bool verify ()
 Verify the operation.
Public Member Functions inherited from mlir::python::MLIR_BINDINGS_PYTHON_DOMAIN::BaseContextObject
 BaseContextObject (PyMlirContextRef ref)
PyMlirContextRefgetContext ()
 Accesses the context reference.

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.
static PyOperationRef createDetached (PyMlirContextRef contextRef, MlirOperation operation, nanobind::object parentKeepAlive=nanobind::object())
 Creates a detached operation.
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.
static nanobind::object createFromCapsule (const nanobind::object &capsule)
 Creates a PyOperation from the MlirOperation wrapped by a capsule.
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.

Friends

class PyOperationBase
class PySymbolTable

Detailed Description

Definition at line 632 of file IRCore.h.

Constructor & Destructor Documentation

◆ ~PyOperation()

mlir::python::MLIR_BINDINGS_PYTHON_DOMAIN::PyOperation::~PyOperation ( )
override

◆ PyOperation()

mlir::python::MLIR_BINDINGS_PYTHON_DOMAIN::PyOperation::PyOperation ( PyMlirContextRef contextRef,
MlirOperation operation )

Definition at line 929 of file IRCore.cpp.

Referenced by getOperation().

Member Function Documentation

◆ checkValid()

void mlir::python::MLIR_BINDINGS_PYTHON_DOMAIN::PyOperation::checkValid ( ) const

◆ clone()

nb::object mlir::python::MLIR_BINDINGS_PYTHON_DOMAIN::PyOperation::clone ( const nanobind::object & ip)

Clones this operation.

Definition at line 1361 of file IRCore.cpp.

◆ create()

nb::object mlir::python::MLIR_BINDINGS_PYTHON_DOMAIN::PyOperation::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 )
static

Creates an operation. See corresponding python docstring.

Definition at line 1245 of file IRCore.cpp.

Referenced by mlir::python::MLIR_BINDINGS_PYTHON_DOMAIN::populateIRCore().

◆ createDetached()

PyOperationRef mlir::python::MLIR_BINDINGS_PYTHON_DOMAIN::PyOperation::createDetached ( PyMlirContextRef contextRef,
MlirOperation operation,
nanobind::object parentKeepAlive = nanobind::object() )
static

Creates a detached operation.

The operation must not be associated with any existing live operation.

Definition at line 981 of file IRCore.cpp.

◆ createFromCapsule()

nb::object mlir::python::MLIR_BINDINGS_PYTHON_DOMAIN::PyOperation::createFromCapsule ( const nanobind::object & capsule)
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 1221 of file IRCore.cpp.

References checkValid(), get(), and mlirPythonOperationToCapsule().

Referenced by mlir::python::MLIR_BINDINGS_PYTHON_DOMAIN::populateIRCore().

◆ createOpView()

nb::object mlir::python::MLIR_BINDINGS_PYTHON_DOMAIN::PyOperation::createOpView ( )

Creates an OpView suitable for this operation.

Definition at line 1370 of file IRCore.cpp.

Referenced by mlir::python::MLIR_BINDINGS_PYTHON_DOMAIN::PyRewritePatternSet::add(), and mlir::python::MLIR_BINDINGS_PYTHON_DOMAIN::populateIRCore().

◆ detachFromParent()

void mlir::python::MLIR_BINDINGS_PYTHON_DOMAIN::PyOperation::detachFromParent ( )

Detaches the operation from its parent block and updates its state accordingly.

Definition at line 1002 of file IRCore.cpp.

Referenced by mlir::python::MLIR_BINDINGS_PYTHON_DOMAIN::populateIRCore().

◆ erase()

void mlir::python::MLIR_BINDINGS_PYTHON_DOMAIN::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 1381 of file IRCore.cpp.

◆ forOperation()

PyOperationRef mlir::python::MLIR_BINDINGS_PYTHON_DOMAIN::PyOperation::forOperation ( PyMlirContextRef contextRef,
MlirOperation operation,
nanobind::object parentKeepAlive = nanobind::object() )
static

◆ get()

MlirOperation mlir::python::MLIR_BINDINGS_PYTHON_DOMAIN::PyOperation::get ( ) const

◆ getBlock()

PyBlock mlir::python::MLIR_BINDINGS_PYTHON_DOMAIN::PyOperation::getBlock ( )

Gets the owning block or raises an exception if the operation has no owning block.

Definition at line 1207 of file IRCore.cpp.

Referenced by mlir::python::MLIR_BINDINGS_PYTHON_DOMAIN::populateIRCore().

◆ getCapsule()

nb::object mlir::python::MLIR_BINDINGS_PYTHON_DOMAIN::PyOperation::getCapsule ( )

Gets a capsule wrapping the void* within the MlirOperation.

Definition at line 1216 of file IRCore.cpp.

Referenced by mlir::python::MLIR_BINDINGS_PYTHON_DOMAIN::populateIRCore().

◆ getOperation()

PyOperation & mlir::python::MLIR_BINDINGS_PYTHON_DOMAIN::PyOperation::getOperation ( )
inlineoverridevirtual

Each must provide access to the raw Operation.

Implements mlir::python::MLIR_BINDINGS_PYTHON_DOMAIN::PyOperationBase.

Definition at line 636 of file IRCore.h.

References PyOperation().

◆ getParentOperation()

std::optional< PyOperationRef > mlir::python::MLIR_BINDINGS_PYTHON_DOMAIN::PyOperation::getParentOperation ( )

Gets the parent operation or raises an exception if the operation has no parent.

Definition at line 1197 of file IRCore.cpp.

◆ getRef()

PyOperationRef mlir::python::MLIR_BINDINGS_PYTHON_DOMAIN::PyOperation::getRef ( )

Definition at line 1013 of file IRCore.cpp.

References checkValid().

Referenced by mlir::python::MLIR_BINDINGS_PYTHON_DOMAIN::populateIRCore().

◆ isAttached()

bool mlir::python::MLIR_BINDINGS_PYTHON_DOMAIN::PyOperation::isAttached ( )
inline

Definition at line 666 of file IRCore.h.

Referenced by mlir::python::MLIR_BINDINGS_PYTHON_DOMAIN::populateIRCore().

◆ operator MlirOperation()

mlir::python::MLIR_BINDINGS_PYTHON_DOMAIN::PyOperation::operator MlirOperation ( ) const
inline

Gets the backing operation.

Definition at line 661 of file IRCore.h.

References get().

◆ parse()

PyOperationRef mlir::python::MLIR_BINDINGS_PYTHON_DOMAIN::PyOperation::parse ( PyMlirContextRef contextRef,
const std::string & sourceStr,
const std::string & sourceName )
static

Parses a source string (either text assembly or bytecode), creating a detached operation.

Definition at line 990 of file IRCore.cpp.

Referenced by mlir::python::MLIR_BINDINGS_PYTHON_DOMAIN::populateIRCore().

◆ setAttached()

void mlir::python::MLIR_BINDINGS_PYTHON_DOMAIN::PyOperation::setAttached ( const nanobind::object & parent = nanobind::object())

◆ setDetached()

void mlir::python::MLIR_BINDINGS_PYTHON_DOMAIN::PyOperation::setDetached ( )

Definition at line 1022 of file IRCore.cpp.

◆ setInvalid()

void mlir::python::MLIR_BINDINGS_PYTHON_DOMAIN::PyOperation::setInvalid ( )
inline

Invalidate the operation.

Definition at line 703 of file IRCore.h.

Referenced by mlir::python::MLIR_BINDINGS_PYTHON_DOMAIN::populateIRCore().

◆ PyOperationBase

friend class PyOperationBase
friend

Definition at line 727 of file IRCore.h.

References PyOperationBase.

Referenced by PyOperationBase.

◆ PySymbolTable

friend class PySymbolTable
friend

Definition at line 728 of file IRCore.h.

References PySymbolTable.

Referenced by PySymbolTable.


The documentation for this class was generated from the following files: