Doxygen Book
nnstreamer_plugin_api_util_impl.c File Reference

Tensor common util functions for NNStreamer. (No gst dependency) More...

#include <string.h>
#include "nnstreamer_plugin_api_util.h"
#include "nnstreamer_log.h"
Include dependency graph for nnstreamer_plugin_api_util_impl.c:

Go to the source code of this file.

Macros

#define GST_TENSOR_META_MAGIC   (0xfeedcced)
 Magic number of tensor meta. More...
 
#define GST_TENSOR_META_MAGIC_VALID(m)   ((m) == GST_TENSOR_META_MAGIC)
 Macro to check the tensor meta. More...
 
#define GST_TENSOR_META_VERSION_VALID(v)   (((v) & 0xDE000000) == 0xDE000000)
 Macro to check the meta version. More...
 
#define GST_TENSOR_META_MAKE_VERSION(major, minor)   ((major) << 12 | (minor) | 0xDE000000)
 Macro to get the version of tensor meta. More...
 
#define GST_TENSOR_META_VERSION   GST_TENSOR_META_MAKE_VERSION(1,0)
 The version of tensor meta. More...
 
#define GST_TENSOR_META_IS_V1(v)   (GST_TENSOR_META_VERSION_VALID(v) && (((v) & 0x00FFF000) & GST_TENSOR_META_MAKE_VERSION(1,0)))
 Macro to check the version of tensor meta. More...
 
#define GST_TENSOR_META_IS_VALID(m)   ((m) && GST_TENSOR_META_MAGIC_VALID ((m)->magic) && GST_TENSOR_META_VERSION_VALID ((m)->version))
 Macro to check the meta is valid. More...
 

Functions

static gint _gcd (gint a, gint b)
 Internal function, copied from gst_util_greatest_common_divisor() to remove dependency of gstreamer. More...
 
static gint _compare_rate (gint a_n, gint a_d, gint b_n, gint b_d)
 Internal function, copied from gst_util_fraction_compare() to remove dependency of gstreamer. More...
 
void gst_tensor_info_init (GstTensorInfo *info)
 Initialize the tensor info structure. More...
 
void gst_tensor_info_free (GstTensorInfo *info)
 Free allocated data in tensor info structure. More...
 
gsize gst_tensor_info_get_size (const GstTensorInfo *info)
 Get data size of single tensor. More...
 
gboolean gst_tensor_info_validate (const GstTensorInfo *info)
 Check the tensor info is valid. More...
 
gboolean gst_tensor_info_is_equal (const GstTensorInfo *i1, const GstTensorInfo *i2)
 Compare tensor info. More...
 
void gst_tensor_info_copy_n (GstTensorInfo *dest, const GstTensorInfo *src, const guint n)
 Copy tensor info up to n elements. More...
 
void gst_tensor_info_copy (GstTensorInfo *dest, const GstTensorInfo *src)
 Copy tensor info. More...
 
gboolean gst_tensor_info_convert_to_meta (GstTensorInfo *info, GstTensorMetaInfo *meta)
 Convert GstTensorInfo structure to GstTensorMetaInfo. More...
 
guint gst_tensor_info_get_rank (const GstTensorInfo *info)
 Get tensor rank. More...
 
GstTensorInfogst_tensors_info_get_nth_info (GstTensorsInfo *info, guint index)
 Get the pointer of nth tensor information. More...
 
void gst_tensors_info_init (GstTensorsInfo *info)
 Initialize the tensors info structure. More...
 
void gst_tensors_info_free (GstTensorsInfo *info)
 Free allocated data in tensors info structure. More...
 
gsize gst_tensors_info_get_size (const GstTensorsInfo *info, gint index)
 Get data size of single tensor. More...
 
gboolean gst_tensors_info_validate (const GstTensorsInfo *info)
 Check the tensors info is valid. More...
 
gboolean gst_tensors_info_is_equal (const GstTensorsInfo *i1, const GstTensorsInfo *i2)
 Compare tensors info. More...
 
void gst_tensors_info_copy (GstTensorsInfo *dest, const GstTensorsInfo *src)
 Copy tensor info. More...
 
guint gst_tensors_info_parse_dimensions_string (GstTensorsInfo *info, const gchar *dim_string)
 Parse the string of dimensions. More...
 
