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 void* ptr;
325 int32_t bufSize;
326 int32_t reserved[2];
327 }sBuffer_t;
329 /**
330 @struct sTIDL_DataParams_t
331 @brief This structure define the parmeters of data or kerner buffer
332 used by TIDL layers (In,Out)
333 @param dataId
334 Address pointing to the actual buffer
335 @param elementType
336 Size of the buffer in bytes
337 @param numDim
338 Address pointing to the actual buffer
339 @param dataQ
340 Number of bits for fractional part if Quant Style is 1
341 Q factor if Quant Style is 2
342 @param minValue
343 Minimum value of 32-bit accumulator for all the values in
344 that layer
345 @param maxValue
346 Maximum value of 32-bit accumulator for all the values in
347 that layer
348 @param pitch
349 Pitch for each dimention
350 @param dimValues
351 Size of the buffer in bytes
353 */
354 typedef struct {
355 int32_t dataId;
356 int32_t elementType;
357 int32_t numDim;
358 int32_t dataQ;
359 int32_t minValue;
360 int32_t maxValue;
361 int32_t pitch[TIDL_DIM_MAX-1];
362 int32_t dimValues[TIDL_DIM_MAX];
363 }sTIDL_DataParams_t;
367 /**
368 @struct sTIDL_DataLayerParams_t
369 @brief This structure define the parmeters of Data layer
370 in TIDL
371 @param numChannels
372 Number of channel in the In or Out data buffer
373 @param dataQ
374 Q value of the data
375 */
376 typedef struct {
377 int32_t numChannels;
378 int32_t dataQ;
379 }sTIDL_DataLayerParams_t;
382 /**
383 @struct sTIDL_ReLUParams_t
384 @brief This structure define the parmeters of ReLU activation layer
385 in TIDL
386 @param slope
387 Buffer containing Slope vales for PRelU
388 @param numChannels
389 Number of channels channels to be processed
390 @param inDataQ
391 Q value of the in data
392 @param outDataQ
393 Q value expected for out data
394 @param slopeQ
395 Q value of slope values for PRelU
396 @param zeroSlopeValue
397 value of slope added for dynamic quantSytle
398 @param reluType
399 value indicates different types of ReLU supported
400 */
401 typedef struct {
402 sBuffer_t slope;
403 int32_t numChannels;
404 int32_t inDataQ;
405 int32_t outDataQ;
406 int32_t slopeQ;
407 int32_t zeroSlopeValue;
408 int32_t reluType;
409 }sTIDL_ReLUParams_t;
411 /**
412 @struct sTIDL_ArgMaxParams_t
413 @brief This structure define the parmeters Arg max layer
414 in TIDL
415 @param numChannels
416 Number of channels channels to be processed
417 @param inDataQ
418 Q value of the in data
419 @param outDataQ
420 Q value expected for out data
421 */
422 typedef struct {
423 int32_t numChannels;
424 int32_t inDataQ;
425 int32_t outDataQ;
426 }sTIDL_ArgMaxParams_t;
428 /**
429 @struct sTIDL_PoolingParams_t
430 @brief This structure define the parmeters spatial Pooling layer
431 in TIDL
432 @param numChannels
433 Number of channels channels to be processed
434 @param poolingType
435 Type of the Pooling as defined in @sa eTIDL_PoolType
436 @param kernelW
437 Kernel width
438 @param kernelH
439 Kernel height
440 @param strideW
441 Stride in horizontal direction
442 @param strideH
443 Stride in vertical direction
444 @param padW
445 Horizontal Padding requirement in number of elements
446 @param padH
447 Vertical Padding requirement in number of elements
448 @param inDataQ
449 Q value of the in data
450 @param outDataQ
451 Q value expected for out data
452 */
453 typedef struct {
454 int32_t numChannels;
455 int32_t poolingType;
456 int32_t kernelW;
457 int32_t kernelH;
458 int32_t strideW;
459 int32_t strideH;
460 int32_t padW;
461 int32_t padH;
462 int32_t inDataQ;
463 int32_t outDataQ;
464 }sTIDL_PoolingParams_t;
466 /**
467 @struct sTIDL_ConvParams_t
468 @brief This structure define the parmeters Convoltuion Layer
469 in TIDL
470 @param weights
471 Buffer containing the kernel parameters
472 @param Bias
473 Buffer containing the Bias parameters
474 @param convolutionType
475 Type of the convolution, Reserved for future use
476 @param numInChannels
477 Number of input channels channels to be processed
478 @param numOutChannels
479 Number of output channels to be processed
480 @param numGroups
481 Number of groups in the convolutions
482 @param kernelW
483 Kernel width
484 @param kernelH.
485 Kernel height
486 @param strideW
487 Stride in horizontal direction
488 @param strideH
489 Stride in vertical direction
490 @param dilationW
491 Dialation in horizontal direction
492 @param dilationH
493 Dialation in vertical direction
494 @param padW
495 Horizontal Padding requirement in number of elements
496 @param padH
497 Vertical Padding requirement in number of elements
498 @param weightsQ
499 Q value of Kernel weights
500 @param zeroWeightValue
501 value of weights added for dynamic quantSytle
502 @param biasQ
503 Q value kernel Bias
504 @param inDataQ
505 Q value of the in data
506 @param outDataQ
507 Q value expected for out data
508 @param interDataQ
509 Q value intermediate ouput data
510 @param enableBias
511 Enable/Disable ouput bias
512 @param enablePooling
513 Enable/Disable 2x2 Spatial pooling
514 @param enableRelU
515 Enable/Disable relU activation part of convolution
516 @param kernelType
517 Defines the different types of optimizations
518 in kernel types supported by TIDL
519 @param poolParams
520 Used only if enablePooling is true
521 @param reluParams
522 Used only if enableRelU is true
523 */
524 typedef struct {
525 sBuffer_t weights;
526 sBuffer_t bias;
527 int32_t convolutionType;
528 int32_t numInChannels;
529 int32_t numOutChannels;
530 int32_t numGroups;
531 int32_t kernelW;
532 int32_t kernelH;
533 int32_t strideW;
534 int32_t strideH;
535 int32_t dilationW;
536 int32_t dilationH;
537 int32_t padW;
538 int32_t padH;
539 int32_t weightsQ;
540 int32_t zeroWeightValue;
541 int32_t biasQ;
542 int32_t inDataQ;
543 int32_t outDataQ;
544 int32_t interDataQ;
545 int32_t enableBias;
546 int32_t enablePooling;
547 int32_t enableRelU;
548 int32_t kernelType;
549 sTIDL_PoolingParams_t poolParams;
550 sTIDL_ReLUParams_t reluParams;
551 }sTIDL_ConvParams_t;
553 /**
554 @struct sTIDL_DetectOutputParams_t
555 @brief This structure define the parmeters of Detection Output Layer
556 in TIDL
557 @param priorBox
558 Buffer containing the data required to form prior Bboxs
559 @param priorBoxSize
560 Siz of the priorBox buffer required to form prior Bboxs
561 @param numClasses
562 number of classes to be detected in the detection Output
563 @param backgroundLabelId
564 To indicate whether or not to ignore background class
565 @param codeType
566 Indicates the coding type to be used for decoding Bboxs
567 @param confThreshold
568 Value to indicates threshold above which objects to be
569 considered for detection
570 @param nmsThreshold
571 Threshold Value used for finding overlap between the
572 bboxs in the NMS
573 @param eta.
574 Value used to update the adaptive Threshold in the NMS
575 @param topK
576 Number of top k objects to keep for class after applying NMS
577 @param keepTopK
578 Number of top k objects to Keep in the final output
579 @param shareLocation
580 Indicate whether same size Boxes used for all classes or not,
581 it is not supported in ti_dl
582 @param varianceEncoded
583 Flag to indicate the variance used in decoding bboxes is
584 encoded along with locations are not
585 */
586 typedef struct {
587 sBuffer_t priorBox;
588 int32_t priorBoxSize;
589 int32_t numClasses;
590 int32_t backgroundLabelId;
591 int32_t codeType;
592 float32_tidl confThreshold;
593 float32_tidl nmsThreshold;
594 float32_tidl eta;
595 int32_t topK;
596 int32_t keepTopK;
597 int32_t shareLocation;
598 int32_t varianceEncoded;
599 }sTIDL_DetectOutputParams_t;
602 /**
603 @struct sTIDL_ConcatParams_t
604 @brief This structure define the parmeters of PriorBox layer
605 in TIDL
606 @param priorBox
607 Buffer containing the priorBox parameters and variance
608 */
609 typedef struct {
610 int32_t axis;
611 int32_t outDataQ;
612 }sTIDL_ConcatParams_t;
615 /**
616 @struct sTIDL_BatchNormParams_t
617 @brief This structure define the parmeters of Batch Norm layer
618 in TIDL
619 @param weights
620 Buffer containing the kernel parameters
621 @param Bias
622 Buffer containing the Bias parameters
623 @param numChannels
624 Number of channels channels to be processed
625 @param biasQ
626 Q value of Bias parameter
627 @param inDataQ
628 Q value of the in data
629 @param outDataQ
630 Q value expected for out data
631 @param weightsQ
632 Q value of Kernel weights
633 @param zeroWeightValue
634 value of weights added for dynamic quantSytle
635 @param enableRelU
636 Enable/Disable relU on the output data
637 @param reluParams
638 Used only if enableRelU is true
639 */
640 typedef struct {
641 sBuffer_t weights;
642 sBuffer_t bias;
643 int32_t numChannels;
644 int32_t biasQ;
645 int32_t inDataQ;
646 int32_t outDataQ;
647 int32_t weightsQ;
648 int32_t zeroWeightValue;
649 int32_t enableRelU;
650 sTIDL_ReLUParams_t reluParams;
651 }sTIDL_BatchNormParams_t;
653 /**
654 @struct sTIDL_BiasParams_t
655 @brief This structure define the parmeters of Bias layer
656 in TIDL
657 @param Bias
658 Buffer containing the Bias parameters
659 @param numChannels
660 Number of channels channels to be processed
661 @param biasQ
662 Q value of Bias parameter
663 @param inDataQ
664 Q value of the in data
665 @param outDataQ
666 Q value expected for out data
667 */
668 typedef struct {
669 sBuffer_t bias;
670 int32_t numChannels;
671 int32_t biasQ;
672 int32_t inDataQ;
673 int32_t outDataQ;
674 }sTIDL_BiasParams_t;
678 /**
679 @struct sTIDL_InnerProductParams_t
680 @brief This structure define the parmeters of Inner Product
681 (Fully connected) layer in TIDL
682 @param weights
683 Buffer containing the kernel parameters
684 @param Bias
685 Buffer containing the Bias parameters
686 @param numInNodes
687 Number of elememnts in the flattend input
688 @param numOutNodes
689 Number of elememnts in the output
690 @param weightsQ
691 Q value of Kernel weights
692 @param zeroWeightValue
693 value of weights added for dynamic quantSytle
694 @param biasQ
695 Q value kernel Bias
696 @param inDataQ
697 Q value of the in data
698 @param outDataQ
699 Q value expected for out data
700 @param interDataQ
701 Q value intermediate ouput data
702 @param enableRelU
703 Enable/Disable relU activation part of convolution
704 @param reluParams
705 Used only if enableRelU is true
706 */
707 typedef struct {
708 sBuffer_t weights;
709 sBuffer_t bias;
710 int32_t activationType;
711 int32_t numInNodes;
712 int32_t numOutNodes;
713 int32_t weightsQ;
714 int32_t zeroWeightValue;
715 int32_t biasQ;
716 int32_t inDataQ;
717 int32_t outDataQ;
718 int32_t interDataQ;
719 int32_t enableRelU;
720 sTIDL_ReLUParams_t reluParams;
721 }sTIDL_InnerProductParams_t;
723 /**
724 @struct sTIDL_EltWiseParams_t
725 @brief This structure define the parmeters of Elementwise layer
726 in TIDL
727 @param Bias
728 Buffer containing the Bias parameters
729 @param numChannels
730 Number of channels channels to be processed
731 @param eltWiseType
732 Type of the element wise opration. Currely only Add op is supported
733 @param numInData
734 Number of input data buffers on which Elementwise operation
735 shall ne performed
736 @param bufSize
737 size of the buffer in bytes
738 @param biasQ
739 Q value kernel Bias
740 @param inDataQ
741 Q value of the in data buffers
742 @param outDataQ
743 Q value expected for out data
744 @param enableRelU
745 Enable/Disable relU activation part of convolution
746 @param reluParams
747 Used only if enableRelU is true
748 */
749 typedef struct {
750 sBuffer_t bias;
751 int32_t numChannels;
752 int32_t eltWiseType;
753 int32_t numInData;
754 int32_t biasQ;
755 int32_t inDataQ[TIDL_NUM_IN_BUFS];
756 int32_t outDataQ;
757 int32_t enableRelU;
758 sTIDL_ReLUParams_t reluParams;
759 }sTIDL_EltWiseParams_t;
761 /**
762 @struct sTIDL_SoftMaxParams_t
763 @brief This structure define the parmeters Soft max layer
764 in TIDL
765 @param numChannels
766 Number of channels channels to be processed
767 @param inDataQ
768 Q value of the in data
769 @param outDataQ
770 Q value expected for out data
771 */
772 typedef struct {
773 int32_t numChannels;
774 int32_t inDataQ;
775 int32_t outDataQ;
776 }sTIDL_SoftMaxParams_t;
778 /**
779 @struct sTIDL_CropParams_t
780 @brief This structure define the parmeters Crop layer
781 in TIDL
782 @param numChannels
783 Number of channels channels to be processed
784 @param inDataQ
785 Q value of the in data
786 @param outDataQ
787 Q value expected for out data
788 */
789 typedef struct {
790 int32_t numChannels;
791 int32_t inDataQ;
792 int32_t outDataQ;
793 int32_t offsetW;
794 int32_t offsetH;
795 }sTIDL_CropParams_t;
797 /**
798 @struct sTIDL_LayerParams_t
799 @brief This union define the layer specific parmeters of all the
800 suported layers in TIDL
801 */
802 /* CHECK_MISRA("-18.4") -> Disable rule 18.4 */
803 typedef union {
804 sTIDL_ConvParams_t convParams;
805 sTIDL_ReLUParams_t reluParams;
806 sTIDL_EltWiseParams_t eltWiseParams;
807 sTIDL_PoolingParams_t poolParams;
808 sTIDL_InnerProductParams_t innerProductParams;
809 sTIDL_DataLayerParams_t dataLayerParams;
810 sTIDL_ArgMaxParams_t argMaxParams;
811 sTIDL_SoftMaxParams_t softMaxParams;
812 sTIDL_CropParams_t cropParams;
813 sTIDL_ConcatParams_t concatParams;
814 sTIDL_DetectOutputParams_t detectOutParams;
815 sTIDL_BiasParams_t biasParams;
816 sTIDL_BatchNormParams_t batchNormParams;
817 }sTIDL_LayerParams_t;
818 /*RESET_MISRA("18.4") -> Reset rule 18.4 */
820 /**
821 @struct sTIDL_Layer_t
822 @brief This structure define the common layer parmeters
823 in TIDL
824 @param layerType
825 Layer Type
826 @param numInBufs
827 Number of input data buffers for the layer
828 @param numOutBufs
829 Number of output data buffers for the layer
830 @param inData
831 Input data buffers details
832 @param outData
833 output data buffers details
834 @param coreID
835 Processing core ID (EVE or DSP)
836 @param layersGroupId
837 Group of layers in the net are processed together. This unique number
838 identify the currently processing group
839 @param weightsElementSizeInBits
840 Size of compute layer weight parameters in bytes
841 */
842 typedef struct {
843 sTIDL_LayerParams_t layerParams;
844 int32_t layerType;
845 int32_t numInBufs;
846 int32_t numOutBufs;
847 sTIDL_DataParams_t inData[TIDL_NUM_IN_BUFS];
848 sTIDL_DataParams_t outData[TIDL_NUM_OUT_BUFS];
849 int32_t coreID;
850 int32_t layersGroupId;
851 int32_t weightsElementSizeInBits;
852 }sTIDL_Layer_t;
854 /**
855 @struct sTIDL_Network_t
856 @brief This structure define the parmeters CNN/Deep learning net
857 in TIDL
858 @param numLayers
859 Number of layers in the network inclusing the input and output data
860 Layers
861 @param weightsElementSize
862 Size of compute layer weight parameters in bytes
863 @param slopeElementSize
864 Size of PRelU layer weight/slope parameters in bytes
865 @param biasElementSize
866 Size of compute layer Bias parameters in bytes
867 @param dataElementSize
868 Size of compute layer input and adat buffers in bytes
869 @param interElementSize
870 Size of compute layer intermeadiate datas in bytes
871 @param quantizationStyle
872 Variable to indicate different types of quantization Styles
873 @param strideOffsetMethod
874 Offset selection method for stride. Refer eTIDL_strideOffsetMethod
875 */
876 typedef struct {
877 int32_t numLayers;
878 int32_t weightsElementSize;
879 int32_t slopeElementSize;
880 int32_t biasElementSize;
881 int32_t dataElementSize;
882 int32_t interElementSize;
883 int32_t quantizationStyle;
884 int32_t strideOffsetMethod;
885 int32_t reserved;
886 sTIDL_Layer_t TIDLLayers[TIDL_NUM_MAX_LAYERS];
887 }sTIDL_Network_t;
889 /**
890 @struct TIDL_CreateParams
891 @brief This structure contains all the parameters which TI DL
892 library at create time
893 @param visionParams
894 Common parmeters for all ivison based modules
896 */
897 typedef struct
898 {
899 char padding[8];
900 //IVISION_Params visionParams;
901 sTIDL_Network_t net;
902 int32_t currCoreId;
903 int32_t currLayersGroupId;
904 int32_t l1MemSize;
905 int32_t l2MemSize;
906 int32_t l3MemSize;
907 int32_t quantHistoryParam1;
908 int32_t quantHistoryParam2;
909 int32_t quantMargin;
910 int32_t optimiseExtMem;
912 } TIDL_CreateParams;