From patchwork Wed Aug 25 10:39:37 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shubhanshu Saxena X-Patchwork-Id: 29769 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6602:2a4a:0:0:0:0 with SMTP id k10csp434956iov; Wed, 25 Aug 2021 03:40:57 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw+hXtvNax50cZ3sT/mjq6gruvR6EcdQ563bCTUyfQbpNPYDQM0fpAEmlSQWDchIeoA8njA X-Received: by 2002:a17:906:c251:: with SMTP id bl17mr45454264ejb.219.1629888057298; Wed, 25 Aug 2021 03:40:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629888057; cv=none; d=google.com; s=arc-20160816; b=Dnf7IvTOlaYy5hMEjmWXfvBgqUrz3bQvfcSiiJChxYKJGvo+N1opBs/7XG/ogPM/GO vjENRs1g+phB2inFtYaMagDq+vYWv10VXXvC/BnMaMaA3DFhMYOkm1itNx/KG1K0PTA2 CVfGAOHPn5HHHZ6VB2o0ZqdQ8CfYOaxtPbEcsF8ks7a69EPxD/TmuAvsCKtA0/fTEcCI +bNyTNPHqcjduZHctXiCePIWRtHS3iWLPzW8xZxD9dVQAUejUs8/bZnoFud4OQsH/gDd 3aFr4Y3Hm/s4wRkoEfR1xlw/KWnNGTnKjFkPptAKYQwbXRfmETSJOOeox3wv5OZ5wYhD 2ZfA== 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=DLZpo8s15XMpfdsJiyOJcUefheczHg2yUIo4aT39jlY=; b=dtOYwlrxDH+1vYZBY04b2uUIgHfZEyFlyPh2HafWAl8XhfuGjC7potFhRI8ZFnA+ub pVW3v+NqCJseXU1AS4GZHEYN/q7Gi1n598031kkJpukDiSuKjeHZYQVkHCNAdy7QHrs2 1f+hKuSHKmaEFWovsF9Q57hZ9RYZityT8FeVzOj6fFt0+W2G9Lwo2FBnkQhARcLLHO4W nkn2jVy5J15CLvyiUJXxdfjP95wsifefqkwfwAfQPkZ0OQ8lt9fw5eC36qzphaxFZtuE 1J4hBaTEG8r07RAKe5T1515W+omuoJNsqA6VAB259AhZ6xCErIudoPx02y4H1TkHmzv7 2a2Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20161025 header.b="m/lwAo8P"; 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 f9si8294925edv.148.2021.08.25.03.40.57; Wed, 25 Aug 2021 03:40:57 -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="m/lwAo8P"; 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 ECCC368A320; Wed, 25 Aug 2021 13:40:25 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-pg1-f171.google.com (mail-pg1-f171.google.com [209.85.215.171]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 08FE4680523 for ; Wed, 25 Aug 2021 13:40:19 +0300 (EEST) Received: by mail-pg1-f171.google.com with SMTP id g184so4137328pgc.6 for ; Wed, 25 Aug 2021 03:40:18 -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=xEtSZIhxjrgP8Qiv8HtecgeSth5SbbKyMevLA+Wlpyw=; b=m/lwAo8Pbl3nSeCBKUUnSHozfizSEYLWdLBKRWAEWGTH9o1hfzV8aNxxf5RMHdhZdZ s/YcoZtwoD5HHg7Sa7xCajBAuLKOu5yh5S+KlRhOeXkUhPFWpmpe/4OK1kzE3c16GTyD /BGr6oAXEAGm+IWhYvi/siOjdqgrOB3jG0x0vELiqxQvZcHGosd3CftayBzlQEjgqvs5 /9sB4P1GtaWrRupkLuXBEnxx6L4mhAqTtDZiKNpN+ZOmbeZzlyWcXaH3l7cD1OcOzP7h 6W2XC5IlGX3rEumL+CpgBNH+QS4aO1BG28RfPrhUkbyQPavG5Xn+QDzK4Rjqb0eh0nd8 S+gQ== 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=xEtSZIhxjrgP8Qiv8HtecgeSth5SbbKyMevLA+Wlpyw=; b=Td4gzmJFi0nnfRMppKe3xbKEqc56/4D4+Gl54ZUzJbOviqNUM20OaEGIm3llaz4jj8 J80eKT5JmUXYygRqJANYUPutB+ZJiGUjC+8Gs7yBFWSSVA8BaPwEalWM25yxczjWeNi7 fx/mINjX0wA+CeqSLiFba3jRcCYYctDs4Is3wBVBj3YzFbaz48JumXreN7W8RkLLYv/5 BncP6Y+NNzpD+fZybFsiTQw+9I8sS4CRQKJrV0Ixfgu1mAtUGG6qSPiPhYEOHJTk+b49 xh98I48BK4cn5kZNfRsDg/uMgrOTdFsq8ildsUATh/NKq7GagzZmXgIZzKAzbUgjb0Zk d1Uw== X-Gm-Message-State: AOAM5310VuqCO8WABF3s4P+4g1hnIO9SxGdFgpvGswYuVva6ZKxhw70c CiTpnM7xvtCVFIDqNYs63yh2uBI6d0mzXA== X-Received: by 2002:a05:6a00:d5c:b0:3e2:78ce:8d31 with SMTP id n28-20020a056a000d5c00b003e278ce8d31mr43842071pfv.39.1629888017340; Wed, 25 Aug 2021 03:40:17 -0700 (PDT) Received: from Pavilion-x360.bbrouter ([103.157.221.29]) by smtp.googlemail.com with ESMTPSA id w16sm4548735pff.130.2021.08.25.03.40.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Aug 2021 03:40:17 -0700 (PDT) From: Shubhanshu Saxena To: ffmpeg-devel@ffmpeg.org Date: Wed, 25 Aug 2021 16:09:37 +0530 Message-Id: <20210825103940.28798-4-shubhanshu.e01@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210825103940.28798-1-shubhanshu.e01@gmail.com> References: <20210825103940.28798-1-shubhanshu.e01@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v4 4/7] 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: DUhuElyi3CZ1 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 b902aca12d..d99368e64b 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 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);