Browse Source

dnn_interface: add interface to support async execution

Signed-off-by: Xie, Lin <lin.xie@intel.com>
Signed-off-by: Wu Zhiwen <zhiwen.wu@intel.com>
Signed-off-by: Guo, Yejun <yejun.guo@intel.com>
tags/n4.4
Guo, Yejun 5 years ago
parent
commit
39f5cb4bd1
2 changed files with 13 additions and 1 deletions
  1. +1
    -1
      libavfilter/dnn/dnn_interface.c
  2. +12
    -0
      libavfilter/dnn_interface.h

+ 1
- 1
libavfilter/dnn/dnn_interface.c View File

@@ -33,7 +33,7 @@ DNNModule *ff_get_dnn_module(DNNBackendType backend_type)
{ {
DNNModule *dnn_module; DNNModule *dnn_module;


dnn_module = av_malloc(sizeof(DNNModule));
dnn_module = av_mallocz(sizeof(DNNModule));
if(!dnn_module){ if(!dnn_module){
return NULL; return NULL;
} }


+ 12
- 0
libavfilter/dnn_interface.h View File

@@ -35,6 +35,13 @@ typedef enum {DNN_NATIVE, DNN_TF, DNN_OV} DNNBackendType;


typedef enum {DNN_FLOAT = 1, DNN_UINT8 = 4} DNNDataType; typedef enum {DNN_FLOAT = 1, DNN_UINT8 = 4} DNNDataType;


typedef enum {
DAST_FAIL, // something wrong
DAST_EMPTY_QUEUE, // no more inference result to get
DAST_NOT_READY, // all queued inferences are not finished
DAST_SUCCESS // got a result frame successfully
} DNNAsyncStatusType;

typedef struct DNNData{ typedef struct DNNData{
void *data; void *data;
DNNDataType dt; DNNDataType dt;
@@ -69,6 +76,11 @@ typedef struct DNNModule{
// Executes model with specified input and output. Returns DNN_ERROR otherwise. // Executes model with specified input and output. Returns DNN_ERROR otherwise.
DNNReturnType (*execute_model)(const DNNModel *model, const char *input_name, AVFrame *in_frame, DNNReturnType (*execute_model)(const DNNModel *model, const char *input_name, AVFrame *in_frame,
const char **output_names, uint32_t nb_output, AVFrame *out_frame); const char **output_names, uint32_t nb_output, AVFrame *out_frame);
// Executes model with specified input and output asynchronously. Returns DNN_ERROR otherwise.
DNNReturnType (*execute_model_async)(const DNNModel *model, const char *input_name, AVFrame *in_frame,
const char **output_names, uint32_t nb_output, AVFrame *out_frame);
// Retrieve inference result.
DNNAsyncStatusType (*get_async_result)(const DNNModel *model, AVFrame **out);
// Frees memory allocated for model. // Frees memory allocated for model.
void (*free_model)(DNNModel **model); void (*free_model)(DNNModel **model);
} DNNModule; } DNNModule;


Loading…
Cancel
Save