TI Deep Learning Product User Guide
itidl_rt.h
Go to the documentation of this file.
1 /*
2 *
3 * Copyright (c) {2015 - 2020} Texas Instruments Incorporated
4 *
5 * All rights reserved not granted herein.
6 *
7 * Limited License.
8 *
9 * Texas Instruments Incorporated grants a world-wide, royalty-free, non-exclusive
10 * license under copyrights and patents it now or hereafter owns or controls to make,
11 * have made, use, import, offer to sell and sell ("Utilize") this software subject to the
12 * terms herein. With respect to the foregoing patent license, such license is granted
13 * solely to the extent that any such patent is necessary to Utilize the software alone.
14 * The patent license shall not apply to any combinations which include this software,
15 * other than combinations with devices manufactured by or for TI ("TI Devices").
16 * No hardware patent is licensed hereunder.
17 *
18 * Redistributions must preserve existing copyright notices and reproduce this license
19 * (including the above copyright notice and the disclaimer and (if applicable) source
20 * code license limitations below) in the documentation and/or other materials provided
21 * with the distribution
22 *
23 * Redistribution and use in binary form, without modification, are permitted provided
24 * that the following conditions are met:
25 *
26 * * No reverse engineering, decompilation, or disassembly of this software is
27 * permitted with respect to any software provided in binary form.
28 *
29 * * any redistribution and use are licensed by TI for use only with TI Devices.
30 *
31 * * Nothing shall obligate TI to provide you with source code for the software
32 * licensed and provided to you in object code.
33 *
34 * If software source code is provided to you, modification and redistribution of the
35 * source code are permitted provided that the following conditions are met:
36 *
37 * * any redistribution and use of the source code, including any resulting derivative
38 * works, are licensed by TI for use only with TI Devices.
39 *
40 * * any redistribution and use of any object code compiled from the source code
41 * and any resulting derivative works, are licensed by TI for use only with TI Devices.
42 *
43 * Neither the name of Texas Instruments Incorporated nor the names of its suppliers
44 *
45 * may be used to endorse or promote products derived from this software without
46 * specific prior written permission.
47 *
48 * DISCLAIMER.
49 *
50 * THIS SOFTWARE IS PROVIDED BY TI AND TI'S LICENSORS "AS IS" AND ANY EXPRESS
51 * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
52 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
53 * IN NO EVENT SHALL TI AND TI'S LICENSORS BE LIABLE FOR ANY DIRECT, INDIRECT,
54 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
55 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
56 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
57 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
58 * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
59 * OF THE POSSIBILITY OF SUCH DAMAGE.
60 *
61 */
62 
77 #ifndef ITIDL_RT_H_
78 #define ITIDL_RT_H_
79 
80 #include <stdint.h>
81 #include <stdarg.h>
82 
83 #ifdef __cplusplus
84 extern "C" {
85 #endif
86 
87 #define TIDLRT_STRING_SIZE ((int32_t) 512)
88 #define TIDLRT_PAD_DIM_MAX ((uint32_t) 4)
89 
98 #define TIDLRT_Uint8 ((int32_t) 0)
99 #define TIDLRT_Int8 ((int32_t) 1)
100 #define TIDLRT_Uint16 ((int32_t) 2)
101 #define TIDLRT_Int16 ((int32_t) 3)
102 #define TIDLRT_Uint32 ((int32_t) 4)
103 #define TIDLRT_Int32 ((int32_t) 5)
104 #define TIDLRT_Float32 ((int32_t) 6)
105 #define TIDLRT_Uint64 ((int32_t) 7)
106 #define TIDLRT_Int64 ((int32_t) 8)
107 
108 /* @} */
109 
118 #define TIDLRT_DIM_BATCH ((int32_t) 0)
119 #define TIDLRT_DIM_NUMCH ((int32_t) 1)
120 #define TIDLRT_DIM_HEIGHT ((int32_t) 2)
121 #define TIDLRT_DIM_WIDTH ((int32_t) 3)
122 #define TIDLRT_DIM_MAX (TIDLRT_DIM_WIDTH+1)
123 /* @} */
124 
133 #define TIDLRT_ROI_PITCH ((uint32_t) 0)
134 #define TIDLRT_CHANNEL_PITCH ((uint32_t) 1)
135 #define TIDLRT_LINE_PITCH ((uint32_t) 2)
136 #define TIDLRT_PITCH_MAX ((uint32_t) (TIDLRT_DIM_MAX - 1))
137 /* @} */
138 
147 #define TIDLRT_MEM_USER_SPACE ((uint32_t) 0)
148 #define TIDLRT_MEM_SHARED ((uint32_t) 1)
149 #define TIDLRT_MEM_NATIVE ((uint32_t) 2)
150 #define TIDLRT_MEM_MAX (TIDLRT_MEM_NATIVE+1)
151 /* @} */
152 
163 #define TIDLRT_LT_NCHW ((uint32_t) 0)
164 #define TIDLRT_LT_NHWC ((uint32_t) 1)
165 #define TIDLRT_LT_MAX (TIDLRT_LT_NHWC+1)
166 /* @} */
167 
168 typedef struct {
173 int8_t name[TIDLRT_STRING_SIZE];
175 int32_t elementType;
177 int32_t numDim;
179 int32_t dimValues[TIDLRT_DIM_MAX];
181 int32_t pitch[TIDLRT_DIM_MAX-1];
183 int32_t padValues[TIDLRT_PAD_DIM_MAX];
185 void * ptr;
187 int32_t dataOffset;
189 uint32_t layout;
191 int32_t zeroPoint;
193 float scale;
195 uint32_t memType;
197 
198 typedef struct {
199  uint64_t cpIn_time_start;
200  uint64_t cpIn_time_end;
201  uint64_t proc_time_start;
202  uint64_t proc_time_end;
204  uint64_t cpOut_time_end;
206 
207 typedef struct {
209 void * netPtr;
213 int32_t net_capacity;
215 int32_t io_capacity;
217 int32_t flowCtrl;
231 int32_t(*TIDLVprintf)(const char * format, va_list arg);
233 int32_t(*TIDLWriteBinToFile)(const char * fileName, void * addr, int32_t size, void *tracePtr);
235 int32_t(*TIDLReadBinFromFile)(const char * fileName, void * addr, int32_t size);
241 uint32_t coreNum;
242 
244 
253 int32_t TIDLRT_create(sTIDLRT_Params_t *prms, void **handle);
254 
262 int32_t TIDLRT_delete(void *handle);
263 
273 int32_t TIDLRT_invoke(void *handle, sTIDLRT_Tensor_t *in[], sTIDLRT_Tensor_t *out[]);
274 
283 int32_t TIDLRT_deactivate(void *handle);
284 
293 
302 
311 int32_t TIDLRT_getDdrStats(uint64_t *read_bytes, uint64_t *write_bytes);
312 
322 void *TIDLRT_allocSharedMem(int32_t alignment, int32_t size);
323 
330 void TIDLRT_freeSharedMem(void *ptr);
331 
339 int32_t TIDLRT_isSharedMem(void *ptr);
340 
341 
342 #ifdef __cplusplus
343 }
344 #endif
345 
347 /* iTI_DL_RT */
348 
349 #endif /*ITIDL_RT_H_ */
350 
float maxPreEmptDelay
Definition: itidl_rt.h:229
int32_t traceLogLevel
Definition: itidl_rt.h:219
uint64_t proc_time_start
Definition: itidl_rt.h:201
uint64_t cpOut_time_start
Definition: itidl_rt.h:203
void * ioBufDescPtr
Definition: itidl_rt.h:211
#define TIDLRT_DIM_MAX
Definition: itidl_rt.h:122
#define TIDLRT_PAD_DIM_MAX
Definition: itidl_rt.h:88
uint32_t layout
Definition: itidl_rt.h:189
int32_t TIDLRT_setParamsDefault(sTIDLRT_Params_t *prms)
Function to set default values for parameters defined in sTIDLRT_Params_t.
void TIDLRT_freeSharedMem(void *ptr)
Function to free the memory allocated using TIDLRT_allocSharedMem.
int32_t elementType
Definition: itidl_rt.h:175
Definition: itidl_rt.h:168
uint32_t coreNum
Definition: itidl_rt.h:241
int32_t flowCtrl
Definition: itidl_rt.h:217
void * ptr
Definition: itidl_rt.h:185
float quantRangeUpdateFactor
Definition: itidl_rt.h:227
int32_t TIDLRT_isSharedMem(void *ptr)
Function to check whether The memory pointed by input pointer is part of shared heap section or NOT...
uint64_t proc_time_end
Definition: itidl_rt.h:202
sTIDLRT_PerfStats_t * stats
Definition: itidl_rt.h:237
int32_t io_capacity
Definition: itidl_rt.h:215
int32_t dataOffset
Definition: itidl_rt.h:187
uint64_t cpIn_time_start
Definition: itidl_rt.h:199
int32_t TIDLRT_setTensorDefault(sTIDLRT_Tensor_t *tensor)
Function to set default values of parameters defined in sTIDLRT_Tensor_t.
uint64_t cpIn_time_end
Definition: itidl_rt.h:200
int targetPriority
Definition: itidl_rt.h:239
void * netPtr
Definition: itidl_rt.h:209
Definition: itidl_rt.h:207
int32_t traceWriteLevel
Definition: itidl_rt.h:221
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.
uint32_t memType
Definition: itidl_rt.h:195
int32_t TIDLRT_create(sTIDLRT_Params_t *prms, void **handle)
Function to create an instance of TIDL runtime.
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 accelerato...
uint64_t cpOut_time_end
Definition: itidl_rt.h:204
int32_t TIDLRT_delete(void *handle)
Function to delete an instance of TIDL runtime.
int32_t zeroPoint
Definition: itidl_rt.h:191
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...
int32_t TIDLRT_deactivate(void *handle)
Function to deactivate a instance of TIDL runtime. Activate will be done by the invoke if the handle ...
int32_t numDim
Definition: itidl_rt.h:177
#define TIDLRT_STRING_SIZE
Definition: itidl_rt.h:87
float quantRangeExpansionFactor
Definition: itidl_rt.h:225
float scale
Definition: itidl_rt.h:193
int32_t net_capacity
Definition: itidl_rt.h:213
void * traceBaseName
Definition: itidl_rt.h:223
Definition: itidl_rt.h:198