tvm
Public Member Functions | List of all members
tvm::runtime::WrappedPythonObject Class Reference

A class that wraps a Python object and preserves its ownership. More...

#include <registry.h>

Collaboration diagram for tvm::runtime::WrappedPythonObject:

Public Member Functions

 WrappedPythonObject ()
 Construct a wrapper that doesn't own anything. More...
 
 WrappedPythonObject (std::nullptr_t)
 Conversion constructor from nullptr. More...
 
 WrappedPythonObject (void *python_obj)
 Take ownership of a python object. More...
 
 ~WrappedPythonObject ()
 Drop ownership of a python object. More...
 
 WrappedPythonObject (WrappedPythonObject &&)
 
WrappedPythonObjectoperator= (WrappedPythonObject &&)
 
 WrappedPythonObject (const WrappedPythonObject &)
 
WrappedPythonObjectoperator= (const WrappedPythonObject &)
 
WrappedPythonObjectoperator= (std::nullptr_t)
 
 operator bool ()
 
void * raw_pointer ()
 

Detailed Description

A class that wraps a Python object and preserves its ownership.

This class is used to wrap a PyObject* from the Python API and preserve its ownership. Allows for the creation of strong references to Python objects, which prevent them from being garbage-collected as long as the wrapper object exists.

Constructor & Destructor Documentation

◆ WrappedPythonObject() [1/5]

tvm::runtime::WrappedPythonObject::WrappedPythonObject ( )
inline

Construct a wrapper that doesn't own anything.

◆ WrappedPythonObject() [2/5]

tvm::runtime::WrappedPythonObject::WrappedPythonObject ( std::nullptr_t  )
inlineexplicit

Conversion constructor from nullptr.

◆ WrappedPythonObject() [3/5]

tvm::runtime::WrappedPythonObject::WrappedPythonObject ( void *  python_obj)
explicit

Take ownership of a python object.

A new strong reference is created for the underlying python object.

Parameters
python_objA PyObject* from the Python.h API. A new strong reference is created using Py_IncRef.

◆ ~WrappedPythonObject()

tvm::runtime::WrappedPythonObject::~WrappedPythonObject ( )

Drop ownership of a python object.

Removes the strong reference held by the wrapper.

◆ WrappedPythonObject() [4/5]

tvm::runtime::WrappedPythonObject::WrappedPythonObject ( WrappedPythonObject &&  )

◆ WrappedPythonObject() [5/5]

tvm::runtime::WrappedPythonObject::WrappedPythonObject ( const WrappedPythonObject )

Member Function Documentation

◆ operator bool()

tvm::runtime::WrappedPythonObject::operator bool ( )
inline

◆ operator=() [1/3]

WrappedPythonObject& tvm::runtime::WrappedPythonObject::operator= ( const WrappedPythonObject )

◆ operator=() [2/3]

WrappedPythonObject& tvm::runtime::WrappedPythonObject::operator= ( std::nullptr_t  )

◆ operator=() [3/3]

WrappedPythonObject& tvm::runtime::WrappedPythonObject::operator= ( WrappedPythonObject &&  )

◆ raw_pointer()

void* tvm::runtime::WrappedPythonObject::raw_pointer ( )
inline

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