Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
* [FFmpeg-devel] [PATCH V2 1/3] lavfi/dnn: fix corruption when TF backend infer failed
@ 2023-03-24  7:30 Ting Fu
  2023-03-24  7:30 ` [FFmpeg-devel] [PATCH V2 2/3] lavfi/dnn: fix mem leak in TF backend error handle Ting Fu
  2023-03-24  7:30 ` [FFmpeg-devel] [PATCH V2 3/3] lavfi/dnn: add error info for TF backend filling task failure Ting Fu
  0 siblings, 2 replies; 4+ messages in thread
From: Ting Fu @ 2023-03-24  7:30 UTC (permalink / raw)
  To: ffmpeg-devel

Signed-off-by: Ting Fu <ting.fu@intel.com>
---
 libavfilter/dnn/dnn_backend_tf.c | 15 +--------------
 1 file changed, 1 insertion(+), 14 deletions(-)

diff --git a/libavfilter/dnn/dnn_backend_tf.c b/libavfilter/dnn/dnn_backend_tf.c
index 3b5084b67b..9570f188d2 100644
--- a/libavfilter/dnn/dnn_backend_tf.c
+++ b/libavfilter/dnn/dnn_backend_tf.c
@@ -175,10 +175,6 @@ static int tf_start_inference(void *args)
                   request->status);
     if (TF_GetCode(request->status) != TF_OK) {
         av_log(&tf_model->ctx, AV_LOG_ERROR, "%s", TF_Message(request->status));
-        tf_free_request(infer_request);
-        if (ff_safe_queue_push_back(tf_model->request_queue, request) < 0) {
-            destroy_request_item(&request);
-        }
         return DNN_GENERIC_ERROR;
     }
     return 0;
