From patchwork Fri Aug 20 14:21:01 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shubhanshu Saxena X-Patchwork-Id: 29637 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6602:2a4a:0:0:0:0 with SMTP id k10csp1309692iov; Fri, 20 Aug 2021 07:23:04 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwU8nufxN8GduJXzhVC6Nl7eflCgp5ECnLKht37HbT3vbvZanbhVEFjnS4G0Agx67+bYj3n X-Received: by 2002:a17:906:e57:: with SMTP id q23mr21904062eji.483.1629469383941; Fri, 20 Aug 2021 07:23:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629469383; cv=none; d=google.com; s=arc-20160816; b=yhgFfKwWTglC9ZgUJsQFgzqLh08KqPHJsGN0zace+8662ntWr/RyiQ+kSTYBrrLXtC SzPYTNwetWDOSjgUyyDb86szz8Mdys7eJuf5pSQumfhlnKmcoAKlhaOccsJCh+0x36QD Ov3KkjEQo+8d40TmFlvlfeHnixLPw3IAw5ZinPoqNUZEbxkjC3ytnccQ9nzBzmWuMrnE NzB8YGX11wAAZptfCdD6dMrw5D37DX4PmfIm3t12gvCl1pY8+fa0iS4JIoRgpyI0mdhb J8fu1zJyLH9AtCZQolwAohjF18iJXQaU3O2qenT8whXHwKKeHMST19kyKZb617TBxSIL AFBA== 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=czpwim1ICXE88eV+XWmWrfusKgA9yKOOCddKShbVjD0=; b=BRQA2ZSGECxYAOnEmpYpRzqCPdDYYSIpnd/kEfyVLLDjGvaHFLyHnl39IVQTaAS0XM q483r/XIqQ83541lefLQkr44RSaRo3KD2JGH+SIFzGZr9pc1aMwpwLOhrw/an8P+KflG WD7le+GKQrZke9dYcHavOCj+Z0AXR5PWCZOmcQlqRhB3v4/8FfqviUUInsvtPJZRslId jRMeFe15lSfNSwBRiceaCSD0ZDAux9vw+cErfBF3tM4I9mLzfhaxKbrZDvpkBcKUbkqT qfc5mmNJKVfD1ps1KkYr08KqGWwQy98Yv9fgModspp2K36hVA7sYG/NsQvLebMD/00A4 ynEg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20161025 header.b="V02L/KPO"; 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 k12si6442009eds.497.2021.08.20.07.23.03; Fri, 20 Aug 2021 07:23:03 -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="V02L/KPO"; 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 A091868A3B8; Fri, 20 Aug 2021 17:22:30 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-pl1-f170.google.com (mail-pl1-f170.google.com [209.85.214.170]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 0201768A26E for ; Fri, 20 Aug 2021 17:22:23 +0300 (EEST) Received: by mail-pl1-f170.google.com with SMTP id w6so6028429plg.9 for ; Fri, 20 Aug 2021 07:22:23 -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=eBa4KlC4Qt5tD1Y/Q0cyABhMDrL5cq9JDHN7xa/kbkA=; b=V02L/KPO6UdQiw7WfdIb2Olp5DMfC/39cGPtrlLEwzWCHa1pbR1GgJRSJS6Yp1ZBdE /xF36pbz2cmjgVDt180ezvK2uOxWr2//Vfx1Em+cm7yTWDEXA2myy5wGDosRE5iFCbjW ZR142PN1i/pg5+1GvtYXc44u51dL08vSAKm+LrQX7+h5eH3B/zHrUM4T2CuN1hXu+qc0 Rkn8DDsevLRGTd+FzYtx5W62I4NnGlnzYH3YcPVxn6w5HJQ5OyyLTPnCVYAADhldSUtx Ni1wRZnQoGgSHfXFYA5f3ABycyAVK933tPfMZlgdNZkxvlsyKs8veHQ/tOzBIMyHCTQf j1pw== 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=eBa4KlC4Qt5tD1Y/Q0cyABhMDrL5cq9JDHN7xa/kbkA=; b=oc3YB+NGt1+6fBQOfzPj+hsIms8mR5itsnHShBi3iCspN60hVk8PhDkjNNQdg/1Bqu Ei+Iu/c3TSH2vXTcLG30OerhRWeQQ9otVSxHa+VtodT4Na+zybvlSPyAhR5o/6UJbmXu dM/POb9Div5Bn/pnj6QiLqMYX8xtVjpFvhO/KLM19EHdkoKF3rLZvz8QYCgQazMENG1T NpxCxJjmwS1uzsKhcnj74n5No36Bu5Inpv396eQW4J+bVwyz1tQofrWO3tXfsB4hJpuN 2FJLrRGhOFqLNmKOIuvTvmFPdyVaVP49VpD3xq3KkY0ddpWd7y/qukIsJu2r6NcGPvtF G46A== X-Gm-Message-State: AOAM532LjuYWieHA5HIhN0maII48CRtz3J/l3c6Pj1zPsMqTmklf1hRz R9gE0CxGF9gFfPiuEa8rbPqD3YBU3N5abQ== X-Received: by 2002:a17:90a:c58b:: with SMTP id l11mr4970575pjt.212.1629469342137; Fri, 20 Aug 2021 07:22:22 -0700 (PDT) Received: from Pavilion-x360.bbrouter ([103.157.220.241]) by smtp.googlemail.com with ESMTPSA id x19sm8276043pgk.37.2021.08.20.07.22.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Aug 2021 07:22:21 -0700 (PDT) From: Shubhanshu Saxena To: ffmpeg-devel@ffmpeg.org Date: Fri, 20 Aug 2021 19:51:01 +0530 Message-Id: <20210820142103.14953-4-shubhanshu.e01@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210820142103.14953-1-shubhanshu.e01@gmail.com> References: <20210820142103.14953-1-shubhanshu.e01@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 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: vqRjKzSllOQl 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 480cab706c..fac19ac413 100644 --- a/doc/filters.texi +++ b/doc/filters.texi @@ -10275,11 +10275,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 @@ -10331,15 +10328,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 4a0b561f29..906934d8c0 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);