Doxygen Book
tensor_filter_single.c File Reference

Element to use general neural network framework directly without gstreamer pipeline. More...

#include <glib.h>
#include <string.h>
#include "nnstreamer_log.h"
#include "tensor_filter_common.h"
#include "tensor_filter_single.h"
Include dependency graph for tensor_filter_single.c:

Go to the source code of this file.

Classes

struct  _GTensorFilterSinglePrivate
 Private data struct for tensor-filter single class. More...
 

Macros

#define G_TENSOR_FILTER_SINGLE_PRIV(obj)   ((GTensorFilterSinglePrivate *) (obj)->priv)
 
#define g_tensor_filter_single_parent_class   parent_class
 

Typedefs

typedef struct _GTensorFilterSinglePrivate GTensorFilterSinglePrivate
 Private data struct for tensor-filter single class. More...
 

Functions

 G_DEFINE_TYPE_WITH_PRIVATE (GTensorFilterSingle, g_tensor_filter_single, G_TYPE_OBJECT)
 
static void g_tensor_filter_single_finalize (GObject *object)
 Function to finalize instance. More...
 
static void g_tensor_filter_single_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
 Setter for tensor_filter_single properties. More...
 
static void g_tensor_filter_single_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
 Getter for tensor_filter_single properties. More...
 
static gboolean g_tensor_filter_single_invoke (GTensorFilterSingle *self, const GstTensorMemory *input, GstTensorMemory *output, gboolean allocate)
 Called when an input supposed to be invoked. More...
 
static gboolean g_tensor_filter_input_configured (GTensorFilterSingle *self)
 Determine if input is configured (both input and output tensor) More...
 
static gboolean g_tensor_filter_output_configured (GTensorFilterSingle *self)
 Determine if output is configured (both input and output tensor) More...
 
static gint g_tensor_filter_set_input_info (GTensorFilterSingle *self, const GstTensorsInfo *in_info, GstTensorsInfo *out_info)
 Set input tensor information in the framework. More...
 
static void g_tensor_filter_destroy_notify (GTensorFilterSingle *self, GstTensorMemory *mem)
 Called to notify the framework to destroy the allocated memory. More...
 
static gboolean g_tensor_filter_allocate_in_invoke (GTensorFilterSingle *self)
 Determine if this filter framework supports allocation in invoke. More...
 
static gboolean g_tensor_filter_single_start (GTensorFilterSingle *self)
 Called when the element starts processing, if fw not loaded. More...
 
static gboolean g_tensor_filter_single_stop (GTensorFilterSingle *self)
 Called when the element stops processing, if fw loaded. More...
 
static void g_tensor_filter_single_class_init (GTensorFilterSingleClass *klass)
 initialize the tensor_filter's class More...
 
static void g_tensor_filter_single_init (GTensorFilterSingle *self)
 initialize the new element More...
 

Detailed Description

Element to use general neural network framework directly without gstreamer pipeline.

Copyright (C) 2019 Parichay Kapoor pk.ka.nosp@m.poor.nosp@m.@sams.nosp@m.ung..nosp@m.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.

Date
28 Aug 2019
See also
http://github.com/nnstreamer/nnstreamer
Author
Parichay Kapoor pk.ka.nosp@m.poor.nosp@m.@sams.nosp@m.ung..nosp@m.com
Bug:
No known bugs except for NYI items

This is the main element for per-NN-framework plugins. Specific implementations for each NN framework must be written in each framework specific files; e.g., tensor_filter_tensorflow_lite.c

Definition in file tensor_filter_single.c.

Macro Definition Documentation

◆ g_tensor_filter_single_parent_class

#define g_tensor_filter_single_parent_class   parent_class

Definition at line 61 of file tensor_filter_single.c.

◆ G_TENSOR_FILTER_SINGLE_PRIV

#define G_TENSOR_FILTER_SINGLE_PRIV (   obj)    ((GTensorFilterSinglePrivate *) (obj)->priv)

Definition at line 59 of file tensor_filter_single.c.

Typedef Documentation

◆ GTensorFilterSinglePrivate

Private data struct for tensor-filter single class.

SECTION:element-tensor_filter_single

An element that invokes neural network models and their framework or an independent shared object implementing tensor_filter_custom.h. The input and output are always in the format of other/tensor or other/tensors. This element is going to be the basis of single shot api.

Function Documentation

◆ G_DEFINE_TYPE_WITH_PRIVATE()