@@ -438,8 +434,6 @@ static int load_tf_model(TFModel *tf_model, const char *model_filename)
     TF_DeleteImportGraphDefOptions(graph_opts);
     TF_DeleteBuffer(graph_def);
     if (TF_GetCode(tf_model->status) != TF_OK){
-        TF_DeleteGraph(tf_model->graph);
-        TF_DeleteStatus(tf_model->status);
         av_log(ctx, AV_LOG_ERROR, "Failed to import serialized graph to model graph\n");
         av_freep(&sess_config);
         return DNN_GENERIC_ERROR;
@@ -452,8 +446,6 @@ static int load_tf_model(TFModel *tf_model, const char *model_filename)
         TF_SetConfig(sess_opts, sess_config, sess_config_length,tf_model->status);
         av_freep(&sess_config);
         if (TF_GetCode(tf_model->status) != TF_OK) {
-            TF_DeleteGraph(tf_model->graph);
-            TF_DeleteStatus(tf_model->status);
             TF_DeleteSessionOptions(sess_opts);
             av_log(ctx, AV_LOG_ERROR, "Failed to set config for sess options with %s\n",
                                       tf_model->ctx.options.sess_config);
@@ -465,8 +457,6 @@ static int load_tf_model(TFModel *tf_model, const char *model_filename)
     TF_DeleteSessionOptions(sess_opts);
     if (TF_GetCode(tf_model->status) != TF_OK)
     {
-        TF_DeleteGraph(tf_model->graph);
-        TF_DeleteStatus(tf_model->status);
         av_log(ctx, AV_LOG_ERROR, "Failed to create new session with model graph\n");
         return DNN_GENERIC_ERROR;
     }
@@ -479,9 +469,6 @@ static int load_tf_model(TFModel *tf_model, const char *model_filename)
                       &init_op, 1, NULL, tf_model->status);
         if (TF_GetCode(tf_model->status) != TF_OK)
         {
-            TF_DeleteSession(tf_model->session, tf_model->status);
-            TF_DeleteGraph(tf_model->graph);
-            TF_DeleteStatus(tf_model->status);
             av_log(ctx, AV_LOG_ERROR, "Failed to run session when initializing\n");
             return DNN_GENERIC_ERROR;
         }
@@ -865,6 +852,7 @@ DNNModel *ff_dnn_load_model_tf(const char *model_filename, DNNFunctionType func_
         av_freep(&model);
         return NULL;
     }
+    model->model = tf_model;
     tf_model->model = model;
     ctx = &tf_model->ctx;
     ctx->class = &dnn_tensorflow_class;
@@ -931,7 +919,6 @@ DNNModel *ff_dnn_load_model_tf(const char *model_filename, DNNFunctionType func_
         goto err;
     }
 
-    model->model = tf_model;
     model->get_input = &get_input_tf;
     model->get_output = &get_output_tf;
     model->options = options;
-- 
2.17.1

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

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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [FFmpeg-devel] [PATCH V2 2/3] lavfi/dnn: fix mem leak in TF backend error handle
  2023-03-24  7:30 [FFmpeg-devel] [PATCH V2 1/3] lavfi/dnn: fix corruption when TF backend infer failed Ting Fu
@ 2023-03-24  7:30 ` Ting Fu
  2023-03-24  7:30 ` [FFmpeg-devel] [PATCH V2 3/3] lavfi/dnn: add error info for TF backend filling task failure Ting Fu
  1 sibling, 0 replies; 4+ messages in thread
From: Ting Fu @ 2023-03-24  7:30 UTC (permalink / raw)
  To: ffmpeg-devel

Signed-off-by: Ting Fu <ting.fu@intel.com>
---
 libavfilter/dnn/dnn_backend_tf.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/libavfilter/dnn/dnn_backend_tf.c b/libavfilter/dnn/dnn_backend_tf.c
index 9570f188d2..fe1baa2e5e 100644
--- a/libavfilter/dnn/dnn_backend_tf.c
+++ b/libavfilter/dnn/dnn_backend_tf.c
@@ -457,6 +457,7 @@ static int load_tf_model(TFModel *tf_model, const char *model_filename)
     TF_DeleteSessionOptions(sess_opts);
     if (TF_GetCode(tf_model->status) != TF_OK)
     {
+        av_freep(&sess_config);
         av_log(ctx, AV_LOG_ERROR, "Failed to create new session with model graph\n");
         return DNN_GENERIC_ERROR;
     }
@@ -469,6 +470,7 @@ static int load_tf_model(TFModel *tf_model, const char *model_filename)
                       &init_op, 1, NULL, tf_model->status);
         if (TF_GetCode(tf_model->status) != TF_OK)
         {
+            av_freep(&sess_config);
             av_log(ctx, AV_LOG_ERROR, "Failed to run session when initializing\n");
             return DNN_GENERIC_ERROR;
         }
@@ -1125,6 +1127,7 @@ err:
     if (ff_safe_queue_push_back(tf_model->request_queue, request) < 0) {
         destroy_request_item(&request);
     }
+    ff_dnn_free_model_tf(&tf_model->model);
     return ret;
 }
 
