MLIR  19.0.0git
Public Member Functions | Static Public Member Functions | Friends | List of all members
mlir::python::PyOperation Class Reference

#include "Bindings/Python/IRModule.h"

+ Inheritance diagram for mlir::python::PyOperation:

Public Member Functions

 ~PyOperation () override
 
PyOperationgetOperation () 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 pybind11::object &parent=pybind11::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< PyOperationRefgetParentOperation ()
 Gets the parent operation or raises an exception if the operation has no parent. More...
 
pybind11::object getCapsule ()
 Gets a capsule wrapping the void* within the MlirOperation. More...
 
pybind11::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...
 
pybind11::object clone (const pybind11::object &ip)
 Clones this operation. More...
 
- Public Member Functions inherited from mlir::python::PyOperationBase
virtual ~PyOperationBase ()=default
 
void print (std::optional< int64_t > largeElementsLimit, bool enableDebugInfo, bool prettyDebugInfo, bool printGenericOpForm, bool useLocalScope, bool assumeVerified, py::object fileObject, bool binary)
 Implements the bound 'print' method and helps with others. More...
 
void print (PyAsmState &state, py::object fileObject, bool binary)
 
pybind11::object getAsm (bool binary, std::optional< int64_t > largeElementsLimit, bool enableDebugInfo, bool prettyDebugInfo, bool printGenericOpForm, bool useLocalScope, bool assumeVerified)
 
void writeBytecode (const pybind11::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 verify ()
 Verify the operation. More...
 
- Public Member Functions inherited from mlir::python::BaseContextObject
 BaseContextObject (PyMlirContextRef ref)
 
PyMlirContextRefgetContext ()
 Accesses the context reference. More...
 

Static Public Member Functions

static PyOperationRef forOperation (PyMlirContextRef contextRef, MlirOperation operation, pybind11::object parentKeepAlive=pybind11::object())
 Returns a PyOperation for the given MlirOperation, optionally associating it with a parentKeepAlive. More...
 
static PyOperationRef createDetached (PyMlirContextRef contextRef, MlirOperation operation, pybind11::object parentKeepAlive=pybind11::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 pybind11::object createFromCapsule (pybind11::object capsule)
 Creates a PyOperation from the MlirOperation wrapped by a capsule. More...
 
static pybind11::object create (const std::string &name, std::optional< std::vector< PyType * >> results, std::optional< std::vector< PyValue * >> operands, std::optional< pybind11::dict > attributes, std::optional< std::vector< PyBlock * >> successors, int regions, DefaultingPyLocation location, const pybind11::object &ip, bool inferType)
 Creates an operation. See corresponding python docstring. More...
 

Friends

class PyOperationBase
 
class PySymbolTable
 

Detailed Description

Definition at line 606 of file IRModule.h.

Constructor & Destructor Documentation

◆ ~PyOperation()

PyOperation::~PyOperation ( )
override

Member Function Documentation

◆ checkValid()

void PyOperation::checkValid ( ) const

◆ clone()

py::object PyOperation::clone ( const pybind11::object &  ip)

◆ create()

py::object PyOperation::create ( const std::string &  name,
std::optional< std::vector< PyType * >>  results,
std::optional< std::vector< PyValue * >>  operands,
std::optional< pybind11::dict >  attributes,
std::optional< std::vector< PyBlock * >>  successors,
int  regions,
DefaultingPyLocation  location,
const pybind11::object &  ip,
bool  inferType 
)
static

Creates an operation. See corresponding python docstring.

Definition at line 1382 of file IRCore.cpp.

Referenced by mlir::python::PyOpView::buildGeneric().

◆ createDetached()

PyOperationRef PyOperation::createDetached ( PyMlirContextRef  contextRef,
MlirOperation  operation,
pybind11::object  parentKeepAlive = pybind11::object() 
)
static

Creates a detached operation.

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

Definition at line 1160 of file IRCore.cpp.

Referenced by clone().

◆ createFromCapsule()

py::object PyOperation::createFromCapsule ( pybind11::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 1358 of file IRCore.cpp.

References mlir::python::PyMlirContext::forContext(), forOperation(), mlirOperationGetContext(), mlirOperationIsNull(), mlirPythonCapsuleToOperation(), and mlir::python::PyObjectRef< T >::releaseObject().

◆ createOpView()

py::object PyOperation::createOpView ( )

◆ detachFromParent()

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

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

Definition at line 631 of file IRModule.h.

References getOperation(), mlirOperationRemoveFromParent(), and setDetached().

◆ erase()

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 1528 of file IRCore.cpp.

References checkValid(), mlir::python::BaseContextObject::getContext(), and mlirOperationDestroy().

◆ forOperation()

PyOperationRef PyOperation::forOperation ( PyMlirContextRef  contextRef,
MlirOperation  operation,
pybind11::object  parentKeepAlive = pybind11::object() 
)
static

◆ get()

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

◆ getBlock()

PyBlock PyOperation::getBlock ( )

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

Definition at line 1344 of file IRCore.cpp.

References checkValid(), get(), getParentOperation(), mlirBlockIsNull(), and mlirOperationGetBlock().

◆ getCapsule()

py::object PyOperation::getCapsule ( )

Gets a capsule wrapping the void* within the MlirOperation.

Definition at line 1353 of file IRCore.cpp.

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

◆ getOperation()

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

Each must provide access to the raw Operation.

Implements mlir::python::PyOperationBase.

Definition at line 609 of file IRModule.h.

Referenced by detachFromParent(), and mlir::python::PyConcreteOpInterface< ConcreteIface >::PyConcreteOpInterface().

◆ getParentOperation()

std::optional< PyOperationRef > PyOperation::getParentOperation ( )

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

Definition at line 1334 of file IRCore.cpp.

References checkValid(), forOperation(), get(), mlir::python::BaseContextObject::getContext(), isAttached(), mlirOperationGetParentOperation(), and mlirOperationIsNull().

Referenced by getBlock().

◆ getRef()

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

◆ isAttached()

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

◆ operator MlirOperation()

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

Gets the backing operation.

Definition at line 638 of file IRModule.h.

References get().

◆ parse()

PyOperationRef 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 1174 of file IRCore.cpp.

◆ setAttached()

void mlir::python::PyOperation::setAttached ( const pybind11::object &  parent = pybind11::object())
inline

Definition at line 650 of file IRModule.h.

Referenced by mlir::python::PyInsertionPoint::insert().

◆ setDetached()

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

Definition at line 654 of file IRModule.h.

Referenced by detachFromParent().

◆ setInvalid()

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

Invalidate the operation.

Definition at line 693 of file IRModule.h.

Friends And Related Function Documentation

◆ PyOperationBase

friend class PyOperationBase
friend

Definition at line 716 of file IRModule.h.

◆ PySymbolTable

friend class PySymbolTable
friend

Definition at line 717 of file IRModule.h.


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