Common functions for various tensor_filters. More...
#include <string.h>
#include <hw_accel.h>
#include <ml_agent.h>
#include <nnstreamer_log.h>
#include <nnstreamer_util.h>
#include "tensor_filter_common.h"
Go to the source code of this file.
Macros | |
#define | silent_debug_info(i, msg) |
#define | REGEX_ACCL_ELEM_START "(" |
#define | REGEX_ACCL_ELEM_PREFIX "(?<!!)" |
#define | REGEX_ACCL_ELEM_SUFFIX "" |
#define | REGEX_ACCL_ELEM_DELIMITER "|" |
#define | REGEX_ACCL_ELEM_END ")?" |
#define | REGEX_ACCL_START "(^(true)[:]?([(]?(" |
#define | REGEX_ACCL_PREFIX "" |
#define | REGEX_ACCL_SUFFIX "" |
#define | REGEX_ACCL_DELIMITER "|" |
#define | REGEX_ACCL_END ")*[)]?))" |
#define | g_free_const(x) g_free((void*)(long)(x)) |
Free memory. More... | |
#define | g_strfreev_const(x) g_strfreev((void*)(long)(x)) |
Functions | |
static GType | accl_hw_get_type (void) |
to get and register hardware accelerator backend enum More... | |
static GList * | parse_accl_hw_all (const gchar *accelerators, const gchar **supported_accelerators) |
parse user given string to extract list of accelerators based on given regex More... | |
static gint | _gtfc_setprop_IS_UPDATABLE (GstTensorFilterPrivate *priv, GstTensorFilterProperties *prop, const GValue *value) |
Handle "PROP_IS_UPDATABLE" for set-property. More... | |
static gint | _gtfc_setprop_ACCELERATOR (GstTensorFilterPrivate *priv, GstTensorFilterProperties *prop, const GValue *value) |
Handle "PROP_ACCELERATOR" for set-property. More... | |
G_LOCK_DEFINE_STATIC (shared_model_table) | |
mutex for shared model table. More... | |
static void | gst_tensors_layout_init (tensors_layout layout) |
Initialize the tensors layout. More... | |
static void | gst_tensors_rank_init (unsigned int ranks[]) |
Initialize the tensors ranks. More... | |
static tensor_layout | gst_tensor_parse_layout_string (const gchar *layoutstr) |
Get tensor layout from string input. More... | |
static guint | gst_tensors_parse_layouts_string (tensors_layout layout, const gchar *layout_string) |
Parse the string of tensor layouts. More... | |
static gchar * | gst_tensor_filter_get_rank_string (const GstTensorFilterProperties *prop, gboolean isInput) |
Get the rank string of the tensors. More... | |
static gchar * | gst_tensor_filter_get_dimension_string (const GstTensorFilterProperties *prop, const gboolean isInput) |
Get the dimension string of tensors considering rank count. More... | |
static gchar * | gst_tensor_filter_get_type_string (const GstTensorFilterProperties *prop, const gboolean is_input) |
Get the type string of tensors. More... | |
static gchar * | gst_tensor_filter_get_name_string (const GstTensorFilterProperties *prop, const gboolean is_input) |
Get the name string of tensors. More... | |
static const gchar * | gst_tensor_get_layout_string (tensor_layout layout) |
Get layout string of tensor layout. More... | |
static gchar * | gst_tensor_filter_get_layout_string (const GstTensorFilterProperties *prop, const gboolean is_input) |
Get the string of layout of tensors. More... | |
static gchar * | strcpy2 (gchar *dest, const gchar *src) |
copy the string from src to destination More... | |
static gchar * | create_regex (const gchar **enum_list, const gchar **regex_utils) |
create regex for the given string list and regex basic elements More... | |
static gboolean | verify_model_path (const GstTensorFilterPrivate *priv) |
Verify validity of path for given model file if verify_model_path is set. More... | |
static void | gst_tensor_filter_properties_init (GstTensorFilterProperties *prop) |
Initialize the GstTensorFilterProperties object. More... | |
static void | gst_tensor_filter_framework_info_init (GstTensorFilterFrameworkInfo *info) |
Initialize the GstTensorFilterFrameworkInfo object. More... | |
static void | gst_tensor_filter_statistics_init (GstTensorFilterStatistics *stat) |
Initialize the GstTensorFilterFrameworkInfo object. More... | |
static gboolean | nnstreamer_filter_validate (const GstTensorFilterFramework *tfsp) |
Validate filter sub-plugin's data. More... | |
int | nnstreamer_filter_probe (GstTensorFilterFramework *tfsp) |
Filter's sub-plugin should call this function to register itself. More... | |
void | nnstreamer_filter_exit (const char *name) |
Filter's sub-plugin may call this to unregister itself. More... | |
void | nnstreamer_filter_set_custom_property_desc (const char *name, const char *prop,...) |
set custom property description for tensor filter sub-plugin More... | |
static const GstTensorFilterFramework * | nnstreamer_filter_find_best_fit (const char *names) |
Find sub-plugin filter given the name list. More... | |
const GstTensorFilterFramework * | nnstreamer_filter_find (const char *name) |
Find filter sub-plugin with the name. More... | |
static void | gst_tensor_filter_parse_modelpaths_string (GstTensorFilterProperties *prop, const gchar *model_files) |
Parse the string of model. More... | |
gboolean | gst_tensor_filter_allocate_in_invoke (GstTensorFilterPrivate *priv) |
check if the allocate_in_invoke is valid for the framework More... | |
void | gst_tensor_filter_destroy_notify_util (GstTensorFilterPrivate *priv, void *data) |
Free the data allocated for tensor filter output. More... | |
gchar * | gst_tensorsinfo_compare_to_string (const GstTensorsInfo *info1, const GstTensorsInfo *info2) |
Printout the comparison results of two tensors as a string. More... | |
void | gst_tensorsinfo_compare_print (const GstTensorsInfo *info1, const GstTensorsInfo *info2) |
Printout the comparison results of two tensors. More... | |
void | gst_tensor_filter_install_properties (GObjectClass *gobject_class) |
Installs all the properties for tensor_filter. More... | |
void | gst_tensor_filter_common_init_property (GstTensorFilterPrivate *priv) |
Initialize the properties for tensor-filter. More... | |
void | gst_tensor_filter_common_free_property (GstTensorFilterPrivate *priv) |
Free the properties for tensor-filter. More... | |
static void | gst_tensor_filter_parse_accelerator (GstTensorFilterPrivate *priv, GstTensorFilterProperties *prop, const char *accelerators) |
Parse the hardware accelerators to be used for this framework. More... | |
static gchar * | _detect_framework_from_config (const gchar *extension) |
Get available framework from config. More... | |
gchar * | gst_tensor_filter_detect_framework (const gchar *const *model_files, const guint num_models, const gboolean load_conf) |
Get neural network framework name from given model file. This does not guarantee the framework is available on the target device. More... | |
static void | gst_tensor_filter_get_available_framework (GstTensorFilterPrivate *priv, const char *fw_name) |
automatically selecting framework for tensor filter More... | |
static gint | _gtfc_setprop_FRAMEWORK (GstTensorFilterPrivate *priv, GstTensorFilterProperties *prop, const GValue *value) |
Handle "PROP_FRAMEWORK" for set-property. More... | |
static gint | _gtfc_setprop_MODEL (GstTensorFilterPrivate *priv, GstTensorFilterProperties *prop, const GValue *value) |
Handle "PROP_MODEL" for set-property. More... | |
static gint | _gtfc_setprop_DIMENSION (GstTensorFilterPrivate *priv, const GValue *value, const gboolean is_input) |
Handle "PROP_INPUT" and "PROP_OUTPUT" for set-property. More... | |
static gint | _gtfc_setprop_TYPE (GstTensorFilterPrivate *priv, const GValue *value, const gboolean is_input) |
Handle "PROP_INPUTTYPE" and "PROP_OUTPUTTYPE" for set-property. More... | |
static gint | _gtfc_setprop_NAME (GstTensorFilterPrivate *priv, const GValue *value, const gboolean is_input) |
Handle "PROP_INPUTNAME" and "PROP_OUTPUTNAME" for set-property. More... | |
static gint | _gtfc_setprop_CUSTOM (GstTensorFilterPrivate *priv, GstTensorFilterProperties *prop, const GValue *value) |
Handle "PROP_CUSTOM" for set-property. More... | |
static gint | _gtfc_setprop_LAYOUT (GstTensorFilterPrivate *priv, const GValue *value, const gboolean is_input) |
Handle "PROP_INPUTLAYOUT" and "PROP_OUTPUTLAYOUT" for set-property. More... | |
static gint | _gtfc_setprop_LATENCY (GstTensorFilterPrivate *priv, GstTensorFilterProperties *prop, const GValue *value) |
Handle "PROP_LATENCY" for set-property. More... | |
static gint | _gtfc_setprop_THROUGHPUT (GstTensorFilterPrivate *priv, GstTensorFilterProperties *prop, const GValue *value) |
Handle "PROP_THROUGHPUT" for set-property. More... | |
static gint | _gtfc_setprop_INPUTCOMBINATION (GstTensorFilterPrivate *priv, GList **prop_list, const GValue *value) |
Handle "PROP_INPUTCOMBINATION" for set-property. More... | |
static gint | _gtfc_setprop_OUTPUTCOMBINATION (GstTensorFilterPrivate *priv, GList **prop_list1, GList **prop_list2, const GValue *value) |
Handle "PROP_OUTPUTCOMBINATION" for set-property. More... | |
static gint | _gtfc_setprop_SHARED_TENSOR_FILTER_KEY (GstTensorFilterProperties *prop, const GValue *value) |
Handle "PROP_SHARED_TENSOR_FILTER_KEY" for set-property. More... | |
static gint | _gtfc_setprop_PROP_INVOKE_DYNAMIC (GstTensorFilterPrivate *priv, const GValue *value) |
Handle "PROP_INVOKE_DYNAMIC" for set-property. More... | |
static gint | _gtfc_setprop_SUSPEND (GstTensorFilterPrivate *priv, const GValue *value) |
Handle "PROP_SUSPEND" for set-property. More... | |
gboolean | gst_tensor_filter_common_set_property (GstTensorFilterPrivate *priv, guint prop_id, const GValue *value, GParamSpec *pspec) |
Set the properties for tensor_filter. More... | |
static void | gst_tensor_filter_property_to_string (GValue *value, GstTensorFilterPrivate *priv, guint prop_id) |
Convert GList to GValue. More... | |
gboolean | gst_tensor_filter_common_get_property (GstTensorFilterPrivate *priv, guint prop_id, GValue *value, GParamSpec *pspec) |
Get the properties for tensor_filter. More... | |
gboolean | gst_tensor_filter_common_get_combined_in_info (GstTensorFilterPrivate *priv, const GstTensorsInfo *in, GstTensorsInfo *combined) |
Configure input tensor info with combi option. More... | |
gboolean | gst_tensor_filter_common_get_combined_out_info (GstTensorFilterPrivate *priv, const GstTensorsInfo *in, const GstTensorsInfo *out, GstTensorsInfo *combined) |
Configure output tensor info with combi option. More... | |
gboolean | gst_tensor_filter_common_get_out_info (GstTensorFilterPrivate *priv, GstTensorsInfo *in, GstTensorsInfo *out) |
Get output tensor info from NN model with given input info. More... | |
void | gst_tensor_filter_load_tensor_info (GstTensorFilterPrivate *priv) |
Load tensor info from NN model. (both input and output tensor) More... | |
void | gst_tensor_filter_common_open_fw (GstTensorFilterPrivate *priv) |
Open NN framework. More... | |
void | gst_tensor_filter_common_unload_fw (GstTensorFilterPrivate *priv) |
Unload NN framework. More... | |
void | gst_tensor_filter_common_close_fw (GstTensorFilterPrivate *priv) |
Close NN framework. More... | |
accl_hw | get_accl_hw_type (const gchar *key) |
return accl_hw type from string More... | |
const gchar * | get_accl_hw_str (const accl_hw key) |
return string based on accl_hw type More... | |
static const gchar ** | add_basic_supported_accelerators (const gchar **supported_accelerators) |
Added basic accelerators (auto, default) to supported accelerators. More... | |
static const gchar ** | filter_supported_accelerators (const gchar **supported_accelerators) |
Filter accelerators based on the runtime system. More... | |
static accl_hw | parse_accl_hw_util (const gchar *accelerators, const gchar **supported_accelerators, const gchar *auto_accelerator, const gchar *default_accelerator) |
parse user given string to extract accelerator based on given regex More... | |
static gint | runtime_check_supported_accelerator (const gchar *accl) |
Check if this accelerator can be used based on the runtime system. More... | |
accl_hw | parse_accl_hw_fill (parse_accl_args accl_args) |
parse user given string to extract accelerator based on given regex filling in optional arguments More... | |
gboolean | gst_tensor_filter_check_hw_availability (const gchar *name, const accl_hw hw, const char *custom) |
Check if the given hw is supported by the framework. More... | |
void * | nnstreamer_filter_shared_model_get (void *instance, const char *key) |
Get the shared model representation that is already shared and has the same key. More... | |
void * | nnstreamer_filter_shared_model_insert_and_get (void *instance, char *key, void *interpreter) |
Insert the new shared model representation and get the value. More... | |
int | nnstreamer_filter_shared_model_remove (void *instance, const char *key, void(*free_callback)(void *)) |
Remove the instance registered at the referred list of shared model table. If referred list is empty, free_callback is executed. More... | |
void | nnstreamer_filter_shared_model_replace (void *instance, const char *key, void *new_interpreter, void(*replace_callback)(void *, void *), void(*free_callback)(void *)) |
Helper to reload interpreter for instances that has shared key. replace_callback is called iterating instances in referred list. More... | |
Variables | |
static const gchar * | regex_accl_utils [] |
static const gchar * | regex_accl_elem_utils [] |
static GHashTable * | shared_model_table = NULL |
Common functions for various tensor_filters.
Copyright (C) 2019 Parichay Kapoor pk.ka poor @sams ung. com
This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; version 2.1 of the License.
This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details.
Definition in file tensor_filter_common.c.
#define g_free_const | ( | x | ) | g_free((void*)(long)(x)) |
Free memory.
Definition at line 87 of file tensor_filter_common.c.
#define g_strfreev_const | ( | x | ) | g_strfreev((void*)(long)(x)) |
Definition at line 88 of file tensor_filter_common.c.
#define REGEX_ACCL_DELIMITER "|" |
Definition at line 63 of file tensor_filter_common.c.
#define REGEX_ACCL_ELEM_DELIMITER "|" |
Definition at line 57 of file tensor_filter_common.c.
#define REGEX_ACCL_ELEM_END ")?" |
Definition at line 58 of file tensor_filter_common.c.
#define REGEX_ACCL_ELEM_PREFIX "(?<!!)" |
Definition at line 55 of file tensor_filter_common.c.
#define REGEX_ACCL_ELEM_START "(" |
Basic elements to form accelerator regex forming
Definition at line 54 of file tensor_filter_common.c.
#define REGEX_ACCL_ELEM_SUFFIX "" |
Definition at line 56 of file tensor_filter_common.c.
#define REGEX_ACCL_END ")*[)]?))" |
Definition at line 64 of file tensor_filter_common.c.
#define REGEX_ACCL_PREFIX "" |
Definition at line 61 of file tensor_filter_common.c.
#define REGEX_ACCL_START "(^(true)[:]?([(]?(" |
Definition at line 60 of file tensor_filter_common.c.
#define REGEX_ACCL_SUFFIX "" |
Definition at line 62 of file tensor_filter_common.c.
#define silent_debug_info | ( | i, | |
msg | |||
) |
Definition at line 35 of file tensor_filter_common.c.
|
static |
Get available framework from config.
key str: framework_priority_<file ext> (e.g., for tensorflow-lite model, model_file.tflite, key str is 'framework_priority_tflite'.
Definition at line 1185 of file tensor_filter_common.c.
|
static |
Handle "PROP_ACCELERATOR" for set-property.
Definition at line 1658 of file tensor_filter_common.c.
|
static |
Handle "PROP_CUSTOM" for set-property.
Definition at line 1627 of file tensor_filter_common.c.
|
static |
Handle "PROP_INPUT" and "PROP_OUTPUT" for set-property.
Once configured, it cannot be changed in runtime for now
Definition at line 1490 of file tensor_filter_common.c.
|
static |
Handle "PROP_FRAMEWORK" for set-property.
set PROP_IS_UPDATABLE in case it was set before framework
set PROP_ACCELERATOR in case it was set before framework
Definition at line 1381 of file tensor_filter_common.c.
|
static |
Handle "PROP_INPUTCOMBINATION" for set-property.
Definition at line 1843 of file tensor_filter_common.c.
|
static |
Handle "PROP_IS_UPDATABLE" for set-property.
Definition at line 1710 of file tensor_filter_common.c.
|
static |
Handle "PROP_LATENCY" for set-property.
Definition at line 1799 of file tensor_filter_common.c.
|
static |
Handle "PROP_INPUTLAYOUT" and "PROP_OUTPUTLAYOUT" for set-property.
Update the properties
Definition at line 1732 of file tensor_filter_common.c.
|
static |
Handle "PROP_MODEL" for set-property.
Store a copy of the original prop in case the reload fails
Reload model if FW has been already opened; In the case of reloading model files, each priv->fw (tensor filter for each nnfw) has responsibility for the verification of the path regardless of priv->fw->verify_model_path.
original prop is sent and not the updated prop
Definition at line 1428 of file tensor_filter_common.c.
|
static |
Handle "PROP_INPUTNAME" and "PROP_OUTPUTNAME" for set-property.
Once configured, it cannot be changed in runtime for now
Definition at line 1588 of file tensor_filter_common.c.
|
static |
Handle "PROP_OUTPUTCOMBINATION" for set-property.
Definition at line 1874 of file tensor_filter_common.c.
|
static |
Handle "PROP_INVOKE_DYNAMIC" for set-property.
Definition at line 1937 of file tensor_filter_common.c.
|
static |
Handle "PROP_SHARED_TENSOR_FILTER_KEY" for set-property.
Definition at line 1917 of file tensor_filter_common.c.
|
static |
Handle "PROP_SUSPEND" for set-property.
Definition at line 1950 of file tensor_filter_common.c.
|
static |
Handle "PROP_THROUGHPUT" for set-property.
Definition at line 1821 of file tensor_filter_common.c.
|
static |
Handle "PROP_INPUTTYPE" and "PROP_OUTPUTTYPE" for set-property.
Once configured, it cannot be changed in runtime for now
Definition at line 1549 of file tensor_filter_common.c.
|
static |
to get and register hardware accelerator backend enum
Definition at line 2883 of file tensor_filter_common.c.
|
static |
Added basic accelerators (auto, default) to supported accelerators.
Count number of elements for the array
Allocate the array
Fill the array
Definition at line 2686 of file tensor_filter_common.c.
|
static |
create regex for the given string list and regex basic elements
[in] | enum_list | list of strings to form regex for |
[in] | regex_utils | list of basic elements to form regex |
create the regex string
escape the special characters
Definition at line 431 of file tensor_filter_common.c.
|
static |
Filter accelerators based on the runtime system.
This filters out NEON accelerator if the system running the tensor_filter does not support NEON instructions
Count number of elements for the array
Allocate the array
Fill the array
Definition at line 2722 of file tensor_filter_common.c.
G_LOCK_DEFINE_STATIC | ( | shared_model_table | ) |
mutex for shared model table.
const gchar* get_accl_hw_str | ( | const accl_hw | key | ) |
return string based on accl_hw type
key | The key enum value |
Definition at line 2598 of file tensor_filter_common.c.
accl_hw get_accl_hw_type | ( | const gchar * | key | ) |
return accl_hw type from string
key | The key string value |
Definition at line 2577 of file tensor_filter_common.c.
gboolean gst_tensor_filter_allocate_in_invoke | ( | GstTensorFilterPrivate * | priv | ) |
check if the allocate_in_invoke is valid for the framework
[in] | priv | Struct containing the properties of the object |
Definition at line 757 of file tensor_filter_common.c.
gboolean gst_tensor_filter_check_hw_availability | ( | const gchar * | name, |
const accl_hw | hw, | ||
const char * | custom | ||
) |
Check if the given hw is supported by the framework.
Only check for specific HW, DEFAULT/AUTO are always supported
Definition at line 2923 of file tensor_filter_common.c.
void gst_tensor_filter_common_close_fw | ( | GstTensorFilterPrivate * | priv | ) |
Close NN framework.
Definition at line 2560 of file tensor_filter_common.c.
void gst_tensor_filter_common_free_property | ( | GstTensorFilterPrivate * | priv | ) |
Free the properties for tensor-filter.
Definition at line 1065 of file tensor_filter_common.c.
gboolean gst_tensor_filter_common_get_combined_in_info | ( | GstTensorFilterPrivate * | priv, |
const GstTensorsInfo * | in, | ||
GstTensorsInfo * | combined | ||
) |
Configure input tensor info with combi option.
Definition at line 2270 of file tensor_filter_common.c.
gboolean gst_tensor_filter_common_get_combined_out_info | ( | GstTensorFilterPrivate * | priv, |
const GstTensorsInfo * | in, | ||
const GstTensorsInfo * | out, | ||
GstTensorsInfo * | combined | ||
) |
Configure output tensor info with combi option.
Definition at line 2315 of file tensor_filter_common.c.
gboolean gst_tensor_filter_common_get_out_info | ( | GstTensorFilterPrivate * | priv, |
GstTensorsInfo * | in, | ||
GstTensorsInfo * | out | ||
) |
Get output tensor info from NN model with given input info.
Definition at line 2374 of file tensor_filter_common.c.
gboolean gst_tensor_filter_common_get_property | ( | GstTensorFilterPrivate * | priv, |
guint | prop_id, | ||
GValue * | value, | ||
GParamSpec * | pspec | ||
) |
Get the properties for tensor_filter.
[in] | priv | Struct containing the properties of the object |
[in] | prop_id | Id for the property |
[in] | value | Container to return the asked property |
[in] | pspec | Metadata to specify the parameter |
Definition at line 2102 of file tensor_filter_common.c.
void gst_tensor_filter_common_init_property | ( | GstTensorFilterPrivate * | priv | ) |
Initialize the properties for tensor-filter.
Definition at line 1041 of file tensor_filter_common.c.
void gst_tensor_filter_common_open_fw | ( | GstTensorFilterPrivate * | priv | ) |
Open NN framework.
Definition at line 2491 of file tensor_filter_common.c.
gboolean gst_tensor_filter_common_set_property | ( | GstTensorFilterPrivate * | priv, |
guint | prop_id, | ||
const GValue * | value, | ||
GParamSpec * | pspec | ||
) |
Set the properties for tensor_filter.
[in] | priv | Struct containing the properties of the object |
[in] | prop_id | Id for the property |
[in] | value | Container to return the asked property |
[in] | pspec | Metadata to specify the parameter |
Although no one return !0 at this point, let's enable error handling.
Definition at line 1967 of file tensor_filter_common.c.
void gst_tensor_filter_common_unload_fw | ( | GstTensorFilterPrivate * | priv | ) |
Unload NN framework.
Definition at line 2545 of file tensor_filter_common.c.
void gst_tensor_filter_destroy_notify_util | ( | GstTensorFilterPrivate * | priv, |
void * | data | ||
) |
Free the data allocated for tensor filter output.
[in] | priv | Struct containing the properties of the object |
[in] | data | Data to be freed |
Definition at line 786 of file tensor_filter_common.c.
gchar* gst_tensor_filter_detect_framework | ( | const gchar *const * | model_files, |
const guint | num_models, | ||
const gboolean | load_conf | ||
) |
Get neural network framework name from given model file. This does not guarantee the framework is available on the target device.
[in] | model_files | the prediction model paths |
[in] | num_models | the number of model files |
[in] | load_conf | flag to load configuration for the priority of framework |
Definition at line 1232 of file tensor_filter_common.c.
|
static |
Initialize the GstTensorFilterFrameworkInfo object.
Definition at line 528 of file tensor_filter_common.c.
|
static |
automatically selecting framework for tensor filter
[in] | priv | Struct containing the properties of the object |
[in] | fw_name | Framework name |
Get framework info for v1
update the accelerator if already set based on v0 or v1
Definition at line 1317 of file tensor_filter_common.c.
|
static |
Get the dimension string of tensors considering rank count.
[in] | prop | GstTensorFilterProperties object |
isInput | TRUE if target is input tensors |
Definition at line 259 of file tensor_filter_common.c.
|
static |
Get the string of layout of tensors.
layout | layout of the tensors |
Definition at line 372 of file tensor_filter_common.c.
|
static |
Get the name string of tensors.
[in] | prop | GstTensorFilterProperties object |
is_input | TRUE if target is input tensors |
Definition at line 327 of file tensor_filter_common.c.
|
static |
Get the rank string of the tensors.
prop | GstTensorFilterProperties object |
isInput | TRUE if target is input tensors |
Definition at line 211 of file tensor_filter_common.c.
|
static |
Get the type string of tensors.
[in] | prop | GstTensorFilterProperties object |
is_input | TRUE if target is input tensors |
Definition at line 304 of file tensor_filter_common.c.
void gst_tensor_filter_install_properties | ( | GObjectClass * | gobject_class | ) |
Installs all the properties for tensor_filter.
[in] | gobject_class | Glib object class whose properties will be set |
min
max
default: off
min
max
default: off
Definition at line 888 of file tensor_filter_common.c.
void gst_tensor_filter_load_tensor_info | ( | GstTensorFilterPrivate * | priv | ) |
Load tensor info from NN model. (both input and output tensor)
if set-property called and already has info, verify it!
In case of dynamic invoke, output tensors info is determined after invoke.
if set-property called and already has info, verify it!
Definition at line 2409 of file tensor_filter_common.c.
|
static |
Parse the hardware accelerators to be used for this framework.
[in] | priv | Struct containing the properties of the object |
[in] | prop | Struct containing the properties of the framework |
[in] | accelerators | user given input for hardware accelerators |
Get h/w accelerators supported by framework (V1 only)
Convert the list to string format Extra 2 entries for basic accelerators : auto and default
Parse the user given h/w accelerators intersected with supported h/w
Convert the GList to regular array
Definition at line 1123 of file tensor_filter_common.c.
|
static |
Parse the string of model.
[out] | prop | Struct containing the properties of the object |
[in] | model_files | the prediction model paths |
Definition at line 728 of file tensor_filter_common.c.
|
static |
Initialize the GstTensorFilterProperties object.
Definition at line 510 of file tensor_filter_common.c.
|
static |
Convert GList to GValue.
Definition at line 2063 of file tensor_filter_common.c.
|
static |
Initialize the GstTensorFilterFrameworkInfo object.
Definition at line 545 of file tensor_filter_common.c.
|
static |
Get layout string of tensor layout.
layout | layout of the tensor |
Definition at line 349 of file tensor_filter_common.c.
|
static |
Get tensor layout from string input.
Definition at line 134 of file tensor_filter_common.c.
|
static |
Initialize the tensors layout.
Definition at line 108 of file tensor_filter_common.c.
|
static |
Parse the string of tensor layouts.
layout | layout of the tensors |
layout_string | string of layout |
Definition at line 173 of file tensor_filter_common.c.
|
static |
Initialize the tensors ranks.
Definition at line 121 of file tensor_filter_common.c.
void gst_tensorsinfo_compare_print | ( | const GstTensorsInfo * | info1, |
const GstTensorsInfo * | info2 | ||
) |
Printout the comparison results of two tensors.
[in] | info1 | The tensors to be shown on the left hand side |
[in] | info2 | The tensors to be shown on the right hand side |
Definition at line 874 of file tensor_filter_common.c.
gchar* gst_tensorsinfo_compare_to_string | ( | const GstTensorsInfo * | info1, |
const GstTensorsInfo * | info2 | ||
) |
Printout the comparison results of two tensors as a string.
[in] | info1 | The tensors to be shown on the left hand side |
[in] | info2 | The tensors to be shown on the right hand side |
Definition at line 811 of file tensor_filter_common.c.
void nnstreamer_filter_exit | ( | const char * | name | ) |
Filter's sub-plugin may call this to unregister itself.
[in] | name | The name of filter sub-plugin. |
Definition at line 638 of file tensor_filter_common.c.
const GstTensorFilterFramework* nnstreamer_filter_find | ( | const char * | name | ) |
Find filter sub-plugin with the name.
[in] | name | The name of filter sub-plugin. |
Definition at line 697 of file tensor_filter_common.c.
|
static |
Find sub-plugin filter given the name list.
[in] | names | comma, whitespace separated list of the sub-plugin name |
Definition at line 664 of file tensor_filter_common.c.
int nnstreamer_filter_probe | ( | GstTensorFilterFramework * | tfsp | ) |
Filter's sub-plugin should call this function to register itself.
[in] | tfsp | Tensor-Filter Sub-Plugin to be registered. |
Definition at line 611 of file tensor_filter_common.c.
void nnstreamer_filter_set_custom_property_desc | ( | const char * | name, |
const char * | prop, | ||
... | |||
) |
set custom property description for tensor filter sub-plugin
Definition at line 647 of file tensor_filter_common.c.
void* nnstreamer_filter_shared_model_get | ( | void * | instance, |
const char * | key | ||
) |
Get the shared model representation that is already shared and has the same key.
[in] | instance | The instance that is sharing the model representation. It will be registered at the referred list. |
[in] | key | The key to find the matched shared representation. |
Definition at line 2993 of file tensor_filter_common.c.
void* nnstreamer_filter_shared_model_insert_and_get | ( | void * | instance, |
char * | key, | ||
void * | interpreter | ||
) |
Insert the new shared model representation and get the value.
[in] | instance | The instance that is sharing the model representation. It will be registered at the referred list. |
[in] | key | The key for shared model. |
[in] | interpreter | The interpreter to be shared. |
Internal error case. The interpreter already exists in shared table, do not insert and return null.
Definition at line 3026 of file tensor_filter_common.c.
int nnstreamer_filter_shared_model_remove | ( | void * | instance, |
const char * | key, | ||
void(*)(void *) | free_callback | ||
) |
Remove the instance registered at the referred list of shared model table. If referred list is empty, free_callback
is executed.
[in] | instance | The instance that should be removed from the referred list. |
[in] | key | The key to find the shared model. |
[in] | free_callback | The callback function to destroy the interpreter, which takes the interpreter as arg. |
Definition at line 3081 of file tensor_filter_common.c.
void nnstreamer_filter_shared_model_replace | ( | void * | instance, |
const char * | key, | ||
void * | new_interpreter, | ||
void(*)(void *, void *) | replace_callback, | ||
void(*)(void *) | free_callback | ||
) |
Helper to reload interpreter for instances that has shared key. replace_callback
is called iterating instances in referred list.
[in] | instance | The instance that is sharing the model representation. |
[in] | key | The key to find the shared model. |
[in] | interpreter | The new interpreter to replace. |
[in] | replace_callback | The callback function to replace with new interpreter. |
[in] | free_callback | The callback function to destroy the old interpreter. |
Definition at line 3128 of file tensor_filter_common.c.
|
static |
Validate filter sub-plugin's data.
Mandatory callbacks are not defined
Definition at line 560 of file tensor_filter_common.c.
|
static |
parse user given string to extract list of accelerators based on given regex
[in] | accelerators | user given input |
[in] | supported_accelerators | list of supported accelerators |
Default to auto mode
Now match each provided element and get specific accelerator
Definition at line 2620 of file tensor_filter_common.c.
accl_hw parse_accl_hw_fill | ( | parse_accl_args | accl_args | ) |
parse user given string to extract accelerator based on given regex filling in optional arguments
remove unsupported accelerators from this list based on runtime system
filtered supported accelerators can be empty
update default accelerator if it is not available at runtime
update auto accelerator if it is not available at runtime
Definition at line 2833 of file tensor_filter_common.c.
|
static |
parse user given string to extract accelerator based on given regex
[in] | accelerators | user given input |
[in] | supported_accelerators | list of supported accelerators |
[in] | auto_accelerator | accelerator to use in auto case (when acceleration is enabled but specific accelerator is not provided or not matching) |
[in] | default_accelerator | accelerator to use by default |
add auto and default accelerator into list of supported accelerators
This can be ACCL_NONE (no acceleration) or a specific accelerator
Definition at line 2763 of file tensor_filter_common.c.
|
static |
Check if this accelerator can be used based on the runtime system.
0 | if filter can be used, -errno otherwise |
Allocate the array
Fill the array
Definition at line 2804 of file tensor_filter_common.c.
|
static |
copy the string from src to destination
[in] | dest | destination string |
[in] | src | source string |
Definition at line 414 of file tensor_filter_common.c.
|
inlinestatic |
Verify validity of path for given model file if verify_model_path is set.
[in] | priv | Struct containing the common tensor-filter properties of the object |
Definition at line 473 of file tensor_filter_common.c.
|
static |
Definition at line 75 of file tensor_filter_common.c.
|
static |
Definition at line 66 of file tensor_filter_common.c.
|
static |
Definition at line 102 of file tensor_filter_common.c.