FFmpeg
Data Structures | Macros | Functions
dnn_backend_tf.c File Reference
#include "dnn_backend_tf.h"
#include "dnn_backend_native.h"
#include "dnn_backend_native_layer_conv2d.h"
#include "dnn_backend_native_layer_depth2space.h"
#include "libavformat/avio.h"
#include "libavutil/avassert.h"
#include "dnn_backend_native_layer_pad.h"
#include "dnn_backend_native_layer_maximum.h"
#include <tensorflow/c/c_api.h>

Go to the source code of this file.

Data Structures

struct  TFModel
 

Macros

#define NAME_BUFFER_SIZE   256
 
#define CLEANUP_ON_ERROR(tf_model)
 

Functions

static void free_buffer (void *data, size_t length)
 
static TF_Buffer * read_graph (const char *model_filename)
 
static TF_Tensor * allocate_input_tensor (const DNNData *input)
 
static DNNReturnType get_input_tf (void *model, DNNData *input, const char *input_name)
 
static DNNReturnType set_input_output_tf (void *model, DNNData *input, const char *input_name, const char **output_names, uint32_t nb_output)
 
static DNNReturnType load_tf_model (TFModel *tf_model, const char *model_filename)
 
static DNNReturnType add_conv_layer (TFModel *tf_model, TF_Operation *transpose_op, TF_Operation **cur_op, ConvolutionalParams *params, const int layer)
 
static DNNReturnType add_depth_to_space_layer (TFModel *tf_model, TF_Operation **cur_op, DepthToSpaceParams *params, const int layer)
 
static DNNReturnType add_pad_layer (TFModel *tf_model, TF_Operation **cur_op, LayerPadParams *params, const int layer)
 
static DNNReturnType add_maximum_layer (TFModel *tf_model, TF_Operation **cur_op, DnnLayerMaximumParams *params, const int layer)
 
static DNNReturnType load_native_model (TFModel *tf_model, const char *model_filename)
 
DNNModelff_dnn_load_model_tf (const char *model_filename)
 
DNNReturnType ff_dnn_execute_model_tf (const DNNModel *model, DNNData *outputs, uint32_t nb_output)
 
void ff_dnn_free_model_tf (DNNModel **model)
 

Detailed Description

DNN tensorflow backend implementation.

Definition in file dnn_backend_tf.c.

Macro Definition Documentation

◆ NAME_BUFFER_SIZE

#define NAME_BUFFER_SIZE   256

Definition at line 246 of file dnn_backend_tf.c.

◆ CLEANUP_ON_ERROR

#define CLEANUP_ON_ERROR (   tf_model)
Value:
{ \
TF_DeleteGraph(tf_model->graph); \
TF_DeleteStatus(tf_model->status); \
return DNN_ERROR; \
}

Function Documentation

◆ free_buffer()

static void free_buffer ( void *  data,
size_t  length 
)
static

Definition at line 48 of file dnn_backend_tf.c.

Referenced by read_graph().

◆ read_graph()

static TF_Buffer* read_graph ( const char *  model_filename)
static

Definition at line 53 of file dnn_backend_tf.c.

Referenced by load_tf_model().

◆ allocate_input_tensor()

static TF_Tensor* allocate_input_tensor ( const DNNData input)
static

Definition at line 86 of file dnn_backend_tf.c.

Referenced by set_input_output_tf().

◆ get_input_tf()

static DNNReturnType get_input_tf ( void *  model,
DNNData input,
const char *  input_name 
)
static

Definition at line 108 of file dnn_backend_tf.c.

Referenced by ff_dnn_load_model_tf().

◆ set_input_output_tf()

static DNNReturnType set_input_output_tf ( void *  model,
DNNData input,
const char *  input_name,
const char **  output_names,
uint32_t  nb_output 
)
static

Definition at line 139 of file dnn_backend_tf.c.

Referenced by ff_dnn_load_model_tf().

◆ load_tf_model()

static DNNReturnType load_tf_model ( TFModel tf_model,
const char *  model_filename 
)
static

Definition at line 222 of file dnn_backend_tf.c.

Referenced by ff_dnn_load_model_tf().

◆ add_conv_layer()

static DNNReturnType add_conv_layer ( TFModel tf_model,
TF_Operation *  transpose_op,
TF_Operation **  cur_op,
ConvolutionalParams params,
const int  layer 
)
static

Definition at line 248 of file dnn_backend_tf.c.

Referenced by load_native_model().

◆ add_depth_to_space_layer()

static DNNReturnType add_depth_to_space_layer ( TFModel tf_model,
TF_Operation **  cur_op,
DepthToSpaceParams params,
const int  layer 
)
static

Definition at line 363 of file dnn_backend_tf.c.

Referenced by load_native_model().

◆ add_pad_layer()

static DNNReturnType add_pad_layer ( TFModel tf_model,
TF_Operation **  cur_op,
LayerPadParams params,
const int  layer 
)
static

Definition at line 385 of file dnn_backend_tf.c.

Referenced by load_native_model().

◆ add_maximum_layer()

static DNNReturnType add_maximum_layer ( TFModel tf_model,
TF_Operation **  cur_op,
DnnLayerMaximumParams params,
const int  layer 
)
static

Definition at line 436 of file dnn_backend_tf.c.

Referenced by load_native_model().

◆ load_native_model()

static DNNReturnType load_native_model ( TFModel tf_model,
const char *  model_filename 
)
static

Definition at line 478 of file dnn_backend_tf.c.

Referenced by ff_dnn_load_model_tf().

◆ ff_dnn_load_model_tf()

DNNModel* ff_dnn_load_model_tf ( const char *  model_filename)

Definition at line 575 of file dnn_backend_tf.c.

Referenced by ff_get_dnn_module().

◆ ff_dnn_execute_model_tf()

DNNReturnType ff_dnn_execute_model_tf ( const DNNModel model,
DNNData outputs,
uint32_t  nb_output 
)

Definition at line 609 of file dnn_backend_tf.c.

Referenced by ff_get_dnn_module().

◆ ff_dnn_free_model_tf()

void ff_dnn_free_model_tf ( DNNModel **  model)

Definition at line 644 of file dnn_backend_tf.c.

Referenced by ff_get_dnn_module().

DNN_ERROR
@ DNN_ERROR
Definition: dnn_interface.h:31