[FFmpeg-devel] [PATCH V2] libavfilter/dnn: add batch mode for async execution

Guo, Yejun yejun.guo at intel.com
Fri Jan 15 13:16:13 EET 2021



> -----Original Message-----
> From: Steven Liu <lq at chinaffmpeg.org>
> Sent: 2021年1月15日 11:34
> To: FFmpeg development discussions and patches <ffmpeg-devel at ffmpeg.org>
> Cc: Steven Liu <lq at chinaffmpeg.org>; Guo, Yejun <yejun.guo at intel.com>
> Subject: Re: [FFmpeg-devel] [PATCH V2] libavfilter/dnn: add batch mode for
> async execution
> 
> 
> 
> > 2021年1月10日 下午9:16,Guo, Yejun <yejun.guo at intel.com> 写道:
> >
> > the default number of batch_size is 1
> >
> > Signed-off-by: Xie, Lin <lin.xie at intel.com>
> > Signed-off-by: Wu Zhiwen <zhiwen.wu at intel.com>
> > Signed-off-by: Guo, Yejun <yejun.guo at intel.com>
> > ---
> > libavfilter/dnn/dnn_backend_openvino.c | 187 ++++++++++++++++++++-----
> > libavfilter/dnn/dnn_backend_openvino.h |   1 +
> > libavfilter/dnn/dnn_interface.c        |   1 +
> > libavfilter/dnn_interface.h            |   2 +
> > libavfilter/vf_dnn_processing.c        |  36 ++++-
> > 5 files changed, 194 insertions(+), 33 deletions(-)
> >
> > diff --git a/libavfilter/dnn/dnn_backend_openvino.c
> > b/libavfilter/dnn/dnn_backend_openvino.c
> > index d27e451eea..5271d1caa5 100644
> > --- a/libavfilter/dnn/dnn_backend_openvino.c
> > +++ b/libavfilter/dnn/dnn_backend_openvino.c
> > @@ -37,6 +37,7 @@
> > typedef struct OVOptions{
> >     char *device_type;
> >     int nireq;
> > +    int batch_size;
> > } OVOptions;
> >
> > typedef struct OVContext {
> > @@ -70,7 +71,8 @@ typedef struct TaskItem {
> >
> > typedef struct RequestItem {
> >     ie_infer_request_t *infer_request;
> > -    TaskItem *task;
> > +    TaskItem **tasks;
> > +    int task_count;
> >     ie_complete_call_back_t callback;
> > } RequestItem;
> >
> > @@ -83,6 +85,7 @@ typedef struct RequestItem { static const AVOption
> > dnn_openvino_options[] = {
> >     { "device", "device to run model", OFFSET(options.device_type),
> AV_OPT_TYPE_STRING, { .str = "CPU" }, 0, 0, FLAGS },
> >     { "nireq",  "number of request",   OFFSET(options.nireq),
> AV_OPT_TYPE_INT,    { .i64 = 0 },     0, INT_MAX, FLAGS },
> > +    { "batch_size",  "batch size per request", OFFSET(options.batch_size),
> AV_OPT_TYPE_INT,    { .i64 = 1 },     1, 1000, FLAGS},
> >     { NULL }
> > };
> >
> > @@ -100,7 +103,19 @@ static DNNDataType
> precision_to_datatype(precision_e precision)
> >     }
> > }
> >
> > -static DNNReturnType fill_model_input_ov(OVModel *ov_model, TaskItem
> > *task, RequestItem *request)
> > +static int get_datatype_size(DNNDataType dt) {
> > +    switch (dt)
> > +    {
> > +    case DNN_FLOAT:
> > +        return sizeof(float);
> > +    default:
> > +        av_assert0(!"not supported yet.");
> > +        return 1;
> Why don’t try about this way ? :D
> avpriv_request_sample()
> AVERROR_PATCHWELCOME;
thanks, good point, will do it this way.



More information about the ffmpeg-devel mailing list