Function TVMFFIObjectCreateOpaque#
Defined in File c_api.h
Function Documentation#
-
int TVMFFIObjectCreateOpaque(void *handle, int32_t type_index, void (*deleter)(void *handle), TVMFFIObjectHandle *out)#
Create an Opaque object by passing in handle, type_index and deleter.
The opaque object’s lifetime is managed as an Object, so it can be retained and released like other objects. When the opaque object is kTVMFFIOpaquePyObject, it can be converted back to the python type when returned or passed as arguments to a python function.
We can support ffi::Function that interacts with these objects, most likely callback registered from python.
For language bindings, we only convert types that we do not recognize into this type. On the C++ side, the most common way to represent such OpaqueObject is to simply use ffi::ObjectRef or ffi::Any.
See also
kTVMFFIOpaquePyObject
Note
The caller must ensure the type_index is a valid opaque object type index.
- Parameters:
handle – The resource handle of the opaque object.
type_index – The type index of the object.
deleter – deleter to recycle
out – The output of the opaque object.
- Returns:
0 when success, nonzero when failure happens