MMALIB User Guide
MMALIB_bufParams.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 
22 #ifndef MMALIB_BUFPARAMS_H_
23 #define MMALIB_BUFPARAMS_H_
24 
25 #ifndef __OPENCL_VERSION__
26 #include <stdint.h>
27 #endif
28 
29 
37 static inline int32_t MMALIB_sizeof(uint32_t type);
38 
40 typedef enum _MMALIB_data_type_e
41 {
42  /* Standard fixed point data types */
56  /* Standard floating point data types */
59  MMALIB_FLOAT64 = 13
62 
63 
64 /* ---------------------------------------------------------------- */
65 /* MISRAC Rule 4.9(DEFINE.FUNC) Deviation: The advisory is not */
66 /* being addressed */
67 /* ---------------------------------------------------------------- */
68 // MACRO for determining signedness of MMALIB data types; fragile in that it depends on ordering of MMALIB_data_type_e
69 #define MMALIB_ISSIGNED(type) ((type) < MMALIB_UINT8 || (type) > MMALIB_UINT128)
70 #define MMALIB_SIGNEDNESS(type) (MMALIB_ISSIGNED((type)) ? "signed" : "unsigned")
71 
73 typedef enum _MMALIB_dimension_e {
74  MMALIB_2D= 0,
75  MMALIB_3D= 1,
76  MMALIB_4D= 2,
77  MMALIB_5D= 3,
78  MMALIB_6D= 4
80 
82 typedef struct
83 {
84  uint32_t data_type;
86  uint32_t dim_x;
89 
91 typedef struct
92 {
93  uint32_t data_type;
95  uint32_t dim_x;
96  uint32_t dim_y;
98  int32_t stride_y;
101 
103 typedef struct
104 {
105  uint32_t data_type;
107  uint32_t dim_x;
109  uint32_t dim_y;
110  int32_t stride_y;
112  uint32_t dim_z;
113  int32_t stride_z;
116 
118 typedef struct
119 {
120  uint32_t data_type;
122  uint32_t dim_0;
123 
124  uint32_t dim_1;
125  int32_t stride_1;
127  uint32_t dim_2;
128  int32_t stride_2;
130  uint32_t dim_3;
131  int32_t stride_3;
133  uint32_t dim_4;
134  int32_t stride_4;
136  uint32_t dim_5;
137  int32_t stride_5;
139  uint32_t dimension;
142 
143 
145 static const int32_t size_of_type[] = {
146 1, // MMALIB_INT8
147 2, // MMALIB_INT16
148 4, // MMALIB_INT32
149 8, // MMALIB_INT64
150 16, // MMALIB_INT128
151 1, // MMALIB_UINT8
152 2, // MMALIB_UINT16
153 3, // MMALIB_UINT24
154 4, // MMALIB_UINT32
155 8, // MMALIB_UINT64
156 16, // MMALIB_UINT128
157 2, // MMALIB_FLOAT16
158 4, // MMALIB_FLOAT32
159 8 // MMALIB_FLOAT64
160 };
161 
162 static inline int32_t MMALIB_sizeof(uint32_t type)
163 {
164 
165  return
166  /* LDRA_JUSTIFY_START
167 <metric start> statement branch <metric end>
168 <justification start> Passing only valid types to MMALIB_sizeofsizeof function. The type never goes beyond 13.
169 <justification end> */
170 (type > (uint32_t) 13) ? 1 :
171 /* LDRA_JUSTIFY_END */
172 size_of_type[type];
173 
174 }
175 
177 #endif /* MMALIB_BUFPARAMS_H_ */
MMALIB_data_type_e
The enumeration of all data types.
static int32_t MMALIB_sizeof(uint32_t type)
static const int32_t size_of_type[]
Inline function returns number of bytes per element given a type of MMALIB_data_type_e.
MMALIB_dimension_e
The enumeration of multidimensional buffer types.
@ MMALIB_UINT32
@ MMALIB_INT32
@ MMALIB_UINT16
@ MMALIB_UINT24
@ MMALIB_FLOAT32
@ MMALIB_UINT128
@ MMALIB_INT64
@ MMALIB_UINT64
@ MMALIB_FLOAT64
@ MMALIB_INT128
@ MMALIB_UINT8
@ MMALIB_INT16
@ MMALIB_FLOAT16
@ MMALIB_INT8
@ MMALIB_5D
@ MMALIB_4D
@ MMALIB_3D
@ MMALIB_2D
@ MMALIB_6D
A structure for a 1 dimensional buffer descriptor.
uint32_t data_type
Values are of type MMALIB_data_type_e.
uint32_t dim_x
Width of buffer in X dimension in elements.
A structure for a 2 dimensional buffer descriptor.
uint32_t dim_x
Width of buffer in X dimension in elements.
uint32_t data_type
Values are of type MMALIB_data_type_e.
int32_t stride_y
Stride in Y dimension in bytes.
uint32_t dim_y
Height of buffer in Y dimension in elements.
A structure for a 3 dimensional buffer descriptor.
uint32_t dim_y
Height of buffer in Y dimension in elements.
uint32_t dim_x
Width of buffer in X dimension in elements.
uint32_t dim_z
Depth of patch in Z dimension in elements.
int32_t stride_z
Stride in Z dimension in bytes.
uint32_t data_type
Values are of type MMALIB_data_type_e.
int32_t stride_y
Stride in Y dimension in bytes.
A structure for a N dimensional buffer descriptor.
uint32_t dim_3
Uninitialized when dimension = {MMALIB_2D, MMALIB_3D}.
uint32_t dimension
Values are of type MMALIB_dimension_e.
uint32_t dim_4
Uninitialized when dimension = {MMALIB_2D, MMALIB_3D, MMALIB_4D}.
uint32_t dim_5
Uninitialized when dimension = {MMALIB_2D, MMALIB_3D, MMALIB_4D, MMALIB_5D}.
int32_t stride_5
Stride in bytes; Uninitialized when dimension = {MMALIB_2D, MMALIB_3D, MMALIB_4D, MMALIB_5D}.
int32_t stride_3
Stride in bytes; Uninitialized when dimension = {MMALIB_2D, MMALIB_3D}.
int32_t stride_2
Stride in bytes; Uninitialized when dimension = {MMALIB_2D}.
int32_t stride_1
Stride in bytes.
uint32_t dim_2
Uninitialized when dimension = {MMALIB_2D}.
uint32_t data_type
Values are of type MMALIB_data_type_e.
int32_t stride_4
Stride in bytes; Uninitialized when dimension = {MMALIB_2D, MMALIB_3D, MMALIB_4D}.