Re: [FFmpeg-devel] [PATCH V2] dnn: move output name from DNNModel.set_input_output to DNNModule.execute_model

2020-08-23 Thread Guo, Yejun


> -Original Message-
> From: ffmpeg-devel  On Behalf Of Fu, Ting
> Sent: 2020年8月21日 18:01
> To: FFmpeg development discussions and patches 
> Subject: Re: [FFmpeg-devel] [PATCH V2] dnn: move output name from
> DNNModel.set_input_output to DNNModule.execute_model
> 
> 
> 
> > -Original Message-
> > From: ffmpeg-devel  On Behalf Of Guo,
> > Yejun
> > Sent: Friday, August 21, 2020 01:34 PM
> > To: ffmpeg-devel@ffmpeg.org
> > Subject: [FFmpeg-devel] [PATCH V2] dnn: move output name from
> > DNNModel.set_input_output to DNNModule.execute_model
> >
> > currently, output is set both at DNNModel.set_input_output and
> > DNNModule.execute_model, it makes sense that the output name is
> > provided at model inference time so all the output info is set at a single 
> > place.
> >
> > and so DNNModel.set_input_output is renamed to DNNModel.set_input
> >
> > Signed-off-by: Guo, Yejun 
> > ---
> > v2: rebase with master
> >
> >  libavfilter/dnn/dnn_backend_native.c   | 44 +++--
> >  libavfilter/dnn/dnn_backend_native.h   |  4 +-
> >  libavfilter/dnn/dnn_backend_openvino.c | 50 +--
> > libavfilter/dnn/dnn_backend_openvino.h |  2 +-
> >  libavfilter/dnn/dnn_backend_tf.c   | 87
> ++
> >  libavfilter/dnn/dnn_backend_tf.h   |  2 +-
> >  libavfilter/dnn_interface.h|  4 +-
> >  libavfilter/vf_derain.c|  6 +--
> >  libavfilter/vf_dnn_processing.c|  9 ++--
> >  libavfilter/vf_sr.c| 11 +++--
> >  10 files changed, 82 insertions(+), 137 deletions(-)
> >
> [...]
> > --
> > 2.7.4
> 
> LGTM, all three backends(Native/TF/OV) function well.
> 
thanks for the test, will push tomorrow if no other comments.

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH V2] dnn: move output name from DNNModel.set_input_output to DNNModule.execute_model

2020-08-21 Thread Fu, Ting


> -Original Message-
> From: ffmpeg-devel  On Behalf Of Guo,
> Yejun
> Sent: Friday, August 21, 2020 01:34 PM
> To: ffmpeg-devel@ffmpeg.org
> Subject: [FFmpeg-devel] [PATCH V2] dnn: move output name from
> DNNModel.set_input_output to DNNModule.execute_model
> 
> currently, output is set both at DNNModel.set_input_output and
> DNNModule.execute_model, it makes sense that the output name is provided at
> model inference time so all the output info is set at a single place.
> 
> and so DNNModel.set_input_output is renamed to DNNModel.set_input
> 
> Signed-off-by: Guo, Yejun 
> ---
> v2: rebase with master
> 
>  libavfilter/dnn/dnn_backend_native.c   | 44 +++--
>  libavfilter/dnn/dnn_backend_native.h   |  4 +-
>  libavfilter/dnn/dnn_backend_openvino.c | 50 +--
> libavfilter/dnn/dnn_backend_openvino.h |  2 +-
>  libavfilter/dnn/dnn_backend_tf.c   | 87 
> ++
>  libavfilter/dnn/dnn_backend_tf.h   |  2 +-
>  libavfilter/dnn_interface.h|  4 +-
>  libavfilter/vf_derain.c|  6 +--
>  libavfilter/vf_dnn_processing.c|  9 ++--
>  libavfilter/vf_sr.c| 11 +++--
>  10 files changed, 82 insertions(+), 137 deletions(-)
> 
[...]
> --
> 2.7.4

LGTM, all three backends(Native/TF/OV) function well.

> 
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 
> To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org
> with subject "unsubscribe".
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH V2] dnn: move output name from DNNModel.set_input_output to DNNModule.execute_model

2020-08-20 Thread Guo, Yejun
currently, output is set both at DNNModel.set_input_output and
DNNModule.execute_model, it makes sense that the output name is
provided at model inference time so all the output info is set
at a single place.

and so DNNModel.set_input_output is renamed to DNNModel.set_input

Signed-off-by: Guo, Yejun 
---
v2: rebase with master

 libavfilter/dnn/dnn_backend_native.c   | 44 +++--
 libavfilter/dnn/dnn_backend_native.h   |  4 +-
 libavfilter/dnn/dnn_backend_openvino.c | 50 +--
 libavfilter/dnn/dnn_backend_openvino.h |  2 +-
 libavfilter/dnn/dnn_backend_tf.c   | 87 ++
 libavfilter/dnn/dnn_backend_tf.h   |  2 +-
 libavfilter/dnn_interface.h|  4 +-
 libavfilter/vf_derain.c|  6 +--
 libavfilter/vf_dnn_processing.c|  9 ++--
 libavfilter/vf_sr.c| 11 +++--
 10 files changed, 82 insertions(+), 137 deletions(-)

