1 /******************************************************************************
2 * Copyright (c) 2017-2018 Texas Instruments Incorporated - http://www.ti.com/
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of Texas Instruments Incorporated nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
20 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
26 * THE POSSIBILITY OF SUCH DAMAGE.
27 *****************************************************************************/
29 #pragma once
31 #define TIDL_NUM_MAX_LAYERS (256)
32 #define TIDL_NUM_IN_BUFS (16)
33 #define TIDL_NUM_OUT_BUFS (16)
34 #define TIDL_STRING_SIZE (256)
35 #define TIDL_MAX_PAD_SIZE (4)
36 /* Fix for JIRA issue TIDL - 303 */
37 #define TIDL_MAX_DATA_BUFS (256)
38 #define TIDL_MAX_ALG_IN_BUFS (16)
39 #define TIDL_MAX_ALG_OUT_BUFS (16)
41 typedef float float32_tidl;
43 /**
44 @enum eTIDL_LayerType
45 @brief This enumerator defines the different types of layers used
46 in deeep learing algorithms
47 */
48 typedef enum
49 {
50 TIDL_DataLayer = 0,
51 TIDL_ConvolutionLayer = 1,
52 TIDL_PoolingLayer = 2,
53 TIDL_ReLULayer = 3,
54 TIDL_PReLULayer = 4,
55 TIDL_EltWiseLayer = 5,
56 TIDL_InnerProductLayer = 6,
57 TIDL_SoftMaxLayer = 7,
58 TIDL_BatchNormLayer = 8,
59 TIDL_BiasLayer = 9,
60 TIDL_ScaleLayer = 10,
61 TIDL_Deconv2DLayer = 11,
62 TIDL_ConcatLayer = 12,
63 TIDL_SplitLayer = 13,
64 TIDL_SliceLayer = 14,
65 TIDL_CropLayer = 15,
66 TIDL_FlattenLayer = 16,
67 TIDL_DropOutLayer = 17,
68 TIDL_ArgMaxLayer = 18,
69 TIDL_DetectionOutputLayer = 19,
70 TIDL_UnSuportedLayer = 255
71 }eTIDL_LayerType;
73 /**
74 @enum eTIDL_ElementType
75 @brief This enumerator defines the different types of element type
76 used by TIDL library
77 */
78 typedef enum
79 {
80 TIDL_UnsignedChar = 0,
81 TIDL_SignedChar = 1,
82 TIDL_UnsignedShort = 2,
83 TIDL_SignedShort = 3,
84 TIDL_UnsignedWord = 4,
85 TIDL_SignedWord = 5
86 }eTIDL_ElementType;
88 /**
89 @enum eTIDL_quantStyle
90 @brief This enumerator defines the different types of quantization Styles
91 supported by TIDL library
92 */
93 typedef enum
94 {
95 TIDL_quantStyleFixed = 0, /*!< In this case, TIDL expects the Quantization
96 information via interface. This is
97 supported by caffe-jacinto training framwork
98 - Currently not suported for user */
99 TIDL_quantStyleDynamic = 1, /*!< IDynamic quantization does not depend
100 on training.Quantization of kernel
101 weights happen during model import
102 using tool */
103 TIDL_quantStyleCustom = 10 /*!< Currently not suported for user */
104 }eTIDL_quantStyle;
106 /**
107 @enum eTIDL_optimiseExtMem
108 @brief This enumerator defines the different types of optimizations
109 supported by TIDL library
110 */
111 typedef enum
112 {
113 TIDL_optimiseExtMemL0 = 0, /*!< In this case, no optmization in output
114 memory, output buffer will not re-use
115 memory from previous layers, So,
116 algorithm uses more external memory.
117 This is Currently used for debugging */
118 TIDL_optimiseExtMemL1 = 1, /*!< In this case, output buffer will
119 re-use memory from previous layers when
120 they have same width and height,
121 So, algorithm uses less external memory
122 compare to L0 case */
123 TIDL_optimiseExtMemL2 = 2 /*!< In this case, output buffer will
124 re-use memory from previous layers when
125 they have different width and height,
126 So, algorithm uses less external memory
127 compare to L1 case */
128 }eTIDL_optimiseExtMem;
130 /**
131 @enum eTIDL_kernelType
132 @brief This enumerator defines the different types of optimizations
133 in kernel types supported by TIDL library
134 */
135 typedef enum
136 {
137 TIDL_sparse = 0, /*!< In this case, only non zero coeffs are
138 considered for convolution */
139 TIDL_dense = 1 /*!< In this case, all coeffs in the kernel
140 considered for convolution */
141 }eTIDL_kernelType;
143 /**
144 @enum eTIDL_strideOffsetMethod
145 @brief This enumerator defines the different logic to choose offset for
146 kernels/windows with stride grater than 1
147 */
148 typedef enum
149 {
150 TIDL_strideOffsetTopLeft = 0,
151 TIDL_strideOffsetCenter = 1,
152 TIDL_strideOffsetMax = 2
153 }eTIDL_strideOffsetMethod;
155 /**
156 @enum eTIDL_PoolType
157 @brief This enumerator defines the different types of spatial pooling
158 supported by TIDL library
159 */
160 typedef enum
161 {
162 TIDL_MaxPooling = 0,
163 TIDL_AveragePooling = 1
164 }eTIDL_PoolType;
166 /**
167 @enum eTIDL_reluType
168 @brief This enumerator defines the different RelU types
169 supported by TIDL library
170 */
171 typedef enum
172 {
173 TIDL_RelU = 0,
174 TIDL_PRelU = 1,
175 TIDL_RelU6 = 2
176 }eTIDL_reluType;
178 /**
179 @enum eTIDL_EltWiseType
180 @brief This enumerator defines the different types of eltWise layer
181 operations. Currently only TIDL_EltWiseSum is supported by TIDL
182 library.
183 */
184 typedef enum
185 {
186 TIDL_EltWiseProduct = 0,
187 TIDL_EltWiseSum = 1,
188 TIDL_EltWiseMax = 2
189 }eTIDL_EltWiseType;
191 /**
192 @enum eTIDL_DataDimIndex
193 @brief This enumerator defines the indices of dimension array of layer data
194 buffer in TIDL library
195 */
196 typedef enum
197 {
198 TIDL_DIM_BATCH = 0,
199 TIDL_DIM_NUMCH = 1,
200 TIDL_DIM_HEIGHT = 2,
201 TIDL_DIM_WIDTH = 3,
202 TIDL_DIM_MAX = 4
203 }eTIDL_DataDimIndex;
205 /**
206 @enum eTIDL_PitchDimIndex
207 @brief This enumerator defines the indices of picth array of layer data
208 buffer in TIDL library
209 */
210 typedef enum
211 {
212 TIDL_ROI_PITCH = 0,
213 TIDL_CHANNEL_PITCH = 1,
214 TIDL_LINE_PITCH = 2,
215 TIDL_PITCH_MAX = (TIDL_DIM_MAX - 1)
216 }eTIDL_PitchDimIndex;
218 /**
219 @enum eTIDL_ErrorType
220 @brief This enumerator defines error numbers that have to be set when layer
221 parameters deviate from expected range of values.
222 */
223 typedef enum
224 {
225 /* Convolution layer error types */
226 TIDL_E_CONVOLUTION = -1000,
227 TIDL_E_CONV_INVALID_INPUT_WIDTH = (TIDL_E_CONVOLUTION - 0),
228 TIDL_E_CONV_INVALID_INPUT_HEIGHT = (TIDL_E_CONVOLUTION - 1),
229 TIDL_E_CONV_INVALID_OUTPUT_WIDTH = (TIDL_E_CONVOLUTION - 2),
230 TIDL_E_CONV_INVALID_OUTPUT_HEIGHT = (TIDL_E_CONVOLUTION - 3),
231 TIDL_E_CONV_INVALID_NUM_IN_CHANNELS = (TIDL_E_CONVOLUTION - 4),
232 TIDL_E_CONV_INVALID_NUM_OUT_CHANNELS = (TIDL_E_CONVOLUTION - 5),
233 TIDL_E_CONV_INVALID_KER_WIDTH = (TIDL_E_CONVOLUTION - 6),
234 TIDL_E_CONV_INVALID_KER_HEIGHT = (TIDL_E_CONVOLUTION - 7),
235 TIDL_E_CONV_INVALID_KER_TYPE = (TIDL_E_CONVOLUTION - 8),
236 TIDL_E_CONV_INVALID_STRIDE_WIDTH = (TIDL_E_CONVOLUTION - 9),
237 TIDL_E_CONV_INVALID_STRIDE_HEIGHT = (TIDL_E_CONVOLUTION - 10),
238 TIDL_E_CONV_NEGATIVE_OUTPUT_SHIFT = (TIDL_E_CONVOLUTION - 11),
239 /* Convolution pooling error types */
240 TIDL_E_CONV_POOL_INVALID_POOL_TYPE = (TIDL_E_CONVOLUTION - 12),
241 TIDL_E_CONV_POOL_INVALID_KER_WIDTH = (TIDL_E_CONVOLUTION - 13),
242 TIDL_E_CONV_POOL_INVALID_KER_HEIGHT = (TIDL_E_CONVOLUTION - 14),
243 TIDL_E_CONV_POOL_INVALID_STRIDE_WIDTH = (TIDL_E_CONVOLUTION - 15),
244 TIDL_E_CONV_POOL_INVALID_STRIDE_HEIGHT = (TIDL_E_CONVOLUTION - 16),
245 /* Deconvolution layer error types */
246 TIDL_E_DECONV_INVALID_INPUT_WIDTH = (TIDL_E_CONVOLUTION - 17),
247 TIDL_E_DECONV_INVALID_INPUT_HEIGHT = (TIDL_E_CONVOLUTION - 18),
248 TIDL_E_DECONV_INVALID_OUTPUT_WIDTH = (TIDL_E_CONVOLUTION - 19),
249 TIDL_E_DECONV_INVALID_OUTPUT_HEIGHT = (TIDL_E_CONVOLUTION - 20),
250 TIDL_E_DECONV_INVALID_NUM_IN_CHANNELS = (TIDL_E_CONVOLUTION - 21),
251 TIDL_E_DECONV_INVALID_NUM_OUT_CHANNELS = (TIDL_E_CONVOLUTION - 22),
252 TIDL_E_DECONV_INVALID_NUM_GROUPS = (TIDL_E_CONVOLUTION - 23),
253 TIDL_E_DECONV_INVALID_STRIDE = (TIDL_E_CONVOLUTION - 24),
255 /* Eltwise layer error types */
256 TIDL_E_ELTWISE = -1020,
257 TIDL_E_ELTWISE_INVALID_INPUT_WIDTH = (TIDL_E_ELTWISE - 0),
258 TIDL_E_ELTWISE_INVALID_INPUT_HEIGHT = (TIDL_E_ELTWISE - 1),
259 TIDL_E_ELTWISE_INVALID_OUTPUT_WIDTH = (TIDL_E_ELTWISE - 2),
260 TIDL_E_ELTWISE_INVALID_OUTPUT_HEIGHT = (TIDL_E_ELTWISE - 3),
261 TIDL_E_ELTWISE_INVALID_ELTWISE_TYPE = (TIDL_E_ELTWISE - 4),
262 TIDL_E_ELTWISE_INVALID_NUM_CHANNELS = (TIDL_E_ELTWISE - 5),
263 TIDL_E_ELTWISE_INVALID_INPUT_TYPE = (TIDL_E_ELTWISE - 6),
265 /* Pooling error types */
266 TIDL_E_POOLING = -1030,
267 TIDL_E_POOL_INVALID_INPUT_WIDTH = (TIDL_E_POOLING - 0),
268 TIDL_E_POOL_INVALID_INPUT_HEIGHT = (TIDL_E_POOLING - 1),
269 TIDL_E_POOL_INVALID_OUTPUT_WIDTH = (TIDL_E_POOLING - 2),
270 TIDL_E_POOL_INVALID_OUTPUT_HEIGHT = (TIDL_E_POOLING - 3),
271 TIDL_E_POOL_INVALID_POOL_TYPE = (TIDL_E_POOLING - 4),
272 TIDL_E_POOL_INVALID_NUM_CHANNELS = (TIDL_E_POOLING - 5),
273 TIDL_E_POOL_INVALID_KER_WIDTH = (TIDL_E_POOLING - 6),
274 TIDL_E_POOL_INVALID_KER_HEIGHT = (TIDL_E_POOLING - 7),
275 TIDL_E_POOL_INVALID_STRIDE_WIDTH = (TIDL_E_POOLING - 8),
276 TIDL_E_POOL_INVALID_STRIDE_HEIGHT = (TIDL_E_POOLING - 9),
278 /* Inner product error types */
279 TIDL_E_INNER_PRODUCT = -1040,
280 TIDL_E_IP_INVALID_NUM_IN_NODES = (TIDL_E_INNER_PRODUCT - 0),
281 TIDL_E_IP_INVALID_NUM_OUT_NODES = (TIDL_E_INNER_PRODUCT - 1),
282 TIDL_E_IP_NEGATIVE_OUTPUT_SHIFT = (TIDL_E_INNER_PRODUCT - 2),
284 /* Argmax error types */
285 TIDL_E_ARGMAX = -1050,
286 TIDL_E_ARGMAX_INVALID_NUM_CHANNELS = (TIDL_E_ARGMAX - 0),
288 /* Bias error types */
289 TIDL_E_BN = -1060,
290 TIDL_E_BN_INVALID_INPUT_WIDTH = (TIDL_E_BN - 0),
291 TIDL_E_BN_INVALID_INPUT_HEIGHT = (TIDL_E_BN - 1),
292 TIDL_E_BN_INVALID_OUTPUT_WIDTH = (TIDL_E_BN - 2),
293 TIDL_E_BN_INVALID_OUTPUT_HEIGHT = (TIDL_E_BN - 3),
294 TIDL_E_BN_INVALID_NUM_CHANNELS = (TIDL_E_BN - 4),
295 TIDL_E_BN_INVALID_ENABLE_RELU = (TIDL_E_BN - 5),
296 TIDL_E_BN_NEGATIVE_OUTPUT_SHIFT = (TIDL_E_BN - 6),
298 /* Crop layer error types */
299 TIDL_E_CROP = -1070,
300 TIDL_E_CROP_INVALID_INPUT_WIDTH = (TIDL_E_CROP - 0),
301 TIDL_E_CROP_INVALID_INPUT_HEIGHT = (TIDL_E_CROP - 1),
302 TIDL_E_CROP_INVALID_OUTPUT_WIDTH = (TIDL_E_CROP - 2),
303 TIDL_E_CROP_INVALID_OUTPUT_HEIGHT = (TIDL_E_CROP - 3),
304 TIDL_E_CROP_INVALID_NUM_CHANNELS = (TIDL_E_CROP - 4),
305 TIDL_E_CROP_INVALID_OFFSET_WIDTH = (TIDL_E_CROP - 5),
306 TIDL_E_CROP_INVALID_OFFSET_HEIGHT = (TIDL_E_CROP - 6),
308 /* Flatten layer error types */
309 TIDL_E_FLATTEN = -1080,
310 TIDL_E_FLATTEN_INVALID_INPUT_WIDTH = (TIDL_E_FLATTEN - 0),
311 TIDL_E_FLATTEN_INVALID_INPUT_HEIGHT = (TIDL_E_FLATTEN - 1),
312 TIDL_E_FLATTEN_INVALID_OUTPUT_WIDTH = (TIDL_E_FLATTEN - 2),
313 TIDL_E_FLATTEN_INVALID_OUTPUT_HEIGHT = (TIDL_E_FLATTEN - 3),
315 /* SoftMax error types */
316 TIDL_E_SOFTMAX = -1090,
317 TIDL_E_SOFTMAX_INVALID_NUM_CHANNELS = (TIDL_E_SOFTMAX - 0),
319 /* Error types common to layers */
320 TIDL_E_COMMON = -1100,
321 TIDL_E_UNSUPPORTED_LAYER = (TIDL_E_COMMON - 0)
322 }eTIDL_ErrorType;
324 /**
325 @struct sBuffer_t
326 @brief This structure define the parmeters of data or kerner buffer
327 memeory in TIDL
328 @param ptr
329 For 32-bit platform, ptr is the address pointing to the actual buffer.
330 For 64-bit platform, ptr can be either the index to buffer of pointers,
331 or the lower 32-bit of the address if upper 32-bit is the same for all
332 pointers.
333 @remark This is to make sure the code is portable across 32-bit and 64-bit platforms.
334 @param bufSize
335 Size of the buffer in bytes
336 */
337 typedef struct
338 {
339 #ifdef PLATFORM_64BIT
340 uint32_t ptr;
341 #else
342 void* ptr;
343 #endif
344 int32_t bufSize;
345 int32_t reserved[2];
346 }sBuffer_t;
348 /**
349 @struct sTIDL_DataParams_t
350 @brief This structure define the parmeters of data or kerner buffer
351 used by TIDL layers (In,Out)
352 @param dataId
353 Address pointing to the actual buffer
354 @param elementType
355 Size of the buffer in bytes
356 @param numDim
357 Address pointing to the actual buffer
358 @param dataQ
359 Number of bits for fractional part if Quant Style is 1
360 Q factor if Quant Style is 2
361 @param minValue
362 Minimum value of 32-bit accumulator for all the values in
363 that layer
364 @param maxValue
365 Maximum value of 32-bit accumulator for all the values in
366 that layer
367 @param pitch
368 Pitch for each dimention
369 @param dimValues
370 Size of the buffer in bytes
372 */
373 typedef struct {
374 int32_t dataId;
375 int32_t elementType;
376 int32_t numDim;
377 int32_t dataQ;
378 int32_t minValue;
379 int32_t maxValue;
380 int32_t pitch[TIDL_DIM_MAX-1];
381 int32_t dimValues[TIDL_DIM_MAX];
382 }sTIDL_DataParams_t;
386 /**
387 @struct sTIDL_DataLayerParams_t
388 @brief This structure define the parmeters of Data layer
389 in TIDL
390 @param numChannels
391 Number of channel in the In or Out data buffer
392 @param dataQ
393 Q value of the data
394 */
395 typedef struct {
396 int32_t numChannels;
397 int32_t dataQ;
398 }sTIDL_DataLayerParams_t;
401 /**
402 @struct sTIDL_ReLUParams_t
403 @brief This structure define the parmeters of ReLU activation layer
404 in TIDL
405 @param slope
406 Buffer containing Slope vales for PRelU
407 @param numChannels
408 Number of channels channels to be processed
409 @param inDataQ
410 Q value of the in data
411 @param outDataQ
412 Q value expected for out data
413 @param slopeQ
414 Q value of slope values for PRelU
415 @param zeroSlopeValue
416 value of slope added for dynamic quantSytle
417 @param reluType
418 value indicates different types of ReLU supported
419 */
420 typedef struct {
421 sBuffer_t slope;
422 int32_t numChannels;
423 int32_t inDataQ;
424 int32_t outDataQ;
425 int32_t slopeQ;
426 int32_t zeroSlopeValue;
427 int32_t reluType;
428 }sTIDL_ReLUParams_t;
430 /**
431 @struct sTIDL_ArgMaxParams_t
432 @brief This structure define the parmeters Arg max layer
433 in TIDL
434 @param numChannels
435 Number of channels channels to be processed
436 @param inDataQ
437 Q value of the in data
438 @param outDataQ
439 Q value expected for out data
440 */
441 typedef struct {
442 int32_t numChannels;
443 int32_t inDataQ;
444 int32_t outDataQ;
445 }sTIDL_ArgMaxParams_t;
447 /**
448 @struct sTIDL_PoolingParams_t
449 @brief This structure define the parmeters spatial Pooling layer
450 in TIDL
451 @param numChannels
452 Number of channels channels to be processed
453 @param poolingType
454 Type of the Pooling as defined in @sa eTIDL_PoolType
455 @param kernelW
456 Kernel width
457 @param kernelH
458 Kernel height
459 @param strideW
460 Stride in horizontal direction
461 @param strideH
462 Stride in vertical direction
463 @param padW
464 Horizontal Padding requirement in number of elements
465 @param padH
466 Vertical Padding requirement in number of elements
467 @param inDataQ
468 Q value of the in data
469 @param outDataQ
470 Q value expected for out data
471 */
472 typedef struct {
473 int32_t numChannels;
474 int32_t poolingType;
475 int32_t kernelW;
476 int32_t kernelH;
477 int32_t strideW;
478 int32_t strideH;
479 int32_t padW;
480 int32_t padH;
481 int32_t inDataQ;
482 int32_t outDataQ;
483 }sTIDL_PoolingParams_t;
485 /**
486 @struct sTIDL_ConvParams_t
487 @brief This structure define the parmeters Convoltuion Layer
488 in TIDL
489 @param weights
490 Buffer containing the kernel parameters
491 @param Bias
492 Buffer containing the Bias parameters
493 @param convolutionType
494 Type of the convolution, Reserved for future use
495 @param numInChannels
496 Number of input channels channels to be processed
497 @param numOutChannels
498 Number of output channels to be processed
499 @param numGroups
500 Number of groups in the convolutions
501 @param kernelW
502 Kernel width
503 @param kernelH.
504 Kernel height
505 @param strideW
506 Stride in horizontal direction
507 @param strideH
508 Stride in vertical direction
509 @param dilationW
510 Dialation in horizontal direction
511 @param dilationH
512 Dialation in vertical direction
513 @param padW
514 Horizontal Padding requirement in number of elements
515 @param padH
516 Vertical Padding requirement in number of elements
517 @param weightsQ
518 Q value of Kernel weights
519 @param zeroWeightValue
520 value of weights added for dynamic quantSytle
521 @param biasQ
522 Q value kernel Bias
523 @param inDataQ
524 Q value of the in data
525 @param outDataQ
526 Q value expected for out data
527 @param interDataQ
528 Q value intermediate ouput data
529 @param enableBias
530 Enable/Disable ouput bias
531 @param enablePooling
532 Enable/Disable 2x2 Spatial pooling
533 @param enableRelU
534 Enable/Disable relU activation part of convolution
535 @param kernelType
536 Defines the different types of optimizations
537 in kernel types supported by TIDL
538 @param poolParams
539 Used only if enablePooling is true
540 @param reluParams
541 Used only if enableRelU is true
542 */
543 typedef struct {
544 sBuffer_t weights;
545 sBuffer_t bias;
546 int32_t convolutionType;
547 int32_t numInChannels;
548 int32_t numOutChannels;
549 int32_t numGroups;
550 int32_t kernelW;
551 int32_t kernelH;
552 int32_t strideW;
553 int32_t strideH;
554 int32_t dilationW;
555 int32_t dilationH;
556 int32_t padW;
557 int32_t padH;
558 int32_t weightsQ;
559 int32_t zeroWeightValue;
560 int32_t biasQ;
561 int32_t inDataQ;
562 int32_t outDataQ;
563 int32_t interDataQ;
564 int32_t enableBias;
565 int32_t enablePooling;
566 int32_t enableRelU;
567 int32_t kernelType;
568 sTIDL_PoolingParams_t poolParams;
569 sTIDL_ReLUParams_t reluParams;
570 }sTIDL_ConvParams_t;
572 /**
573 @struct sTIDL_DetectOutputParams_t
574 @brief This structure define the parmeters of Detection Output Layer
575 in TIDL
576 @param priorBox
577 Buffer containing the data required to form prior Bboxs
578 @param priorBoxSize
579 Siz of the priorBox buffer required to form prior Bboxs
580 @param numClasses
581 number of classes to be detected in the detection Output
582 @param backgroundLabelId
583 To indicate whether or not to ignore background class
584 @param codeType
585 Indicates the coding type to be used for decoding Bboxs
586 @param confThreshold
587 Value to indicates threshold above which objects to be
588 considered for detection
589 @param nmsThreshold
590 Threshold Value used for finding overlap between the
591 bboxs in the NMS
592 @param eta.
593 Value used to update the adaptive Threshold in the NMS
594 @param topK
595 Number of top k objects to keep for class after applying NMS
596 @param keepTopK
597 Number of top k objects to Keep in the final output
598 @param shareLocation
599 Indicate whether same size Boxes used for all classes or not,
600 it is not supported in ti_dl
601 @param varianceEncoded
602 Flag to indicate the variance used in decoding bboxes is
603 encoded along with locations are not
604 */
605 typedef struct {
606 sBuffer_t priorBox;
607 int32_t priorBoxSize;
608 int32_t numClasses;
609 int32_t backgroundLabelId;
610 int32_t codeType;
611 float32_tidl confThreshold;
612 float32_tidl nmsThreshold;
613 float32_tidl eta;
614 int32_t topK;
615 int32_t keepTopK;
616 int32_t shareLocation;
617 int32_t varianceEncoded;
618 }sTIDL_DetectOutputParams_t;
621 /**
622 @struct sTIDL_ConcatParams_t
623 @brief This structure define the parmeters of PriorBox layer
624 in TIDL
625 @param priorBox
626 Buffer containing the priorBox parameters and variance
627 */
628 typedef struct {
629 int32_t axis;
630 int32_t outDataQ;
631 }sTIDL_ConcatParams_t;
634 /**
635 @struct sTIDL_BatchNormParams_t
636 @brief This structure define the parmeters of Batch Norm layer
637 in TIDL
638 @param weights
639 Buffer containing the kernel parameters
640 @param Bias
641 Buffer containing the Bias parameters
642 @param numChannels
643 Number of channels channels to be processed
644 @param biasQ
645 Q value of Bias parameter
646 @param inDataQ
647 Q value of the in data
648 @param outDataQ
649 Q value expected for out data
650 @param weightsQ
651 Q value of Kernel weights
652 @param zeroWeightValue
653 value of weights added for dynamic quantSytle
654 @param enableRelU
655 Enable/Disable relU on the output data
656 @param reluParams
657 Used only if enableRelU is true
658 */
659 typedef struct {
660 sBuffer_t weights;
661 sBuffer_t bias;
662 int32_t numChannels;
663 int32_t biasQ;
664 int32_t inDataQ;
665 int32_t outDataQ;
666 int32_t weightsQ;
667 int32_t zeroWeightValue;
668 int32_t enableRelU;
669 sTIDL_ReLUParams_t reluParams;
670 }sTIDL_BatchNormParams_t;
672 /**
673 @struct sTIDL_BiasParams_t
674 @brief This structure define the parmeters of Bias layer
675 in TIDL
676 @param Bias
677 Buffer containing the Bias parameters
678 @param numChannels
679 Number of channels channels to be processed
680 @param biasQ
681 Q value of Bias parameter
682 @param inDataQ
683 Q value of the in data
684 @param outDataQ
685 Q value expected for out data
686 */
687 typedef struct {
688 sBuffer_t bias;
689 int32_t numChannels;
690 int32_t biasQ;
691 int32_t inDataQ;
692 int32_t outDataQ;
693 }sTIDL_BiasParams_t;
697 /**
698 @struct sTIDL_InnerProductParams_t
699 @brief This structure define the parmeters of Inner Product
700 (Fully connected) layer in TIDL
701 @param weights
702 Buffer containing the kernel parameters
703 @param Bias
704 Buffer containing the Bias parameters
705 @param numInNodes
706 Number of elememnts in the flattend input
707 @param numOutNodes
708 Number of elememnts in the output
709 @param weightsQ
710 Q value of Kernel weights
711 @param zeroWeightValue
712 value of weights added for dynamic quantSytle
713 @param biasQ
714 Q value kernel Bias
715 @param inDataQ
716 Q value of the in data
717 @param outDataQ
718 Q value expected for out data
719 @param interDataQ
720 Q value intermediate ouput data
721 @param enableRelU
722 Enable/Disable relU activation part of convolution
723 @param reluParams
724 Used only if enableRelU is true
725 */
726 typedef struct {
727 sBuffer_t weights;
728 sBuffer_t bias;
729 int32_t activationType;
730 int32_t numInNodes;
731 int32_t numOutNodes;
732 int32_t weightsQ;
733 int32_t zeroWeightValue;
734 int32_t biasQ;
735 int32_t inDataQ;
736 int32_t outDataQ;
737 int32_t interDataQ;
738 int32_t enableRelU;
739 sTIDL_ReLUParams_t reluParams;
740 }sTIDL_InnerProductParams_t;
742 /**
743 @struct sTIDL_EltWiseParams_t
744 @brief This structure define the parmeters of Elementwise layer
745 in TIDL
746 @param Bias
747 Buffer containing the Bias parameters
748 @param numChannels
749 Number of channels channels to be processed
750 @param eltWiseType
751 Type of the element wise opration. Currely only Add op is supported
752 @param numInData
753 Number of input data buffers on which Elementwise operation
754 shall ne performed
755 @param bufSize
756 size of the buffer in bytes
757 @param biasQ
758 Q value kernel Bias
759 @param inDataQ
760 Q value of the in data buffers
761 @param outDataQ
762 Q value expected for out data
763 @param enableRelU
764 Enable/Disable relU activation part of convolution
765 @param reluParams
766 Used only if enableRelU is true
767 */
768 typedef struct {
769 sBuffer_t bias;
770 int32_t numChannels;
771 int32_t eltWiseType;
772 int32_t numInData;
773 int32_t biasQ;
774 int32_t inDataQ[TIDL_NUM_IN_BUFS];
775 int32_t outDataQ;
776 int32_t enableRelU;
777 sTIDL_ReLUParams_t reluParams;
778 }sTIDL_EltWiseParams_t;
780 /**
781 @struct sTIDL_SoftMaxParams_t
782 @brief This structure define the parmeters Soft max layer
783 in TIDL
784 @param numChannels
785 Number of channels channels to be processed
786 @param inDataQ
787 Q value of the in data
788 @param outDataQ
789 Q value expected for out data
790 */
791 typedef struct {
792 int32_t numChannels;
793 int32_t inDataQ;
794 int32_t outDataQ;
795 }sTIDL_SoftMaxParams_t;
797 /**
798 @struct sTIDL_CropParams_t
799 @brief This structure define the parmeters Crop layer
800 in TIDL
801 @param numChannels
802 Number of channels channels to be processed
803 @param inDataQ
804 Q value of the in data
805 @param outDataQ
806 Q value expected for out data
807 */
808 typedef struct {
809 int32_t numChannels;
810 int32_t inDataQ;
811 int32_t outDataQ;
812 int32_t offsetW;
813 int32_t offsetH;
814 }sTIDL_CropParams_t;
816 /**
817 @struct sTIDL_LayerParams_t
818 @brief This union define the layer specific parmeters of all the
819 suported layers in TIDL
820 */
821 /* CHECK_MISRA("-18.4") -> Disable rule 18.4 */
822 typedef union {
823 sTIDL_ConvParams_t convParams;
824 sTIDL_ReLUParams_t reluParams;
825 sTIDL_EltWiseParams_t eltWiseParams;
826 sTIDL_PoolingParams_t poolParams;
827 sTIDL_InnerProductParams_t innerProductParams;
828 sTIDL_DataLayerParams_t dataLayerParams;
829 sTIDL_ArgMaxParams_t argMaxParams;
830 sTIDL_SoftMaxParams_t softMaxParams;
831 sTIDL_CropParams_t cropParams;
832 sTIDL_ConcatParams_t concatParams;
833 sTIDL_DetectOutputParams_t detectOutParams;
834 sTIDL_BiasParams_t biasParams;
835 sTIDL_BatchNormParams_t batchNormParams;
836 }sTIDL_LayerParams_t;
837 /*RESET_MISRA("18.4") -> Reset rule 18.4 */
839 /**
840 @struct sTIDL_Layer_t
841 @brief This structure define the common layer parmeters
842 in TIDL
843 @param layerType
844 Layer Type
845 @param numInBufs
846 Number of input data buffers for the layer
847 @param numOutBufs
848 Number of output data buffers for the layer
849 @param inData
850 Input data buffers details
851 @param outData
852 output data buffers details
853 @param coreID
854 Processing core ID (EVE or DSP)
855 @param layersGroupId
856 Group of layers in the net are processed together. This unique number
857 identify the currently processing group
858 @param weightsElementSizeInBits
859 Size of compute layer weight parameters in bytes
860 @param strideOffsetMethod
861 Offset selection method for stride. Refer eTIDL_strideOffsetMethod
862 */
863 typedef struct {
864 sTIDL_LayerParams_t layerParams;
865 int32_t layerType;
866 int32_t numInBufs;
867 int32_t numOutBufs;
868 sTIDL_DataParams_t inData[TIDL_NUM_IN_BUFS];
869 sTIDL_DataParams_t outData[TIDL_NUM_OUT_BUFS];
870 int32_t coreID;
871 int32_t layersGroupId;
872 int32_t weightsElementSizeInBits;
873 int32_t strideOffsetMethod;
874 }sTIDL_Layer_t;
876 /**
877 @struct sTIDL_1_2_Layer_t
878 @brief This structure define the common layer parmeters
879 in TIDL-API 1.2.x or earlier
880 @param layerType
881 Layer Type
882 @param numInBufs
883 Number of input data buffers for the layer
884 @param numOutBufs
885 Number of output data buffers for the layer
886 @param inData
887 Input data buffers details
888 @param outData
889 output data buffers details
890 @param coreID
891 Processing core ID (EVE or DSP)
892 @param layersGroupId
893 Group of layers in the net are processed together. This unique number
894 identify the currently processing group
895 @param weightsElementSizeInBits
896 Size of compute layer weight parameters in bytes
897 */
898 typedef struct {
899 sTIDL_LayerParams_t layerParams;
900 int32_t layerType;
901 int32_t numInBufs;
902 int32_t numOutBufs;
903 sTIDL_DataParams_t inData[TIDL_NUM_IN_BUFS];
904 sTIDL_DataParams_t outData[TIDL_NUM_OUT_BUFS];
905 int32_t coreID;
906 int32_t layersGroupId;
907 int32_t weightsElementSizeInBits;
908 }sTIDL_1_2_Layer_t;
910 /**
911 @struct sTIDL_Network_t
912 @brief This structure define the parmeters CNN/Deep learning net
913 in TIDL
914 @param numLayers
915 Number of layers in the network inclusing the input and output data
916 Layers
917 @param weightsElementSize
918 Size of compute layer weight parameters in bytes
919 @param slopeElementSize
920 Size of PRelU layer weight/slope parameters in bytes
921 @param biasElementSize
922 Size of compute layer Bias parameters in bytes
923 @param dataElementSize
924 Size of compute layer input and adat buffers in bytes
925 @param interElementSize
926 Size of compute layer intermeadiate datas in bytes
927 @param quantizationStyle
928 Variable to indicate different types of quantization Styles
929 */
930 typedef struct {
931 int32_t numLayers;
932 int32_t weightsElementSize;
933 int32_t slopeElementSize;
934 int32_t biasElementSize;
935 int32_t dataElementSize;
936 int32_t interElementSize;
937 int32_t quantizationStyle;
938 int32_t reserved;
939 sTIDL_Layer_t TIDLLayers[TIDL_NUM_MAX_LAYERS];
940 }sTIDL_Network_t;
942 /**
943 @struct sTIDL_1_2_Network_t
944 @brief This structure define the parmeters CNN/Deep learning net
945 in TIDL-API 1.2.x or earlier
946 @param numLayers
947 Number of layers in the network inclusing the input and output data
948 Layers
949 @param weightsElementSize
950 Size of compute layer weight parameters in bytes
951 @param slopeElementSize
952 Size of PRelU layer weight/slope parameters in bytes
953 @param biasElementSize
954 Size of compute layer Bias parameters in bytes
955 @param dataElementSize
956 Size of compute layer input and adat buffers in bytes
957 @param interElementSize
958 Size of compute layer intermeadiate datas in bytes
959 @param quantizationStyle
960 Variable to indicate different types of quantization Styles
961 @param strideOffsetMethod
962 Offset selection method for stride. Refer eTIDL_strideOffsetMethod
963 */
964 typedef struct {
965 int32_t numLayers;
966 int32_t weightsElementSize;
967 int32_t slopeElementSize;
968 int32_t biasElementSize;
969 int32_t dataElementSize;
970 int32_t interElementSize;
971 int32_t quantizationStyle;
972 int32_t strideOffsetMethod;
973 int32_t reserved;
974 sTIDL_1_2_Layer_t TIDLLayers[TIDL_NUM_MAX_LAYERS];
975 }sTIDL_1_2_Network_t;
977 /**
978 @struct TIDL_CreateParams
979 @brief This structure contains all the parameters which TI DL
980 library at create time
981 @param visionParams
982 Common parmeters for all ivison based modules
984 @param net
985 This structure define the parmeters CNN/Deep learning net
986 in TIDL
987 @param currCoreId
988 Id of the core (EVE/DSP) on which TIDL is running
989 @param currLayersGroupId
990 Id of the each layer (EVE/DSP) on which that layer is
991 running
992 @param l1MemSize
993 Value indicates the available l1MemSize for TIDL
994 @param l2MemSize
995 Value indicates the available l2MemSize for TIDL
996 @param l3MemSize
997 Value indicates the available l3MemSize for TIDL
998 @param quantHistoryParam1
999 weights used for previously processed inference
1000 during application boot time
1001 @param quantHistoryParam2
1002 weights used for previously processed inference during
1003 application execution (After initial few frames)
1004 @param quantMargin
1005 margin added to the average in percentage
1006 @param optimiseExtMem
1007 Value indicates type of memory optimization to be
1008 used by TIDL library
1009 */
1010 typedef struct
1011 {
1012 char padding[8];
1013 //IVISION_Params visionParams;
1014 sTIDL_Network_t net;
1015 int32_t currCoreId;
1016 int32_t currLayersGroupId;
1017 int32_t l1MemSize;
1018 int32_t l2MemSize;
1019 int32_t l3MemSize;
1020 int32_t quantHistoryParam1;
1021 int32_t quantHistoryParam2;
1022 int32_t quantMargin;
1023 int32_t optimiseExtMem;
1025 } TIDL_CreateParams;