@@ -1161,12 +1164,14 @@ int ff_dnn_execute_model_tf(const DNNModel *model, DNNExecBaseParams *exec_param
 
     ret = extract_lltask_from_task(task, tf_model->lltask_queue);
     if (ret != 0) {
+        av_freep(&task);
         av_log(ctx, AV_LOG_ERROR, "unable to extract last level task from task.\n");
         return ret;
     }
 
     request = ff_safe_queue_pop_front(tf_model->request_queue);
     if (!request) {
+        av_freep(&task);
         av_log(ctx, AV_LOG_ERROR, "unable to get infer request.\n");
         return AVERROR(EINVAL);
     }
-- 
2.17.1

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

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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [FFmpeg-devel] [PATCH V2 3/3] lavfi/dnn: add error info for TF backend filling task failure
  2023-03-24  7:30 [FFmpeg-devel] [PATCH V2 1/3] lavfi/dnn: fix corruption when TF backend infer failed Ting Fu
  2023-03-24  7:30 ` [FFmpeg-devel] [PATCH V2 2/3] lavfi/dnn: fix mem leak in TF backend error handle Ting Fu
@ 2023-03-24  7:30 ` Ting Fu
  2023-03-25 10:54   ` Guo, Yejun
  1 sibling, 1 reply; 4+ messages in thread
From: Ting Fu @ 2023-03-24  7:30 UTC (permalink / raw)
  To: ffmpeg-devel

Signed-off-by: Ting Fu <ting.fu@intel.com>
---
 libavfilter/dnn/dnn_backend_tf.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/libavfilter/dnn/dnn_backend_tf.c b/libavfilter/dnn/dnn_backend_tf.c
index fe1baa2e5e..3d372a5628 100644
--- a/libavfilter/dnn/dnn_backend_tf.c
+++ b/libavfilter/dnn/dnn_backend_tf.c
@@ -1152,6 +1152,7 @@ int ff_dnn_execute_model_tf(const DNNModel *model, DNNExecBaseParams *exec_param
 
     ret = ff_dnn_fill_task(task, exec_params, tf_model, ctx->options.async, 1);
     if (ret != 0) {
+        av_log(ctx, AV_LOG_ERROR, "Fill task with invalid parameter(s).\n");
         av_freep(&task);
         return ret;
     }
-- 
2.17.1

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

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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [FFmpeg-devel] [PATCH V2 3/3] lavfi/dnn: add error info for TF backend filling task failure
  2023-03-24  7:30 ` [FFmpeg-devel] [PATCH V2 3/3] lavfi/dnn: add error info for TF backend filling task failure Ting Fu
@ 2023-03-25 10:54   ` Guo, Yejun
  0 siblings, 0 replies; 4+ messages in thread
From: Guo, Yejun @ 2023-03-25 10:54 UTC (permalink / raw)
  To: FFmpeg development discussions and patches



> -----Original Message-----
> From: ffmpeg-devel <ffmpeg-devel-bounces@ffmpeg.org> On Behalf Of
> Ting Fu
> Sent: Friday, March 24, 2023 3:31 PM
> To: ffmpeg-devel@ffmpeg.org
> Subject: [FFmpeg-devel] [PATCH V2 3/3] lavfi/dnn: add error info for TF
> backend filling task failure
> 
> Signed-off-by: Ting Fu <ting.fu@intel.com>
> ---
>  libavfilter/dnn/dnn_backend_tf.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/libavfilter/dnn/dnn_backend_tf.c
> b/libavfilter/dnn/dnn_backend_tf.c
> index fe1baa2e5e..3d372a5628 100644
> --- a/libavfilter/dnn/dnn_backend_tf.c
> +++ b/libavfilter/dnn/dnn_backend_tf.c
> @@ -1152,6 +1152,7 @@ int ff_dnn_execute_model_tf(const DNNModel
> *model, DNNExecBaseParams *exec_param
> 
>      ret = ff_dnn_fill_task(task, exec_params, tf_model, ctx->options.async, 1);
>      if (ret != 0) {
> +        av_log(ctx, AV_LOG_ERROR, "Fill task with invalid
> + parameter(s).\n");
>          av_freep(&task);
>          return ret;
>      }
> --
This patch set LGTM, will push, thanks.
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-03-25 10:55 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-24  7:30 [FFmpeg-devel] [PATCH V2 1/3] lavfi/dnn: fix corruption when TF backend infer failed Ting Fu
2023-03-24  7:30 ` [FFmpeg-devel] [PATCH V2 2/3] lavfi/dnn: fix mem leak in TF backend error handle Ting Fu
2023-03-24  7:30 ` [FFmpeg-devel] [PATCH V2 3/3] lavfi/dnn: add error info for TF backend filling task failure Ting Fu
2023-03-25 10:54   ` Guo, Yejun

Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
		ffmpegdev@gitmailbox.com
	public-inbox-index ffmpegdev

Example config snippet for mirrors.


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git