tvm
Classes | Macros | Typedefs | Enumerations | Functions
c_runtime_api.h File Reference
#include <dlpack/dlpack.h>
#include <stddef.h>
#include <stdint.h>
Include dependency graph for c_runtime_api.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

union  TVMValue
 Union type of values being passed through API and function calls. More...
 
struct  TVMByteArray
 Byte array type used to pass in byte array When kTVMBytes is used as data type. More...
 

Macros

#define TVM_WEAK   __attribute__((weak))
 
#define TVM_ATTRIBUTE_UNUSED
 
#define TVM_VERSION   "0.17.dev0"
 

Typedefs

typedef int64_t tvm_index_t
 type of array index. More...
 
typedef DLTensor * TVMArrayHandle
 the array handle More...
 
typedef void * TVMModuleHandle
 Handle to TVM runtime modules. More...
 
typedef void * TVMFunctionHandle
 Handle to packed function handle. More...
 
typedef void * TVMRetValueHandle
 Handle to hold return value. More...
 
typedef void * TVMStreamHandle
 The stream that is specific to device can be NULL, which indicates the default one. More...
 
typedef void * TVMObjectHandle
 Handle to Object. More...
 
typedef int(* TVMPackedCFunc) (TVMValue *args, int *type_codes, int num_args, TVMRetValueHandle ret, void *resource_handle)
 C type of packed function. More...
 
typedef void(* TVMPackedCFuncFinalizer) (void *resource_handle)
 C callback to free the resource handle in C packed function. More...
 
typedef int(* TVMExtensionFuncDeclarer) (TVMFunctionHandle register_func_handle)
 Signature for extension function declarer. More...
 

Enumerations

enum  TVMDeviceExtType {
  kDLAOCL = 32 , kDLSDAccel , kOpenGL , kDLMicroDev ,
  TVMDeviceExtType_End
}
 Extension device types in TVM. More...
 
enum  TVMArgTypeCode {
  kTVMArgInt = kDLInt , kTVMArgFloat = kDLFloat , kTVMOpaqueHandle = 3U , kTVMNullptr = 4U ,
  kTVMDataType = 5U , kDLDevice = 6U , kTVMDLTensorHandle = 7U , kTVMObjectHandle = 8U ,
  kTVMModuleHandle = 9U , kTVMPackedFuncHandle = 10U , kTVMStr = 11U , kTVMBytes = 12U ,
  kTVMNDArrayHandle = 13U , kTVMObjectRValueRefArg = 14U , kTVMExtBegin = 15U , kTVMNNVMFirst = 16U ,
  kTVMNNVMLast = 20U , kTVMExtReserveEnd = 64U , kTVMExtEnd = 128U
}
 The type code in used and only used in TVM FFI for argument passing. More...
 

Functions

void TVMAPISetLastError (const char *msg)
 Used for implementing C API function. Set last error message before return. More...
 
void TVMAPISetLastPythonError (void *py_object)
 Used for implementing C API function. Set last exception before return. More...
 
void * TVMGetLastPythonError ()
 Return the previous python error, if any. More...
 
const char * TVMGetLastError (void)
 return str message of the last error all function in this file will return 0 when success and nonzero when an error occurred, TVMGetLastError can be called to retrieve the error More...
 
const char * TVMGetLastBacktrace ()
 Return the backtrace of the most recent error. More...
 
void TVMDropLastPythonError ()
 Remove the propagated python error, if any. More...
 
void TVMThrowLastError ()
 Re-throw the most recent error. More...
 
int TVMModLoadFromFile (const char *file_name, const char *format, TVMModuleHandle *out)
 Load module from file. More...
 
int TVMModImport (TVMModuleHandle mod, TVMModuleHandle dep)
 Add dep to mod's dependency. This allows functions in this module to use modules. More...
 
int TVMModGetFunction (TVMModuleHandle mod, const char *func_name, int query_imports, TVMFunctionHandle *out)
 Get function from the module. More...
 
int TVMModFree (TVMModuleHandle mod)
 Free the Module. More...
 
int TVMFuncFree (TVMFunctionHandle func)
 Free the function when it is no longer needed. More...
 