diff --git a/libavfilter/dnn/dnn_backend_native.c 
b/libavfilter/dnn/dnn_backend_native.c
index 0be9c0b..65a5670 100644
--- a/libavfilter/dnn/dnn_backend_native.c
+++ b/libavfilter/dnn/dnn_backend_native.c
@@ -50,7 +50,7 @@ static DNNReturnType get_input_native(void *model, DNNData 
*input, const char *i
 return DNN_ERROR;
 }
 
-static DNNReturnType set_input_output_native(void *model, DNNData *input, 
const char *input_name, const char **output_names, uint32_t nb_output)
+static DNNReturnType set_input_native(void *model, DNNData *input, const char 
*input_name)
 {
 NativeModel *native_model = (NativeModel *)model;
 DnnOperand *oprd = NULL;
@@ -87,27 +87,6 @@ static DNNReturnType set_input_output_native(void *model, 
DNNData *input, const
 
 input->data = oprd->data;
 
-/* outputs */
-native_model->nb_output = 0;
-av_freep(&native_model->output_indexes);
-native_model->output_indexes = av_mallocz_array(nb_output, 
sizeof(*native_model->output_indexes));
-if (!native_model->output_indexes)
-return DNN_ERROR;
-
-for (uint32_t i = 0; i < nb_output; ++i) {
-const char *output_name = output_names[i];
-for (int j = 0; j < native_model->operands_num; ++j) {
-oprd = &native_model->operands[j];
-if (strcmp(oprd->name, output_name) == 0) {
-native_model->output_indexes[native_model->nb_output++] = j;
-break;
-}
-}
-}
-
-if (native_model->nb_output != nb_output)
-return DNN_ERROR;
-
 return DNN_SUCCESS;
 }
 
@@ -243,7 +222,7 @@ DNNModel *ff_dnn_load_model_native(const char 
*model_filename, const char *optio
 return NULL;
 }
 
-model->set_input_output = &set_input_output_native;
+model->set_input = &set_input_native;
 model->get_input = &get_input_native;
 model->options = options;
 
@@ -255,11 +234,10 @@ fail:
 return NULL;
 }
 
-DNNReturnType ff_dnn_execute_model_native(const DNNModel *model, DNNData 
*outputs, uint32_t nb_output)
+DNNReturnType ff_dnn_execute_model_native(const DNNModel *model, DNNData 
*outputs, const char **output_names, uint32_t nb_output)
 {
 NativeModel *native_model = (NativeModel *)model->model;
 int32_t layer;
-uint32_t nb = FFMIN(nb_output, native_model->nb_output);
 
 if (native_model->layers_num <= 0 || native_model->operands_num <= 0)
 return DNN_ERROR;
@@ -274,8 +252,19 @@ DNNReturnType ff_dnn_execute_model_native(const DNNModel 
*model, DNNData *output
 native_model->layers[layer].params);
 }
 
-for (uint32_t i = 0; i < nb; ++i) {
-DnnOperand *oprd = 
&native_model->operands[native_model->output_indexes[i]];
+for (uint32_t i = 0; i < nb_output; ++i) {
+DnnOperand *oprd = NULL;
+const char *output_name = output_names[i];
+for (int j = 0; j < native_model->operands_num; ++j) {
+if (strcmp(native_model->operands[j].name, output_name) == 0) {
+oprd = &native_model->operands[j];
+break;
+}
+}
+
+if (oprd == NULL)
+return DNN_ERROR;
+
 outputs[i].data = oprd->data;
 outputs[i].height = oprd->dims[1];
 outputs[i].width = oprd->dims[2];
@@ -335,7 +324,6 @@ void ff_dnn_free_model_native(DNNModel **model)
 av_freep(&native_model->operands);
 }
 
-av_freep(&native_model->output_indexes);
 av_freep(&native_model);
 }
 av_freep(model);
diff --git a/libavfilter/dnn/dnn_backend_native.h 
b/libavfilter/dnn/dnn_backend_native.h
index 228d5b7..554098f 100644
--- a/libavfilter/dnn/dnn_backend_native.h
+++ b/libavfilter/dnn/dnn_backend_native.h
@@ -112,13 +112,11 @@ typedef struct NativeModel{
 int32_t layers_num;
 DnnOperand *operands;
 int32_t operands_num;
-int32_t *output_indexes;
-uint32_t nb_output;
 } NativeModel;
 
 DNNModel *ff_dnn_load_model_native(const char *model_filename, const char