guint gst_tensors_info_parse_types_string (GstTensorsInfo *info, const gchar *type_string)
 Parse the string of types. More...
 
guint gst_tensors_info_parse_names_string (GstTensorsInfo *info, const gchar *name_string)
 Parse the string of names. More...
 
gchar * gst_tensors_info_get_dimensions_string (const GstTensorsInfo *info)
 Get the string of dimensions in tensors info. More...
 
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. More...
 
gchar * gst_tensors_info_get_types_string (const GstTensorsInfo *info)
 Get the string of types in tensors info. More...
 
gchar * gst_tensors_info_get_names_string (const GstTensorsInfo *info)
 Get the string of tensor names in tensors info. More...
 
gchar * gst_tensors_info_to_string (const GstTensorsInfo *info)
 GstTensorsInfo represented as a string. Caller should free it. More...
 
void gst_tensors_config_init (GstTensorsConfig *config)
 Initialize the tensors config info structure (for other/tensors) More...
 
void gst_tensors_config_free (GstTensorsConfig *config)
 Free allocated data in tensors config structure. More...
 
gboolean gst_tensors_config_validate (const GstTensorsConfig *config)
 Check the tensors are all configured. More...
 
gboolean gst_tensors_config_is_equal (const GstTensorsConfig *c1, const GstTensorsConfig *c2)
 Compare tensor config info. More...
 
void gst_tensors_config_copy (GstTensorsConfig *dest, const GstTensorsConfig *src)
 Copy tensors config. More...
 
gchar * gst_tensors_config_to_string (const GstTensorsConfig *config)
 Tensor config represented as a string. Caller should free it. More...
 
gboolean gst_tensor_dimension_is_valid (const tensor_dim dim)
 Check the tensor dimension is valid. More...
 
gboolean gst_tensor_dimension_is_equal (const tensor_dim dim1, const tensor_dim dim2)
 Compare the tensor dimension. More...
 
guint gst_tensor_dimension_get_rank (const tensor_dim dim)
 Get the rank of tensor dimension. More...
 
guint gst_tensor_dimension_get_min_rank (const tensor_dim dim)
 Get the minimum rank of tensor dimension. More...
 
guint gst_tensor_parse_dimension (const gchar *dimstr, tensor_dim dim)
 Parse tensor dimension parameter string. More...
 
gchar * gst_tensor_get_dimension_string (const tensor_dim dim)
 Get dimension string from given tensor dimension. More...
 
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. More...
 
gboolean gst_tensor_dimension_string_is_equal (const gchar *dimstr1, const gchar *dimstr2)
 Compare dimension strings. More...
 
gulong gst_tensor_get_element_count (const tensor_dim dim)
 Count the number of elements of a tensor. More...
 
gsize gst_tensor_get_element_size (tensor_type type)
 Get element size of tensor type (byte per element) More...
 
tensor_type gst_tensor_get_type (const gchar *typestr)
 Get tensor type from string input. More...
 
const gchar * gst_tensor_get_type_string (tensor_type type)
 Get type string of tensor type. More...
 
tensor_format gst_tensor_get_format (const gchar *format_str)
 Get tensor format from string input. More...
 
const gchar * gst_tensor_get_format_string (tensor_format format)
 Get tensor format string. More...
 
void gst_tensor_meta_info_init (GstTensorMetaInfo *meta)
 Initialize the tensor meta info structure. More...
 
void gst_tensor_meta_info_get_version (GstTensorMetaInfo *meta, guint *major, guint *minor)
 Get the version of tensor meta. More...
 
gboolean gst_tensor_meta_info_validate (GstTensorMetaInfo *meta)
 Check the meta info is valid. More...
 
gsize gst_tensor_meta_info_get_header_size (GstTensorMetaInfo *meta)
 Get the header size to handle a tensor meta. More...
 
gsize gst_tensor_meta_info_get_data_size (GstTensorMetaInfo *meta)
 Get the data size calculated from tensor meta. More...
 
gboolean gst_tensor_meta_info_update_header (GstTensorMetaInfo *meta, gpointer header)
 Update header from tensor meta. More...
 
gboolean gst_tensor_meta_info_parse_header (GstTensorMetaInfo *meta, gpointer header)
 Parse header and fill the tensor meta. More...
 
