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

#include "Bindings/Python/IRModule.h"

+ Inheritance diagram for mlir::python::PyModule:

Public Member Functions

 PyModule (PyModule &)=delete
 
 PyModule (PyMlirContext &&)=delete
 
 ~PyModule ()
 
MlirModule get ()
 Gets the backing MlirModule. More...
 
PyModuleRef getRef ()
 Gets a strong reference to this module. More...
 
pybind11::object getCapsule ()
 Gets a capsule wrapping the void* within the MlirModule. More...
 
- Public Member Functions inherited from mlir::python::BaseContextObject
 BaseContextObject (PyMlirContextRef ref)
 
PyMlirContextRefgetContext ()
 Accesses the context reference. More...
 

Static Public Member Functions

static PyModuleRef forModule (MlirModule module)
 Returns a PyModule reference for the given MlirModule. More...
 
static pybind11::object createFromCapsule (pybind11::object capsule)
 Creates a PyModule from the MlirModule wrapped by a capsule. More...
 

Detailed Description

Definition at line 523 of file IRModule.h.

Constructor & Destructor Documentation

◆ PyModule() [1/2]

mlir::python::PyModule::PyModule ( PyModule )
delete

Referenced by forModule().

◆ PyModule() [2/2]

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

◆ ~PyModule()

PyModule::~PyModule ( )

Member Function Documentation

◆ createFromCapsule()

py::object PyModule::createFromCapsule ( pybind11::object  capsule)
static

Creates a PyModule from the MlirModule wrapped by a capsule.

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

Definition at line 1093 of file IRCore.cpp.

References forModule(), mlirModuleIsNull(), mlirPythonCapsuleToModule(), and mlir::python::PyObjectRef< T >::releaseObject().

◆ forModule()

PyModuleRef PyModule::forModule ( MlirModule  module)
static

Returns a PyModule reference for the given MlirModule.

This may return a pre-existing or new object.

Definition at line 1067 of file IRCore.cpp.

References mlir::python::PyMlirContext::forContext(), mlirModuleGetContext(), and PyModule().

Referenced by createFromCapsule().

◆ get()

MlirModule mlir::python::PyModule::get ( )
inline

Gets the backing MlirModule.

Definition at line 533 of file IRModule.h.

Referenced by getCapsule().

◆ getCapsule()

py::object PyModule::getCapsule ( )

Gets a capsule wrapping the void* within the MlirModule.

Note that the module does not (yet) provide a corresponding factory for constructing from a capsule as that would require uniquing PyModule instances, which is not currently done.

Definition at line 1100 of file IRCore.cpp.

References get(), and mlirPythonModuleToCapsule().

◆ getRef()

PyModuleRef mlir::python::PyModule::getRef ( )
inline

Gets a strong reference to this module.

Definition at line 536 of file IRModule.h.


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