int TVMFuncCall (TVMFunctionHandle func, TVMValue *arg_values, int *type_codes, int num_args, TVMValue *ret_val, int *ret_type_code)
 Call a Packed TVM Function. More...
 
int TVMCFuncSetReturn (TVMRetValueHandle ret, TVMValue *value, int *type_code, int num_ret)
 Set the return value of TVMPackedCFunc. More...
 
int TVMCbArgToReturn (TVMValue *value, int *code)
 Inplace translate callback argument value to return value. This is only needed for non-POD arguments. More...
 
int TVMFuncCreateFromCFunc (TVMPackedCFunc func, void *resource_handle, TVMPackedCFuncFinalizer fin, TVMFunctionHandle *out)
 Wrap a TVMPackedCFunc to become a FunctionHandle. More...
 
int TVMFuncRegisterGlobal (const char *name, TVMFunctionHandle f, int override)
 Register the function to runtime's global table. More...
 
int TVMFuncGetGlobal (const char *name, TVMFunctionHandle *out)
 Get a global function. More...
 
int TVMFuncListGlobalNames (int *out_size, const char ***out_array)
 List all the globally registered function name. More...
 
int TVMFuncRemoveGlobal (const char *name)
 Remove a global function. More...
 
int TVMArrayAlloc (const tvm_index_t *shape, int ndim, int dtype_code, int dtype_bits, int dtype_lanes, int device_type, int device_id, TVMArrayHandle *out)
 Allocate a nd-array's memory, including space of shape, of given spec. More...
 
int TVMArrayFree (TVMArrayHandle handle)
 Free the TVM Array. More...
 
int TVMArrayCopyFromBytes (TVMArrayHandle handle, void *data, size_t nbytes)
 Copy array data from CPU byte array. More...
 
int TVMArrayCopyToBytes (TVMArrayHandle handle, void *data, size_t nbytes)
 Copy array data to CPU byte array. More...
 
int TVMArrayCopyFromTo (TVMArrayHandle from, TVMArrayHandle to, TVMStreamHandle stream)
 Copy the array, both from and to must be valid during the copy. More...
 
int TVMArrayFromDLPack (DLManagedTensor *from, TVMArrayHandle *out)
 Produce an array from the DLManagedTensor that shares data memory with the DLManagedTensor. More...
 
int TVMArrayToDLPack (TVMArrayHandle from, DLManagedTensor **out)
 Produce a DLMangedTensor from the array that shares data memory with the array. More...
 
void TVMDLManagedTensorCallDeleter (DLManagedTensor *dltensor)
 Delete (free) a DLManagedTensor's data. More...
 
int TVMStreamCreate (int device_type, int device_id, TVMStreamHandle *out)
 Create a new runtime stream. More...
 
int TVMStreamFree (int device_type, int device_id, TVMStreamHandle stream)
 Free a created stream handle. More...
 
int TVMSetStream (int device_type, int device_id, TVMStreamHandle handle)
 Set the runtime stream of current thread to be stream. The subsequent calls to the same device_type will use the setted stream handle. The specific type of stream is runtime device dependent. More...
 
int TVMSynchronize (int device_type, int device_id, TVMStreamHandle stream)
 Wait until all computations on stream completes. More...
 
int TVMStreamStreamSynchronize (int device_type, int device_id, TVMStreamHandle src, TVMStreamHandle dst)
 Synchronize two streams of execution. More...
 
int TVMObjectGetTypeIndex (TVMObjectHandle obj, unsigned *out_tindex)
 Get the type_index from an object. More...
 
int TVMObjectTypeKey2Index (const char *type_key, unsigned *out_tindex)
 Convert type key to type index. More...
 
int TVMObjectTypeIndex2Key (unsigned tindex, char **out_type_key)
 Convert type index to type key. More...
 
int TVMObjectRetain (TVMObjectHandle obj)
 Increase the reference count of an object. More...
 
int TVMObjectFree (TVMObjectHandle obj)
 Free the object. More...
 
int TVMByteArrayFree (TVMByteArray *arr)
 Free a TVMByteArray returned from TVMFuncCall, and associated memory. More...
 
int TVMDeviceAllocDataSpace (DLDevice dev, size_t nbytes, size_t alignment, DLDataType type_hint, void **out_data)
 Allocate a data space on device. More...
 
