Struct TVMFFIObjectAllocHeader

Struct TVMFFIObjectAllocHeader#

Struct Documentation#

struct TVMFFIObjectAllocHeader#

Mandatory header placed immediately before each TVMFFIObject body.

A TVMFFIObject::deleter may invoke this header’s delete_space callback when the object’s storage lifetime ends. Frontend custom allocators can use this mechanism to coordinate cleanup of language-specific state, such as a cached PyObject wrapper, with reclamation of the TVM FFI allocation.

The callback may be NULL if the object deleter releases the storage directly.

Public Members

void (*delete_space)(void *ptr)#

Reclaim storage allocated for a TVMFFIObject.

When used, TVMFFIObject::deleter invokes this callback after the object’s weak lifetime ends. The callback is responsible for eventually reclaiming the complete allocator-owned allocation, including any private prefix, and cleaning up associated frontend state.

Note

ptr points to the object body, not to the preceding TVMFFIObjectAllocHeader. The object’s C++ lifetime may already have ended, so the callback must not access its fields.

Note

This callback may be NULL if the object deleter reclaims the allocation directly.

Param ptr:

Pointer to the object body returned by the allocator.