gboolean gst_tensor_meta_info_convert (GstTensorMetaInfo *meta, GstTensorInfo *info)
 Convert GstTensorMetaInfo structure to GstTensorInfo. More...
 
gint find_key_strv (const gchar **strv, const gchar *key)
 Find the index value of the given key string array. More...
 
gchar * nnstreamer_version_string (void)
 Get the version of NNStreamer (string). More...
 
void nnstreamer_version_fetch (guint *major, guint *minor, guint *micro)
 Get the version of NNStreamer (int, divided). More...
 

Variables

static const gchar * tensor_element_typename []
 String representations for each tensor element type. More...
 
static const guint tensor_element_size []
 Byte-per-element of each tensor element type. More...
 
static const gchar * tensor_format_name []
 String representations for tensor format. More...
 

Detailed Description

Tensor common util functions for NNStreamer. (No gst dependency)

Copyright (c) 2022 Samsung Electronics Co., Ltd. All Rights Reserved.

Date
28 Jan 2022
See also
https://github.com/nnstreamer/nnstreamer
Author
Gichan Jang gicha.nosp@m.n2.j.nosp@m.ang@s.nosp@m.amsu.nosp@m.ng.co.nosp@m.m
Bug:
No known bugs except for NYI items

Definition in file nnstreamer_plugin_api_util_impl.c.

Macro Definition Documentation

◆ GST_TENSOR_META_IS_V1

#define GST_TENSOR_META_IS_V1 (   v)    (GST_TENSOR_META_VERSION_VALID(v) && (((v) & 0x00FFF000) & GST_TENSOR_META_MAKE_VERSION(1,0)))

Macro to check the version of tensor meta.

Definition at line 1360 of file nnstreamer_plugin_api_util_impl.c.

◆ GST_TENSOR_META_IS_VALID

#define GST_TENSOR_META_IS_VALID (   m)    ((m) && GST_TENSOR_META_MAGIC_VALID ((m)->magic) && GST_TENSOR_META_VERSION_VALID ((m)->version))

Macro to check the meta is valid.

Definition at line 1365 of file nnstreamer_plugin_api_util_impl.c.

◆ GST_TENSOR_META_MAGIC

#define GST_TENSOR_META_MAGIC   (0xfeedcced)

Magic number of tensor meta.

Definition at line 1335 of file nnstreamer_plugin_api_util_impl.c.

◆ GST_TENSOR_META_MAGIC_VALID

#define GST_TENSOR_META_MAGIC_VALID (   m)    ((m) == GST_TENSOR_META_MAGIC)

Macro to check the tensor meta.

Definition at line 1340 of file nnstreamer_plugin_api_util_impl.c.

◆ GST_TENSOR_META_MAKE_VERSION

#define GST_TENSOR_META_MAKE_VERSION (   major,
  minor 
)    ((major) << 12 | (minor) | 0xDE000000)

Macro to get the version of tensor meta.

Definition at line 1350 of file nnstreamer_plugin_api_util_impl.c.

◆ GST_TENSOR_META_VERSION

#define GST_TENSOR_META_VERSION   GST_TENSOR_META_MAKE_VERSION(1,0)

The version of tensor meta.

Definition at line 1355 of file nnstreamer_plugin_api_util_impl.c.

◆ GST_TENSOR_META_VERSION_VALID

#define GST_TENSOR_META_VERSION_VALID (   v)    (((v) & 0xDE000000) == 0xDE000000)

Macro to check the meta version.

Definition at line 1345 of file nnstreamer_plugin_api_util_impl.c.

Function Documentation

◆ _compare_rate()

static gint _compare_rate ( gint  a_n,
gint  a_d,
gint  b_n,
gint  b_d 
)
static

Internal function, copied from gst_util_fraction_compare() to remove dependency of gstreamer.

Definition at line 83 of file nnstreamer_plugin_api_util_impl.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _gcd()

static gint _gcd ( gint  a,
gint  b 
)
static

Internal function, copied from gst_util_greatest_common_divisor() to remove dependency of gstreamer.

Definition at line 67 of file nnstreamer_plugin_api_util_impl.c.

Here is the caller graph for this function:

◆ find_key_strv()