int TVMDeviceAllocDataSpaceWithScope (DLDevice dev, int ndim, const int64_t *shape, DLDataType dtype, const char *mem_scope, void **out_data)
 Allocate a data space on device with special memory scope. More...
 
int TVMDeviceFreeDataSpace (DLDevice dev, void *ptr)
 Free a data space on device. More...
 
int TVMDeviceCopyDataFromTo (DLTensor *from, DLTensor *to, TVMStreamHandle stream)
 Copy data from one place to another. More...
 
int TVMObjectDerivedFrom (uint32_t child_type_index, uint32_t parent_type_index, int *is_derived)
 Check that an object is derived from another. More...
 

Macro Definition Documentation

◆ TVM_ATTRIBUTE_UNUSED

#define TVM_ATTRIBUTE_UNUSED

◆ TVM_VERSION

#define TVM_VERSION   "0.17.dev0"

◆ TVM_WEAK

#define TVM_WEAK   __attribute__((weak))

Typedef Documentation

◆ tvm_index_t

typedef int64_t tvm_index_t

type of array index.

◆ TVMArrayHandle

typedef DLTensor* TVMArrayHandle

the array handle

◆ TVMExtensionFuncDeclarer

typedef int(* TVMExtensionFuncDeclarer) (TVMFunctionHandle register_func_handle)

Signature for extension function declarer.

TVM call this function to get the extension functions The declarer will call register_func to register function and their name.

Parameters
register_func_handleThe register function
Returns
0 if success, -1 if failure happens

◆ TVMFunctionHandle

typedef void* TVMFunctionHandle

Handle to packed function handle.

◆ TVMModuleHandle

typedef void* TVMModuleHandle

Handle to TVM runtime modules.

◆ TVMObjectHandle

typedef void* TVMObjectHandle

Handle to Object.

◆ TVMPackedCFunc

typedef int(* TVMPackedCFunc) (TVMValue *args, int *type_codes, int num_args, TVMRetValueHandle ret, void *resource_handle)

C type of packed function.

Parameters
argsThe arguments
type_codesThe type codes of the arguments
num_argsNumber of arguments.
retThe return value handle.
resource_handleThe handle additional resouce handle from front-end.
Returns
0 if success, -1 if failure happens, set error via TVMAPISetLastError.
See also
TVMCFuncSetReturn

◆ TVMPackedCFuncFinalizer

typedef void(* TVMPackedCFuncFinalizer) (void *resource_handle)

C callback to free the resource handle in C packed function.

Parameters
resource_handleThe handle additional resouce handle from front-end.

◆ TVMRetValueHandle

typedef void* TVMRetValueHandle

Handle to hold return value.

◆ TVMStreamHandle

typedef void* TVMStreamHandle

The stream that is specific to device can be NULL, which indicates the default one.

Enumeration Type Documentation

◆ TVMArgTypeCode

The type code in used and only used in TVM FFI for argument passing.

DLPack consistency: 1) kTVMArgInt is compatible with kDLInt 2) kTVMArgFloat is compatible with kDLFloat 3) kDLUInt is not in ArgTypeCode, but has a spared slot

Downstream consistency: The kDLInt, kDLUInt, kDLFloat are kept consistent with the original ArgType code

It is only used in argument passing, and should not be confused with DataType::TypeCode, which is DLPack-compatible.

See also
tvm::runtime::DataType::TypeCode
Enumerator
kTVMArgInt 
kTVMArgFloat 
kTVMOpaqueHandle 
kTVMNullptr 
kTVMDataType 
kDLDevice 
kTVMDLTensorHandle 
kTVMObjectHandle 
kTVMModuleHandle 
kTVMPackedFuncHandle 
kTVMStr 
kTVMBytes 
kTVMNDArrayHandle 
kTVMObjectRValueRefArg 
kTVMExtBegin 
kTVMNNVMFirst 
kTVMNNVMLast 
kTVMExtReserveEnd 
kTVMExtEnd 

◆ TVMDeviceExtType

Extension device types in TVM.

Additional enumerators to supplement those provided by DLPack's DLDeviceType enumeration.

