TI Deep Learning Product User Guide
itidl_rt.h File Reference

Introduction

This file defines the public interface for TIDL Runtime API.
This same API supports a client on a different CPU, out-of-process on the same CPU, or in-process.
This interface is targeted for users developing inference application
with imported TIDL models and users developing offload APIs for Open source
runtime engines like TFlite (Delegate) and ONNX runtime (Execution provider) etc.

Version
0.1 June 2020 : Initial Code

Go to the source code of this file.

Data Structures

struct  sTIDLRT_Tensor_t
 
struct  sTIDLRT_PerfStats_t
 
struct  sTIDLRT_Params_t
 

Macros

#define TIDLRT_STRING_SIZE   ((int32_t) 512)
 
#define TIDLRT_PAD_DIM_MAX   ((uint32_t) 4)
 
TIDL Element Type

This group defines the different types of element type used by TIDL library

#define TIDLRT_Uint8   ((int32_t) 0)
 
#define TIDLRT_Int8   ((int32_t) 1)
 
#define TIDLRT_Uint16   ((int32_t) 2)
 
#define TIDLRT_Int16   ((int32_t) 3)
 
#define TIDLRT_Uint32   ((int32_t) 4)
 
#define TIDLRT_Int32   ((int32_t) 5)
 
#define TIDLRT_Float32   ((int32_t) 6)
 
#define TIDLRT_Uint64   ((int32_t) 7)
 
#define TIDLRT_Int64   ((int32_t) 8)
 
TIDL Data Dimension Index

This group defines the indices of dimension array of layer data buffer in TIDL library

#define TIDLRT_DIM_BATCH   ((int32_t) 0)
 
#define TIDLRT_DIM_NUMCH   ((int32_t) 1)
 
#define TIDLRT_DIM_HEIGHT   ((int32_t) 2)
 
#define TIDLRT_DIM_WIDTH   ((int32_t) 3)
 
#define TIDLRT_DIM_MAX   (TIDLRT_DIM_WIDTH+1)
 
TIDL Pitch Dimension Index

This group defines the indices of pitch array of layer data buffer in TIDL library

#define TIDLRT_ROI_PITCH   ((uint32_t) 0)
 
#define TIDLRT_CHANNEL_PITCH   ((uint32_t) 1)
 
#define TIDLRT_LINE_PITCH   ((uint32_t) 2)
 
#define TIDLRT_PITCH_MAX   ((uint32_t) (TIDLRT_DIM_MAX - 1))
 
Memory types in TIDL RT

Memory types definition used in the context of TIDL RT

#define TIDLRT_MEM_USER_SPACE   ((uint32_t) 0)
 
#define TIDLRT_MEM_SHARED   ((uint32_t) 1)
 
#define TIDLRT_MEM_NATIVE   ((uint32_t) 2)
 
#define TIDLRT_MEM_MAX   (TIDLRT_MEM_NATIVE+1)
 
Tensor Layout Type

This group defines the indices Tensor Layout Type supported by TIDL RT library.
TIDLRT_LT_NCHW — Channels first, (Number_of_ROIs, Number_Of_Channels, Height , Width)- example (1,3,360,720 )
TIDLRT_LT_NHWC — Channels last, (Number_of_ROIs, Height , Width, Number_Of_Channels)- example (1,360,720,3 ).

#define TIDLRT_LT_NCHW   ((uint32_t) 0)
 
#define TIDLRT_LT_NHWC   ((uint32_t) 1)
 
#define TIDLRT_LT_MAX   (TIDLRT_LT_NHWC+1)
 

Functions

int32_t TIDLRT_create (sTIDLRT_Params_t *prms, void **handle)
 Function to create an instance of TIDL runtime. More...
 
int32_t TIDLRT_delete (void *handle)
 Function to delete an instance of TIDL runtime. More...
 
int32_t TIDLRT_invoke (void *handle, sTIDLRT_Tensor_t *in[], sTIDLRT_Tensor_t *out[])
 Function to run inference on input using a TIDL RT instance handle. More...
 
int32_t TIDLRT_deactivate (void *handle)
 Function to deactivate a instance of TIDL runtime. Activate will be done by the invoke if the handle is not active. More...
 