gint find_key_strv ( const gchar **  strv,
const gchar *  key 
)

Find the index value of the given key string array.

Returns
Corresponding index. Returns -1 if not found.
Parameters
strvNull terminated array of gchar *
keyThe key string value

Definition at line 1586 of file nnstreamer_plugin_api_util_impl.c.

Here is the caller graph for this function:

◆ gst_tensor_dimension_get_min_rank()

guint gst_tensor_dimension_get_min_rank ( const tensor_dim  dim)

Get the minimum rank of tensor dimension.

The C-arrays with dim 4:4:4 and 4:4:4:1 have same data. In this case, this function returns min rank 3.

Parameters
dimtensor dimension.
Returns
tensor rank (Minimum rank is 1 if given dimension is valid)

Definition at line 1017 of file nnstreamer_plugin_api_util_impl.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ gst_tensor_dimension_get_rank()

guint gst_tensor_dimension_get_rank ( const tensor_dim  dim)

Get the rank of tensor dimension.

Parameters
dimtensor dimension.
Returns
tensor rank (Minimum rank is 1 if given dimension is valid)

Definition at line 998 of file nnstreamer_plugin_api_util_impl.c.

Here is the caller graph for this function:

◆ gst_tensor_dimension_is_equal()

gboolean gst_tensor_dimension_is_equal ( const tensor_dim  dim1,
const tensor_dim  dim2 
)

Compare the tensor dimension.

Returns
TRUE if given tensors have same dimension.

Definition at line 972 of file nnstreamer_plugin_api_util_impl.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ gst_tensor_dimension_is_valid()

gboolean gst_tensor_dimension_is_valid ( const tensor_dim  dim)

Check the tensor dimension is valid.

Parameters
dimtensor dimension
Returns
TRUE if dimension is valid

Definition at line 940 of file nnstreamer_plugin_api_util_impl.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ gst_tensor_dimension_string_is_equal()

gboolean gst_tensor_dimension_string_is_equal ( const gchar *  dimstr1,
const gchar *  dimstr2 
)

Compare dimension strings.

Returns
TRUE if equal, FALSE if given dimension strings are invalid or not equal.

Definition at line 1140 of file nnstreamer_plugin_api_util_impl.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ gst_tensor_get_dimension_string()

gchar* gst_tensor_get_dimension_string ( const tensor_dim  dim)

Get dimension string from given tensor dimension.

Parameters
dimtensor dimension
Returns
Formatted string of given dimension (d1:d2:d3:...:d15:d16).
Note
The returned value should be freed with g_free()

Definition at line 1083 of file nnstreamer_plugin_api_util_impl.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ gst_tensor_get_element_count()

gulong gst_tensor_get_element_count ( const tensor_dim  dim)

Count the number of elements of a tensor.

Returns
The number of elements. 0 if error.
Parameters
dimThe tensor dimension

Definition at line 1186 of file nnstreamer_plugin_api_util_impl.c.

Here is the caller graph for this function:

◆ gst_tensor_get_element_size()

gsize gst_tensor_get_element_size ( tensor_type  type)

Get element size of tensor type (byte per element)

Definition at line 1205 of file nnstreamer_plugin_api_util_impl.c.

Here is the caller graph for this function:

◆ gst_tensor_get_format()

tensor_format gst_tensor_get_format ( const gchar *  format_str)

Get tensor format from string input.

Parameters
format_strThe string format name, supposed to be one of tensor_format_name[].
Returns
Corresponding tensor_format. _NNS_TENSOR_FORMAT_END if unrecognized value is there.

Definition at line 1309 of file nnstreamer_plugin_api_util_impl.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ gst_tensor_get_format_string()

const gchar* gst_tensor_get_format_string ( tensor_format  format)

Get tensor format string.

Definition at line 1325 of file nnstreamer_plugin_api_util_impl.c.

Here is the caller graph for this function:

◆ 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.

Parameters
dimtensor dimension
rankrank count of given tensor dimension
Returns
Formatted string of given dimension
Note
If rank count is 3, then returned string is 'd1:d2:d3`. The returned value should be freed with g_free().

Definition at line 1107 of file nnstreamer_plugin_api_util_impl.c.

Here is the caller graph for this function:

◆ gst_tensor_get_type()

