From patchwork Sat Jul 31 05:35:14 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shubhanshu Saxena X-Patchwork-Id: 29148 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a5d:965a:0:0:0:0:0 with SMTP id d26csp136071ios; Fri, 30 Jul 2021 22:43:53 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzeICoX7v3VP6M6cygvl+o760vuET11QUTVgtfeMBV10yAEDO9go1N6B/vxtpDz+r4RbnHS X-Received: by 2002:a17:906:8a66:: with SMTP id hy6mr5988420ejc.309.1627710233728; Fri, 30 Jul 2021 22:43:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627710233; cv=none; d=google.com; s=arc-20160816; b=hGdUEdPdhCOlk10kOpt+Dg0YCDxlf8uzv3ZfsmFnVQZUylLvOgHn6a3JjqBWqqdvkU 8Ecdv3kAU0xZ2wbZW/DB9EQjhLsKIcNaZfTiaL6kT55sgu9fxbv8YbS3Cp6Ii9xg1q5j yywTSpuoDiWpaXBYiEv39UuAplJEtrtm1HNBcW9cYnxBa2ZrzblBmhqe0VRGuzQwYIa7 ifpISTL+q43KCACNiApPXwDTogGNaeJHVQF3iYSZ4xAOES8h67QyGysF44uPjfdjvzYa TxzhAMy3P1jAH0zWQrPwjsM91WZAyyowDMW+/4uUSa6Gqaa78wlqbi9+kMMAq5uA726S oTxQ== 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=KfHwMy0bD6ebqItukOzpbVUkbLZJOnQ72zlViXBuH0g=; b=gtLkyrvsKpdrJeEBMeqSzFieBYLOtC9FyC4BABApSB5gIcdnLkOka4gFLLsQLwuCby rDWe7eieHj+1/NOlhhri9+J0jj3h8EJ14f5R4X0lkL3N6lFoyckWnrlHCOURYtN7I4Cn gRDJD5zhkCRjnu5UP1LzMzsyQsCRl2w00Aoyphk5YE2px88kIgidMM6n0jDb0ALFEOyq HAeM5U1N12Ai6r1qLFmyyFc24xjIKwu/s2X4GCTJxSHJpimOl4Xlnt4WMGFbf3Yf3GMc RIArmmM7p+kJIS3ZGwzzVuIOBc8yT6SpaUGbUApmZYu6Wx87KWXAE9QPsMJFrm3UJnAe Fg0w== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20161025 header.b=adMV16tt; 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 bq16si3760573edb.303.2021.07.30.22.43.53; Fri, 30 Jul 2021 22:43:53 -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=adMV16tt; 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 CC4B968A3AD; Sat, 31 Jul 2021 08:43:50 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-pl1-f180.google.com (mail-pl1-f180.google.com [209.85.214.180]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id ADD7E68A305 for ; Sat, 31 Jul 2021 08:43:44 +0300 (EEST) Received: by mail-pl1-f180.google.com with SMTP id i10so13579286pla.3 for ; Fri, 30 Jul 2021 22:43:44 -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=x6U0tprtfKfu21C6PdlWYMVrnFE50Ul36ctx/RJmXEE=; b=adMV16tt5ubk0CW//G8DwCx/CD/fsg3sCG9zLIsB15A/cDkBr1aVlOpShZi+MXklAa GbPD5HBDfE/4Lknz6fOnhJnikEMIBF7H0Wb0zVa0S+2TztP6+jtPJ9RxzSo4XbgK+Gdg /70zhfw2vXGk/g4gUm2ZDNbyIQDuhMcNi5t8xegCkRLV/rfhiNKXpB6gegY1xPxwx+R1 Nki8a023mDBzJJ1Sn47U07Idp3fXq7tHZDDMBzg5n9acCgC5vdlCjibfSLX2TI+5rT/y 5B1Bx3YI1TwVFiST49WS6HO5/+gGfpe8aKsQh9mjAP71DJEirQJPLsXZXSp3nREQVw5R eAeg== 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=x6U0tprtfKfu21C6PdlWYMVrnFE50Ul36ctx/RJmXEE=; b=AcMjYX5IuDr8gxjmoqZxi9mfbLQI/B78x2JSbyxNN0lPRmZhtq3lSTrnNoCjPvWX25 UoKM0e4XDSJ/FI02yzoGMhZzPdZ6Z15uWr1ozwjg8vCfZjNLhScpBKdn0xPvvSo2Qjai vxJUT1fEjMdiyS0YZbgvVWEMIJcE+4Noi74Zqq+o9oAlkTa6gYJAOu7oPNmrrcdkZgg8 R65LXYuIfPCNp5ENaT76fGfA8PAMBHqGHRoRnqKW4fYhH1+DzePnnVohWwdXtGNM6tvu TB8Z4c7IJNV1Z6OzTQuRXyRMdE1COUgyKTbje8yHqr4VnWvktHgw9gsPsL0fTAArLsP1 953Q== X-Gm-Message-State: AOAM531uTtoO/7Nootl3RT0De1ZhCbRgymehs+2DfXlVbpXHR2iujXT5 h4sjR4MC45qWpfMdozk53L7HhjtARFRSqw== X-Received: by 2002:a17:902:b084:b029:12b:6caa:7d9e with SMTP id p4-20020a170902b084b029012b6caa7d9emr5495967plr.57.1627709765235; Fri, 30 Jul 2021 22:36:05 -0700 (PDT) Received: from localhost.localdomain ([103.157.220.250]) by smtp.googlemail.com with ESMTPSA id p34sm4312266pfh.172.2021.07.30.22.36.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 30 Jul 2021 22:36:04 -0700 (PDT) From: Shubhanshu Saxena To: ffmpeg-devel@ffmpeg.org Date: Sat, 31 Jul 2021 11:05:14 +0530 Message-Id: <20210731053516.7700-6-shubhanshu.e01@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210731053516.7700-1-shubhanshu.e01@gmail.com> References: <20210731053516.7700-1-shubhanshu.e01@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 6/8] 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: xqV8GCrTd8Bf 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 102e91a667..c3425e01a8 100644 --- a/libavfilter/dnn/dnn_backend_tf.c +++ b/libavfilter/dnn/dnn_backend_tf.c @@ -74,6 +74,7 @@ typedef struct TFInferRequest { typedef struct TFRequestItem { TFInferRequest *infer_request; InferenceItem *inference; + TF_Status *status; DNNAsyncExecModule exec_module; } TFRequestItem; @@ -164,9 +165,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; @@ -186,6 +187,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); } @@ -905,6 +907,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;