tvm
|
Defines generic string-based function lookup structs. More...
Go to the source code of this file.
Classes | |
struct | TVMFuncRegistry |
A data structure that facilitates function lookup by C-string name. More... | |
struct | TVMMutableFuncRegistry |
A TVMFuncRegistry that supports adding and changing the functions. More... | |
Macros | |
#define | TVM_AVERAGE_FUNCTION_NAME_STRLEN_BYTES 10 |
Typedefs | |
typedef uint16_t | tvm_function_index_t |
typedef uint16_t | tvm_module_index_t |
typedef struct TVMFuncRegistry | TVMFuncRegistry |
A data structure that facilitates function lookup by C-string name. More... | |
typedef struct TVMMutableFuncRegistry | TVMMutableFuncRegistry |
A TVMFuncRegistry that supports adding and changing the functions. More... | |
Functions | |
uint16_t | TVMFuncRegistry_GetNumFuncs (const TVMFuncRegistry *reg) |
Get the of the number of functions from registry. More... | |
int | TVMFuncRegistry_SetNumFuncs (const TVMFuncRegistry *reg, const uint16_t num_funcs) |
Set the number of functions to registry. More... | |
const char * | TVMFuncRegistry_Get0thFunctionName (const TVMFuncRegistry *reg) |
Get the address of 0th function from registry. More... | |
tvm_crt_error_t | TVMFuncRegistry_Lookup (const TVMFuncRegistry *reg, const char *name, tvm_function_index_t *function_index) |
Get packed function from registry by name. More... | |
tvm_crt_error_t | TVMFuncRegistry_GetByIndex (const TVMFuncRegistry *reg, tvm_function_index_t index, TVMBackendPackedCFunc *out_func) |
Fetch TVMBackendPackedCFunc given a function index. More... | |
tvm_crt_error_t | TVMMutableFuncRegistry_Create (TVMMutableFuncRegistry *reg, uint8_t *buffer, size_t buffer_size_bytes) |
Create a new mutable function registry from a block of memory. More... | |
tvm_crt_error_t | TVMMutableFuncRegistry_Set (TVMMutableFuncRegistry *reg, const char *name, TVMBackendPackedCFunc func, int override) |
Add or set a function in the registry. More... | |
Defines generic string-based function lookup structs.
#define TVM_AVERAGE_FUNCTION_NAME_STRLEN_BYTES 10 |
typedef uint16_t tvm_function_index_t |
typedef uint16_t tvm_module_index_t |
typedef struct TVMFuncRegistry TVMFuncRegistry |
A data structure that facilitates function lookup by C-string name.
typedef struct TVMMutableFuncRegistry TVMMutableFuncRegistry |
A TVMFuncRegistry that supports adding and changing the functions.
const char* TVMFuncRegistry_Get0thFunctionName | ( | const TVMFuncRegistry * | reg | ) |
Get the address of 0th function from registry.
reg | TVMFunctionRegistry instance that contains the function. |
tvm_crt_error_t TVMFuncRegistry_GetByIndex | ( | const TVMFuncRegistry * | reg, |
tvm_function_index_t | index, | ||
TVMBackendPackedCFunc * | out_func | ||
) |
Fetch TVMBackendPackedCFunc given a function index.
reg | TVMFunctionRegistry instance that contains the function. |
index | Index of the function. |
out_func | Pointer which receives the function pointer at index , if a valid index was given. Unmodified otherwise. |
uint16_t TVMFuncRegistry_GetNumFuncs | ( | const TVMFuncRegistry * | reg | ) |
Get the of the number of functions from registry.
reg | TVMFunctionRegistry instance that contains the function. |
tvm_crt_error_t TVMFuncRegistry_Lookup | ( | const TVMFuncRegistry * | reg, |
const char * | name, | ||
tvm_function_index_t * | function_index | ||
) |
Get packed function from registry by name.
reg | TVMFunctionRegistry instance that contains the function. , * |
name | The function name |
function_index | Pointer to receive the 0-based index of the function in the registry, if it was found. Unmodified otherwise. |
name
. int TVMFuncRegistry_SetNumFuncs | ( | const TVMFuncRegistry * | reg, |
const uint16_t | num_funcs | ||
) |
Set the number of functions to registry.
reg | TVMFunctionRegistry instance that contains the function. |
num_funcs | The number of functions |
tvm_crt_error_t TVMMutableFuncRegistry_Create | ( | TVMMutableFuncRegistry * | reg, |
uint8_t * | buffer, | ||
size_t | buffer_size_bytes | ||
) |
Create a new mutable function registry from a block of memory.
reg | TVMMutableFuncRegistry to create. |
buffer | Backing memory available for this function registry. |
buffer_size_bytes | Number of bytes available in buffer. |
tvm_crt_error_t TVMMutableFuncRegistry_Set | ( | TVMMutableFuncRegistry * | reg, |
const char * | name, | ||
TVMBackendPackedCFunc | func, | ||
int | override | ||
) |
Add or set a function in the registry.
reg | The mutable function registry to affect. |
name | Name of the function. |
func | The function pointer. |
override | non-zero if an existing entry should be overridden. |
reg
already contains max_functions
entries. kTvmErrorFunctionAlreadyDefined when a function named name
is already present in the registry, and override
== 0.