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 - http://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 inline int32_t MMALIB_sizeof(uint32_t type)
146 {
147 
148  int32_t size = 1;
149 
150  if((type == (uint32_t)MMALIB_INT8) ||
151  (type == (uint32_t)MMALIB_UINT8))
152  {
153  size = 1;
154  }
155  else if((type == (uint32_t)MMALIB_INT16) ||
156  (type == (uint32_t)MMALIB_UINT16) ||
157  (type == (uint32_t)MMALIB_FLOAT16))
158  {
159  size = 2;
160  }
161  else if(type == (uint32_t)MMALIB_UINT24)
162  {
163  size = 3;
164  }
165  else if((type == (uint32_t)MMALIB_INT32) ||
166  (type == (uint32_t)MMALIB_UINT32) ||
167  (type == (uint32_t)MMALIB_FLOAT32))
168  {
169  size = 4;
170  }
171  else if((type == (uint32_t)MMALIB_INT64) ||
172  (type == (uint32_t)MMALIB_UINT64) ||
173  (type == (uint32_t)MMALIB_FLOAT64))
174  {
175  size = 8;
176  }
177  else if((type == (uint32_t)MMALIB_INT128) ||
178  (type == (uint32_t)MMALIB_UINT128))
179  {
180  size = 16;
181  }
182  else {
183  size = 1;
184  }
185 
186  return size;
187 }
188 
190 #endif /* MMALIB_BUFPARAMS_H_ */
MMALIB_data_type_e
The enumeration of all data types.
static int32_t MMALIB_sizeof(uint32_t 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}.