Doxygen Book
tensor_typedef.h
Go to the documentation of this file.
1 
28 #ifndef __GST_TENSOR_TYPEDEF_H__
29 #define __GST_TENSOR_TYPEDEF_H__
30 
31 #include <stddef.h>
32 #include <stdint.h>
33 
34 #define NNS_TENSOR_RANK_LIMIT (16)
35 
42 #define NNS_TENSOR_SIZE_LIMIT (256)
43 #define NNS_TENSOR_SIZE_LIMIT_STR "256"
44 
52 #define NNS_TENSOR_MEMORY_MAX (16)
53 
57 #define NNS_TENSOR_SIZE_EXTRA_LIMIT (NNS_TENSOR_SIZE_LIMIT - NNS_TENSOR_MEMORY_MAX)
58 
59 #define NNS_MIMETYPE_TENSOR "other/tensor"
60 #define NNS_MIMETYPE_TENSORS "other/tensors"
61 
62 #define GST_TENSOR_NUM_TENSORS_RANGE "(int) [ 1, " NNS_TENSOR_SIZE_LIMIT_STR " ]"
63 #define GST_TENSOR_RATE_RANGE "(fraction) [ 0, max ]"
64 
68 #define GST_TENSOR_TYPE_ALL "{ float16, float32, float64, int64, uint64, int32, uint32, int16, uint16, int8, uint8 }"
69 
73 #define GST_TENSOR_FORMAT_ALL "{ static, flexible, sparse }"
74 
78 #define GST_TENSOR_CAP_DEFAULT \
79  NNS_MIMETYPE_TENSOR ", " \
80  "framerate = " GST_TENSOR_RATE_RANGE
81 
97 #define GST_TENSORS_CAP_MAKE(fmt) \
98  NNS_MIMETYPE_TENSORS ", " \
99  "format = (string) " fmt ", " \
100  "framerate = " GST_TENSOR_RATE_RANGE
101 
107 #define GST_TENSORS_CAP_WITH_NUM(num) \
108  NNS_MIMETYPE_TENSORS ", " \
109  "format = (string) static, num_tensors = " num ", " \
110  "framerate = " GST_TENSOR_RATE_RANGE
111 
115 #define GST_TENSORS_CAP_DEFAULT \
116  GST_TENSORS_CAP_WITH_NUM (GST_TENSOR_NUM_TENSORS_RANGE)
117 
123 #define GST_TENSORS_FLEX_CAP_DEFAULT \
124  GST_TENSORS_CAP_MAKE ("flexible")
125 
131 #define GST_TENSORS_SPARSE_CAP_DEFAULT \
132  GST_TENSORS_CAP_MAKE ("sparse")
133 
138 typedef enum _nns_tensor_type
139 {
153 } tensor_type;
154 
158 #if defined(FLOAT16_SUPPORT)
159 #if defined(__aarch64__) || defined(__arm__)
160 
161 typedef __fp16 float16;
162 #elif defined(__x86_64) || defined(__i686__)
163 
164 typedef _Float16 float16;
165 #else
166 #error "Float 16 supported only with aarch64, arm, x86/64. In arm, you need -mfp16-format=ieee"
167 #endif /* x86/64, arm64/arm32 */
168 #endif /* FLOAT16_SUPPORT */
169 
179 typedef enum _nns_media_type
180 {
184  _NNS_TEXT = 2,
187  _NNS_MEDIA_ANY = 0x1000,
188 } media_type;
189 
193 typedef enum _tensor_format
194 {
198 
200 } tensor_format;
201 
220 typedef enum _nns_tensor_layout
221 {
226 } tensor_layout;
227 
231 typedef union {
232  int32_t _int32_t;
233  uint32_t _uint32_t;
234  int16_t _int16_t;
235  uint16_t _uint16_t;
236  int8_t _int8_t;
237  uint8_t _uint8_t;
238  double _double;
239  float _float;
240  int64_t _int64_t;
241  uint64_t _uint64_t;
242 #ifdef FLOAT16_SUPPORT
243  float16 _float16;
244 #endif
246 
248 
252 typedef struct
253 {
254  void *data;
255  size_t size;
257 
261 typedef struct
262 {
263  char *name;
268 } GstTensorInfo;
269 
273 typedef struct
274 {
275  unsigned int num_tensors;
280 
284 typedef struct
285 {
287  int rate_n;
288  int rate_d;
290 
294 typedef struct
295 {
296  uint32_t nnz;
298 
310 typedef struct
311 {
312  uint32_t magic;
313  uint32_t version;
314  uint32_t type;
316  uint32_t format;
317  uint32_t media_type;
318 
322  union {
324  };
325 
327 
328 #endif /*__GST_TENSOR_TYPEDEF_H__*/
tensor_element::_uint16_t
uint16_t _uint16_t
Definition: tensor_typedef.h:235
_NNS_LAYOUT_ANY
@ _NNS_LAYOUT_ANY
Definition: tensor_typedef.h:222
_NNS_UINT64
@ _NNS_UINT64
Definition: tensor_typedef.h:149
GstTensorInfo::name
char * name
Definition: tensor_typedef.h:263
GstTensorInfo
Internal data structure for tensor info.
Definition: tensor_typedef.h:261
NNS_TENSOR_MEMORY_MAX
#define NNS_TENSOR_MEMORY_MAX
This value, 16, can be checked with gst_buffer_get_max_memory(), which is GST_BUFFER_MEM_MAX in gstre...
Definition: tensor_typedef.h:52
_NNS_INT64
@ _NNS_INT64
Definition: tensor_typedef.h:148
tensor_dim
uint32_t tensor_dim[NNS_TENSOR_RANK_LIMIT]
Definition: tensor_typedef.h:247
GstTensorMemory::data
void * data
Definition: tensor_typedef.h:254
GstTensorsInfo
Internal meta data exchange format for a other/tensors instance.
Definition: tensor_typedef.h:273
_NNS_FLOAT16
@ _NNS_FLOAT16
Definition: tensor_typedef.h:150
_NNS_VIDEO
@ _NNS_VIDEO
Definition: tensor_typedef.h:182
GstTensorMetaInfo::sparse_info
GstSparseTensorInfo sparse_info
Definition: tensor_typedef.h:323
tensor_element::_float
float _float
Definition: tensor_typedef.h:239
_NNS_OCTET
@ _NNS_OCTET
Definition: tensor_typedef.h:185
_NNS_UINT16
@ _NNS_UINT16
Definition: tensor_typedef.h:143
GstTensorsInfo::extra
GstTensorInfo * extra
Definition: tensor_typedef.h:277
tensor_element::_int64_t
int64_t _int64_t
Definition: tensor_typedef.h:240
GstTensorMetaInfo::version
uint32_t version
Definition: tensor_typedef.h:313
GstTensorMetaInfo
Data structure to describe a tensor data. This represents the basic information of a memory block for...
Definition: tensor_typedef.h:310
GstTensorMetaInfo::type
uint32_t type
Definition: tensor_typedef.h:314
GstTensorMemory
The unit of each data tensors. It will be used as an input/output tensor of other/tensors.
Definition: tensor_typedef.h:252
GstTensorsConfig::rate_d
int rate_d
Definition: tensor_typedef.h:288
_NNS_TENSOR
@ _NNS_TENSOR
Definition: tensor_typedef.h:186
GstTensorMetaInfo::media_type
uint32_t media_type
Definition: tensor_typedef.h:317
GstSparseTensorInfo::nnz
uint32_t nnz
Definition: tensor_typedef.h:296
GstSparseTensorInfo
Internal data structure for sparse tensor info.
Definition: tensor_typedef.h:294
tensor_type
enum _nns_tensor_type tensor_type
Possible data element types of other/tensor.
GstTensorsConfig::rate_n
int rate_n
Definition: tensor_typedef.h:287
_NNS_END
@ _NNS_END
Definition: tensor_typedef.h:152
_NNS_TENSOR_FORMAT_FLEXIBLE
@ _NNS_TENSOR_FORMAT_FLEXIBLE
Definition: tensor_typedef.h:196
GstTensorMemory::size
size_t size
Definition: tensor_typedef.h:255
_NNS_LAYOUT_NCHW
@ _NNS_LAYOUT_NCHW
Definition: tensor_typedef.h:224
tensor_format
enum _tensor_format tensor_format
Data format of tensor stream in the pipeline.
_NNS_FLOAT32
@ _NNS_FLOAT32
Definition: tensor_typedef.h:147
_NNS_TENSOR_FORMAT_STATIC
@ _NNS_TENSOR_FORMAT_STATIC
Definition: tensor_typedef.h:195
tensor_layout
enum _nns_tensor_layout tensor_layout
Tensor layout format for other/tensor.
_nns_tensor_type
_nns_tensor_type
Possible data element types of other/tensor.
Definition: tensor_typedef.h:138
tensor_element::_double
double _double
Definition: tensor_typedef.h:238
GstTensorMetaInfo::magic
uint32_t magic
Definition: tensor_typedef.h:312
_NNS_TENSOR_FORMAT_SPARSE
@ _NNS_TENSOR_FORMAT_SPARSE
Definition: tensor_typedef.h:197
_NNS_TEXT
@ _NNS_TEXT
Definition: tensor_typedef.h:184
GstTensorsConfig
Internal data structure for configured tensors info (for other/tensors).
Definition: tensor_typedef.h:284
tensor_element::_int8_t
int8_t _int8_t
Definition: tensor_typedef.h:236
GstTensorMetaInfo::dimension
tensor_dim dimension
Definition: tensor_typedef.h:315
_NNS_INT32
@ _NNS_INT32
Definition: tensor_typedef.h:140
_tensor_format
_tensor_format
Data format of tensor stream in the pipeline.
Definition: tensor_typedef.h:193
media_type
enum _nns_media_type media_type
Float16 compiler extension support.
_NNS_MEDIA_INVALID
@ _NNS_MEDIA_INVALID
Definition: tensor_typedef.h:181
_NNS_AUDIO
@ _NNS_AUDIO
Definition: tensor_typedef.h:183
_NNS_INT16
@ _NNS_INT16
Definition: tensor_typedef.h:142
tensor_element::_int32_t
int32_t _int32_t
Definition: tensor_typedef.h:232
GstTensorMetaInfo::format
uint32_t format
Definition: tensor_typedef.h:316
GstTensorsInfo::num_tensors
unsigned int num_tensors
Definition: tensor_typedef.h:275
_NNS_FLOAT64
@ _NNS_FLOAT64
Definition: tensor_typedef.h:146
_nns_media_type
_nns_media_type
Float16 compiler extension support.
Definition: tensor_typedef.h:179
tensor_element
To make the code simple with all the types. "C++ Template"-like.
Definition: tensor_typedef.h:231
_NNS_LAYOUT_NHWC
@ _NNS_LAYOUT_NHWC
Definition: tensor_typedef.h:223
GstTensorInfo::type
tensor_type type
Definition: tensor_typedef.h:266
GstTensorsConfig::info
GstTensorsInfo info
Definition: tensor_typedef.h:286
_nns_tensor_layout
_nns_tensor_layout
Tensor layout format for other/tensor.
Definition: tensor_typedef.h:220
_NNS_TENSOR_FORMAT_END
@ _NNS_TENSOR_FORMAT_END
Definition: tensor_typedef.h:199
_NNS_UINT32
@ _NNS_UINT32
Definition: tensor_typedef.h:141
_NNS_INT8
@ _NNS_INT8
Definition: tensor_typedef.h:144
tensor_element::_uint32_t
uint32_t _uint32_t
Definition: tensor_typedef.h:233
GstTensorInfo::dimension
tensor_dim dimension
Definition: tensor_typedef.h:267
tensor_element::_uint64_t
uint64_t _uint64_t
Definition: tensor_typedef.h:241
_NNS_UINT8
@ _NNS_UINT8
Definition: tensor_typedef.h:145
NNS_TENSOR_RANK_LIMIT
#define NNS_TENSOR_RANK_LIMIT
Definition: tensor_typedef.h:34
tensor_element::_uint8_t
uint8_t _uint8_t
Definition: tensor_typedef.h:237
_NNS_LAYOUT_NONE
@ _NNS_LAYOUT_NONE
Definition: tensor_typedef.h:225
GstTensorsInfo::format
tensor_format format
Definition: tensor_typedef.h:278
_NNS_MEDIA_ANY
@ _NNS_MEDIA_ANY
Definition: tensor_typedef.h:187
tensor_element::_int16_t
int16_t _int16_t
Definition: tensor_typedef.h:234