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

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

Classes

struct  ErrorCapture
 RAII object that captures any error diagnostics emitted to the provided context. More...

Public Member Functions

 PyMlirContext ()=delete
 PyMlirContext (MlirContext context)
 PyMlirContext (const PyMlirContext &)=delete
 PyMlirContext (PyMlirContext &&)=delete
 ~PyMlirContext ()
MlirContext get ()
 Accesses the underlying MlirContext.
PyMlirContextRef getRef ()
 Gets a strong reference to this context, which will ensure it is kept alive for the life of the reference.
nanobind::object getCapsule ()
 Gets a capsule wrapping the void* within the MlirContext.
size_t getLiveModuleCount ()
 Gets the count of live modules associated with this context.
void contextExit (const nanobind::object &excType, const nanobind::object &excVal, const nanobind::object &excTb)
nanobind::object attachDiagnosticHandler (nanobind::object callback)
 Attaches a Python callback as a diagnostic handler, returning a registration object (internally a PyDiagnosticHandler).
void setEmitErrorDiagnostics (bool value)
 Controls whether error diagnostics should be propagated to diagnostic handlers, instead of being captured by ErrorCapture.
bool getEmitErrorDiagnostics ()

Static Public Member Functions

static PyMlirContextRef forContext (MlirContext context)
 Returns a context reference for the singleton PyMlirContext wrapper for the given context.
static nanobind::object createFromCapsule (nanobind::object capsule)
 Creates a PyMlirContext from the MlirContext wrapped by a capsule.
static size_t getLiveCount ()
 Gets the count of live context objects. Used for testing.
static nanobind::object contextEnter (nanobind::object context)
 Enter and exit the context manager.

Friends

class PyModule
class PyOperation

Detailed Description

Definition at line 200 of file IRCore.h.

Constructor & Destructor Documentation

◆ PyMlirContext() [1/4]

mlir::python::MLIR_BINDINGS_PYTHON_DOMAIN::PyMlirContext::PyMlirContext ( )
delete

◆ PyMlirContext() [2/4]

mlir::python::MLIR_BINDINGS_PYTHON_DOMAIN::PyMlirContext::PyMlirContext ( MlirContext context)

Definition at line 443 of file IRCore.cpp.

◆ PyMlirContext() [3/4]

mlir::python::MLIR_BINDINGS_PYTHON_DOMAIN::PyMlirContext::PyMlirContext ( const PyMlirContext & )
delete

References PyMlirContext().

◆ PyMlirContext() [4/4]

mlir::python::MLIR_BINDINGS_PYTHON_DOMAIN::PyMlirContext::PyMlirContext ( PyMlirContext && )
delete

References forContext(), and PyMlirContext().

◆ ~PyMlirContext()

mlir::python::MLIR_BINDINGS_PYTHON_DOMAIN::PyMlirContext::~PyMlirContext ( )

Definition at line 450 of file IRCore.cpp.

Member Function Documentation

◆ attachDiagnosticHandler()

nb::object mlir::python::MLIR_BINDINGS_PYTHON_DOMAIN::PyMlirContext::attachDiagnosticHandler ( nanobind::object callback)

Attaches a Python callback as a diagnostic handler, returning a registration object (internally a PyDiagnosticHandler).

Definition at line 517 of file IRCore.cpp.

References mlir::python::MLIR_BINDINGS_PYTHON_DOMAIN::PyThreadContextEntry::popContext().

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

◆ contextEnter()

nb::object mlir::python::MLIR_BINDINGS_PYTHON_DOMAIN::PyMlirContext::contextEnter ( nanobind::object context)
static

Enter and exit the context manager.

Definition at line 507 of file IRCore.cpp.

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

◆ contextExit()

void mlir::python::MLIR_BINDINGS_PYTHON_DOMAIN::PyMlirContext::contextExit ( const nanobind::object & excType,
const nanobind::object & excVal,
const nanobind::object & excTb )

◆ createFromCapsule()

nb::object mlir::python::MLIR_BINDINGS_PYTHON_DOMAIN::PyMlirContext::createFromCapsule ( nanobind::object capsule)
static

Creates a PyMlirContext from the MlirContext wrapped by a capsule.

Note that PyMlirContext instances are uniqued, so the returned object may be a pre-existing object. Ownership of the underlying MlirContext is taken by calling this function.

Definition at line 470 of file IRCore.cpp.

References get(), and mlirPythonContextToCapsule().

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

◆ forContext()

◆ get()

◆ getCapsule()

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

Gets a capsule wrapping the void* within the MlirContext.

Definition at line 466 of file IRCore.cpp.

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

◆ getEmitErrorDiagnostics()

bool mlir::python::MLIR_BINDINGS_PYTHON_DOMAIN::PyMlirContext::getEmitErrorDiagnostics ( )
inline

Definition at line 248 of file IRCore.h.

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

◆ getLiveCount()

size_t mlir::python::MLIR_BINDINGS_PYTHON_DOMAIN::PyMlirContext::getLiveCount ( )
static

Gets the count of live context objects. Used for testing.

Definition at line 502 of file IRCore.cpp.

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

◆ getLiveModuleCount()

size_t mlir::python::MLIR_BINDINGS_PYTHON_DOMAIN::PyMlirContext::getLiveModuleCount ( )

Gets the count of live modules associated with this context.

Used for testing.

Definition at line 1883 of file IRCore.cpp.

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

◆ getRef()

PyMlirContextRef mlir::python::MLIR_BINDINGS_PYTHON_DOMAIN::PyMlirContext::getRef ( )

Gets a strong reference to this context, which will ensure it is kept alive for the life of the reference.

Definition at line 462 of file IRCore.cpp.

Referenced by mlir::python::MLIR_BINDINGS_PYTHON_DOMAIN::PySymbolRefAttribute::fromList(), and mlir::python::MLIR_BINDINGS_PYTHON_DOMAIN::populateIRCore().

◆ setEmitErrorDiagnostics()

void mlir::python::MLIR_BINDINGS_PYTHON_DOMAIN::PyMlirContext::setEmitErrorDiagnostics ( bool value)
inline

Controls whether error diagnostics should be propagated to diagnostic handlers, instead of being captured by ErrorCapture.

Definition at line 247 of file IRCore.h.

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

◆ PyModule

friend class PyModule
friend

Definition at line 273 of file IRCore.h.

References PyModule.

Referenced by PyModule.

◆ PyOperation

friend class PyOperation
friend

Definition at line 274 of file IRCore.h.

References PyOperation.

Referenced by PyOperation.


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