tensor_type gst_tensor_get_type ( const gchar *  typestr)

Get tensor type from string input.

Returns
Corresponding tensor_type. _NNS_END if unrecognized value is there.
Parameters
typestrThe string type name, supposed to be one of tensor_element_typename[]

Definition at line 1218 of file nnstreamer_plugin_api_util_impl.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ gst_tensor_get_type_string()

const gchar* gst_tensor_get_type_string ( tensor_type  type)

Get type string of tensor type.

Definition at line 1296 of file nnstreamer_plugin_api_util_impl.c.

Here is the caller graph for this function:

◆ gst_tensor_info_convert_to_meta()

gboolean gst_tensor_info_convert_to_meta ( GstTensorInfo info,
GstTensorMetaInfo meta 
)

Convert GstTensorInfo structure to GstTensorMetaInfo.

Parameters
[in]infoGstTensorInfo to be converted
[out]metatensor meta structure to be filled
Returns
TRUE if successfully set the meta
Todo:
handle rank from info.dimension

Definition at line 260 of file nnstreamer_plugin_api_util_impl.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ gst_tensor_info_copy()

void gst_tensor_info_copy ( GstTensorInfo dest,
const GstTensorInfo src 
)

Copy tensor info.

Note
Copied info should be freed with gst_tensor_info_free()

Definition at line 248 of file nnstreamer_plugin_api_util_impl.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ 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.

Note
Copied info should be freed with gst_tensor_info_free()

Definition at line 227 of file nnstreamer_plugin_api_util_impl.c.

Here is the caller graph for this function:

◆ gst_tensor_info_free()

void gst_tensor_info_free ( GstTensorInfo info)

Free allocated data in tensor info structure.

Parameters
infotensor info structure

Definition at line 140 of file nnstreamer_plugin_api_util_impl.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ gst_tensor_info_get_rank()

guint gst_tensor_info_get_rank ( const GstTensorInfo info)

Get tensor rank.

Parameters
infotensor info structure
Returns
tensor rank (Minimum rank is 1 if given info is valid)

Definition at line 285 of file nnstreamer_plugin_api_util_impl.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ gst_tensor_info_get_size()

gsize gst_tensor_info_get_size ( const GstTensorInfo info)

Get data size of single tensor.

Parameters
infotensor info structure
Returns
data size

Definition at line 156 of file nnstreamer_plugin_api_util_impl.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ gst_tensor_info_init()

void gst_tensor_info_init ( GstTensorInfo info)

Initialize the tensor info structure.

Parameters
infotensor info structure to be initialized

Definition at line 121 of file nnstreamer_plugin_api_util_impl.c.

Here is the caller graph for this function:

◆ gst_tensor_info_is_equal()

gboolean gst_tensor_info_is_equal ( const GstTensorInfo i1,
const GstTensorInfo i2 
)

Compare tensor info.

Returns
TRUE if equal, FALSE if given tensor infos are invalid or not equal.

Definition at line 197 of file nnstreamer_plugin_api_util_impl.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ gst_tensor_info_validate()

gboolean gst_tensor_info_validate ( const GstTensorInfo info)

Check the tensor info is valid.

Parameters
infotensor info structure
Returns
TRUE if info is valid

Definition at line 174 of file nnstreamer_plugin_api_util_impl.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ gst_tensor_meta_info_convert()

gboolean gst_tensor_meta_info_convert ( GstTensorMetaInfo meta,
GstTensorInfo info 
)

Convert GstTensorMetaInfo structure to GstTensorInfo.

Parameters
[in]metatensor meta structure to be converted
[out]infoGstTensorInfo to be filled
Returns
TRUE if successfully set the info

Definition at line 1562 of file nnstreamer_plugin_api_util_impl.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ 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.

Parameters
[in]metatensor meta structure
Returns
The data size for meta info (0 if meta is invalid)

Definition at line 1477 of file nnstreamer_plugin_api_util_impl.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ 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.

Parameters
[in]metatensor meta structure
Returns
Header size for meta info (0 if meta is invalid)

Definition at line 1456 of file nnstreamer_plugin_api_util_impl.c.

Here is the caller graph for this function:

◆ 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.

Parameters
[in]metatensor meta structure
[out]majorpointer to get the major version number
[out]minorpointer to get the minor version number