G_DEFINE_TYPE_WITH_PRIVATE ( GTensorFilterSingle  ,
g_tensor_filter_single  ,
G_TYPE_OBJECT   
)

◆ g_tensor_filter_allocate_in_invoke()

static gboolean g_tensor_filter_allocate_in_invoke ( GTensorFilterSingle self)
inlinestatic

Determine if this filter framework supports allocation in invoke.

Definition at line 231 of file tensor_filter_single.c.

Here is the caller graph for this function:

◆ g_tensor_filter_destroy_notify()

static void g_tensor_filter_destroy_notify ( GTensorFilterSingle self,
GstTensorMemory mem 
)
static

Called to notify the framework to destroy the allocated memory.

Parameters
self"this" pointer
memMemory wrapper for the allocated memory by the filter

Definition at line 296 of file tensor_filter_single.c.

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

◆ g_tensor_filter_input_configured()

static gboolean g_tensor_filter_input_configured ( GTensorFilterSingle self)
static

Determine if input is configured (both input and output tensor)

Definition at line 200 of file tensor_filter_single.c.

Here is the caller graph for this function:

◆ g_tensor_filter_output_configured()

static gboolean g_tensor_filter_output_configured ( GTensorFilterSingle self)
static

Determine if output is configured (both input and output tensor)

Definition at line 216 of file tensor_filter_single.c.

Here is the caller graph for this function:

◆ g_tensor_filter_set_input_info()

static gint g_tensor_filter_set_input_info ( GTensorFilterSingle self,
const GstTensorsInfo in_info,
GstTensorsInfo out_info 
)
static

Set input tensor information in the framework.

Parameters
self"this" pointer
in_infoinformation on the input tensor
out_infoupdated information on the output tensor
Returns
0 for success, -errno for failure.

Definition at line 400 of file tensor_filter_single.c.

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

◆ g_tensor_filter_single_class_init()

static void g_tensor_filter_single_class_init ( GTensorFilterSingleClass klass)
static

initialize the tensor_filter's class

Definition at line 89 of file tensor_filter_single.c.

Here is the call graph for this function:

◆ g_tensor_filter_single_finalize()

static void g_tensor_filter_single_finalize ( GObject *  object)
static

Function to finalize instance.

stop if not already stopped

Definition at line 133 of file tensor_filter_single.c.

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

◆ g_tensor_filter_single_get_property()

static void g_tensor_filter_single_get_property ( GObject *  object,
guint  prop_id,
GValue *  value,
GParamSpec *  pspec 
)
static

Getter for tensor_filter_single properties.

Definition at line 178 of file tensor_filter_single.c.

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

◆ g_tensor_filter_single_init()

static void g_tensor_filter_single_init ( GTensorFilterSingle self)
static

initialize the new element

Definition at line 115 of file tensor_filter_single.c.

Here is the call graph for this function:

◆ g_tensor_filter_single_invoke()

static gboolean g_tensor_filter_single_invoke ( GTensorFilterSingle self,
const GstTensorMemory input,
GstTensorMemory output,
gboolean  allocate 
)
static

Called when an input supposed to be invoked.

Parameters
self"this" pointer
inputmemory containing input data to run processing on
outputmemory to put output data into after processing
allocatetrue to allocate output data (false means tensor data is already allocated)
Returns
TRUE if there is no error.
Todo:
refactor this local variable

start if not already started

Todo:
how can we remove memcpy if output data is already allocated single-shot should fill the output data, but sub-plugin allocates new memory.

Definition at line 321 of file tensor_filter_single.c.

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

◆ g_tensor_filter_single_set_property()

static void g_tensor_filter_single_set_property ( GObject *  object,
guint  prop_id,
const GValue *  value,
GParamSpec *  pspec 
)
static

Setter for tensor_filter_single properties.

Definition at line 157 of file tensor_filter_single.c.

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

◆ g_tensor_filter_single_start()

static gboolean g_tensor_filter_single_start ( GTensorFilterSingle self)
static

Called when the element starts processing, if fw not loaded.

Parameters
self"this" pointer
Returns
TRUE if there is no error.

open framework, load model

Definition at line 246 of file tensor_filter_single.c.

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

◆ g_tensor_filter_single_stop()

static gboolean g_tensor_filter_single_stop ( GTensorFilterSingle self)
static

Called when the element stops processing, if fw loaded.

Parameters
self"this" pointer
Returns
TRUE if there is no error.

close framework, unload model

Definition at line 277 of file tensor_filter_single.c.

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