tvm
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
Classes | Macros | Functions
stack_allocator.h File Reference
#include <stddef.h>
#include <stdint.h>
#include "crt_config.h"
#include "error_codes.h"
Include dependency graph for stack_allocator.h:

Go to the source code of this file.

Classes

struct  tvm_workspace_t
 

Macros

#define STACK_ALLOCATOR_TAG   0xabcd1234
 
#define STACK_ALLOCATOR_TAG_SIZE_BYTES   4
 
#define TVM_RUNTIME_ALLOC_ALIGNMENT_BYTES   16
 

Functions

tvm_crt_error_t StackMemoryManager_Init (tvm_workspace_t *tvm_runtime_workspace, uint8_t *g_aot_memory, size_t workspace_size)
 Initialize the stack-based memory manager. More...
 
tvm_crt_error_t StackMemoryManager_Allocate (tvm_workspace_t *tvm_runtime_workspace, int32_t nbytes, void **current_alloc)
 The intended user-facing function to allocate within the buffer. It wraps StackMemoryManager_Allocate_Body enable and disable the LIFO check that is useful for debugging the AoT codegen. More...
 
tvm_crt_error_t StackMemoryManager_Allocate_Body (tvm_workspace_t *tvm_runtime_workspace, int32_t nbytes, void **current_alloc, uint8_t do_lifo_check)
 The internal function that accepts allocate inputs and an extra byte to say to enable the LIFO check that is useful in debugging for debugging the AoT codegen. More...
 
tvm_crt_error_t StackMemoryManager_Free (tvm_workspace_t *tvm_runtime_workspace, void *ptr)
 The intended user-facing function to free the tensor within the buffer. It wraps StackMemoryManager_Free_Body enable and disable the stack allocator. More...
 
tvm_crt_error_t StackMemoryManager_Free_Body (tvm_workspace_t *tvm_runtime_workspace, void *ptr, uint8_t do_lifo_check)
 The internal function that accepts free inputs and an extra byte to say to enable the LIFO check that is useful in debugging for debugging the AoT codegen. More...
 

Macro Definition Documentation

◆ STACK_ALLOCATOR_TAG

#define STACK_ALLOCATOR_TAG   0xabcd1234

◆ STACK_ALLOCATOR_TAG_SIZE_BYTES

#define STACK_ALLOCATOR_TAG_SIZE_BYTES   4

◆ TVM_RUNTIME_ALLOC_ALIGNMENT_BYTES

#define TVM_RUNTIME_ALLOC_ALIGNMENT_BYTES   16

Memory alignment for allocator

Function Documentation

◆ StackMemoryManager_Allocate()

tvm_crt_error_t StackMemoryManager_Allocate ( tvm_workspace_t tvm_runtime_workspace,
int32_t  nbytes,
void **  current_alloc 
)

The intended user-facing function to allocate within the buffer. It wraps StackMemoryManager_Allocate_Body enable and disable the LIFO check that is useful for debugging the AoT codegen.

Parameters
tvm_runtime_workspaceThe tvm_workspace_t struct containing state
nbytesThe number of bytes required for the allocation
current_allocThe pointer-to-pointer to be populated with the allocated address

◆ StackMemoryManager_Allocate_Body()

tvm_crt_error_t StackMemoryManager_Allocate_Body ( tvm_workspace_t tvm_runtime_workspace,
int32_t  nbytes,
void **  current_alloc,
uint8_t  do_lifo_check 
)

The internal function that accepts allocate inputs and an extra byte to say to enable the LIFO check that is useful in debugging for debugging the AoT codegen.

Parameters
tvm_runtime_workspaceThe tvm_workspace_t struct containing state
nbytesThe number of bytes required for the allocation
current_allocThe pointer-to-pointer to be populated with the allocated address
do_lifo_checkThis being non-zero indicates to perform a check LIFO pattern Allocs/Frees

◆ StackMemoryManager_Free()

tvm_crt_error_t StackMemoryManager_Free ( tvm_workspace_t tvm_runtime_workspace,
void *  ptr 
)

The intended user-facing function to free the tensor within the buffer. It wraps StackMemoryManager_Free_Body enable and disable the stack allocator.

Parameters
tvm_runtime_workspaceThe tvm_workspace_t struct containing state
ptrThe base pointer of the tensor to be free'd

◆ StackMemoryManager_Free_Body()

tvm_crt_error_t StackMemoryManager_Free_Body ( tvm_workspace_t tvm_runtime_workspace,
void *  ptr,
uint8_t  do_lifo_check 
)

The internal function that accepts free inputs and an extra byte to say to enable the LIFO check that is useful in debugging for debugging the AoT codegen.

Parameters
tvm_runtime_workspaceThe tvm_workspace_t struct containing state
ptrThe base pointer of tensor to be free'd within the workspace buffer
do_lifo_checkThis being non-zero indicates to perform a check LIFO pattern Allocs/Frees

◆ StackMemoryManager_Init()

tvm_crt_error_t StackMemoryManager_Init ( tvm_workspace_t tvm_runtime_workspace,
uint8_t *  g_aot_memory,
size_t  workspace_size 
)

Initialize the stack-based memory manager.

Parameters
tvm_runtime_workspaceThe tvm_workspace_t struct containing state
g_aot_memoryThe memory buffer used to allocate within
workspace_sizeThe total size of the workspace buffer workspace