Definition at line 1393 of file nnstreamer_plugin_api_util_impl.c.

◆ gst_tensor_meta_info_init()

void gst_tensor_meta_info_init ( GstTensorMetaInfo meta)

Initialize the tensor meta info structure.

Parameters
[in,out]metatensor meta structure to be initialized

Definition at line 1372 of file nnstreamer_plugin_api_util_impl.c.

Here is the caller graph for this function:

◆ gst_tensor_meta_info_parse_header()

gboolean gst_tensor_meta_info_parse_header ( GstTensorMetaInfo meta,
gpointer  header 
)

Parse header and fill the tensor meta.

Parameters
[out]metatensor meta structure to be filled
[in]headerpointer to header to be parsed
Returns
TRUE if successfully set the meta
Todo:
update meta info for each version

Definition at line 1527 of file nnstreamer_plugin_api_util_impl.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ gst_tensor_meta_info_update_header()

gboolean gst_tensor_meta_info_update_header ( GstTensorMetaInfo meta,
gpointer  header 
)

Update header from tensor meta.

Parameters
[in]metatensor meta structure
[out]headerpointer to header to be updated
Returns
TRUE if successfully set the header
Note
User should allocate enough memory for header (see gst_tensor_meta_info_get_header_size()).

Definition at line 1505 of file nnstreamer_plugin_api_util_impl.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ gst_tensor_meta_info_validate()

gboolean gst_tensor_meta_info_validate ( GstTensorMetaInfo meta)

Check the meta info is valid.

Parameters
[in]metatensor meta structure
Returns
TRUE if given meta is valid

Definition at line 1414 of file nnstreamer_plugin_api_util_impl.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ gst_tensor_parse_dimension()

guint gst_tensor_parse_dimension ( const gchar *  dimstr,
tensor_dim  dim 
)

Parse tensor dimension parameter string.

Returns
The Rank. 0 if error.
Parameters
dimstrThe dimension string in the format of d1:...:d16, d1:d2:d3, d1:d2, or d1, where dN is a positive integer and d1 is the innermost dimension; i.e., dim[d16]...[d1];
dimdimension to be filled.

Definition at line 1040 of file nnstreamer_plugin_api_util_impl.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ gst_tensors_config_copy()

void gst_tensors_config_copy ( GstTensorsConfig dest,
const GstTensorsConfig src 
)

Copy tensors config.

Definition at line 904 of file nnstreamer_plugin_api_util_impl.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ gst_tensors_config_free()

void gst_tensors_config_free ( GstTensorsConfig config)

Free allocated data in tensors config structure.

Parameters
configtensors config structure

Definition at line 845 of file nnstreamer_plugin_api_util_impl.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ gst_tensors_config_init()

void gst_tensors_config_init ( GstTensorsConfig config)

Initialize the tensors config info structure (for other/tensors)

Parameters
configtensors config structure to be initialized

Definition at line 830 of file nnstreamer_plugin_api_util_impl.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ gst_tensors_config_is_equal()

gboolean gst_tensors_config_is_equal ( const GstTensorsConfig c1,
const GstTensorsConfig c2 
)

Compare tensor config info.

Compare tensor config info (for other/tensors)

Parameters
TRUEif equal

Definition at line 881 of file nnstreamer_plugin_api_util_impl.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ gst_tensors_config_to_string()

gchar* gst_tensors_config_to_string ( const GstTensorsConfig config)

Tensor config represented as a string. Caller should free it.

Parameters
configtensor config structure
Returns
The newly allocated string representing the config. Free after use.

Definition at line 920 of file nnstreamer_plugin_api_util_impl.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ gst_tensors_config_validate()

gboolean gst_tensors_config_validate ( const GstTensorsConfig config)

Check the tensors are all configured.

Check the tensors are all configured (for other/tensors)

Parameters
configtensor config structure
Returns
TRUE if configured

Definition at line 858 of file nnstreamer_plugin_api_util_impl.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ gst_tensors_info_copy()

void gst_tensors_info_copy ( GstTensorsInfo dest,
const GstTensorsInfo src 
)

Copy tensor info.

Note
Copied info should be freed with gst_tensors_info_free()

Definition at line 502 of file nnstreamer_plugin_api_util_impl.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ gst_tensors_info_free()