MAINTAINERS NOTE #1: We need to ensure that the two devices are identified by the same integer. Currently this requires manual verification. Discussed here: https://github.com/dmlc/dlpack/issues/111 As of DLPack v0.7, the highest-valued enumerator in DLDeviceType is kDLHexagon = 16.

MAINTAINERS NOTE #2: As of DLPack v0.7, the definition for DLDeviceType specifies an underlying storage type of int32_t. That guarantees a variable of type DLDeviceType is capable of holding any integers provided by either of these enumerations.

However, the int32_t specification only applies when the header file is compiled as C++, and this header file is also meant to work as C code. So the unspecified storage type could be a latent bug when compiled as C.

Enumerator
kDLAOCL 
kDLSDAccel 
kOpenGL 
kDLMicroDev 
TVMDeviceExtType_End 

Function Documentation

◆ TVMAPISetLastError()

void TVMAPISetLastError ( const char *  msg)

Used for implementing C API function. Set last error message before return.

Parameters
msgThe error message to be set.

◆ TVMAPISetLastPythonError()

void TVMAPISetLastPythonError ( void *  py_object)

Used for implementing C API function. Set last exception before return.

Parameters
py_objectThe python exception to be set

◆ TVMArrayAlloc()

int TVMArrayAlloc ( const tvm_index_t shape,
int  ndim,
int  dtype_code,
int  dtype_bits,
int  dtype_lanes,
int  device_type,
int  device_id,
TVMArrayHandle out 
)

Allocate a nd-array's memory, including space of shape, of given spec.

Parameters
shapeThe shape of the array, the data content will be copied to out
ndimThe number of dimension of the array.
dtype_codeThe type code of the dtype
dtype_bitsThe number of bits of dtype
dtype_lanesThe number of lanes in the dtype.
device_typeThe device type.
device_idThe device id.
outThe output handle.
Returns
0 when success, nonzero when failure happens

◆ TVMArrayCopyFromBytes()

int TVMArrayCopyFromBytes ( TVMArrayHandle  handle,
void *  data,
size_t  nbytes 
)

Copy array data from CPU byte array.

Parameters
handleThe array handle.
datathe data pointer
nbytesThe number of bytes to copy.
Returns
0 when success, nonzero when failure happens

◆ TVMArrayCopyFromTo()

int TVMArrayCopyFromTo ( TVMArrayHandle  from,
TVMArrayHandle  to,
TVMStreamHandle  stream 
)

Copy the array, both from and to must be valid during the copy.

Parameters
fromThe array to be copied from.
toThe target space.
streamThe stream where the copy happens, can be NULL.
Returns
0 when success, nonzero when failure happens

◆ TVMArrayCopyToBytes()

int TVMArrayCopyToBytes ( TVMArrayHandle  handle,
void *  data,
size_t  nbytes 
)

Copy array data to CPU byte array.

Parameters
handleThe array handle.
datathe data pointer
nbytesThe number of bytes to copy.
Returns
0 when success, nonzero when failure happens

◆ TVMArrayFree()

int TVMArrayFree ( TVMArrayHandle  handle)

Free the TVM Array.

Parameters
handleThe array handle to be freed.
Returns
0 when success, nonzero when failure happens

◆ TVMArrayFromDLPack()

int TVMArrayFromDLPack ( DLManagedTensor *  from,
TVMArrayHandle out 
)

Produce an array from the DLManagedTensor that shares data memory with the DLManagedTensor.

Parameters
fromThe source DLManagedTensor.
outThe output array handle.
Returns
0 when success, nonzero when failure happens

◆ TVMArrayToDLPack()

int TVMArrayToDLPack ( TVMArrayHandle  from,
DLManagedTensor **  out 
)

Produce a DLMangedTensor from the array that shares data memory with the array.

Parameters
fromThe source array.
outThe DLManagedTensor handle.
Returns
0 when success, nonzero when failure happens

◆ TVMByteArrayFree()

int TVMByteArrayFree ( TVMByteArray arr)

Free a TVMByteArray returned from TVMFuncCall, and associated memory.

Parameters
arrThe TVMByteArray instance.
Returns
0 on success, -1 on failure.

◆ TVMCbArgToReturn()

int TVMCbArgToReturn ( TVMValue value,
int *  code 
)

Inplace translate callback argument value to return value. This is only needed for non-POD arguments.

