Doxygen Book
tensor_filter_common.h
Go to the documentation of this file.
1 
25 #ifndef __G_TENSOR_FILTER_COMMON_H__
26 #define __G_TENSOR_FILTER_COMMON_H__
27 
28 #include <glib-object.h>
29 #include <errno.h>
30 #include <nnstreamer_subplugin.h>
33 #include "nnstreamer_watchdog.h"
34 
35 G_BEGIN_DECLS
36 
40 #ifndef DBG
41 #define DBG (!priv->silent)
42 #endif
43 
45 #define GST_TF_FW_VN(fw, vn) \
46  (fw && checkGstTensorFilterFrameworkVersion (fw->version, vn))
47 #define GST_TF_FW_V0(fw) GST_TF_FW_VN (fw, 0)
48 #define GST_TF_FW_V1(fw) GST_TF_FW_VN (fw, 1)
49 
53 #define gst_tensor_filter_v0_call(priv,ret,funcname,...) do { \
54  gst_tensor_filter_common_open_fw (priv); \
55  ret = -1; \
56  if ((priv)->prop.fw_opened && (priv)->fw && (priv)->fw->funcname) { \
57  ret = (priv)->fw->funcname (&(priv)->prop, &(priv)->privateData, __VA_ARGS__); \
58  } \
59  } while (0)
60 
61 #define gst_tensor_filter_v1_call(priv,ret,funcname,...) do { \
62  gst_tensor_filter_common_open_fw (priv); \
63  ret = -1; \
64  if ((priv)->prop.fw_opened && (priv)->fw && (priv)->fw->funcname) { \
65  ret = (priv)->fw->funcname ((priv)->fw, &(priv)->prop, (priv)->privateData, __VA_ARGS__); \
66  } \
67  } while (0)
68 
69 #define GST_TF_FW_INVOKE_COMPAT(priv,ret,in,out) do { \
70  ret = -1; \
71  if (GST_TF_FW_V0 ((priv)->fw)) { \
72  ret = (priv)->fw->invoke_NN (&(priv)->prop, &(priv)->privateData, (in), (out)); \
73  } else if (GST_TF_FW_V1 ((priv)->fw)) { \
74  ret = (priv)->fw->invoke ((priv)->fw, &(priv)->prop, (priv)->privateData, (in), (out)); \
75  } \
76  } while (0)
77 
78 #define GST_TF_STAT_MAX_RECENT (10)
79 
83 enum
84 {
112 };
113 
118 {
125  guint latency_ignore_count; /* number of initial latency measurements to ignore in averaging */
127 
132 {
133  GList *in_combi;
134  GList *out_combi_i;
135  GList *out_combi_o;
136  gboolean in_combi_defined;
140 
144 typedef struct {
146  GList *referred_list;
148 
153 {
154  void *privateData;
160  /* internal properties for tensor-filter */
161  gboolean silent;
162  gboolean configured;
163  gboolean is_updatable;
164  gchar *config_path;
170  gboolean latency_reporting;
176 
183 extern gchar *
185  const GstTensorsInfo * info2);
192 extern void
194  const GstTensorsInfo * info2);
195 
201 extern gboolean
203 
208 extern void gst_tensor_filter_install_properties (GObjectClass * gobject_class);
209 
213 extern void
215 
219 extern void
221 
230 extern gboolean
232  guint prop_id, const GValue * value, GParamSpec * pspec);
233 
242 extern gboolean
244  guint prop_id, GValue * value, GParamSpec * pspec);
245 
249 extern gboolean
251  const GstTensorsInfo * in, GstTensorsInfo * combined);
252 
256 extern gboolean
258  const GstTensorsInfo * in, const GstTensorsInfo * out, GstTensorsInfo * combined);
259 
263 extern gboolean
265  GstTensorsInfo * in, GstTensorsInfo * out);
266 
271 extern void
273 
278 
283 
288 
296 extern gchar *
297 gst_tensor_filter_detect_framework (const gchar * const *model_files, const guint num_models, const gboolean load_conf);
298 
306 extern gboolean
307 gst_tensor_filter_check_hw_availability (const gchar * name, const accl_hw hw, const char *custom);
308 
312 extern void
314 
315 G_END_DECLS
316 #endif /* __G_TENSOR_FILTER_COMMON_H__ */
GstTensorFilterCombination
struct _GstTensorFilterCombination GstTensorFilterCombination
Structure definition for tensor-filter in/out combination.
accl_hw
accl_hw
acceleration hw properties.
Definition: nnstreamer_plugin_api_filter.h:80
_GstTensorFilterPrivate::silent
gboolean silent
Definition: tensor_filter_common.h:161
_GstTensorFilterStatistics::latest_invoke_time
gint64 latest_invoke_time
Definition: tensor_filter_common.h:123
GstTensorFilterSharedModelRepresentation
Data Structure to store shared table.
Definition: tensor_filter_common.h:144
gst_tensorsinfo_compare_print
void gst_tensorsinfo_compare_print(const GstTensorsInfo *info1, const GstTensorsInfo *info2)
Printout the comparison results of two tensors.
Definition: tensor_filter_common.c:874
gst_tensor_filter_common_init_property
void gst_tensor_filter_common_init_property(GstTensorFilterPrivate *priv)
Initialize the properties for tensor-filter.
Definition: tensor_filter_common.c:1041
PROP_IS_UPDATABLE
@ PROP_IS_UPDATABLE
Definition: tensor_filter_common.h:102
_GstTensorFilterPrivate::latency_reported
gint64 latency_reported
Definition: tensor_filter_common.h:171
data
svtc_1 data
Definition: gsttensor_if.c:844
_GstTensorFilterPrivate::out_config
GstTensorsConfig out_config
Definition: tensor_filter_common.h:166
PROP_INPUTNAME
@ PROP_INPUTNAME
Definition: tensor_filter_common.h:91
nnstreamer_subplugin.h
Subplugin Manager for NNStreamer.
_GstTensorFilterPrivate::throughput_mode
gint throughput_mode
Definition: tensor_filter_common.h:169
_GstTensorFilterPrivate::latency_reporting
gboolean latency_reporting
Definition: tensor_filter_common.h:170
GstTensorsInfo
Internal meta data exchange format for a other/tensors instance.
Definition: tensor_typedef.h:273
GstTensorFilterSharedModelRepresentation::shared_interpreter
void * shared_interpreter
Definition: tensor_filter_common.h:145
_GstTensorFilterPrivate::stat
GstTensorFilterStatistics stat
Definition: tensor_filter_common.h:157
gst_tensor_filter_common_get_combined_in_info
gboolean gst_tensor_filter_common_get_combined_in_info(GstTensorFilterPrivate *priv, const GstTensorsInfo *in, GstTensorsInfo *combined)
Configure input tensor info with combi option.
Definition: tensor_filter_common.c:2270
PROP_INPUTLAYOUT
@ PROP_INPUTLAYOUT
Definition: tensor_filter_common.h:92
GstTensorFilterPrivate
struct _GstTensorFilterPrivate GstTensorFilterPrivate
Structure definition for common tensor-filter properties.
gst_tensor_filter_common_get_combined_out_info
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: tensor_filter_common.c:2315
PROP_CUSTOM
@ PROP_CUSTOM
Definition: tensor_filter_common.h:99
_GstTensorFilterPrivate::config_path
gchar * config_path
Definition: tensor_filter_common.h:164
PROP_OUTPUTLAYOUT
@ PROP_OUTPUTLAYOUT
Definition: tensor_filter_common.h:97
PROP_LATENCY
@ PROP_LATENCY
Definition: tensor_filter_common.h:103
_GstTensorFilterFramework
Tensor_Filter Subplugin definition.
Definition: nnstreamer_plugin_api_filter.h:249
_GstTensorFilterPrivate::in_config
GstTensorsConfig in_config
Definition: tensor_filter_common.h:165
_GstTensorFilterPrivate::watchdog_h
nns_watchdog_h watchdog_h
Definition: tensor_filter_common.h:174
PROP_CONFIG
@ PROP_CONFIG
Definition: tensor_filter_common.h:110
nnstreamer_plugin_api_util.h
Optional/Additional NNStreamer APIs for sub-plugin writers. (No GStreamer dependency)
_GstTensorFilterStatistics::latency_ignore_count
guint latency_ignore_count
Definition: tensor_filter_common.h:125
GstTensorFilterStatistics
struct _GstTensorFilterStatistics GstTensorFilterStatistics
Structure definition for tensor-filter statistics.
_GstTensorFilterStatistics::recent_latencies
void * recent_latencies
Definition: tensor_filter_common.h:124
PROP_SUSPEND
@ PROP_SUSPEND
Definition: tensor_filter_common.h:111
PROP_INPUT
@ PROP_INPUT
Definition: tensor_filter_common.h:89
_GstTensorFilterStatistics::old_total_invoke_num
gint64 old_total_invoke_num
Definition: tensor_filter_common.h:121
gst_tensor_filter_allocate_in_invoke
gboolean gst_tensor_filter_allocate_in_invoke(GstTensorFilterPrivate *priv)
check if the allocate_in_invoke is valid for the framework
Definition: tensor_filter_common.c:757
gst_tensor_filter_common_get_out_info
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: tensor_filter_common.c:2374
PROP_OUTPUTCOMBINATION
@ PROP_OUTPUTCOMBINATION
Definition: tensor_filter_common.h:106
_GstTensorFilterCombination::out_combi_i_defined
gboolean out_combi_i_defined
Definition: tensor_filter_common.h:137
PROP_SUBPLUGINS
@ PROP_SUBPLUGINS
Definition: tensor_filter_common.h:100
PROP_MODEL
@ PROP_MODEL
Definition: tensor_filter_common.h:88
PROP_INPUTTYPE
@ PROP_INPUTTYPE
Definition: tensor_filter_common.h:90
PROP_OUTPUT
@ PROP_OUTPUT
Definition: tensor_filter_common.h:94
PROP_OUTPUTRANKS
@ PROP_OUTPUTRANKS
Definition: tensor_filter_common.h:98
_GstTensorFilterCombination::out_combi_i
GList * out_combi_i
Definition: tensor_filter_common.h:134
PROP_SHARED_TENSOR_FILTER_KEY
@ PROP_SHARED_TENSOR_FILTER_KEY
Definition: tensor_filter_common.h:107
PROP_OUTPUTNAME
@ PROP_OUTPUTNAME
Definition: tensor_filter_common.h:96
PROP_LATENCY_REPORT
@ PROP_LATENCY_REPORT
Definition: tensor_filter_common.h:108
gst_tensor_filter_common_open_fw
void gst_tensor_filter_common_open_fw(GstTensorFilterPrivate *priv)
Open NN framework.
Definition: tensor_filter_common.c:2491
_GstTensorFilterStatistics::old_total_invoke_latency
gint64 old_total_invoke_latency
Definition: tensor_filter_common.h:122
gst_tensor_filter_load_tensor_info
void gst_tensor_filter_load_tensor_info(GstTensorFilterPrivate *priv)
Load tensor info from NN model. (both input and output tensor)
Definition: tensor_filter_common.c:2409
_GstTensorFilterFrameworkInfo
Tensor_Filter Subplugin framework related information.
Definition: nnstreamer_plugin_api_filter.h:158
_GstTensorFilterPrivate::info
GstTensorFilterFrameworkInfo info
Definition: tensor_filter_common.h:156
gst_tensor_filter_common_unload_fw
void gst_tensor_filter_common_unload_fw(GstTensorFilterPrivate *priv)
Unload NN framework.
Definition: tensor_filter_common.c:2545
PROP_INPUTRANKS
@ PROP_INPUTRANKS
Definition: tensor_filter_common.h:93
GstTensorsConfig
Internal data structure for configured tensors info (for other/tensors).
Definition: tensor_typedef.h:284
PROP_INVOKE_DYNAMIC
@ PROP_INVOKE_DYNAMIC
Definition: tensor_filter_common.h:109
nnstreamer_watchdog.h
NNStreamer watchdog header to manage the schedule in the element.
nnstreamer_plugin_api_filter.h
Mandatory APIs for NNStreamer Filter sub-plugins (No External Dependencies)
_GstTensorFilterPrivate
Structure definition for common tensor-filter properties.
Definition: tensor_filter_common.h:152
gst_tensor_filter_common_get_property
gboolean gst_tensor_filter_common_get_property(GstTensorFilterPrivate *priv, guint prop_id, GValue *value, GParamSpec *pspec)
Get the properties for tensor_filter.
Definition: tensor_filter_common.c:2102
_GstTensorFilterCombination::in_combi
GList * in_combi
Definition: tensor_filter_common.h:133
_GstTensorFilterPrivate::fw
const GstTensorFilterFramework * fw
Definition: tensor_filter_common.h:158
_GstTensorFilterProperties
GstTensorFilter's properties for NN framework (internal data structure)
Definition: nnstreamer_plugin_api_filter.h:112
_GstTensorFilterPrivate::is_updatable
gboolean is_updatable
Definition: tensor_filter_common.h:163
gst_tensor_filter_destroy_notify_util
void gst_tensor_filter_destroy_notify_util(GstTensorFilterPrivate *priv, void *data)
Free the data allocated for tensor filter output.
Definition: tensor_filter_common.c:786
_GstTensorFilterCombination::in_combi_defined
gboolean in_combi_defined
Definition: tensor_filter_common.h:136
_GstTensorFilterStatistics::total_invoke_latency
gint64 total_invoke_latency
Definition: tensor_filter_common.h:120
_GstTensorFilterStatistics
Structure definition for tensor-filter statistics.
Definition: tensor_filter_common.h:117
_GstTensorFilterPrivate::configured
gboolean configured
Definition: tensor_filter_common.h:162
_GstTensorFilterCombination
Structure definition for tensor-filter in/out combination.
Definition: tensor_filter_common.h:131
_GstTensorFilterCombination::out_combi_o
GList * out_combi_o
Definition: tensor_filter_common.h:135
PROP_SILENT
@ PROP_SILENT
Definition: tensor_filter_common.h:86
PROP_FRAMEWORK
@ PROP_FRAMEWORK
Definition: tensor_filter_common.h:87
PROP_THROUGHPUT
@ PROP_THROUGHPUT
Definition: tensor_filter_common.h:104
PROP_INPUTCOMBINATION
@ PROP_INPUTCOMBINATION
Definition: tensor_filter_common.h:105
gst_tensor_filter_check_hw_availability
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.
Definition: tensor_filter_common.c:2923
gst_tensor_filter_detect_framework
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 ava...
Definition: tensor_filter_common.c:1232
_GstTensorFilterPrivate::combi
GstTensorFilterCombination combi
Definition: tensor_filter_common.h:173
GstTensorFilterSharedModelRepresentation::referred_list
GList * referred_list
Definition: tensor_filter_common.h:146
_GstTensorFilterPrivate::prop
GstTensorFilterProperties prop
Definition: tensor_filter_common.h:155
PROP_0
@ PROP_0
Definition: tensor_filter_common.h:85
gst_tensor_filter_common_close_fw
void gst_tensor_filter_common_close_fw(GstTensorFilterPrivate *priv)
Close NN framework.
Definition: tensor_filter_common.c:2560
_GstTensorFilterCombination::out_combi_o_defined
gboolean out_combi_o_defined
Definition: tensor_filter_common.h:138
PROP_ACCELERATOR
@ PROP_ACCELERATOR
Definition: tensor_filter_common.h:101
PROP_OUTPUTTYPE
@ PROP_OUTPUTTYPE
Definition: tensor_filter_common.h:95
gst_tensor_filter_install_properties
void gst_tensor_filter_install_properties(GObjectClass *gobject_class)
Installs all the properties for tensor_filter.
Definition: tensor_filter_common.c:888
_GstTensorFilterPrivate::latency_mode
gint latency_mode
Definition: tensor_filter_common.h:168
_GstTensorFilterPrivate::privateData
void * privateData
Definition: tensor_filter_common.h:154
nns_watchdog_h
void * nns_watchdog_h
Definition: nnstreamer_watchdog.h:25
gst_tensor_filter_common_free_property
void gst_tensor_filter_common_free_property(GstTensorFilterPrivate *priv)
Free the properties for tensor-filter.
Definition: tensor_filter_common.c:1065
_GstTensorFilterStatistics::total_invoke_num
gint64 total_invoke_num
Definition: tensor_filter_common.h:119
gst_tensorsinfo_compare_to_string
gchar * gst_tensorsinfo_compare_to_string(const GstTensorsInfo *info, const GstTensorsInfo *info2)
Printout the comparison results of two tensors as a string.
Definition: tensor_filter_common.c:811
gst_tensor_filter_common_set_property
gboolean gst_tensor_filter_common_set_property(GstTensorFilterPrivate *priv, guint prop_id, const GValue *value, GParamSpec *pspec)
Set the properties for tensor_filter.
Definition: tensor_filter_common.c:1967