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 #define TIDL_MAX_DATA_BUFS (128)
37 #define TIDL_MAX_ALG_IN_BUFS (16)
38 #define TIDL_MAX_ALG_OUT_BUFS (16)
40 typedef float float32_tidl;
42 /**
43 @enum eTIDL_LayerType
44 @brief This enumerator defines the different types of layers used
45 in deeep learing algorithms
46 */
47 typedef enum
48 {
49 TIDL_DataLayer = 0,
50 TIDL_ConvolutionLayer = 1,
51 TIDL_PoolingLayer = 2,
52 TIDL_ReLULayer = 3,
53 TIDL_PReLULayer = 4,
54 TIDL_EltWiseLayer = 5,
55 TIDL_InnerProductLayer = 6,
56 TIDL_SoftMaxLayer = 7,
57 TIDL_BatchNormLayer = 8,
58 TIDL_BiasLayer = 9,
59 TIDL_ScaleLayer = 10,
60 TIDL_Deconv2DLayer = 11,
61 TIDL_ConcatLayer = 12,
62 TIDL_SplitLayer = 13,
63 TIDL_SliceLayer = 14,
64 TIDL_CropLayer = 15,
65 TIDL_FlattenLayer = 16,
66 TIDL_DropOutLayer = 17,
67 TIDL_ArgMaxLayer = 18,
68 TIDL_DetectionOutputLayer = 19,
69 TIDL_UnSuportedLayer = 255
70 }eTIDL_LayerType;
72 /**
73 @enum eTIDL_ElementType
74 @brief This enumerator defines the different types of element type
75 used by TIDL library
76 */
77 typedef enum
78 {
79 TIDL_UnsignedChar = 0,
80 TIDL_SignedChar = 1,
81 TIDL_UnsignedShort = 2,
82 TIDL_SignedShort = 3,
83 TIDL_UnsignedWord = 4,
84 TIDL_SignedWord = 5
85 }eTIDL_ElementType;
87 /**
88 @enum eTIDL_quantStyle
89 @brief This enumerator defines the different types of quantization Styles
90 supported by TIDL library
91 */
92 typedef enum
93 {
94 TIDL_quantStyleFixed = 0, /*!< In this case, TIDL expects the Quantization
95 information via interface. This is
96 supported by caffe-jacinto training framwork
97 - Currently not suported for user */
98 TIDL_quantStyleDynamic = 1, /*!< IDynamic quantization does not depend
99 on training.Quantization of kernel
100 weights happen during model import
101 using tool */
102 TIDL_quantStyleCustom = 10 /*!< Currently not suported for user */
103 }eTIDL_quantStyle;
105 /**
106 @enum eTIDL_optimiseExtMem
107 @brief This enumerator defines the different types of optimizations
108 supported by TIDL library
109 */
110 typedef enum
111 {
112 TIDL_optimiseExtMemL0 = 0, /*!< In this case, no optmization in output
113 memory, output buffer will not re-use
114 memory from previous layers, So,
115 algorithm uses more external memory.
116 This is Currently used for debugging */
117 TIDL_optimiseExtMemL1 = 1, /*!< In this case, output buffer will
118 re-use memory from previous layers when
119 they have same width and height,
120 So, algorithm uses less external memory
121 compare to L0 case */
122 TIDL_optimiseExtMemL2 = 2 /*!< In this case, output buffer will
123 re-use memory from previous layers when
124 they have different width and height,
125 So, algorithm uses less external memory
126 compare to L1 case */
127 }eTIDL_optimiseExtMem;
129 /**
130 @enum eTIDL_kernelType
131 @brief This enumerator defines the different types of optimizations
132 in kernel types supported by TIDL library
133 */
134 typedef enum
135 {
136 TIDL_sparse = 0, /*!< In this case, only non zero coeffs are
137 considered for convolution */
138 TIDL_dense = 1 /*!< In this case, all coeffs in the kernel
139 considered for convolution */
140 }eTIDL_kernelType;
142 /**
143 @enum eTIDL_strideOffsetMethod
144 @brief This enumerator defines the different logic to choose offset for
145 kernels/windows with stride grater than 1
146 */
147 typedef enum
148 {
149 TIDL_strideOffsetTopLeft = 0,
150 TIDL_strideOffsetCenter = 1,
151 TIDL_strideOffsetMax = 2
152 }eTIDL_strideOffsetMethod;
154 /**
155 @enum eTIDL_PoolType
156 @brief This enumerator defines the different types of spatial pooling
157 supported by TIDL library
158 */
159 typedef enum
160 {
161 TIDL_MaxPooling = 0,
162 TIDL_AveragePooling = 1
163 }eTIDL_PoolType;
165 /**
166 @enum eTIDL_reluType
167 @brief This enumerator defines the different RelU types
168 supported by TIDL library
169 */
170 typedef enum
171 {
172 TIDL_RelU = 0,
173 TIDL_PRelU = 1,
174 TIDL_RelU6 = 2
175 }eTIDL_reluType;
177 /**
178 @enum eTIDL_EltWiseType
179 @brief This enumerator defines the different types of eltWise layer
180 operations. Currently only TIDL_EltWiseSum is supported by TIDL
181 library.
182 */
183 typedef enum
184 {
185 TIDL_EltWiseProduct = 0,
186 TIDL_EltWiseSum = 1,
187 TIDL_EltWiseMax = 2
188 }eTIDL_EltWiseType;
190 /**
191 @enum eTIDL_DataDimIndex
192 @brief This enumerator defines the indices of dimension array of layer data
193 buffer in TIDL library
194 */
195 typedef enum
196 {
197 TIDL_DIM_BATCH = 0,
198 TIDL_DIM_NUMCH = 1,
199 TIDL_DIM_HEIGHT = 2,
200 TIDL_DIM_WIDTH = 3,
201 TIDL_DIM_MAX = 4
202 }eTIDL_DataDimIndex;
204 /**
205 @enum eTIDL_PitchDimIndex
206 @brief This enumerator defines the indices of picth array of layer data
207 buffer in TIDL library
208 */
209 typedef enum
210 {
211 TIDL_ROI_PITCH = 0,
212 TIDL_CHANNEL_PITCH = 1,
213 TIDL_LINE_PITCH = 2,
214 TIDL_PITCH_MAX = (TIDL_DIM_MAX - 1)
215 }eTIDL_PitchDimIndex;
217 /**
218 @enum eTIDL_ErrorType
219 @brief This enumerator defines error numbers that have to be set when layer
220 parameters deviate from expected range of values.
221 */
222 typedef enum
223 {
224 /* Convolution layer error types */
225 TIDL_E_CONVOLUTION = -1000,
226 TIDL_E_CONV_INVALID_INPUT_WIDTH = (TIDL_E_CONVOLUTION - 0),
227 TIDL_E_CONV_INVALID_INPUT_HEIGHT = (TIDL_E_CONVOLUTION - 1),
228 TIDL_E_CONV_INVALID_OUTPUT_WIDTH = (TIDL_E_CONVOLUTION - 2),
229 TIDL_E_CONV_INVALID_OUTPUT_HEIGHT = (TIDL_E_CONVOLUTION - 3),
230 TIDL_E_CONV_INVALID_NUM_IN_CHANNELS = (TIDL_E_CONVOLUTION - 4),
231 TIDL_E_CONV_INVALID_NUM_OUT_CHANNELS = (TIDL_E_CONVOLUTION - 5),
232 TIDL_E_CONV_INVALID_KER_WIDTH = (TIDL_E_CONVOLUTION - 6),
233 TIDL_E_CONV_INVALID_KER_HEIGHT = (TIDL_E_CONVOLUTION - 7),
234 TIDL_E_CONV_INVALID_KER_TYPE = (TIDL_E_CONVOLUTION - 8),
235 TIDL_E_CONV_INVALID_STRIDE_WIDTH = (TIDL_E_CONVOLUTION - 9),
236 TIDL_E_CONV_INVALID_STRIDE_HEIGHT = (TIDL_E_CONVOLUTION - 10),
237 TIDL_E_CONV_NEGATIVE_OUTPUT_SHIFT = (TIDL_E_CONVOLUTION - 11),
238 /* Convolution pooling error types */
239 TIDL_E_CONV_POOL_INVALID_POOL_TYPE = (TIDL_E_CONVOLUTION - 12),
240 TIDL_E_CONV_POOL_INVALID_KER_WIDTH = (TIDL_E_CONVOLUTION - 13),
241 TIDL_E_CONV_POOL_INVALID_KER_HEIGHT = (TIDL_E_CONVOLUTION - 14),
242 TIDL_E_CONV_POOL_INVALID_STRIDE_WIDTH = (TIDL_E_CONVOLUTION - 15),
243 TIDL_E_CONV_POOL_INVALID_STRIDE_HEIGHT = (TIDL_E_CONVOLUTION - 16),
245 /* Eltwise layer error types */
246 TIDL_E_ELTWISE = -1020,
247 TIDL_E_ELTWISE_INVALID_INPUT_WIDTH = (TIDL_E_ELTWISE - 0),
248 TIDL_E_ELTWISE_INVALID_INPUT_HEIGHT = (TIDL_E_ELTWISE - 1),
249 TIDL_E_ELTWISE_INVALID_OUTPUT_WIDTH = (TIDL_E_ELTWISE - 2),
250 TIDL_E_ELTWISE_INVALID_OUTPUT_HEIGHT = (TIDL_E_ELTWISE - 3),
251 TIDL_E_ELTWISE_INVALID_ELTWISE_TYPE = (TIDL_E_ELTWISE - 4),
252 TIDL_E_ELTWISE_INVALID_NUM_CHANNELS = (TIDL_E_ELTWISE - 5),
254 /* Pooling error types */
255 TIDL_E_POOLING = -1030,
256 TIDL_E_POOL_INVALID_INPUT_WIDTH = (TIDL_E_POOLING - 0),
257 TIDL_E_POOL_INVALID_INPUT_HEIGHT = (TIDL_E_POOLING - 1),
258 TIDL_E_POOL_INVALID_OUTPUT_WIDTH = (TIDL_E_POOLING - 2),
259 TIDL_E_POOL_INVALID_OUTPUT_HEIGHT = (TIDL_E_POOLING - 3),
260 TIDL_E_POOL_INVALID_POOL_TYPE = (TIDL_E_POOLING - 4),
261 TIDL_E_POOL_INVALID_NUM_CHANNELS = (TIDL_E_POOLING - 5),
262 TIDL_E_POOL_INVALID_KER_WIDTH = (TIDL_E_POOLING - 6),
263 TIDL_E_POOL_INVALID_KER_HEIGHT = (TIDL_E_POOLING - 7),
264 TIDL_E_POOL_INVALID_STRIDE_WIDTH = (TIDL_E_POOLING - 8),
265 TIDL_E_POOL_INVALID_STRIDE_HEIGHT = (TIDL_E_POOLING - 9),
267 /* Inner product error types */
268 TIDL_E_INNER_PRODUCT = -1040,
269 TIDL_E_IP_INVALID_NUM_IN_NODES = (TIDL_E_INNER_PRODUCT - 0),
270 TIDL_E_IP_INVALID_NUM_OUT_NODES = (TIDL_E_INNER_PRODUCT - 1),
271 TIDL_E_IP_NEGATIVE_OUTPUT_SHIFT = (TIDL_E_INNER_PRODUCT - 2),
273 /* Argmax error types */
274 TIDL_E_ARGMAX = -1050,
275 TIDL_E_ARGMAX_INVALID_NUM_CHANNELS = (TIDL_E_ARGMAX - 0),
277 /* Bias error types */
278 TIDL_E_BN = -1060,
279 TIDL_E_BN_INVALID_INPUT_WIDTH = (TIDL_E_BN - 0),
280 TIDL_E_BN_INVALID_INPUT_HEIGHT = (TIDL_E_BN - 1),
281 TIDL_E_BN_INVALID_OUTPUT_WIDTH = (TIDL_E_BN - 2),
282 TIDL_E_BN_INVALID_OUTPUT_HEIGHT = (TIDL_E_BN - 3),
283 TIDL_E_BN_INVALID_NUM_CHANNELS = (TIDL_E_BN - 4),
284 TIDL_E_BN_INVALID_ENABLE_RELU = (TIDL_E_BN - 5),
285 TIDL_E_BN_NEGATIVE_OUTPUT_SHIFT = (TIDL_E_BN - 6),
287 /* Crop layer error types */
288 TIDL_E_CROP = -1070,
289 TIDL_E_CROP_INVALID_INPUT_WIDTH = (TIDL_E_CROP - 0),
290 TIDL_E_CROP_INVALID_INPUT_HEIGHT = (TIDL_E_CROP - 1),
291 TIDL_E_CROP_INVALID_OUTPUT_WIDTH = (TIDL_E_CROP - 2),
292 TIDL_E_CROP_INVALID_OUTPUT_HEIGHT = (TIDL_E_CROP - 3),
293 TIDL_E_CROP_INVALID_NUM_CHANNELS = (TIDL_E_CROP - 4),
294 TIDL_E_CROP_INVALID_OFFSET_WIDTH = (TIDL_E_CROP - 5),
295 TIDL_E_CROP_INVALID_OFFSET_HEIGHT = (TIDL_E_CROP - 6),
297 /* Flatten layer error types */
298 TIDL_E_FLATTEN = -1080,
299 TIDL_E_FLATTEN_INVALID_INPUT_WIDTH = (TIDL_E_FLATTEN - 0),
300 TIDL_E_FLATTEN_INVALID_INPUT_HEIGHT = (TIDL_E_FLATTEN - 1),
301 TIDL_E_FLATTEN_INVALID_OUTPUT_WIDTH = (TIDL_E_FLATTEN - 2),
302 TIDL_E_FLATTEN_INVALID_OUTPUT_HEIGHT = (TIDL_E_FLATTEN - 3),
304 /* SoftMax error types */
305 TIDL_E_SOFTMAX = -1090,
306 TIDL_E_SOFTMAX_INVALID_NUM_CHANNELS = (TIDL_E_SOFTMAX - 0),
308 /* Error types common to layers */
309 TIDL_E_COMMON = -1100,
310 TIDL_E_UNSUPPORTED_LAYER = (TIDL_E_COMMON - 0)
311 }eTIDL_ErrorType;
313 /**
314 @struct sBuffer_t
315 @brief This structure define the parmeters of data or kerner buffer
316 memeory in TIDL
317 @param ptr
318 Address pointing to the actual buffer
319 @param bufSize
320 Size of the buffer in bytes
321 */
322 typedef struct
323 {
324 // The tidl-viewer binary is built for 64b x86/Linux. On such systems,
325 // void* is 64b and this breaks structure size/layout required by TIDL.
326 // Cannot use -m32 with yocto builds. Workaround is to use int32_t for ptr.
327 // ptr is not used by the tidl-viewer.
328 #if defined(__x86_64__)
329 int32_t ptr;
330 #else
331 void* ptr;
332 #endif
333 int32_t bufSize;
334 int32_t reserved[2];
335 }sBuffer_t;
337 /**
338 @struct sTIDL_DataParams_t
339 @brief This structure define the parmeters of data or kerner buffer
340 used by TIDL layers (In,Out)
341 @param dataId
342 Address pointing to the actual buffer
343 @param elementType
344 Size of the buffer in bytes
345 @param numDim
346 Address pointing to the actual buffer
347 @param dataQ
348 Number of bits for fractional part if Quant Style is 1
349 Q factor if Quant Style is 2
350 @param minValue
351 Minimum value of 32-bit accumulator for all the values in
352 that layer
353 @param maxValue
354 Maximum value of 32-bit accumulator for all the values in
355 that layer
356 @param pitch
357 Pitch for each dimention
358 @param dimValues
359 Size of the buffer in bytes
361 */
362 typedef struct {
363 int32_t dataId;
364 int32_t elementType;
365 int32_t numDim;
366 int32_t dataQ;
367 int32_t minValue;
368 int32_t maxValue;
369 int32_t pitch[TIDL_DIM_MAX-1];
370 int32_t dimValues[TIDL_DIM_MAX];
371 }sTIDL_DataParams_t;
375 /**
376 @struct sTIDL_DataLayerParams_t
377 @brief This structure define the parmeters of Data layer
378 in TIDL
379 @param numChannels
380 Number of channel in the In or Out data buffer
381 @param dataQ
382 Q value of the data
383 */
384 typedef struct {
385 int32_t numChannels;
386 int32_t dataQ;
387 }sTIDL_DataLayerParams_t;
390 /**
391 @struct sTIDL_ReLUParams_t
392 @brief This structure define the parmeters of ReLU activation layer
393 in TIDL
394 @param slope
395 Buffer containing Slope vales for PRelU
396 @param numChannels
397 Number of channels channels to be processed
398 @param inDataQ
399 Q value of the in data
400 @param outDataQ
401 Q value expected for out data
402 @param slopeQ
403 Q value of slope values for PRelU
404 @param zeroSlopeValue
405 value of slope added for dynamic quantSytle
406 @param reluType
407 value indicates different types of ReLU supported
408 */
409 typedef struct {
410 sBuffer_t slope;
411 int32_t numChannels;
412 int32_t inDataQ;
413 int32_t outDataQ;
414 int32_t slopeQ;
415 int32_t zeroSlopeValue;
416 int32_t reluType;
417 }sTIDL_ReLUParams_t;
419 /**
420 @struct sTIDL_ArgMaxParams_t
421 @brief This structure define the parmeters Arg max layer
422 in TIDL
423 @param numChannels
424 Number of channels channels to be processed
425 @param inDataQ
426 Q value of the in data
427 @param outDataQ
428 Q value expected for out data
429 */
430 typedef struct {
431 int32_t numChannels;
432 int32_t inDataQ;
433 int32_t outDataQ;
434 }sTIDL_ArgMaxParams_t;
436 /**
437 @struct sTIDL_PoolingParams_t
438 @brief This structure define the parmeters spatial Pooling layer
439 in TIDL
440 @param numChannels
441 Number of channels channels to be processed
442 @param poolingType
443 Type of the Pooling as defined in @sa eTIDL_PoolType
444 @param kernelW
445 Kernel width
446 @param kernelH
447 Kernel height
448 @param strideW
449 Stride in horizontal direction
450 @param strideH
451 Stride in vertical direction
452 @param padW
453 Horizontal Padding requirement in number of elements
454 @param padH
455 Vertical Padding requirement in number of elements
456 @param inDataQ
457 Q value of the in data
458 @param outDataQ
459 Q value expected for out data
460 */
461 typedef struct {
462 int32_t numChannels;
463 int32_t poolingType;
464 int32_t kernelW;
465 int32_t kernelH;
466 int32_t strideW;
467 int32_t strideH;
468 int32_t padW;
469 int32_t padH;
470 int32_t inDataQ;
471 int32_t outDataQ;
472 }sTIDL_PoolingParams_t;
474 /**
475 @struct sTIDL_ConvParams_t
476 @brief This structure define the parmeters Convoltuion Layer
477 in TIDL
478 @param weights
479 Buffer containing the kernel parameters
480 @param Bias
481 Buffer containing the Bias parameters
482 @param convolutionType
483 Type of the convolution, Reserved for future use
484 @param numInChannels
485 Number of input channels channels to be processed
486 @param numOutChannels
487 Number of output channels to be processed
488 @param numGroups
489 Number of groups in the convolutions
490 @param kernelW
491 Kernel width
492 @param kernelH.
493 Kernel height
494 @param strideW
495 Stride in horizontal direction
496 @param strideH
497 Stride in vertical direction
498 @param dilationW
499 Dialation in horizontal direction
500 @param dilationH
501 Dialation in vertical direction
502 @param padW
503 Horizontal Padding requirement in number of elements
504 @param padH
505 Vertical Padding requirement in number of elements
506 @param weightsQ
507 Q value of Kernel weights
508 @param zeroWeightValue
509 value of weights added for dynamic quantSytle
510 @param biasQ
511 Q value kernel Bias
512 @param inDataQ
513 Q value of the in data
514 @param outDataQ
515 Q value expected for out data
516 @param interDataQ
517 Q value intermediate ouput data
518 @param enableBias
519 Enable/Disable ouput bias
520 @param enablePooling
521 Enable/Disable 2x2 Spatial pooling
522 @param enableRelU
523 Enable/Disable relU activation part of convolution
524 @param kernelType
525 Defines the different types of optimizations
526 in kernel types supported by TIDL
527 @param poolParams
528 Used only if enablePooling is true
529 @param reluParams
530 Used only if enableRelU is true
531 */
532 typedef struct {
533 sBuffer_t weights;
534 sBuffer_t bias;
535 int32_t convolutionType;
536 int32_t numInChannels;
537 int32_t numOutChannels;
538 int32_t numGroups;
539 int32_t kernelW;
540 int32_t kernelH;
541 int32_t strideW;
542 int32_t strideH;
543 int32_t dilationW;
544 int32_t dilationH;
545 int32_t padW;
546 int32_t padH;
547 int32_t weightsQ;
548 int32_t zeroWeightValue;
549 int32_t biasQ;
550 int32_t inDataQ;
551 int32_t outDataQ;
552 int32_t interDataQ;
553 int32_t enableBias;
554 int32_t enablePooling;
555 int32_t enableRelU;
556 int32_t kernelType;
557 sTIDL_PoolingParams_t poolParams;
558 sTIDL_ReLUParams_t reluParams;
559 }sTIDL_ConvParams_t;
561 /**
562 @struct sTIDL_DetectOutputParams_t
563 @brief This structure define the parmeters of Detection Output Layer
564 in TIDL
565 @param priorBox
566 Buffer containing the data required to form prior Bboxs
567 @param priorBoxSize
568 Siz of the priorBox buffer required to form prior Bboxs
569 @param numClasses
570 number of classes to be detected in the detection Output
571 @param backgroundLabelId
572 To indicate whether or not to ignore background class
573 @param codeType
574 Indicates the coding type to be used for decoding Bboxs
575 @param confThreshold
576 Value to indicates threshold above which objects to be
577 considered for detection
578 @param nmsThreshold
579 Threshold Value used for finding overlap between the
580 bboxs in the NMS
581 @param eta.
582 Value used to update the adaptive Threshold in the NMS
583 @param topK
584 Number of top k objects to keep for class after applying NMS
585 @param keepTopK
586 Number of top k objects to Keep in the final output
587 @param shareLocation
588 Indicate whether same size Boxes used for all classes or not,
589 it is not supported in ti_dl
590 @param varianceEncoded
591 Flag to indicate the variance used in decoding bboxes is
592 encoded along with locations are not
593 */
594 typedef struct {
595 sBuffer_t priorBox;
596 int32_t priorBoxSize;
597 int32_t numClasses;
598 int32_t backgroundLabelId;
599 int32_t codeType;
600 float32_tidl confThreshold;
601 float32_tidl nmsThreshold;
602 float32_tidl eta;
603 int32_t topK;
604 int32_t keepTopK;
605 int32_t shareLocation;
606 int32_t varianceEncoded;
607 }sTIDL_DetectOutputParams_t;
610 /**
611 @struct sTIDL_ConcatParams_t
612 @brief This structure define the parmeters of PriorBox layer
613 in TIDL
614 @param priorBox
615 Buffer containing the priorBox parameters and variance
616 */
617 typedef struct {
618 int32_t axis;
619 int32_t outDataQ;
620 }sTIDL_ConcatParams_t;
623 /**
624 @struct sTIDL_BatchNormParams_t
625 @brief This structure define the parmeters of Batch Norm layer
626 in TIDL
627 @param weights
628 Buffer containing the kernel parameters
629 @param Bias
630 Buffer containing the Bias parameters
631 @param numChannels
632 Number of channels channels to be processed
633 @param biasQ
634 Q value of Bias parameter
635 @param inDataQ
636 Q value of the in data
637 @param outDataQ
638 Q value expected for out data
639 @param weightsQ
640 Q value of Kernel weights
641 @param zeroWeightValue
642 value of weights added for dynamic quantSytle
643 @param enableRelU
644 Enable/Disable relU on the output data
645 @param reluParams
646 Used only if enableRelU is true
647 */
648 typedef struct {
649 sBuffer_t weights;
650 sBuffer_t bias;
651 int32_t numChannels;
652 int32_t biasQ;
653 int32_t inDataQ;
654 int32_t outDataQ;
655 int32_t weightsQ;
656 int32_t zeroWeightValue;
657 int32_t enableRelU;
658 sTIDL_ReLUParams_t reluParams;
659 }sTIDL_BatchNormParams_t;
661 /**
662 @struct sTIDL_BiasParams_t
663 @brief This structure define the parmeters of Bias layer
664 in TIDL
665 @param Bias
666 Buffer containing the Bias parameters
667 @param numChannels
668 Number of channels channels to be processed
669 @param biasQ
670 Q value of Bias parameter
671 @param inDataQ
672 Q value of the in data
673 @param outDataQ
674 Q value expected for out data
675 */
676 typedef struct {
677 sBuffer_t bias;
678 int32_t numChannels;
679 int32_t biasQ;
680 int32_t inDataQ;
681 int32_t outDataQ;
682 }sTIDL_BiasParams_t;
686 /**
687 @struct sTIDL_InnerProductParams_t
688 @brief This structure define the parmeters of Inner Product
689 (Fully connected) layer in TIDL
690 @param weights
691 Buffer containing the kernel parameters
692 @param Bias
693 Buffer containing the Bias parameters
694 @param numInNodes
695 Number of elememnts in the flattend input
696 @param numOutNodes
697 Number of elememnts in the output
698 @param weightsQ
699 Q value of Kernel weights
700 @param zeroWeightValue
701 value of weights added for dynamic quantSytle
702 @param biasQ
703 Q value kernel Bias
704 @param inDataQ
705 Q value of the in data
706 @param outDataQ
707 Q value expected for out data
708 @param interDataQ
709 Q value intermediate ouput data
710 @param enableRelU
711 Enable/Disable relU activation part of convolution
712 @param reluParams
713 Used only if enableRelU is true
714 */
715 typedef struct {
716 sBuffer_t weights;
717 sBuffer_t bias;
718 int32_t activationType;
719 int32_t numInNodes;
720 int32_t numOutNodes;
721 int32_t weightsQ;
722 int32_t zeroWeightValue;
723 int32_t biasQ;
724 int32_t inDataQ;
725 int32_t outDataQ;
726 int32_t interDataQ;
727 int32_t enableRelU;
728 sTIDL_ReLUParams_t reluParams;
729 }sTIDL_InnerProductParams_t;
731 /**
732 @struct sTIDL_EltWiseParams_t
733 @brief This structure define the parmeters of Elementwise layer
734 in TIDL
735 @param Bias
736 Buffer containing the Bias parameters
737 @param numChannels
738 Number of channels channels to be processed
739 @param eltWiseType
740 Type of the element wise opration. Currely only Add op is supported
741 @param numInData
742 Number of input data buffers on which Elementwise operation
743 shall ne performed
744 @param bufSize
745 size of the buffer in bytes
746 @param biasQ
747 Q value kernel Bias
748 @param inDataQ
749 Q value of the in data buffers
750 @param outDataQ
751 Q value expected for out data
752 @param enableRelU
753 Enable/Disable relU activation part of convolution
754 @param reluParams
755 Used only if enableRelU is true
756 */
757 typedef struct {
758 sBuffer_t bias;
759 int32_t numChannels;
760 int32_t eltWiseType;
761 int32_t numInData;
762 int32_t biasQ;
763 int32_t inDataQ[TIDL_NUM_IN_BUFS];
764 int32_t outDataQ;
765 int32_t enableRelU;
766 sTIDL_ReLUParams_t reluParams;
767 }sTIDL_EltWiseParams_t;
769 /**
770 @struct sTIDL_SoftMaxParams_t
771 @brief This structure define the parmeters Soft max layer
772 in TIDL
773 @param numChannels
774 Number of channels channels to be processed
775 @param inDataQ
776 Q value of the in data
777 @param outDataQ
778 Q value expected for out data
779 */
780 typedef struct {
781 int32_t numChannels;
782 int32_t inDataQ;
783 int32_t outDataQ;
784 }sTIDL_SoftMaxParams_t;
786 /**
787 @struct sTIDL_CropParams_t
788 @brief This structure define the parmeters Crop layer
789 in TIDL
790 @param numChannels
791 Number of channels channels to be processed
792 @param inDataQ
793 Q value of the in data
794 @param outDataQ
795 Q value expected for out data
796 */
797 typedef struct {
798 int32_t numChannels;
799 int32_t inDataQ;
800 int32_t outDataQ;
801 int32_t offsetW;
802 int32_t offsetH;
803 }sTIDL_CropParams_t;
805 /**
806 @struct sTIDL_LayerParams_t
807 @brief This union define the layer specific parmeters of all the
808 suported layers in TIDL
809 */
810 /* CHECK_MISRA("-18.4") -> Disable rule 18.4 */
811 typedef union {
812 sTIDL_ConvParams_t convParams;
813 sTIDL_ReLUParams_t reluParams;
814 sTIDL_EltWiseParams_t eltWiseParams;
815 sTIDL_PoolingParams_t poolParams;
816 sTIDL_InnerProductParams_t innerProductParams;
817 sTIDL_DataLayerParams_t dataLayerParams;
818 sTIDL_ArgMaxParams_t argMaxParams;
819 sTIDL_SoftMaxParams_t softMaxParams;
820 sTIDL_CropParams_t cropParams;
821 sTIDL_ConcatParams_t concatParams;
822 sTIDL_DetectOutputParams_t detectOutParams;
823 sTIDL_BiasParams_t biasParams;
824 sTIDL_BatchNormParams_t batchNormParams;
825 }sTIDL_LayerParams_t;
826 /*RESET_MISRA("18.4") -> Reset rule 18.4 */
828 /**
829 @struct sTIDL_Layer_t
830 @brief This structure define the common layer parmeters
831 in TIDL
832 @param layerType
833 Layer Type
834 @param numInBufs
835 Number of input data buffers for the layer
836 @param numOutBufs
837 Number of output data buffers for the layer
838 @param inData
839 Input data buffers details
840 @param outData
841 output data buffers details
842 @param coreID
843 Processing core ID (EVE or DSP)
844 @param layersGroupId
845 Group of layers in the net are processed together. This unique number
846 identify the currently processing group
847 @param weightsElementSizeInBits
848 Size of compute layer weight parameters in bytes
849 */
850 typedef struct {
851 sTIDL_LayerParams_t layerParams;
852 int32_t layerType;
853 int32_t numInBufs;
854 int32_t numOutBufs;
855 sTIDL_DataParams_t inData[TIDL_NUM_IN_BUFS];
856 sTIDL_DataParams_t outData[TIDL_NUM_OUT_BUFS];
857 int32_t coreID;
858 int32_t layersGroupId;
859 int32_t weightsElementSizeInBits;
860 }sTIDL_Layer_t;
862 /**
863 @struct sTIDL_Network_t
864 @brief This structure define the parmeters CNN/Deep learning net
865 in TIDL
866 @param numLayers
867 Number of layers in the network inclusing the input and output data
868 Layers
869 @param weightsElementSize
870 Size of compute layer weight parameters in bytes
871 @param slopeElementSize
872 Size of PRelU layer weight/slope parameters in bytes
873 @param biasElementSize
874 Size of compute layer Bias parameters in bytes
875 @param dataElementSize
876 Size of compute layer input and adat buffers in bytes
877 @param interElementSize
878 Size of compute layer intermeadiate datas in bytes
879 @param quantizationStyle
880 Variable to indicate different types of quantization Styles
881 @param strideOffsetMethod
882 Offset selection method for stride. Refer eTIDL_strideOffsetMethod
883 */
884 typedef struct {
885 int32_t numLayers;
886 int32_t weightsElementSize;
887 int32_t slopeElementSize;
888 int32_t biasElementSize;
889 int32_t dataElementSize;
890 int32_t interElementSize;
891 int32_t quantizationStyle;
892 int32_t strideOffsetMethod;
893 int32_t reserved;
894 sTIDL_Layer_t TIDLLayers[TIDL_NUM_MAX_LAYERS];
895 }sTIDL_Network_t;
897 /**
898 @struct TIDL_CreateParams
899 @brief This structure contains all the parameters which TI DL
900 library at create time
901 @param visionParams
902 Common parmeters for all ivison based modules
904 */
905 typedef struct
906 {
907 char padding[8];
908 //IVISION_Params visionParams;
909 sTIDL_Network_t net;
910 int32_t currCoreId;
911 int32_t currLayersGroupId;
912 int32_t l1MemSize;
913 int32_t l2MemSize;
914 int32_t l3MemSize;
915 int32_t quantHistoryParam1;
916 int32_t quantHistoryParam2;
917 int32_t quantMargin;
918 int32_t optimiseExtMem;
920 } TIDL_CreateParams;