Parameters
valueThe value to be translated.
codeThe type code to be translated.
Note
This function will do a shallow copy when necessary.
Returns
0 when success, nonzero when failure happens.

◆ TVMCFuncSetReturn()

int TVMCFuncSetReturn ( TVMRetValueHandle  ret,
TVMValue value,
int *  type_code,
int  num_ret 
)

Set the return value of TVMPackedCFunc.

This function is called by TVMPackedCFunc to set the return value. When this function is not called, the function returns null by default.

Parameters
retThe return value handle, pass by ret in TVMPackedCFunc
valueThe value to be returned.
type_codeThe type of the value to be returned.
num_retNumber of return values, for now only 1 is supported.

◆ TVMDeviceAllocDataSpace()

int TVMDeviceAllocDataSpace ( DLDevice  dev,
size_t  nbytes,
size_t  alignment,
DLDataType  type_hint,
void **  out_data 
)

Allocate a data space on device.

Parameters
devThe device to perform operation.
nbytesThe number of bytes in memory.
alignmentThe alignment of the memory.
type_hintThe type of elements. Only needed by certain backends such as nbytes & alignment are sufficient for most backends.
out_dataThe allocated device pointer.
Returns
0 when success, nonzero when failure happens

◆ TVMDeviceAllocDataSpaceWithScope()

int TVMDeviceAllocDataSpaceWithScope ( DLDevice  dev,
int  ndim,
const int64_t *  shape,
DLDataType  dtype,
const char *  mem_scope,
void **  out_data 
)

Allocate a data space on device with special memory scope.

Note
The memory could use a special multi-dimensional memory layout. That is why we pass shape and dtype instead of raw number of bytes.
Parameters
devThe device to perform operation.
ndimThe number of dimension of the tensor.
shapeThe shape of the tensor.
dtypeThe type of elements.
mem_scopeThe memory scope of the tensor, can be nullptr, which indicate the default global DRAM
out_dataThe allocated device pointer.
Returns
0 when success, nonzero when failure happens

◆ TVMDeviceCopyDataFromTo()

int TVMDeviceCopyDataFromTo ( DLTensor *  from,
DLTensor *  to,
TVMStreamHandle  stream 
)

Copy data from one place to another.

Note
This API is designed to support special memory with shape dependent layout. We pass in DLTensor* with shape information to support these cases.
Parameters
fromThe source tensor.
toThe target tensor.
streamOptional stream object.
Returns
0 when success, nonzero when failure happens.

◆ TVMDeviceFreeDataSpace()

int TVMDeviceFreeDataSpace ( DLDevice  dev,
void *  ptr 
)

Free a data space on device.

Parameters
devThe device to perform operation.
ptrThe data space.
Returns
0 when success, nonzero when failure happens

◆ TVMDLManagedTensorCallDeleter()

void TVMDLManagedTensorCallDeleter ( DLManagedTensor *  dltensor)

Delete (free) a DLManagedTensor's data.

Parameters
dltensorPointer to the DLManagedTensor.

◆ TVMDropLastPythonError()

void TVMDropLastPythonError ( )

Remove the propagated python error, if any.

Removes the TVM-held reference to a thrown python exception object. Because these objects contain references to the stack frames from which the exception was thrown, maintaining a reference to an exception object prevents any local python variables from being garbage-collected. After retrieving the object using TVMGetLastPythonError, the Python FFI interface uses this method to clear the TVM-held reference to the exception, to allow garbage collection to continue.

◆ TVMFuncCall()

int TVMFuncCall ( TVMFunctionHandle  func,
TVMValue arg_values,
int *  type_codes,
int  num_args,
TVMValue ret_val,
int *  ret_type_code 
)

Call a Packed TVM Function.

Parameters
funcnode handle of the function.
arg_valuesThe arguments
type_codesThe type codes of the arguments
num_argsNumber of arguments.
ret_valThe return value.
ret_type_codethe type code of return value.
Returns
0 when success, nonzero when failure happens
Note
TVM calls always exchanges with type bits=64, lanes=1
API calls always exchanges with type bits=64, lanes=1 If API call returns container handles (e.g. FunctionHandle) these handles should be managed by the front-end. The front-end need to call free function (e.g. TVMFuncFree) to free these handles.

