MMALIB User Guide
c7524f/MMALIB_types.h
Go to the documentation of this file.
1 /******************************************************************************
2  * *
3  * module name :MMALIB *
4  * *
5  * module descripton :Matrix Multiply Accelerator Library module for C7x+MMA *
6  * *
7  * Copyright (C) 2017-2018 Texas Instruments Incorporated - https://www.ti.com/ *
8  * ALL RIGHTS RESERVED *
9  * *
10  ******************************************************************************/
11 
23 #ifndef C75x4_MMALIB_TYPES_H_
24 #define C75x4_MMALIB_TYPES_H_ 1
25 
26 #include <c7x.h> // for streaming engine, streaming address gen.
27 //#include <c7x_scalable.h> // for device scalability
28 
29 //using namespace c7x;
30 
34 
35 
36 
37 #ifdef __cplusplus
38 #include <c7x_scalable.h> // for device scalability
39 
40 /******************************************************************************
41  *
42  * PREDEFINED VECTORS
43  *
44  ******************************************************************************/
45 
46 extern const c7x::uchar_vec MMALIB_vperm_convolve_col_scale_No_1;
47 extern const c7x::uchar_vec MMALIB_vperm_convolve_col_scale_No_2;
48 extern const c7x::uchar_vec MMALIB_vperm_convolve_col_scale_No_3;
49 extern const c7x::uchar_vec MMALIB_vperm_convolve_col_scale_No_4;
50 extern const c7x::uchar_vec MMALIB_vperm_convolve_col_scale_No_5;
51 extern const c7x::uchar_vec MMALIB_vperm_convolve_col_scale_No_6;
52 extern const c7x::uchar_vec MMALIB_vperm_convolve_col_scale_No_7;
53 
54 // permutation register values for 32-bit bias
55 extern const c7x::uchar_vec MMALIB_vperm_convolve_col_biasVec0_32bit_No_1;
56 extern const c7x::uchar_vec MMALIB_vperm_convolve_col_biasVec1_32bit_No_1;
57 
58 extern const c7x::uchar_vec MMALIB_vperm_convolve_col_biasVec0_32bit_No_2;
59 extern const c7x::uchar_vec MMALIB_vperm_convolve_col_biasVec1_32bit_No_2;
60 
61 
62 extern const c7x::uchar_vec MMALIB_vperm_convolve_col_biasVec0_32bit_No_3;
63 extern const c7x::uchar_vec MMALIB_vperm_convolve_col_biasVec1_32bit_No_3;
64 
65 extern const c7x::uchar_vec MMALIB_vperm_convolve_col_biasVec0_32bit_No_4;
66 extern const c7x::uchar_vec MMALIB_vperm_convolve_col_biasVec1_32bit_No_4;
67 
68 // permutation register values for 64-bit bias
69 extern const c7x::uchar_vec MMALIB_vperm_convolve_col_biasVec0_64bit_No_1;
70 extern const c7x::uchar_vec MMALIB_vperm_convolve_col_biasVec1_64bit_No_1;
71 
72 // split groups
73 extern const c7x::uchar_vec MMALIB_vperm_convolve_col_splitGroups_scale_No_1;
74 extern const c7x::uchar_vec MMALIB_vperm_convolve_col_splitGroups_scale_No_2;
75 extern const c7x::uchar_vec MMALIB_vperm_convolve_col_splitGroups_scale_No_3;
76 extern const c7x::uchar_vec MMALIB_vperm_convolve_col_splitGroups_scale_No_4;
77 extern const c7x::uchar_vec MMALIB_vperm_convolve_col_splitGroups_scale_No_5;
78 extern const c7x::uchar_vec MMALIB_vperm_convolve_col_splitGroups_scale_No_6;
79 extern const c7x::uchar_vec MMALIB_vperm_convolve_col_splitGroups_scale_No_7;
80 
81 // permutation register values for 32-bit bias, split groups
82 extern const c7x::uchar_vec MMALIB_vperm_convolve_col_splitGroups_biasVec0_32bit_No_1;
83 extern const c7x::uchar_vec MMALIB_vperm_convolve_col_splitGroups_biasVec1_32bit_No_1;
84 
85 extern const c7x::uchar_vec MMALIB_vperm_convolve_col_splitGroups_biasVec0_32bit_No_2;
86 extern const c7x::uchar_vec MMALIB_vperm_convolve_col_splitGroups_biasVec1_32bit_No_2;
87 
88 extern const c7x::uchar_vec MMALIB_vperm_convolve_col_splitGroups_biasVec0_32bit_No_3;
89 extern const c7x::uchar_vec MMALIB_vperm_convolve_col_splitGroups_biasVec1_32bit_No_3;
90 
91 extern const c7x::uchar_vec MMALIB_vperm_convolve_col_splitGroups_biasVec0_32bit_No_4;
92 extern const c7x::uchar_vec MMALIB_vperm_convolve_col_splitGroups_biasVec1_32bit_No_4;
93 
94 
95 // permutation register values for 64-bit bias, split groups
96 extern const c7x::uchar_vec MMALIB_vperm_convolve_col_splitGroups_biasVec0_64bit_No_1;
97 extern const c7x::uchar_vec MMALIB_vperm_convolve_col_splitGroups_biasVec1_64bit_No_1;
98 
99 
100 extern "C" {
101 #endif /* __cplusplus */
102 
112 /*******************************************************************************
113  *
114  * TYPEDEFS
115  *
116  ******************************************************************************/
117 
119  typedef enum {
125  } MMALIB_activation_type_e; // formerly eMMAActivationType
127 
129  typedef enum {
133 
135  typedef enum {
139 
142 
144  typedef enum {
149 
150 
151  /*******************************************************************************
152  *
153  * DEFINES
154  *
155  ******************************************************************************/
156 
157 /* #define MMALIB_BYTE_WIDTH 32 //!< MMA width in bytes */
158 
159 
160 
161  /* ---------------------------------------------------------------- */
162  /* MISRAC Rule 4.9(DEFINE.FUNC) Deviation: The advisory is not */
163  /* being addressed */
164  /* ---------------------------------------------------------------- */
167  #define MMALIB_CALC_STRIDE(BYTES, ALIGN_SHIFT) \
168  (((((BYTES)-1) >> (ALIGN_SHIFT)) + 1) << (ALIGN_SHIFT))
169 
171 #define MMALIB_MMA_SIZE_8_BIT_SHIFT 5
172 #define MMALIB_MMA_SIZE_16_BIT_SHIFT 4
173 #define MMALIB_MMA_SIZE_32_BIT_SHIFT 3
174 
175 
176  /* /\*! @brief MMA size as a function of precision *\/ */
177  /* //#define MMALIB_MMA_SIZE_1_BYTE 1 */
178  /* #define MMALIB_MMA_SIZE_8_BIT \ */
179  /* ((uint32_t)(((uint32_t)1) \ */
180  /* << MMALIB_MMA_SIZE_8_BIT_SHIFT)) //!< Shift for MMA size when data */
181  /* //!< type is 8-bit integers */
182  /* #define MMALIB_MMA_SIZE_16_BIT \ */
183  /* ((uint32_t)(((uint32_t)1) \ */
184  /* << MMALIB_MMA_SIZE_16_BIT_SHIFT)) //!< Shift for MMA size when data */
185  /* //!< type is 16-bit integers */
186  /* #define MMALIB_MMA_SIZE_32_BIT \ */
187  /* ((int32_t)(((uint32_t)1) \ */
188  /* << MMALIB_MMA_SIZE_32_BIT_SHIFT)) //!< Shift for MMA size when data */
189  /* //!< type is 32-bit integers */
190 
191 
192 /*******************************************************************************
193  *
194  * DEFINES
195  *
196  ******************************************************************************/
197 
198 #define MMALIB_ILUT_SUPPORT 1
199 #define MMALIB_ILUT_NUM_BYTES 256
200 
201 
202 /*******************************************************************************
203  *
204  * Macros
205  *
206  ******************************************************************************/
207 
209 #ifdef __cplusplus
210 }
211 #endif /* __cplusplus */
212 #endif /* C75x4_MMALIB_TYPES_H_ */
213 
214 /* ======================================================================== */
215 /* End of file: MMALIB_types.h */
216 /* ======================================================================== */
MMALIB_enableDynamicRange_type_e
The enumeration of possible dynamic range enable settings.
MMALIB_enableDynamicRange_type_e MMALIB_enableDynamicRange_type
Type for enableDynamicRange variables.
MMALIB_initDynamicRange_type_e MMALIB_initDynamicRange_type
Type for initDynamicRange variables.
MMALIB_activation_type_e MMALIB_activation_type
MMALIB_initDynamicRange_type_e
The enumeration of possible dynamic range reset options.
MMALIB_quantMethod_type_e MMALIB_quantMethod_type
Type for initDynamicRange variables.
MMALIB_quantMethod_type_e
The enumeration of possible quantization methods.
MMALIB_activation_type_e
The enumeration of possible activation operations on the computation.
@ MMALIB_DYNAMIC_RANGE_ENABLE
Enable dynamic range computation.
@ MMALIB_DYNAMIC_RANGE_DISABLE
Disable dynamic range computation.
@ MMALIB_DYNAMIC_RANGE_NOINIT
Do not reset dynamic range min/max at start of computation.
@ MMALIB_DYNAMIC_RANGE_INIT
Reset dynamic range min/max at start of computation.
@ MMALIB_QUANT_PER_CHANNEL
@ MMALIB_QUANT_PER_KERNEL
@ MMALIB_PSAT
Return result after parameterized saturation.
@ MMALIB_SATURATION
Return result after saturating.
@ MMALIB_NONE
Return result as-is (allow wrapping)
@ MMALIB_RELU
Return result after applying ReLU operation.
@ MMALIB_ROUNDING
Return result after rounding.