From patchwork Sun Aug 8 10:55:36 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shubhanshu Saxena X-Patchwork-Id: 29350 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:6c0f:0:0:0:0:0 with SMTP id a15csp1981183ioh; Sun, 8 Aug 2021 03:57:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzvWnfBxAg1zgw46E6zGNiOzZmxo+0BnbLVqUKcRszp9C6qewT9mLGmEKLfmIxHmGSCJi2X X-Received: by 2002:a05:6402:30bb:: with SMTP id df27mr23870650edb.186.1628420227506; Sun, 08 Aug 2021 03:57:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628420227; cv=none; d=google.com; s=arc-20160816; b=YKT9FZjCr4NlQ50XEfz97hZcdwUjxMiu9VMKyfCQ0B8vyI7E1XeMyRCCRcTOHcFmvP DLTWGakn163LTG0u+5LwoSypjucPaIur8bxE7hbNZxDZEjmicn2/kIbtuS82m++Z5q4G CEknZDMWd8xaQ7BWYgnt75CmU/b2gKZgRFOrUQLcstFvnK6r0KtlUVIhiTB7po7f6GQJ ZtjlcpeRT/7oN/ixnwMgQcaHe62ciqV+aT90esfkmzfJ2Aml5cwbRmyMLG/vPvEpQCUQ GxL2GqZREjXDwQ/ut8gO9sVXOtbnqt8zEOgfiUrtQW2zuXqRWwb9GxoiGOyeVfLzJq0j 8z3w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature:delivered-to; bh=f+WSFKBA9FzXE+IUBoApd7lWgIwP06DRkt0a8gZ2ZCw=; b=RLyDwdaShPE3TopLneTUg4QKSh7qB8fda75uK1wWFQwV89g/uR0cDxkaoP2+FltBf8 OKAJ/XAF8Qnotb17AkiRuSo3EpQiXlb6JeYugrzUlelzbck4vP+4mPT3ACW1YnSV45IJ dPcI+7i9Ho/llBwivEKzlnpXzSxWp/Y+CBYZ+bQWzK0YNubzvnbGAtdblDqpjPqjWCaa AJDd4Qn2dgu/eEPpA0FwlfkSzq3xFtn533Tv5dzugS8Bx6m9W5sik3Xj9F91xjMYxNca XwIZwhT/HDPeXS/U3qGkoCako/3T7EJLqd9+rpMLMVdPRKIqt2/h8hYxOJV4jy4gWDIZ YAMg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20161025 header.b=Tf82Jgj4; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id 18si14996525ejj.476.2021.08.08.03.57.07; Sun, 08 Aug 2021 03:57:07 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20161025 header.b=Tf82Jgj4; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 1037B68A4D1; Sun, 8 Aug 2021 13:56:24 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-pl1-f176.google.com (mail-pl1-f176.google.com [209.85.214.176]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 109EE68A4C2 for ; Sun, 8 Aug 2021 13:56:18 +0300 (EEST) Received: by mail-pl1-f176.google.com with SMTP id u2so13315840plg.10 for ; Sun, 08 Aug 2021 03:56:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=aIC+ys4Ka+f4jwa/BCqleqVXbU7cT/w7k8QSQ04uLvA=; b=Tf82Jgj4MKFqJkRb75BBUaqgwXAiG07kcEdsTZPMLVzDIXE6SC8A2B026t1j3IeiMh yJJS+GlTI2PvVtSzB6bpIyik8GQBOewEujq4ucJXmobAV2Nd1fZHzYa5e87tsfdmCBJd CjjlthYetLD6LZYPMV7nGohq5Kv85prrmip1rWBBBvS7+xq3hnrS1Esaj8fliwZafJH5 nR32Yr0KuQ8bRDFjkmkHGaNhp9laLHWZVWh4nMpI1hXnkZjsfg2yaM179KR3YW8zYbtk ytSDVF2UrLw/YNuCT4PLC5SJbd2dVi/7J+3lJGb7iBMEnqT1JE0oyds8OBbl2xidnvY4 BuWA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=aIC+ys4Ka+f4jwa/BCqleqVXbU7cT/w7k8QSQ04uLvA=; b=M51V1MOlCgXZ0JbDMdvywLn+6GNuCewhq5rfPtv/pAVCv7/sUSlDwPt7dJZtFqTs30 PnL2s4Az/BfWN2SUzrwSldeozWCIavLkvh/dwiZ4uBfssJGuHTaG6iNtk3VW3HntBNIN Ddo30VaM9rMF/9FSkIOpWXeBZafBOEJ39ghu6S3vZONvw7DIZe1JI6ZYC5mvMSlUAHFT jZx6I8UUc0iJJY1n6g+B0udHsKbqpmFX7ZXuxTVgIlnJaYcskcLsaqJyykaXbTj4xUkY 885YVebKDllv0PzSwQfik4wFPerp2Tf21vAa4aocjCqJHn+f/CkNw2KFgOdv1W/ljxkS m2mg== X-Gm-Message-State: AOAM532r5lmdR8Ar+hM88SBtYCV2iBc9I2Zu+pUtmyeF1qgp4s9TSAo9 gq2cHUaRt+j1rTbUwxWP7o59bgbmoPsq/w== X-Received: by 2002:a63:b950:: with SMTP id v16mr444343pgo.328.1628420176309; Sun, 08 Aug 2021 03:56:16 -0700 (PDT) Received: from localhost.localdomain ([103.133.123.69]) by smtp.googlemail.com with ESMTPSA id r18sm20917405pgk.54.2021.08.08.03.56.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 08 Aug 2021 03:56:16 -0700 (PDT) From: Shubhanshu Saxena To: ffmpeg-devel@ffmpeg.org Date: Sun, 8 Aug 2021 16:25:36 +0530 Message-Id: <20210808105539.18822-6-shubhanshu.e01@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210808105539.18822-1-shubhanshu.e01@gmail.com> References: <20210808105539.18822-1-shubhanshu.e01@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v3 6/9] [GSoC] lavfi/dnn_backend_tf: Add TF_Status to TFRequestItem X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: Shubhanshu Saxena Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: bQm0fpnGdBAa Since requests are running in parallel, there is inconsistency in the status of the execution. To resolve it, we avoid using mutex as it would result in single TF_Session running at a time. So add TF_Status to the TFRequestItem Signed-off-by: Shubhanshu Saxena --- libavfilter/dnn/dnn_backend_tf.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/libavfilter/dnn/dnn_backend_tf.c b/libavfilter/dnn/dnn_backend_tf.c index ad5f1e633e..935a2618a1 100644 --- a/libavfilter/dnn/dnn_backend_tf.c +++ b/libavfilter/dnn/dnn_backend_tf.c @@ -75,6 +75,7 @@ typedef struct TFInferRequest { typedef struct TFRequestItem { TFInferRequest *infer_request; InferenceItem *inference; + TF_Status *status; DNNAsyncExecModule exec_module; } TFRequestItem; @@ -165,9 +166,9 @@ static DNNReturnType tf_start_inference(void *args) infer_request->tf_input, &infer_request->input_tensor, 1, infer_request->tf_outputs, infer_request->output_tensors, task->nb_output, NULL, 0, NULL, - tf_model->status); - if (TF_GetCode(tf_model->status) != TF_OK) { - av_log(&tf_model->ctx, AV_LOG_ERROR, "%s", TF_Message(tf_model->status)); + request->status); + if (TF_GetCode(request->status) != TF_OK) { + av_log(&tf_model->ctx, AV_LOG_ERROR, "%s", TF_Message(request->status)); return DNN_ERROR; } return DNN_SUCCESS; @@ -187,6 +188,7 @@ static inline void destroy_request_item(TFRequestItem **arg) { tf_free_request(request->infer_request); av_freep(&request->infer_request); av_freep(&request->inference); + TF_DeleteStatus(request->status); ff_dnn_async_module_cleanup(&request->exec_module); av_freep(arg); } @@ -906,6 +908,7 @@ DNNModel *ff_dnn_load_model_tf(const char *model_filename, DNNFunctionType func_ av_freep(&item); goto err; } + item->status = TF_NewStatus(); item->exec_module.start_inference = &tf_start_inference; item->exec_module.callback = &infer_completion_callback; item->exec_module.args = item;