int32_t TIDLRT_setParamsDefault (sTIDLRT_Params_t *prms)
 Function to set default values for parameters defined in sTIDLRT_Params_t. More...
 
int32_t TIDLRT_setTensorDefault (sTIDLRT_Tensor_t *tensor)
 Function to set default values of parameters defined in sTIDLRT_Tensor_t. More...
 
int32_t TIDLRT_getDdrStats (uint64_t *read_bytes, uint64_t *write_bytes)
 Function to get the number of bytes read and written during the last inference call TIDLRT_invoke. More...
 
void * TIDLRT_allocSharedMem (int32_t alignment, int32_t size)
 Function to allocate memory in the shared heap memory section between the Host core and DL accelerator. Allocating memory here would help in avoiding buffer copy between the cores. More...
 
void TIDLRT_freeSharedMem (void *ptr)
 Function to free the memory allocated using TIDLRT_allocSharedMem. More...
 
int32_t TIDLRT_isSharedMem (void *ptr)
 Function to check whether The memory pointed by input pointer is part of shared heap section or NOT. More...
 

Macro Definition Documentation

◆ TIDLRT_STRING_SIZE

#define TIDLRT_STRING_SIZE   ((int32_t) 512)

◆ TIDLRT_PAD_DIM_MAX

#define TIDLRT_PAD_DIM_MAX   ((uint32_t) 4)

◆ TIDLRT_Uint8

#define TIDLRT_Uint8   ((int32_t) 0)

◆ TIDLRT_Int8

#define TIDLRT_Int8   ((int32_t) 1)

◆ TIDLRT_Uint16

#define TIDLRT_Uint16   ((int32_t) 2)

◆ TIDLRT_Int16

#define TIDLRT_Int16   ((int32_t) 3)

◆ TIDLRT_Uint32

#define TIDLRT_Uint32   ((int32_t) 4)

◆ TIDLRT_Int32

#define TIDLRT_Int32   ((int32_t) 5)

◆ TIDLRT_Float32

#define TIDLRT_Float32   ((int32_t) 6)

◆ TIDLRT_Uint64

#define TIDLRT_Uint64   ((int32_t) 7)

◆ TIDLRT_Int64

#define TIDLRT_Int64   ((int32_t) 8)

◆ TIDLRT_DIM_BATCH

#define TIDLRT_DIM_BATCH   ((int32_t) 0)

◆ TIDLRT_DIM_NUMCH

#define TIDLRT_DIM_NUMCH   ((int32_t) 1)

◆ TIDLRT_DIM_HEIGHT

#define TIDLRT_DIM_HEIGHT   ((int32_t) 2)

◆ TIDLRT_DIM_WIDTH

#define TIDLRT_DIM_WIDTH   ((int32_t) 3)

◆ TIDLRT_DIM_MAX

#define TIDLRT_DIM_MAX   (TIDLRT_DIM_WIDTH+1)

◆ TIDLRT_ROI_PITCH

#define TIDLRT_ROI_PITCH   ((uint32_t) 0)

◆ TIDLRT_CHANNEL_PITCH

#define TIDLRT_CHANNEL_PITCH   ((uint32_t) 1)

◆ TIDLRT_LINE_PITCH

#define TIDLRT_LINE_PITCH   ((uint32_t) 2)

◆ TIDLRT_PITCH_MAX

#define TIDLRT_PITCH_MAX   ((uint32_t) (TIDLRT_DIM_MAX - 1))

◆ TIDLRT_MEM_USER_SPACE

#define TIDLRT_MEM_USER_SPACE   ((uint32_t) 0)

◆ TIDLRT_MEM_SHARED

#define TIDLRT_MEM_SHARED   ((uint32_t) 1)

◆ TIDLRT_MEM_NATIVE

#define TIDLRT_MEM_NATIVE   ((uint32_t) 2)

◆ TIDLRT_MEM_MAX

#define TIDLRT_MEM_MAX   (TIDLRT_MEM_NATIVE+1)

◆ TIDLRT_LT_NCHW

#define TIDLRT_LT_NCHW   ((uint32_t) 0)

◆ TIDLRT_LT_NHWC

#define TIDLRT_LT_NHWC   ((uint32_t) 1)

◆ TIDLRT_LT_MAX