◆ TVMFuncCreateFromCFunc()

int TVMFuncCreateFromCFunc ( TVMPackedCFunc  func,
void *  resource_handle,
TVMPackedCFuncFinalizer  fin,
TVMFunctionHandle out 
)

Wrap a TVMPackedCFunc to become a FunctionHandle.

The resource_handle will be managed by TVM API, until the function is no longer used.

Parameters
funcThe packed C function.
resource_handleThe resource handle from front-end, can be NULL.
finThe finalizer on resource handle when the FunctionHandle get freed, can be NULL
outthe result function handle.
Returns
0 when success, nonzero when failure happens

◆ TVMFuncFree()

int TVMFuncFree ( TVMFunctionHandle  func)

Free the function when it is no longer needed.

Parameters
funcThe function handle
Returns
0 when success, nonzero when failure happens

◆ TVMFuncGetGlobal()

int TVMFuncGetGlobal ( const char *  name,
TVMFunctionHandle out 
)

Get a global function.

Parameters
nameThe name of the function.
outthe result function pointer, NULL if it does not exist.
Note
The function handle of global function is managed by TVM runtime, So TVMFuncFree is should not be called when it get deleted.

◆ TVMFuncListGlobalNames()

int TVMFuncListGlobalNames ( int *  out_size,
const char ***  out_array 
)

List all the globally registered function name.

Parameters
out_sizeThe number of functions
out_arrayThe array of function names.
Returns
0 when success, nonzero when failure happens

◆ TVMFuncRegisterGlobal()

int TVMFuncRegisterGlobal ( const char *  name,
TVMFunctionHandle  f,
int  override 
)

Register the function to runtime's global table.

The registered function then can be pulled by the backend by the name.

Parameters
nameThe name of the function.
fThe function to be registered.
overrideWhether allow override already registered function.

◆ TVMFuncRemoveGlobal()

int TVMFuncRemoveGlobal ( const char *  name)

Remove a global function.

Parameters
nameThe name of the function.

◆ TVMGetLastBacktrace()

const char* TVMGetLastBacktrace ( )

Return the backtrace of the most recent error.

Returns the backtrace of the most recent error, if an error exists, and the error contains a backtrace. If no error exists or the error does not contain a backtrace, returns nullptr.

Returns
The backtrace of the most recent error

◆ TVMGetLastError()

const char* TVMGetLastError ( void  )

return str message of the last error all function in this file will return 0 when success and nonzero when an error occurred, TVMGetLastError can be called to retrieve the error

this function is threadsafe and can be called by different thread

Returns
error info

◆ TVMGetLastPythonError()

void* TVMGetLastPythonError ( )

Return the previous python error, if any.

Used to propagate the original Python exception to a python try/except, when there are C++ stack frames between the location thro

Returns
The previous argument passed during the most recent call to TVMAPISetLastPythonError. If TVMAPISetLastPythonError has not been called, or if TVMDropLastPythonError has been called since the most recent to TVMAPISetLastPythonError, returns nullptr.

◆ TVMModFree()

int TVMModFree ( TVMModuleHandle  mod)

Free the Module.

Parameters
modThe module to be freed.
Note
This may not free up the module's resources. If there is active TVMFunctionHandle uses the module Or if this module is imported by another active module.

The all functions remains valid until TVMFuncFree is called.

Returns
0 when success, nonzero when failure happens

◆ TVMModGetFunction()

int TVMModGetFunction ( TVMModuleHandle  mod,
const char *  func_name,
int  query_imports,
TVMFunctionHandle out 
)

Get function from the module.

Parameters
modThe module handle.
func_nameThe name of the function.
query_importsWhether to query imported modules
outThe result function, can be NULL if it is not available.
Returns
0 when no error is thrown, nonzero when failure happens

◆ TVMModImport()

int TVMModImport ( TVMModuleHandle  mod,
TVMModuleHandle  dep 
)

Add dep to mod's dependency. This allows functions in this module to use modules.

Parameters
modThe module handle.
depThe dependent module to be imported.
Returns
0 when success, nonzero when failure happens

◆ TVMModLoadFromFile()

int TVMModLoadFromFile ( const char *  file_name,
const char *  format,
TVMModuleHandle out 
)

