Doxygen Book
nnstreamer_plugin_api_util.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: LGPL-2.1-only */
14 #ifndef __NNS_PLUGIN_API_UTIL_H__
15 #define __NNS_PLUGIN_API_UTIL_H__
16 
17 #include <glib.h>
18 #include <tensor_typedef.h>
19 #include <nnstreamer_version.h>
20 
21 G_BEGIN_DECLS
22 
26 #define _STR_NULL(str) ((str) ? (str) : "(NULL)")
27 
32 extern void
34 
39 extern void
41 
47 extern gsize
49 
55 extern gboolean
57 
62 extern gboolean
64 
69 extern void
71  const guint n);
72 
77 extern void
79 
86 extern gboolean
88 
94 extern guint
96 
103 extern GstTensorInfo *
104 gst_tensors_info_get_nth_info (GstTensorsInfo * info, guint index);
105 
110 extern void
112 
117 extern void
119 
126 gsize
127 gst_tensors_info_get_size (const GstTensorsInfo * info, gint index);
128 
135 extern guint
137  const gchar *dim_string);
138 
145 extern guint
147  const gchar * type_string);
148 
155 extern guint
157  const gchar * name_string);
158 
165 extern gchar *
167 
176 extern gchar *
177 gst_tensors_info_get_rank_dimensions_string (const GstTensorsInfo * info, const unsigned int rank);
178 
185 extern gchar *
187 
194 extern gchar *
196 
202 extern gboolean
204 
209 extern gboolean
211 
216 extern void
218 
224 extern gchar *
226 
231 extern void
233 
238 extern void
240 
246 extern gboolean
248 
253 extern gboolean
255  const GstTensorsConfig * c2);
256 
260 extern void
262 
268 extern gchar *
270 
274 #define gst_tensors_config_is_static(c) ((c)->info.format == _NNS_TENSOR_FORMAT_STATIC)
275 
279 #define gst_tensors_config_is_flexible(c) ((c)->info.format == _NNS_TENSOR_FORMAT_FLEXIBLE)
280 
284 #define gst_tensors_config_is_sparse(c) ((c)->info.format == _NNS_TENSOR_FORMAT_SPARSE)
285 
291 extern gboolean
293 
298 extern gboolean
299 gst_tensor_dimension_is_equal (const tensor_dim dim1, const tensor_dim dim2);
300 
306 extern guint
308 
315 extern guint
317 
324 extern guint
325 gst_tensor_parse_dimension (const gchar * dimstr, tensor_dim dim);
326 
333 extern gchar *
335 
344 extern gchar *
345 gst_tensor_get_rank_dimension_string (const tensor_dim dim, const unsigned int rank);
346 
351 extern gboolean
352 gst_tensor_dimension_string_is_equal (const gchar * dimstr1, const gchar * dimstr2);
353 
359 extern gulong
361 
365 extern gsize
367 
373 extern tensor_type
374 gst_tensor_get_type (const gchar * typestr);
375 
379 extern const gchar *
381 
387 extern tensor_format
388 gst_tensor_get_format (const gchar * format_str);
389 
393 extern const gchar *
395 
402 extern gint
403 find_key_strv (const gchar ** strv, const gchar * key);
404 
409 extern void
411 
418 extern void
419 gst_tensor_meta_info_get_version (GstTensorMetaInfo * meta, guint * major, guint * minor);
420 
426 extern gboolean
428 
434 extern gsize
436 
442 extern gsize
444 
452 extern gboolean
453 gst_tensor_meta_info_update_header (GstTensorMetaInfo * meta, gpointer header);
454 
461 extern gboolean
462 gst_tensor_meta_info_parse_header (GstTensorMetaInfo * meta, gpointer header);
463 
470 gboolean
472 
477 extern gchar *
479 
486 extern void
487 nnstreamer_version_fetch (guint * major, guint * minor, guint * micro);
488 
489 G_END_DECLS
490 #endif /* __NNS_PLUGIN_API_UTIL_H__ */
find_key_strv
gint find_key_strv(const gchar **strv, const gchar *key)
Find the index value of the given key string array.
Definition: nnstreamer_plugin_api_util_impl.c:1586
gst_tensor_dimension_string_is_equal
gboolean gst_tensor_dimension_string_is_equal(const gchar *dimstr1, const gchar *dimstr2)
Compare dimension strings.
Definition: nnstreamer_plugin_api_util_impl.c:1140
gst_tensor_get_type
tensor_type gst_tensor_get_type(const gchar *typestr)
Get tensor type from string input.
Definition: nnstreamer_plugin_api_util_impl.c:1218
gst_tensors_config_is_equal
gboolean gst_tensors_config_is_equal(const GstTensorsConfig *c1, const GstTensorsConfig *c2)
Compare tensor config info (for other/tensors)
Definition: nnstreamer_plugin_api_util_impl.c:881
gst_tensor_dimension_is_valid
gboolean gst_tensor_dimension_is_valid(const tensor_dim dim)
Check the tensor dimension is valid.
Definition: nnstreamer_plugin_api_util_impl.c:940
gst_tensor_get_type_string
const gchar * gst_tensor_get_type_string(tensor_type type)
Get type string of tensor type.
Definition: nnstreamer_plugin_api_util_impl.c:1296
nnstreamer_version_string
gchar * nnstreamer_version_string(void)
Get the version of NNStreamer.
Definition: nnstreamer_plugin_api_util_impl.c:1609
GstTensorInfo
Internal data structure for tensor info.
Definition: tensor_typedef.h:261
tensor_dim
uint32_t tensor_dim[NNS_TENSOR_RANK_LIMIT]
Definition: tensor_typedef.h:247
gst_tensor_get_rank_dimension_string
gchar * gst_tensor_get_rank_dimension_string(const tensor_dim dim, const unsigned int rank)
Get dimension string from given tensor dimension and rank count.
Definition: nnstreamer_plugin_api_util_impl.c:1107
gst_tensors_info_parse_names_string
guint gst_tensors_info_parse_names_string(GstTensorsInfo *info, const gchar *name_string)
Parse the string of names.
Definition: nnstreamer_plugin_api_util_impl.c:612
GstTensorsInfo
Internal meta data exchange format for a other/tensors instance.
Definition: tensor_typedef.h:273
gst_tensor_meta_info_update_header
gboolean gst_tensor_meta_info_update_header(GstTensorMetaInfo *meta, gpointer header)
Update header from tensor meta.
Definition: nnstreamer_plugin_api_util_impl.c:1505
gst_tensor_get_format
tensor_format gst_tensor_get_format(const gchar *format_str)
Get tensor format from string input.
Definition: nnstreamer_plugin_api_util_impl.c:1309
gst_tensors_info_validate
gboolean gst_tensors_info_validate(const GstTensorsInfo *info)
Check the tensors info is valid.
Definition: nnstreamer_plugin_api_util_impl.c:404
gst_tensor_meta_info_validate
gboolean gst_tensor_meta_info_validate(GstTensorMetaInfo *meta)
Check the meta info is valid.
Definition: nnstreamer_plugin_api_util_impl.c:1414
gst_tensor_info_copy
void gst_tensor_info_copy(GstTensorInfo *dest, const GstTensorInfo *src)
Copy tensor info.
Definition: nnstreamer_plugin_api_util_impl.c:248
gst_tensors_info_init
void gst_tensors_info_init(GstTensorsInfo *info)
Initialize the tensors info structure.
Definition: nnstreamer_plugin_api_util_impl.c:325
gst_tensor_meta_info_get_data_size
gsize gst_tensor_meta_info_get_data_size(GstTensorMetaInfo *meta)
Get the data size calculated from tensor meta.
Definition: nnstreamer_plugin_api_util_impl.c:1477
GstTensorMetaInfo
Data structure to describe a tensor data. This represents the basic information of a memory block for...
Definition: tensor_typedef.h:310
gst_tensors_info_free
void gst_tensors_info_free(GstTensorsInfo *info)
Free allocated data in tensors info structure.
Definition: nnstreamer_plugin_api_util_impl.c:347
nnstreamer_version_fetch
void nnstreamer_version_fetch(guint *major, guint *minor, guint *micro)
Get the version of NNStreamer (int, divided).
Definition: nnstreamer_plugin_api_util_impl.c:1624
gst_tensor_parse_dimension
guint gst_tensor_parse_dimension(const gchar *dimstr, tensor_dim dim)
Parse tensor dimension parameter string.
Definition: nnstreamer_plugin_api_util_impl.c:1040
gst_tensors_info_get_types_string
gchar * gst_tensors_info_get_types_string(const GstTensorsInfo *info)
Get the string of types in tensors info.
Definition: nnstreamer_plugin_api_util_impl.c:714
gst_tensors_info_to_string
gchar * gst_tensors_info_to_string(const GstTensorsInfo *info)
GstTensorsInfo represented as a string. Caller should free it.
Definition: nnstreamer_plugin_api_util_impl.c:783
tensor_type
enum _nns_tensor_type tensor_type
Possible data element types of other/tensor.
gst_tensor_info_copy_n
void gst_tensor_info_copy_n(GstTensorInfo *dest, const GstTensorInfo *src, const guint n)
Copy tensor info up to n elements.
Definition: nnstreamer_plugin_api_util_impl.c:227
gst_tensor_meta_info_parse_header
gboolean gst_tensor_meta_info_parse_header(GstTensorMetaInfo *meta, gpointer header)
Parse header and fill the tensor meta.
Definition: nnstreamer_plugin_api_util_impl.c:1527
gst_tensor_dimension_get_rank
guint gst_tensor_dimension_get_rank(const tensor_dim dim)
Get the rank of tensor dimension.
Definition: nnstreamer_plugin_api_util_impl.c:998
gst_tensors_config_copy
void gst_tensors_config_copy(GstTensorsConfig *dest, const GstTensorsConfig *src)
Copy tensors config.
Definition: nnstreamer_plugin_api_util_impl.c:904
gst_tensor_get_element_count
gulong gst_tensor_get_element_count(const tensor_dim dim)
Count the number of elements of a tensor.
Definition: nnstreamer_plugin_api_util_impl.c:1186
gst_tensor_get_element_size
gsize gst_tensor_get_element_size(tensor_type type)
Get element size of tensor type (byte per element)
Definition: nnstreamer_plugin_api_util_impl.c:1205
tensor_format
enum _tensor_format tensor_format
Data format of tensor stream in the pipeline.
gst_tensors_config_free
void gst_tensors_config_free(GstTensorsConfig *config)
Free allocated data in tensors config structure.
Definition: nnstreamer_plugin_api_util_impl.c:845
gst_tensor_get_format_string
const gchar * gst_tensor_get_format_string(tensor_format format)
Get tensor format string.
Definition: nnstreamer_plugin_api_util_impl.c:1325
gst_tensor_info_convert_to_meta
gboolean gst_tensor_info_convert_to_meta(GstTensorInfo *info, GstTensorMetaInfo *meta)
Convert GstTensorInfo structure to GstTensorMetaInfo.
Definition: nnstreamer_plugin_api_util_impl.c:260
gst_tensor_meta_info_convert
gboolean gst_tensor_meta_info_convert(GstTensorMetaInfo *meta, GstTensorInfo *info)
Convert GstTensorMetaInfo structure to GstTensorInfo.
Definition: nnstreamer_plugin_api_util_impl.c:1562
gst_tensor_get_dimension_string
gchar * gst_tensor_get_dimension_string(const tensor_dim dim)
Get dimension string from given tensor dimension.
Definition: nnstreamer_plugin_api_util_impl.c:1083
GstTensorsConfig
Internal data structure for configured tensors info (for other/tensors).
Definition: tensor_typedef.h:284
gst_tensors_config_to_string
gchar * gst_tensors_config_to_string(const GstTensorsConfig *config)
Tensor config represented as a string. Caller should free it.
Definition: nnstreamer_plugin_api_util_impl.c:920
gst_tensor_info_init
void gst_tensor_info_init(GstTensorInfo *info)
Initialize the tensor info structure.
Definition: nnstreamer_plugin_api_util_impl.c:121
tensor_typedef.h
Common header file for NNStreamer, the GStreamer plugin for neural networks.
gst_tensor_info_validate
gboolean gst_tensor_info_validate(const GstTensorInfo *info)
Check the tensor info is valid.
Definition: nnstreamer_plugin_api_util_impl.c:174
gst_tensor_info_get_size
gsize gst_tensor_info_get_size(const GstTensorInfo *info)
Get data size of single tensor.
Definition: nnstreamer_plugin_api_util_impl.c:156
gst_tensor_info_free
void gst_tensor_info_free(GstTensorInfo *info)
Free allocated data in tensor info structure.
Definition: nnstreamer_plugin_api_util_impl.c:140
gst_tensor_info_is_equal
gboolean gst_tensor_info_is_equal(const GstTensorInfo *i1, const GstTensorInfo *i2)
Compare tensor info.
Definition: nnstreamer_plugin_api_util_impl.c:197
gst_tensor_meta_info_get_version
void gst_tensor_meta_info_get_version(GstTensorMetaInfo *meta, guint *major, guint *minor)
Get the version of tensor meta.
Definition: nnstreamer_plugin_api_util_impl.c:1393
gst_tensors_info_get_nth_info
GstTensorInfo * gst_tensors_info_get_nth_info(GstTensorsInfo *info, guint index)
Get the pointer of nth tensor information.
Definition: nnstreamer_plugin_api_util_impl.c:296
gst_tensors_info_get_size
gsize gst_tensors_info_get_size(const GstTensorsInfo *info, gint index)
Get data size of single tensor.
Definition: nnstreamer_plugin_api_util_impl.c:376
gst_tensors_info_is_equal
gboolean gst_tensors_info_is_equal(const GstTensorsInfo *i1, const GstTensorsInfo *i2)
Compare tensors info.
Definition: nnstreamer_plugin_api_util_impl.c:454
gst_tensor_dimension_is_equal
gboolean gst_tensor_dimension_is_equal(const tensor_dim dim1, const tensor_dim dim2)
Compare the tensor dimension.
Definition: nnstreamer_plugin_api_util_impl.c:972
gst_tensors_config_init
void gst_tensors_config_init(GstTensorsConfig *config)
Initialize the tensors config info structure (for other/tensors)
Definition: nnstreamer_plugin_api_util_impl.c:830
gst_tensor_info_get_rank
guint gst_tensor_info_get_rank(const GstTensorInfo *info)
Get tensor rank.
Definition: nnstreamer_plugin_api_util_impl.c:285
gst_tensors_info_parse_dimensions_string
guint gst_tensors_info_parse_dimensions_string(GstTensorsInfo *info, const gchar *dim_string)
Parse the string of dimensions.
Definition: nnstreamer_plugin_api_util_impl.c:532
gst_tensors_config_validate
gboolean gst_tensors_config_validate(const GstTensorsConfig *config)
Check the tensors are all configured (for other/tensors)
Definition: nnstreamer_plugin_api_util_impl.c:858
gst_tensors_info_get_names_string
gchar * gst_tensors_info_get_names_string(const GstTensorsInfo *info)
Get the string of tensor names in tensors info.
Definition: nnstreamer_plugin_api_util_impl.c:749
gst_tensor_dimension_get_min_rank
guint gst_tensor_dimension_get_min_rank(const tensor_dim dim)
Get the minimum rank of tensor dimension.
Definition: nnstreamer_plugin_api_util_impl.c:1017
gst_tensors_info_get_dimensions_string
gchar * gst_tensors_info_get_dimensions_string(const GstTensorsInfo *info)
Get the string of dimensions in tensors info.
Definition: nnstreamer_plugin_api_util_impl.c:661
gst_tensors_info_copy
void gst_tensors_info_copy(GstTensorsInfo *dest, const GstTensorsInfo *src)
Copy tensor info.
Definition: nnstreamer_plugin_api_util_impl.c:502
type
svtc_1 type
Definition: gsttensor_if.c:843
gst_tensor_meta_info_init
void gst_tensor_meta_info_init(GstTensorMetaInfo *meta)
Initialize the tensor meta info structure.
Definition: nnstreamer_plugin_api_util_impl.c:1372
gst_tensors_info_get_rank_dimensions_string
gchar * gst_tensors_info_get_rank_dimensions_string(const GstTensorsInfo *info, const unsigned int rank)
Get the string of dimensions in tensors info and rank count.
Definition: nnstreamer_plugin_api_util_impl.c:676
gst_tensors_info_parse_types_string
guint gst_tensors_info_parse_types_string(GstTensorsInfo *info, const gchar *type_string)
Parse the string of types.
Definition: nnstreamer_plugin_api_util_impl.c:572
gst_tensor_meta_info_get_header_size
gsize gst_tensor_meta_info_get_header_size(GstTensorMetaInfo *meta)
Get the header size to handle a tensor meta.
Definition: nnstreamer_plugin_api_util_impl.c:1456