From patchwork Wed Aug 25 21:10:47 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shubhanshu Saxena X-Patchwork-Id: 29780 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6602:2a4a:0:0:0:0 with SMTP id k10csp911015iov; Wed, 25 Aug 2021 14:12:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyAf90fEM0fvlYwcT7FQcBuC2ef9NoGY3DA6WPZA/XQds4FDZqjWTJyQSswrCC7SR+fJ/T5 X-Received: by 2002:a17:906:640f:: with SMTP id d15mr627056ejm.419.1629925942587; Wed, 25 Aug 2021 14:12:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629925942; cv=none; d=google.com; s=arc-20160816; b=WZ7z6Rmz/FkU7lQVn6gezF7wSvAYg3i0/yysa3voGuk6mV8ESeUbtkcJrddZX1qcz4 OwM4IwpRynqCIxfV7vNMLUYJ03yTp9dcs5aBTc34d+MiCNT815iWEp2KyfRCEcWZquI0 YFoaU0Qwnua+JRsUJ4iPcf7CySi0LW1UL2Nq4Ite/+pahgjJQPcFzrCJeWcGNjRyfD7D i0DuzqmAmqsxOV3alJFll77qsP8pDrOg9Hjc7QpSDeWvtbbNGZfaAQ+1xHXwf+JhQ1w/ HTvaci7iUw/mFedccgoCHfnjndMffovN/mEjwKPJ8lrxsxC7reA5jwcgFnuU1PFYAavk 8cXg== 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=0ezu6rzYhExVxaNKvH2XT1cr/GX8j9WSeCJXe8FT0Xc=; b=B0Evvfd6sy9wSoa9Mmu1dLBjM50MCuBcFq8BkTYZp3tnM8/eKL43xWZVTyaJaNKH9L cg9XjdkzQblEefF6f0R0jMC4+1uwc/0zACwLQTPDNfM/g/+O17S9FrMQAF4LCqFGE9rw wVem0XTLd6ZbNSepFvE15xRxKB+tkvAgP0OC6sfTgyT7eFVsrCLjZyx4zU+6dYoimDdS a/kLOz8oRxbniDThrTkO8HKFbPKa1hGPOYUA6Mmzno7JzeQxE1ubGWxUrJg0mTGldlhO zUCw7r93XPepI6kX5tuVIfYAtSd6pUwFBr0ja1s9B1giz5zEPWjb5t6i0qtU+c1z+3ed 4g9w== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20161025 header.b=IKp0WFhh; 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 i25si942715eds.119.2021.08.25.14.12.22; Wed, 25 Aug 2021 14:12:22 -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=IKp0WFhh; 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 8058068980E; Thu, 26 Aug 2021 00:11:54 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-pg1-f169.google.com (mail-pg1-f169.google.com [209.85.215.169]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 8C13C680A47 for ; Thu, 26 Aug 2021 00:11:46 +0300 (EEST) Received: by mail-pg1-f169.google.com with SMTP id 17so952986pgp.4 for ; Wed, 25 Aug 2021 14:11:46 -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=Sk4KJ9zxC2Gj9KV09vaPbN/8WSJwXCRd5dcCoh2XUa0=; b=IKp0WFhhZmuq5j1Uj7+RmeHXfhYHESy3eJ/PMCFnOeiB0g36SIsyd/O9a6zSamf2U/ 0S+KNhUkRcRs/hbuN9wNKiRPRZ/9RFm+1fFzUjy5eLDdL03WwPSlgurJmfIbxX6em+kQ nKetz6XJYJWpExoi/hNO2teTJZma7K4BJ7H/oK3XcgUipczLbC1qEz5RC7Dtf4eT1+b8 ecfWh9qLdfbYGviMRwtudf1Fds5+B65HxfPTuov21SwW7NS2N5jC6dtPpt3FSpMtu+ou bDh6bo2l0eRM/M8ZnLsntA9L2rqeOylO7jA4XrsGcjeQxGT3uPv5evB0FvpKAtxVIL5D uWMQ== 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=Sk4KJ9zxC2Gj9KV09vaPbN/8WSJwXCRd5dcCoh2XUa0=; b=XDvfJCRyhMn2aptY/wU+KC2ZSRHvtAe6gnVMxhNRwHWvkQ6R1S/s2+0buuZ1RUf18j 7dTzu/8uuhlmpReMtdCRoibosDa8gNID43Q1MCLabUF24OFxhD8IJaR1aYK5odbYv3rs nnDSxgu0YYLxAghoBebKm451I2F5PSYT15dt07K1IH1+bE08KrY2B24hz3t5MEDTosKD JJF7RKcIKHgslnkSYHSqqVNBCsBpv+9UuZdVbdzJaNvD/6lf0e40+Aa3iW0pWMiK4kzL GoEziP5w0Ij5IlMVwcR3Ds6qoCrO1/SiVGlKXTk/P+jUPyaomOP9tGRCKiX+RkPSqJ4w QEYw== X-Gm-Message-State: AOAM532gCUdSM5mthYOCwc39lF+kdfGzV3tBl7fEp32L8CKlXLHOz2j6 RuXrm4M8rP9+i8B6JMMnq0G3Efhg8P8G9w== X-Received: by 2002:a63:e214:: with SMTP id q20mr179962pgh.134.1629925904680; Wed, 25 Aug 2021 14:11:44 -0700 (PDT) Received: from Pavilion-x360.bbrouter ([103.157.221.29]) by smtp.googlemail.com with ESMTPSA id o11sm600357pfd.124.2021.08.25.14.11.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Aug 2021 14:11:44 -0700 (PDT) From: Shubhanshu Saxena To: ffmpeg-devel@ffmpeg.org Date: Thu, 26 Aug 2021 02:40:47 +0530 Message-Id: <20210825211049.18861-4-shubhanshu.e01@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210825211049.18861-2-shubhanshu.e01@gmail.com> References: <20210825211049.18861-2-shubhanshu.e01@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v5 4/6] libavfilter: Remove Async Flag from DNN Filter Side 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: KqulIZuPagQo Remove async flag from filter's perspective after the unification of async and sync modes in the DNN backend. Signed-off-by: Shubhanshu Saxena --- doc/filters.texi | 14 ++++---------- libavfilter/dnn/dnn_backend_tf.c | 7 +++++++ libavfilter/dnn_filter_common.c | 7 ------- libavfilter/dnn_filter_common.h | 2 +- 4 files changed, 12 insertions(+), 18 deletions(-) diff --git a/doc/filters.texi b/doc/filters.texi index 47ceeb18c6..7aff920311 100644 --- a/doc/filters.texi +++ b/doc/filters.texi @@ -10283,11 +10283,8 @@ and the second line is the name of label id 1, etc. The label id is considered as name if the label file is not provided. @item backend_configs -Set the configs to be passed into backend - -@item async -use DNN async execution if set (default: set), -roll back to sync execution if the backend does not support async. +Set the configs to be passed into backend. To use async execution, set async (default: set). +Roll back to sync execution if the backend does not support async. @end table @@ -10339,15 +10336,12 @@ Set the input name of the dnn network. Set the output name of the dnn network. @item backend_configs -Set the configs to be passed into backend +Set the configs to be passed into backend. To use async execution, set async (default: set). +Roll back to sync execution if the backend does not support async. For tensorflow backend, you can set its configs with @option{sess_config} options, please use tools/python/tf_sess_config.py to get the configs of TensorFlow backend for your system. -@item async -use DNN async execution if set (default: set), -roll back to sync execution if the backend does not support async. - @end table @subsection Examples diff --git a/libavfilter/dnn/dnn_backend_tf.c b/libavfilter/dnn/dnn_backend_tf.c index 84952ece5a..6e41470da4 100644 --- a/libavfilter/dnn/dnn_backend_tf.c +++ b/libavfilter/dnn/dnn_backend_tf.c @@ -884,6 +884,13 @@ DNNModel *ff_dnn_load_model_tf(const char *model_filename, DNNFunctionType func_ ctx->options.nireq = av_cpu_count() / 2 + 1; } +#if !HAVE_PTHREAD_CANCEL + if (ctx->options.async) { + ctx->options.async = 0; + av_log(filter_ctx, AV_LOG_WARNING, "pthread is not supported, roll back to sync.\n"); + } +#endif + tf_model->request_queue = ff_safe_queue_create(); if (!tf_model->request_queue) { goto err; diff --git a/libavfilter/dnn_filter_common.c b/libavfilter/dnn_filter_common.c index 455eaa37f4..3045ce0131 100644 --- a/libavfilter/dnn_filter_common.c +++ b/libavfilter/dnn_filter_common.c @@ -84,13 +84,6 @@ int ff_dnn_init(DnnContext *ctx, DNNFunctionType func_type, AVFilterContext *fil return AVERROR(EINVAL); } -#if !HAVE_PTHREAD_CANCEL - if (ctx->async) { - ctx->async = 0; - av_log(filter_ctx, AV_LOG_WARNING, "pthread is not supported, roll back to sync.\n"); - } -#endif - return 0; } diff --git a/libavfilter/dnn_filter_common.h b/libavfilter/dnn_filter_common.h index 4d92c1dc36..635ae631c1 100644 --- a/libavfilter/dnn_filter_common.h +++ b/libavfilter/dnn_filter_common.h @@ -46,7 +46,7 @@ typedef struct DnnContext { { "output", "output name of the model", OFFSET(model_outputnames_string), AV_OPT_TYPE_STRING, { .str = NULL }, 0, 0, FLAGS },\ { "backend_configs", "backend configs", OFFSET(backend_options), AV_OPT_TYPE_STRING, { .str = NULL }, 0, 0, FLAGS },\ { "options", "backend configs (deprecated, use backend_configs)", OFFSET(backend_options), AV_OPT_TYPE_STRING, { .str = NULL }, 0, 0, FLAGS | AV_OPT_FLAG_DEPRECATED},\ - { "async", "use DNN async inference", OFFSET(async), AV_OPT_TYPE_BOOL, { .i64 = 1}, 0, 1, FLAGS}, + { "async", "use DNN async inference (ignored, use backend_configs='async=1')", OFFSET(async), AV_OPT_TYPE_BOOL, { .i64 = 1}, 0, 1, FLAGS}, int ff_dnn_init(DnnContext *ctx, DNNFunctionType func_type, AVFilterContext *filter_ctx);