Load module from file.

Parameters
file_nameThe file name to load the module from.
formatThe format of the module.
outThe result module
Returns
0 when success, nonzero when failure happens
Note
The resulting module do not contain import relation. It can be reconstructed by TVMModImport.

◆ TVMObjectDerivedFrom()

int TVMObjectDerivedFrom ( uint32_t  child_type_index,
uint32_t  parent_type_index,
int *  is_derived 
)

Check that an object is derived from another.

Parameters
child_type_indexThe type index of the derived type.
parent_type_indexThe type index of the parent type.
is_derivedA boolean representing whether this predicate holds.
Returns
0 when success, nonzero when failure happens.

◆ TVMObjectFree()

int TVMObjectFree ( TVMObjectHandle  obj)

Free the object.

Parameters
objThe object handle.
Note
Internally we decrease the reference counter of the object. The object will be freed when every reference to the object are removed.
Returns
0 when success, nonzero when failure happens

◆ TVMObjectGetTypeIndex()

int TVMObjectGetTypeIndex ( TVMObjectHandle  obj,
unsigned *  out_tindex 
)

Get the type_index from an object.

Parameters
objThe object handle.
out_tindexthe output type index.
Returns
0 when success, nonzero when failure happens

◆ TVMObjectRetain()

int TVMObjectRetain ( TVMObjectHandle  obj)

Increase the reference count of an object.

Parameters
objThe object handle.
Note
Internally we increase the reference counter of the object.
Returns
0 when success, nonzero when failure happens

◆ TVMObjectTypeIndex2Key()

int TVMObjectTypeIndex2Key ( unsigned  tindex,
char **  out_type_key 
)

Convert type index to type key.

Parameters
tindexThe type index.
out_type_keyThe output type key.
Returns
0 when success, nonzero when failure happens

◆ TVMObjectTypeKey2Index()

int TVMObjectTypeKey2Index ( const char *  type_key,
unsigned *  out_tindex 
)

Convert type key to type index.

Parameters
type_keyThe key of the type.
out_tindexthe corresponding type index.
Returns
0 when success, nonzero when failure happens

◆ TVMSetStream()

int TVMSetStream ( int  device_type,
int  device_id,
TVMStreamHandle  handle 
)

Set the runtime stream of current thread to be stream. The subsequent calls to the same device_type will use the setted stream handle. The specific type of stream is runtime device dependent.

Parameters
device_typeThe device type.
device_idThe device id.
handleThe stream handle.
Returns
0 when success, nonzero when failure happens

◆ TVMStreamCreate()

int TVMStreamCreate ( int  device_type,
int  device_id,
TVMStreamHandle out 
)

Create a new runtime stream.

Parameters
device_typeThe device type.
device_idThe device id.
outThe new stream handle.
Returns
0 when success, nonzero when failure happens

◆ TVMStreamFree()

int TVMStreamFree ( int  device_type,
int  device_id,
TVMStreamHandle  stream 
)

Free a created stream handle.

Parameters
device_typeThe device type.
device_idThe device id.
streamThe stream to be freed.
Returns
0 when success, nonzero when failure happens

◆ TVMStreamStreamSynchronize()

int TVMStreamStreamSynchronize ( int  device_type,
int  device_id,
TVMStreamHandle  src,
TVMStreamHandle  dst 
)

Synchronize two streams of execution.

Parameters
device_typeThe device type.
device_idThe device id.
srcThe source stream to synchronize.
dstThe destination stream to synchronize.
Returns
0 when success, nonzero when failure happens

◆ TVMSynchronize()

int TVMSynchronize ( int  device_type,
int  device_id,
TVMStreamHandle  stream 
)

Wait until all computations on stream completes.

Parameters
device_typeThe device type.
device_idThe device id.
streamThe stream to be synchronized.
Returns
0 when success, nonzero when failure happens

◆ TVMThrowLastError()

void TVMThrowLastError ( )

Re-throw the most recent error.

If an error was previously set using TVMAPISetLastError or TVMAPISetLastPythonError, re-throw the error. This is similar to LOG(FATAL) << TVMGetLastError(), but includes handling to propagate a python exception across C++ stack frames, or to append a stack trace to an error message.