MLIR 22.0.0git
mlir::python::PyValue Class Reference

Wrapper around the generic MlirValue. More...

#include "Bindings/Python/IRModule.h"

Public Member Functions

virtual ~PyValue ()=default
 PyValue (PyOperationRef parentOperation, MlirValue value)
 operator MlirValue () const
MlirValue get ()
PyOperationRefgetParentOperation ()
void checkValid ()
nanobind::object getCapsule ()
 Gets a capsule wrapping the void* within the MlirValue.
nanobind::object maybeDownCast ()

Static Public Member Functions

static PyValue createFromCapsule (nanobind::object capsule)
 Creates a PyValue from the MlirValue wrapped by a capsule.

Detailed Description

Wrapper around the generic MlirValue.

Values are managed completely by the operation that resulted in their definition. For op result value, this is the operation that defines the value. For block argument values, this is the operation that contains the block to which the value is an argument (blocks cannot be detached in Python bindings so such operation always exists).

Definition at line 1167 of file IRModule.h.

Constructor & Destructor Documentation

◆ ~PyValue()

virtual mlir::python::PyValue::~PyValue ( )
virtualdefault

◆ PyValue()

mlir::python::PyValue::PyValue ( PyOperationRef parentOperation,
MlirValue value )
inline

Definition at line 1173 of file IRModule.h.

Referenced by createFromCapsule().

Member Function Documentation

◆ checkValid()

void mlir::python::PyValue::checkValid ( )
inline

Definition at line 1180 of file IRModule.h.

◆ createFromCapsule()

PyValue PyValue::createFromCapsule ( nanobind::object capsule)
static

Creates a PyValue from the MlirValue wrapped by a capsule.

Ownership of the underlying MlirValue is still tied to the owning operation.

Definition at line 2140 of file IRCore.cpp.

References mlir::python::PyMlirContext::forContext(), mlir::python::PyOperation::forOperation(), mlirBlockArgumentGetOwner(), mlirBlockGetParentOperation(), mlirOperationGetContext(), mlirOpResultGetOwner(), mlirPythonCapsuleToValue(), mlirValueIsABlockArgument(), mlirValueIsAOpResult(), and PyValue().

◆ get()

MlirValue mlir::python::PyValue::get ( )
inline

Definition at line 1177 of file IRModule.h.

Referenced by getCapsule(), getOpResultOrValue(), and maybeDownCast().

◆ getCapsule()

nb::object PyValue::getCapsule ( )

Gets a capsule wrapping the void* within the MlirValue.

Definition at line 2121 of file IRCore.cpp.

References get(), and mlirPythonValueToCapsule().

◆ getParentOperation()

PyOperationRef & mlir::python::PyValue::getParentOperation ( )
inline

Definition at line 1178 of file IRModule.h.

◆ maybeDownCast()

◆ operator MlirValue()

mlir::python::PyValue::operator MlirValue ( ) const
inline

Definition at line 1175 of file IRModule.h.


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