summaryrefslogtreecommitdiff
path: root/libavfilter/dnn
diff options
context:
space:
mode:
authorTing Fu <ting.fu-at-intel.com@ffmpeg.org>2023-03-24 15:30:38 +0800
committerGuo Yejun <yejun.guo@intel.com>2023-03-26 09:19:42 +0800
commit5c216d081d24fddbcc64dc876a0cb31523c618c6 (patch)
treeb22882e14e0a1579a297ff5f27520b299217f1e4 /libavfilter/dnn
parent06b451d276e80e659bf12165aa8ef4cf9a48cc38 (diff)
downloadffmpeg-5c216d081d24fddbcc64dc876a0cb31523c618c6.tar.gz
lavfi/dnn: fix corruption when TF backend infer failed
Signed-off-by: Ting Fu <ting.fu@intel.com>
Diffstat (limited to 'libavfilter/dnn')
-rw-r--r--libavfilter/dnn/dnn_backend_tf.c15
1 files changed, 1 insertions, 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;