void gst_tensors_info_free ( GstTensorsInfo info)

Free allocated data in tensors info structure.

Parameters
infotensors info structure

Definition at line 347 of file nnstreamer_plugin_api_util_impl.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ gst_tensors_info_get_dimensions_string()

gchar* gst_tensors_info_get_dimensions_string ( const GstTensorsInfo info)

Get the string of dimensions in tensors info.

Parameters
infotensors info structure
Returns
string of dimensions in tensors info (NULL if the number of tensors is 0)
Note
The returned value should be freed with g_free()

Definition at line 661 of file nnstreamer_plugin_api_util_impl.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ 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.

Parameters
infotensors info structure
Returns
string of names in tensors info (NULL if the number of tensors is 0)
Note
The returned value should be freed with g_free()

Definition at line 749 of file nnstreamer_plugin_api_util_impl.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ gst_tensors_info_get_nth_info()

GstTensorInfo* gst_tensors_info_get_nth_info ( GstTensorsInfo info,
guint  index 
)

Get the pointer of nth tensor information.

Parameters
infotensors info structure
indexthe index of tensor to be fetched
Returns
The pointer to tensor info structure

Definition at line 296 of file nnstreamer_plugin_api_util_impl.c.

Here is the call graph for this function:

◆ 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.

Parameters
infotensors info structure
rankrank count of given tensor dimension
Returns
Formatted string of given dimension
Note
If rank count is 3, then returned string is 'd1:d2:d3`. The returned value should be freed with g_free()

Definition at line 676 of file nnstreamer_plugin_api_util_impl.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ gst_tensors_info_get_size()

gsize gst_tensors_info_get_size ( const GstTensorsInfo info,
gint  index 
)

Get data size of single tensor.

Parameters
infotensors info structure
indexthe index of tensor (-1 to get total size of tensors)
Returns
data size

Definition at line 376 of file nnstreamer_plugin_api_util_impl.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ gst_tensors_info_get_types_string()

gchar* gst_tensors_info_get_types_string ( const GstTensorsInfo info)

Get the string of types in tensors info.

Parameters
infotensors info structure
Returns
string of types in tensors info (NULL if the number of tensors is 0)
Note
The returned value should be freed with g_free()

Definition at line 714 of file nnstreamer_plugin_api_util_impl.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ gst_tensors_info_init()

void gst_tensors_info_init ( GstTensorsInfo info)

Initialize the tensors info structure.

Parameters
infotensors info structure to be initialized
Note
default format is static

Definition at line 325 of file nnstreamer_plugin_api_util_impl.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ gst_tensors_info_is_equal()

gboolean gst_tensors_info_is_equal ( const GstTensorsInfo i1,
const GstTensorsInfo i2 
)

Compare tensors info.

Returns
TRUE if equal, FALSE if given tensor infos are invalid or not equal.

Definition at line 454 of file nnstreamer_plugin_api_util_impl.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ gst_tensors_info_parse_dimensions_string()

guint gst_tensors_info_parse_dimensions_string ( GstTensorsInfo info,
const gchar *  dim_string 
)

Parse the string of dimensions.

Parameters
infotensors info structure
dim_stringstring of dimensions
Returns
number of parsed dimensions

Definition at line 532 of file nnstreamer_plugin_api_util_impl.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ gst_tensors_info_parse_names_string()

guint gst_tensors_info_parse_names_string ( GstTensorsInfo info,
const gchar *  name_string 
)

Parse the string of names.

Parameters
infotensors info structure
name_stringstring of names
Returns
number of parsed names

Definition at line 612 of file nnstreamer_plugin_api_util_impl.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ gst_tensors_info_parse_types_string()

guint gst_tensors_info_parse_types_string ( GstTensorsInfo info,
const gchar *  type_string 
)

Parse the string of types.

Parameters
infotensors info structure
type_stringstring of types
Returns
number of parsed types

Definition at line 572 of file nnstreamer_plugin_api_util_impl.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ gst_tensors_info_to_string()

gchar* gst_tensors_info_to_string ( const GstTensorsInfo info)

GstTensorsInfo represented as a string. Caller should free it.

Parameters
infoGstTensorsInfo structure
Returns
The newly allocated string representing the tensors info. Free after use.

