[FFmpeg-devel] [PATCH v2] libavfi/dnn: add LibTorch as one of DNN backend

Chen, Wenbin wenbin.chen at intel.com
Tue Feb 20 06:16:36 EET 2024


> Hello,
> 
> On Fri, 2 Feb 2024, at 08:26, wenbin.chen-at-intel.com at ffmpeg.org wrote:
> > +static void infer_completion_callback(void *args) {
> > +    THRequestItem *request = (THRequestItem*)args;
> > +    LastLevelTaskItem *lltask = request->lltask;
> > +    TaskItem *task = lltask->task;
> > +    DNNData outputs = { 0 };
> > +    THInferRequest *infer_request = request->infer_request;
> > +    THModel *th_model = (THModel *)task->model;
> > +    torch::Tensor *output = infer_request->output;
> > +
> > +    c10::IntArrayRef sizes = output->sizes();
> > +    assert(sizes.size == 5);
> 
> Why 5?

5 means 5 channels: [batch_size, frame_number, channel, height, width]
I only add video SR support, so it only support this type of data for now.
I will change the code to be more easy to read.

> 
> > +    outputs.order = DCO_RGB;
> > +    outputs.layout = DL_NCHW;
> > +    outputs.dims[2] = sizes.at(3);
> > +    outputs.dims[3] = sizes.at(4);
> > +    outputs.dt = DNN_FLOAT;
> > +    outputs.dims[1] = 3;
> 
> Why 3?

It is RGB so the channel is 3, but I should use sizes.at(2) instead of a magic number.
Thanks for pointing it out. I will update it in patch v3.

> 
> 
> --
> Jean-Baptiste Kempf -  President
> +33 672 704 734
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel at ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request at ffmpeg.org with subject "unsubscribe".


More information about the ffmpeg-devel mailing list