![]() |
PandA-2024.02
|


Go to the source code of this file.
Data Structures | |
| 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 kBytes is used as data type. More... | |
Macros | |
| #define | TVM_WEAK __attribute__((weak)) |
| #define | TVM_DLL __attribute__((visibility("default"))) |
| #define | TVM_VERSION "0.6.dev" |
Typedefs | |
| typedef int64_t | tvm_index_t |
| type of array index. More... | |
| typedef DLDataType | TVMType |
| The data type used in TVM Runtime. More... | |
| typedef DLContext | TVMContext |
| The Device information, abstract away common device types. More... | |
| typedef DLTensor | TVMArray |
| The tensor array stucture to TVM API. More... | |
| typedef TVMArray * | 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 = 5, kDLSDAccel = 6, kOpenGL = 11, kDLMicroDev = 13 } |
| Extension device types in TVM. More... | |
| enum | TVMTypeCode { kHandle = 3U, kNull = 4U, kTVMType = 5U, kTVMContext = 6U, kArrayHandle = 7U, kNodeHandle = 8U, kModuleHandle = 9U, kFuncHandle = 10U, kStr = 11U, kBytes = 12U, kNDArrayContainer = 13U, kObjectCell = 14U, kExtBegin = 15U, kNNVMFirst = 16U, kNNVMLast = 20U, kExtReserveEnd = 64U, kExtEnd = 128U, kCustomBegin = 129U } |
| The type code in TVMType. More... | |
Functions | |
| TVM_DLL void | TVMAPISetLastError (const char *msg) |
| Used for implementing C API function. Set last error message before return. More... | |
| TVM_DLL const char * | TVMGetLastError (void) |
| return str message of the last error all function in this file will return 0 when success and -1 when an error occurred, TVMGetLastError can be called to retrieve the error More... | |
| TVM_DLL int | TVMModLoadFromFile (const char *file_name, const char *format, TVMModuleHandle *out) |
| Load module from file. More... | |
| TVM_DLL int | TVMModImport (TVMModuleHandle mod, TVMModuleHandle dep) |
| Add dep to mod's dependency. This allows functions in this module to use modules. More... | |
| TVM_DLL int | TVMModGetFunction (TVMModuleHandle mod, const char *func_name, int query_imports, TVMFunctionHandle *out) |
| Get function from the module. More... | |
| TVM_DLL int | TVMExtTypeFree (void *handle, int type_code) |
| Free front-end extension type resource. More... | |
| TVM_DLL int | TVMModFree (TVMModuleHandle mod) |
| Free the Module. More... | |
| TVM_DLL int | TVMFuncFree (TVMFunctionHandle func) |
| Free the function when it is no longer needed. More... | |
| TVM_DLL 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... | |
| TVM_DLL int | TVMCFuncSetReturn (TVMRetValueHandle ret, TVMValue *value, int *type_code, int num_ret) |
| Set the return value of TVMPackedCFunc. More... | |
| TVM_DLL int | TVMCbArgToReturn (TVMValue *value, int code) |
| Inplace translate callback argument value to return value. This is only needed for non-POD arguments. More... | |
| TVM_DLL int | TVMFuncCreateFromCFunc (TVMPackedCFunc func, void *resource_handle, TVMPackedCFuncFinalizer fin, TVMFunctionHandle *out) |
| Wrap a TVMPackedCFunc to become a FunctionHandle. More... | |
| TVM_DLL int | TVMFuncRegisterGlobal (const char *name, TVMFunctionHandle f, int override) |
| Register the function to runtime's global table. More... | |
| TVM_DLL int | TVMFuncGetGlobal (const char *name, TVMFunctionHandle *out) |
| Get a global function. More... | |
| TVM_DLL int | TVMFuncListGlobalNames (int *out_size, const char ***out_array) |
| List all the globally registered function name. More... | |
| TVM_DLL 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... | |
| TVM_DLL int | TVMArrayFree (TVMArrayHandle handle) |
| Free the TVM Array. More... | |
| TVM_DLL int | TVMArrayCopyFromBytes (TVMArrayHandle handle, void *data, size_t nbytes) |
| Copy array data from CPU byte array. More... | |
| TVM_DLL int | TVMArrayCopyToBytes (TVMArrayHandle handle, void *data, size_t nbytes) |
| Copy array data to CPU byte array. More... | |
| TVM_DLL int | TVMArrayCopyFromTo (TVMArrayHandle from, TVMArrayHandle to, TVMStreamHandle stream) |
| Copy the array, both from and to must be valid during the copy. More... | |
| TVM_DLL int | TVMArrayFromDLPack (DLManagedTensor *from, TVMArrayHandle *out) |
| Produce an array from the DLManagedTensor that shares data memory with the DLManagedTensor. More... | |
| TVM_DLL int | TVMArrayToDLPack (TVMArrayHandle from, DLManagedTensor **out) |
| Produce a DLMangedTensor from the array that shares data memory with the array. More... | |
| TVM_DLL void | TVMDLManagedTensorCallDeleter (DLManagedTensor *dltensor) |
| Delete (free) a DLManagedTensor's data. More... | |
| TVM_DLL int | TVMStreamCreate (int device_type, int device_id, TVMStreamHandle *out) |
| Create a new runtime stream. More... | |
| TVM_DLL int | TVMStreamFree (int device_type, int device_id, TVMStreamHandle stream) |
| Free a created stream handle. More... | |
| TVM_DLL 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... | |
| TVM_DLL int | TVMSynchronize (int device_type, int device_id, TVMStreamHandle stream) |
| Wait until all computations on stream completes. More... | |
| TVM_DLL int | TVMStreamStreamSynchronize (int device_type, int device_id, TVMStreamHandle src, TVMStreamHandle dst) |
| Synchronize two streams of execution. More... | |
| TVM_DLL int | TVMGetObjectTag (TVMObjectHandle obj, int *tag) |
| Get the tag from an object. More... | |
| #define TVM_DLL __attribute__((visibility("default"))) |
Definition at line 59 of file c_runtime_api.h.
| #define TVM_VERSION "0.6.dev" |
Definition at line 64 of file c_runtime_api.h.
| #define TVM_WEAK __attribute__((weak)) |
Definition at line 43 of file c_runtime_api.h.
| typedef int64_t tvm_index_t |
type of array index.
Definition at line 77 of file c_runtime_api.h.
The tensor array stucture to TVM API.
Definition at line 142 of file c_runtime_api.h.
| typedef TVMArray* TVMArrayHandle |
the array handle
Definition at line 145 of file c_runtime_api.h.
| typedef DLContext TVMContext |
The Device information, abstract away common device types.
Definition at line 137 of file c_runtime_api.h.
| 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.
| register_func_handle | The register function |
Definition at line 354 of file c_runtime_api.h.
| typedef void* TVMFunctionHandle |
Handle to packed function handle.
Definition at line 172 of file c_runtime_api.h.
| typedef void* TVMModuleHandle |
Handle to TVM runtime modules.
Definition at line 170 of file c_runtime_api.h.
| typedef void* TVMObjectHandle |
Handle to Object.
Definition at line 181 of file c_runtime_api.h.
| typedef int(* TVMPackedCFunc) (TVMValue *args, int *type_codes, int num_args, TVMRetValueHandle ret, void *resource_handle) |
C type of packed function.
| args | The arguments |
| type_codes | The type codes of the arguments |
| num_args | Number of arguments. |
| ret | The return value handle. |
| resource_handle | The handle additional resouce handle from fron-end. |
Definition at line 332 of file c_runtime_api.h.
| typedef void(* TVMPackedCFuncFinalizer) (void *resource_handle) |
C callback to free the resource handle in C packed function.
| resource_handle | The handle additional resouce handle from fron-end. |
Definition at line 343 of file c_runtime_api.h.
| typedef void* TVMRetValueHandle |
Handle to hold return value.
Definition at line 174 of file c_runtime_api.h.
| typedef void* TVMStreamHandle |
The stream that is specific to device can be NULL, which indicates the default one.
Definition at line 179 of file c_runtime_api.h.
| typedef DLDataType TVMType |
The data type used in TVM Runtime.
Examples
Definition at line 132 of file c_runtime_api.h.
| enum TVMDeviceExtType |
Extension device types in TVM.
| Enumerator | |
|---|---|
| kDLAOCL | |
| kDLSDAccel | |
| kOpenGL | |
| kDLMicroDev | |
Definition at line 80 of file c_runtime_api.h.
| enum TVMTypeCode |
The type code in TVMType.
Definition at line 92 of file c_runtime_api.h.
| TVM_DLL void TVMAPISetLastError | ( | const char * | msg | ) |
Used for implementing C API function. Set last error message before return.
| msg | The error message to be set. |
| TVM_DLL 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.
| shape | The shape of the array, the data content will be copied to out |
| ndim | The number of dimension of the array. |
| dtype_code | The type code of the dtype |
| dtype_bits | The number of bits of dtype |
| dtype_lanes | The number of lanes in the dtype. |
| device_type | The device type of context |
| device_id | The device id of context. |
| out | The output handle. |
| TVM_DLL int TVMArrayCopyFromBytes | ( | TVMArrayHandle | handle, |
| void * | data, | ||
| size_t | nbytes | ||
| ) |
Copy array data from CPU byte array.
| handle | The array handle. |
| data | the data pointer |
| nbytes | The number of bytes to copy. |
| TVM_DLL int TVMArrayCopyFromTo | ( | TVMArrayHandle | from, |
| TVMArrayHandle | to, | ||
| TVMStreamHandle | stream | ||
| ) |
Copy the array, both from and to must be valid during the copy.
| from | The array to be copied from. |
| to | The target space. |
| stream | The stream where the copy happens, can be NULL. |
| TVM_DLL int TVMArrayCopyToBytes | ( | TVMArrayHandle | handle, |
| void * | data, | ||
| size_t | nbytes | ||
| ) |
Copy array data to CPU byte array.
| handle | The array handle. |
| data | the data pointer |
| nbytes | The number of bytes to copy. |
| TVM_DLL int TVMArrayFree | ( | TVMArrayHandle | handle | ) |
Free the TVM Array.
| handle | The array handle to be freed. |
| TVM_DLL int TVMArrayFromDLPack | ( | DLManagedTensor * | from, |
| TVMArrayHandle * | out | ||
| ) |
Produce an array from the DLManagedTensor that shares data memory with the DLManagedTensor.
| from | The source DLManagedTensor. |
| out | The output array handle. |
| TVM_DLL int TVMArrayToDLPack | ( | TVMArrayHandle | from, |
| DLManagedTensor ** | out | ||
| ) |
Produce a DLMangedTensor from the array that shares data memory with the array.
| from | The source array. |
| out | The DLManagedTensor handle. |
Inplace translate callback argument value to return value. This is only needed for non-POD arguments.
| value | The value to be translated. |
| code | The type code to be translated. |
| TVM_DLL 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.
| ret | The return value handle, pass by ret in TVMPackedCFunc |
| value | The value to be returned. |
| type_code | The type of the value to be returned. |
| num_ret | Number of return values, for now only 1 is supported. |
| TVM_DLL void TVMDLManagedTensorCallDeleter | ( | DLManagedTensor * | dltensor | ) |
Delete (free) a DLManagedTensor's data.
| dltensor | Pointer to the DLManagedTensor. |
| TVM_DLL int TVMExtTypeFree | ( | void * | handle, |
| int | type_code | ||
| ) |
Free front-end extension type resource.
| handle | The extension handle. |
| type_code | The type of of the extension type. |
| TVM_DLL 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.
| func | node handle of the function. |
| arg_values | The arguments |
| type_codes | The type codes of the arguments |
| num_args | Number of arguments. |
| ret_val | The return value. |
| ret_type_code | the type code of return value. |
| TVM_DLL 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.
| func | The packed C function. |
| resource_handle | The resource handle from front-end, can be NULL. |
| fin | The finalizer on resource handle when the FunctionHandle get freed, can be NULL |
| out | the result function handle. |
| TVM_DLL int TVMFuncFree | ( | TVMFunctionHandle | func | ) |
Free the function when it is no longer needed.
| func | The function handle |
| TVM_DLL int TVMFuncGetGlobal | ( | const char * | name, |
| TVMFunctionHandle * | out | ||
| ) |
Get a global function.
| name | The name of the function. |
| out | the result function pointer, NULL if it does not exist. |
| TVM_DLL int TVMFuncListGlobalNames | ( | int * | out_size, |
| const char *** | out_array | ||
| ) |
List all the globally registered function name.
| out_size | The number of functions |
| out_array | The array of function names. |
| TVM_DLL 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.
| name | The name of the function. |
| f | The function to be registered. |
| override | Whether allow override already registered function. |
| TVM_DLL const char* TVMGetLastError | ( | void | ) |
return str message of the last error all function in this file will return 0 when success and -1 when an error occurred, TVMGetLastError can be called to retrieve the error
this function is threadsafe and can be called by different thread
| TVM_DLL int TVMGetObjectTag | ( | TVMObjectHandle | obj, |
| int * | tag | ||
| ) |
Get the tag from an object.
| obj | The object handle. |
| tag | The tag of object. |
| TVM_DLL int TVMModFree | ( | TVMModuleHandle | mod | ) |
Free the Module.
| mod | The module to be freed. |
The all functions remains valid until TVMFuncFree is called.
| TVM_DLL int TVMModGetFunction | ( | TVMModuleHandle | mod, |
| const char * | func_name, | ||
| int | query_imports, | ||
| TVMFunctionHandle * | out | ||
| ) |
Get function from the module.
| mod | The module handle. |
| func_name | The name of the function. |
| query_imports | Whether to query imported modules |
| out | The result function, can be NULL if it is not available. |
| TVM_DLL int TVMModImport | ( | TVMModuleHandle | mod, |
| TVMModuleHandle | dep | ||
| ) |
Add dep to mod's dependency. This allows functions in this module to use modules.
| mod | The module handle. |
| dep | The dependent module to be imported. |
| TVM_DLL int TVMModLoadFromFile | ( | const char * | file_name, |
| const char * | format, | ||
| TVMModuleHandle * | out | ||
| ) |
Load module from file.
| file_name | The file name to load the module from. |
| format | The format of the module. |
| out | The result module |
| TVM_DLL 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.
| device_type | The device type of context |
| device_id | The device id of context. |
| handle | The stream handle. |
| TVM_DLL int TVMStreamCreate | ( | int | device_type, |
| int | device_id, | ||
| TVMStreamHandle * | out | ||
| ) |
Create a new runtime stream.
| device_type | The device type of context |
| device_id | The device id of context |
| out | The new stream handle |
| TVM_DLL int TVMStreamFree | ( | int | device_type, |
| int | device_id, | ||
| TVMStreamHandle | stream | ||
| ) |
Free a created stream handle.
| device_type | The device type of context |
| device_id | The device id of context |
| stream | The stream to be freed |
| TVM_DLL int TVMStreamStreamSynchronize | ( | int | device_type, |
| int | device_id, | ||
| TVMStreamHandle | src, | ||
| TVMStreamHandle | dst | ||
| ) |
Synchronize two streams of execution.
| device_type | The device type of context |
| device_id | The device id of context |
| src | The source stream to synchronize. |
| dst | The destination stream to synchronize. |
| TVM_DLL int TVMSynchronize | ( | int | device_type, |
| int | device_id, | ||
| TVMStreamHandle | stream | ||
| ) |
Wait until all computations on stream completes.
| device_type | The device type of context |
| device_id | The device id of context. |
| stream | The stream to be synchronized. |
1.8.13