Definition at line 783 of file nnstreamer_plugin_api_util_impl.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ gst_tensors_info_validate()

gboolean gst_tensors_info_validate ( const GstTensorsInfo info)

Check the tensors info is valid.

Parameters
infotensors info structure
Returns
TRUE if info is valid

Definition at line 404 of file nnstreamer_plugin_api_util_impl.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ nnstreamer_version_fetch()

void nnstreamer_version_fetch ( guint *  major,
guint *  minor,
guint *  micro 
)

Get the version of NNStreamer (int, divided).

Parameters
[out]majorMAJOR.minor.micro, won't set if it's null.
[out]minormajor.MINOR.micro, won't set if it's null.
[out]micromajor.minor.MICRO, won't set if it's null.

Definition at line 1624 of file nnstreamer_plugin_api_util_impl.c.

◆ nnstreamer_version_string()

gchar* nnstreamer_version_string ( void  )

Get the version of NNStreamer (string).

Get the version of NNStreamer.

Returns
Newly allocated string. The returned string should be freed with g_free().

Definition at line 1609 of file nnstreamer_plugin_api_util_impl.c.

Variable Documentation

◆ tensor_element_size

const guint tensor_element_size[]
static
Initial value:
= {
[_NNS_INT32] = 4,
[_NNS_UINT32] = 4,
[_NNS_INT16] = 2,
[_NNS_UINT16] = 2,
[_NNS_INT8] = 1,
[_NNS_UINT8] = 1,
[_NNS_FLOAT64] = 8,
[_NNS_FLOAT32] = 4,
[_NNS_INT64] = 8,
[_NNS_UINT64] = 8,
[_NNS_FLOAT16] = 2,
[_NNS_END] = 0,
}

Byte-per-element of each tensor element type.

Definition at line 38 of file nnstreamer_plugin_api_util_impl.c.

◆ tensor_element_typename

const gchar* tensor_element_typename[]
static
Initial value:
= {
[_NNS_INT32] = "int32",
[_NNS_UINT32] = "uint32",
[_NNS_INT16] = "int16",
[_NNS_UINT16] = "uint16",
[_NNS_INT8] = "int8",
[_NNS_UINT8] = "uint8",
[_NNS_FLOAT64] = "float64",
[_NNS_FLOAT32] = "float32",
[_NNS_INT64] = "int64",
[_NNS_UINT64] = "uint64",
[_NNS_FLOAT16] = "float16",
[_NNS_END] = NULL,
}

String representations for each tensor element type.

Definition at line 20 of file nnstreamer_plugin_api_util_impl.c.

◆ tensor_format_name

const gchar* tensor_format_name[]
static
Initial value:

String representations for tensor format.

Definition at line 56 of file nnstreamer_plugin_api_util_impl.c.

_NNS_UINT64
@ _NNS_UINT64
Definition: tensor_typedef.h:149
_NNS_INT64
@ _NNS_INT64
Definition: tensor_typedef.h:148
_NNS_FLOAT16
@ _NNS_FLOAT16
Definition: tensor_typedef.h:150
_NNS_UINT16
@ _NNS_UINT16
Definition: tensor_typedef.h:143
_NNS_END
@ _NNS_END
Definition: tensor_typedef.h:152
_NNS_TENSOR_FORMAT_FLEXIBLE
@ _NNS_TENSOR_FORMAT_FLEXIBLE
Definition: tensor_typedef.h:196
_NNS_FLOAT32
@ _NNS_FLOAT32
Definition: tensor_typedef.h:147
_NNS_TENSOR_FORMAT_STATIC
@ _NNS_TENSOR_FORMAT_STATIC
Definition: tensor_typedef.h:195
_NNS_TENSOR_FORMAT_SPARSE
@ _NNS_TENSOR_FORMAT_SPARSE
Definition: tensor_typedef.h:197
_NNS_INT32
@ _NNS_INT32
Definition: tensor_typedef.h:140
_NNS_INT16
@ _NNS_INT16
Definition: tensor_typedef.h:142
_NNS_FLOAT64
@ _NNS_FLOAT64
Definition: tensor_typedef.h:146
_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
_NNS_UINT8
@ _NNS_UINT8
Definition: tensor_typedef.h:145