Doxygen Book
tensor_filter_custom_easy.h File Reference

Custom tensor processing interface for simple functions. More...

#include <stdint.h>
#include "tensor_typedef.h"
#include "tensor_filter_custom.h"
Include dependency graph for tensor_filter_custom_easy.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Typedefs

typedef int(* NNS_custom_invoke_dynamic) (void *private_data, const GstTensorsInfo *in_info, GstTensorsInfo *out_info, const GstTensorMemory *input, GstTensorMemory *output)
 Invoke the "main function" with flexible input and output. Output tensor memory should be allocated. More...
 

Functions

G_BEGIN_DECLS int NNS_custom_easy_register (const char *modelname, NNS_custom_invoke func, void *data, const GstTensorsInfo *in_info, const GstTensorsInfo *out_info)
 Register the custom-easy tensor function. More...
 
int NNS_custom_easy_dynamic_register (const char *modelname, NNS_custom_invoke_dynamic func, void *data, const GstTensorsInfo *in_info)
 Register the custom-easy tensor function for dynamic invoke. More...
 
int NNS_custom_easy_unregister (const char *modelname)
 Unregister the custom-easy tensor function. More...
 

Detailed Description

Custom tensor processing interface for simple functions.

GStreamer Tensor_Filter, Customized Module, Easy Mode Copyright (C) 2019 MyungJoo Ham myung.nosp@m.joo..nosp@m.ham@s.nosp@m.amsu.nosp@m.ng.co.nosp@m.m

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
24 Oct 2019
See also
http://github.com/nnstreamer/nnstreamer
Author
MyungJoo Ham myung.nosp@m.joo..nosp@m.ham@s.nosp@m.amsu.nosp@m.ng.co.nosp@m.m
Bug:
No known bugs except for NYI items

How To for NNdevelopers:

Case 1. Provide the function as a shared object for other apps.

  1. Define struct, "NNStreamer_custom_easy", with the functions defined.
  2. Call NNS_custom_easy_register() at a global init/constructor function.
  3. Compile as a shared object. (.so in Linux) And install at the custom-filter path.
  4. Use NNStreamer (tensor_filter framework=custom_easy, model=${modelname}, custom=${_FILEPATH_OF_YOUR_SO} ...)
  5. Note that you may register multiple models (functions) with a single .so.

Case 2. Define the function in the app.

  1. Define struct, "NNStreamer_custom_easy", with the functions defined.
  2. Register the struct with "NNS_custom_easy_register" API.
  3. Construct the nnstreamer pipeline and execute it in the app.

Note that this does not support flexible dimensions.

To Packagers:

This file is to be packaged as "devel" package for NN developers.

Definition in file tensor_filter_custom_easy.h.

Typedef Documentation

◆ NNS_custom_invoke_dynamic

typedef int(* NNS_custom_invoke_dynamic) (void *private_data, const GstTensorsInfo *in_info, GstTensorsInfo *out_info, const GstTensorMemory *input, GstTensorMemory *output)

Invoke the "main function" with flexible input and output. Output tensor memory should be allocated.

Parameters
[in/out]private_data A subplugin may save its internal private data here. The subplugin is responsible for alloc/free of this pointer.
[in]infostructure of input tensors info
[out]infostructure of output tensors info. The subplugin should fill this info.
[in]inputThe array of input tensors. Allocated and filled by tensor_filter/main
[out]outputThe array of output tensors. The subplugin should allocate the memory block for output tensor. (data in GstTensorMemory)
Note
rank limit (NNS_TENSOR_RANK_LIMIT) and typesize (tensor_element_size) defined in tensor_typedef.h
Returns
0 if success

Definition at line 76 of file tensor_filter_custom_easy.h.

Function Documentation

◆ NNS_custom_easy_dynamic_register()

int NNS_custom_easy_dynamic_register ( const char *  modelname,
NNS_custom_invoke_dynamic  func,
void *  data,
const GstTensorsInfo in_info 
)

Register the custom-easy tensor function for dynamic invoke.

Parameters
[in]modelnameThe name of custom-easy tensor function.
[in]funcThe tensor function body
[in/out]private_data The internal data for the function
[in]in_infoInput tensor metadata.
Note
NNS_custom_invoke_dynamic defined in tensor_filter_custom.h Output buffers should be allocated in the invoke function.

Register the custom-easy tensor function for dynamic invoke.

Returns
0 if success. -ERRNO if error.

Definition at line 112 of file tensor_filter_custom_easy.c.

Here is the call graph for this function:

◆ NNS_custom_easy_register()

G_BEGIN_DECLS int NNS_custom_easy_register ( const char *  modelname,
NNS_custom_invoke  func,
void *  data,
const GstTensorsInfo in_info,
const GstTensorsInfo out_info 
)

Register the custom-easy tensor function.

Parameters
[in]modelnameThe name of custom-easy tensor function.
[in]funcThe tensor function body
[in/out]private_data The internal data for the function
[in]in_infoInput tensor metadata.
[in]out_infoOutput tensor metadata
Note
NNS_custom_invoke defined in tensor_filter_custom.h Output buffers for func are preallocated.

Register the custom-easy tensor function.

Returns
0 if success. -ERRNO if error.

Definition at line 76 of file tensor_filter_custom_easy.c.

Here is the call graph for this function:

◆ NNS_custom_easy_unregister()

int NNS_custom_easy_unregister ( const char *  modelname)

Unregister the custom-easy tensor function.

Parameters
[in]modelnameThe registered name of custom-easy tensor function.
Returns
0 if success, non-zero if error
0 if success. -EINVAL if invalid model name.

Definition at line 144 of file tensor_filter_custom_easy.c.

Here is the call graph for this function: