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_DIM1 ((int32_t) 1)
120 #define TIDLRT_DIM_DIM2 ((int32_t) 2)
121 #define TIDLRT_DIM_NUMCH ((int32_t) 3)
122 #define TIDLRT_DIM_HEIGHT ((int32_t) 4)
123 #define TIDLRT_DIM_WIDTH ((int32_t) 5)
124 #define TIDLRT_DIM_MAX (TIDLRT_DIM_WIDTH+1)
125 /* @} */
126 
135 #define TIDLRT_ROI_PITCH ((uint32_t) 0)
136 #define TIDLRT_DIM1_PITCH ((uint32_t) 1)
137 #define TIDLRT_DIM2_PITCH ((uint32_t) 2)
138 #define TIDLRT_CHANNEL_PITCH ((uint32_t) 3)
139 #define TIDLRT_LINE_PITCH ((uint32_t) 4)
140 #define TIDLRT_PITCH_MAX ((uint32_t) (TIDLRT_DIM_MAX - 1))
141 /* @} */
142 
151 #define TIDLRT_MEM_USER_SPACE ((uint32_t) 0)
152 #define TIDLRT_MEM_SHARED ((uint32_t) 1)
153 #define TIDLRT_MEM_NATIVE ((uint32_t) 2)
154 #define TIDLRT_MEM_MAX (TIDLRT_MEM_NATIVE+1)
155 /* @} */
156 
167 #define TIDLRT_LT_NCHW ((uint32_t) 0)
168 #define TIDLRT_LT_NHWC ((uint32_t) 1)
169 #define TIDLRT_LT_MAX (TIDLRT_LT_NHWC+1)
170 /* @} */
171 
172 typedef struct {
177 int8_t name[TIDLRT_STRING_SIZE];
179 int32_t elementType;
181 int32_t numDim;
183 int32_t dimValues[TIDLRT_DIM_MAX];
185 int32_t pitch[TIDLRT_DIM_MAX-1];
187 int32_t padValues[TIDLRT_PAD_DIM_MAX];
189 void * ptr;
191 int32_t dataOffset;
193 uint32_t layout;
195 int32_t zeroPoint;
197 float scale;
199 uint32_t memType;
201 
202 typedef struct {
203  uint64_t cpIn_time_start;
204  uint64_t cpIn_time_end;
205  uint64_t proc_time_start;
206  uint64_t proc_time_end;
208  uint64_t cpOut_time_end;
210 
211 typedef struct {
213 void * netPtr;
217 int32_t net_capacity;
219 int32_t io_capacity;
221 int32_t flowCtrl;
227 char traceBaseName[TIDLRT_STRING_SIZE];
235 int32_t(*TIDLVprintf)(const char * format, va_list arg);
237 int32_t(*TIDLWriteBinToFile)(const char * fileName, void * addr, int32_t size, int32_t count);
239 int32_t(*TIDLReadBinFromFile)(const char * fileName, void * addr, int32_t size, int32_t count);
245 uint32_t coreNum;
247 int32_t coreStartIdx;
249 char traceSubgraphName[TIDLRT_STRING_SIZE];
251 
260 int32_t TIDLRT_create(sTIDLRT_Params_t *prms, void **handle);
261 
269 int32_t TIDLRT_delete(void *handle);
270 
280 int32_t TIDLRT_invoke(void *handle, sTIDLRT_Tensor_t *in[], sTIDLRT_Tensor_t *out[]);
281 
290 int32_t TIDLRT_deactivate(void *handle);
291 
300 
309 
318 int32_t TIDLRT_getDdrStats(uint64_t *read_bytes, uint64_t *write_bytes);
319 
329 void *TIDLRT_allocSharedMem(int32_t alignment, int32_t size);
330 
337 void TIDLRT_freeSharedMem(void *ptr);
338 
346 int32_t TIDLRT_isSharedMem(void *ptr);
347 
348 
349 #ifdef __cplusplus
350 }
351 #endif
352 
354 /* iTI_DL_RT */
355 
356 #endif /*ITIDL_RT_H_ */
357 
float maxPreEmptDelay
Definition: itidl_rt.h:233
int32_t traceLogLevel
Definition: itidl_rt.h:223
uint64_t proc_time_start
Definition: itidl_rt.h:205
uint64_t cpOut_time_start
Definition: itidl_rt.h:207
void * ioBufDescPtr
Definition: itidl_rt.h:215
#define TIDLRT_DIM_MAX
Definition: itidl_rt.h:124
#define TIDLRT_PAD_DIM_MAX
Definition: itidl_rt.h:88
uint32_t layout
Definition: itidl_rt.h:193
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:179
Definition: itidl_rt.h:172
uint32_t coreNum
Definition: itidl_rt.h:245
int32_t flowCtrl
Definition: itidl_rt.h:221
void * ptr
Definition: itidl_rt.h:189
float quantRangeUpdateFactor
Definition: itidl_rt.h:231
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:206
sTIDLRT_PerfStats_t * stats
Definition: itidl_rt.h:241
int32_t io_capacity
Definition: itidl_rt.h:219
int32_t dataOffset
Definition: itidl_rt.h:191
uint64_t cpIn_time_start
Definition: itidl_rt.h:203
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:204
int targetPriority
Definition: itidl_rt.h:243
void * netPtr
Definition: itidl_rt.h:213
Definition: itidl_rt.h:211
int32_t traceWriteLevel
Definition: itidl_rt.h:225
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:199
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:208
int32_t TIDLRT_delete(void *handle)
Function to delete an instance of TIDL runtime.
int32_t zeroPoint
Definition: itidl_rt.h:195
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:181
#define TIDLRT_STRING_SIZE
Definition: itidl_rt.h:87
float quantRangeExpansionFactor
Definition: itidl_rt.h:229
float scale
Definition: itidl_rt.h:197
int32_t net_capacity
Definition: itidl_rt.h:217
int32_t coreStartIdx
Definition: itidl_rt.h:247
Definition: itidl_rt.h:202