#define TIDLRT_LT_MAX   (TIDLRT_LT_NHWC+1)

Function Documentation

◆ TIDLRT_create()

int32_t TIDLRT_create ( sTIDLRT_Params_t prms,
void **  handle 
)

Function to create an instance of TIDL runtime.

Parameters
prms: Pointer to user configuration as defined in sTIDLRT_Params_t
handle: Pointer to the Successfully created instance is returned with this
Remarks
None
Returns
VX_SUCCESS (0) - Successful
VX_FAILURE ( < 0) - Unspecified error

◆ TIDLRT_delete()

int32_t TIDLRT_delete ( void *  handle)

Function to delete an instance of TIDL runtime.

Parameters
handle: Pointer to the Successfully created TIDL RT instance
Remarks
None
Returns
VX_SUCCESS (0) - Successful
VX_FAILURE ( < 0) - Unspecified error

◆ TIDLRT_invoke()

int32_t TIDLRT_invoke ( void *  handle,
sTIDLRT_Tensor_t in[],
sTIDLRT_Tensor_t out[] 
)

Function to run inference on input using a TIDL RT instance handle.

Parameters
handle: Pointer to the Successfully created TIDL RT instance
in: Pointer to list of input tensors as defined in sTIDLRT_Tensor_t
out: Pointer to list of output tensors as defined in sTIDLRT_Tensor_t
Remarks
None
Returns
VX_SUCCESS (0) - Successful
VX_FAILURE ( < 0) - Unspecified error

◆ TIDLRT_deactivate()

int32_t TIDLRT_deactivate ( void *  handle)

Function to deactivate a instance of TIDL runtime. Activate will be done by the invoke if the handle is not active.

Parameters
handle: Pointer to the Successfully created TIDL RT instance
Remarks
None
Returns
VX_SUCCESS (0) - Successful
VX_FAILURE ( < 0) - Unspecified error

◆ TIDLRT_setParamsDefault()

int32_t TIDLRT_setParamsDefault ( sTIDLRT_Params_t prms)

Function to set default values for parameters defined in sTIDLRT_Params_t.

Parameters
prms: Pointer to a instance of sTIDLRT_Params_t
Remarks
None
Returns
VX_SUCCESS (0) - Successful
VX_FAILURE ( < 0) - Unspecified error

◆ TIDLRT_setTensorDefault()

int32_t TIDLRT_setTensorDefault ( sTIDLRT_Tensor_t tensor)

Function to set default values of parameters defined in sTIDLRT_Tensor_t.

Parameters
tensor: Pointer to a instance of sTIDLRT_Tensor_t
Remarks
None
Returns
VX_SUCCESS (0) - Successful
VX_FAILURE ( < 0) - Unspecified error

◆ TIDLRT_getDdrStats()

int32_t TIDLRT_getDdrStats ( uint64_t *  read_bytes,
uint64_t *  write_bytes 
)

Function to get the number of bytes read and written during the last inference call TIDLRT_invoke.

Parameters
read_bytes: Number of bytes read from DDR memory
write_bytes: Number of bytes written to DDR memory
Remarks
None
Returns
VX_SUCCESS (0) - Successful
VX_FAILURE ( < 0) - Unspecified error

◆ TIDLRT_allocSharedMem()

void* TIDLRT_allocSharedMem ( int32_t  alignment,
int32_t  size 
)

Function to allocate memory in the shared heap memory section between the Host core and DL accelerator. Allocating memory here would help in avoiding buffer copy between the cores.

Parameters
alignment: Bases address alignment required in number of bytes
size: Number of bytes to be allocated
Remarks
None
Returns
Pinter to allocated memory - Successful
NULL - Error

◆ TIDLRT_freeSharedMem()

void TIDLRT_freeSharedMem ( void *  ptr)

Function to free the memory allocated using TIDLRT_allocSharedMem.

Parameters
ptr: Pointer to allocated memory
Remarks
None
Returns
None

◆ TIDLRT_isSharedMem()

int32_t TIDLRT_isSharedMem ( void *  ptr)

Function to check whether The memory pointed by input pointer is part of shared heap section or NOT.

Parameters
ptr: Pointer to the memory
Remarks
None
Returns
1 - True
0 - False