From patchwork Tue Aug 24 05:31:48 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shubhanshu Saxena X-Patchwork-Id: 29753 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6602:2a4a:0:0:0:0 with SMTP id k10csp2724309iov; Mon, 23 Aug 2021 22:33:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwa5o1aTuO57Ulr16W6K+ZdBntpsdjueZSbGngwE3YwFdInv25jhMyOisJ/ct8YPI5efpuD X-Received: by 2002:a17:907:7291:: with SMTP id dt17mr40061622ejc.162.1629783200484; Mon, 23 Aug 2021 22:33:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629783200; cv=none; d=google.com; s=arc-20160816; b=wV81N2oubY7SRa1LGI+p7rIFV2cUnmM3cTiMEtx9owbySHVGZbPqulpt0WR78f2h5V X4RXs5ooEK7yt1Ip5t0BHKPFRIZJ+GtIRoFxjZJ0ZoBPXUdIIKa8oA5jM+hBQ25KJu+S n5UG/aJAMN4aqzQW1oCLZLpuZfYqD1iLNYZitMWpcYpYCIhjCAXLhtI6jSlaEdxqK5/J RuKmBpQ4Pjleyb4DToRKH8U/MPMSG5IoF2Bnw2UHi4ADnlB4KkWJAvTcGH/6gxqHLTIU VlpxAwcwBZ4dxIlDGH2X3YP3YUDqNmtA2KII/Ww8/FneKJ/h0rSXipAsqyNqTkUGOo5p u1SQ== 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=Fh6CqL4OUU6AoJYJJozE3cpLMkekNShpDatdul+c3kjbaII5cbDGfU/DojBK/X7pDN 5z3gxU3yBNHlhQoYXZgwFcbIVryTRupcQNvMbx9BPCgrLSe+KxlSXOc9bXm1JgIqAaFx RSpvy3F4Gcaxx/3hTAHyyfNaQDvHxtEFnuddCkC48PqKmhaJV/WdKkfJJYdMQqIOpFoD F+qMb6dlcQFjFpnwoGynge+lGY3wlbFSUE87kaNyDnNIW4MXsPlG/DjHk5qDY3rlvweY Hok4uGUOjkLVa8alAldIo/jrPkfz7rZlfvJDO7tb2Sc/g3+JSq30WZ94XpmiDBmN64P+ z/ew== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20161025 header.b=nq1stbI4; 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 v12si15442679ejv.679.2021.08.23.22.33.20; Mon, 23 Aug 2021 22:33:20 -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=nq1stbI4; 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 5615C68A26E; Tue, 24 Aug 2021 08:32:48 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-pj1-f54.google.com (mail-pj1-f54.google.com [209.85.216.54]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id AF9AA680074 for ; Tue, 24 Aug 2021 08:32:41 +0300 (EEST) Received: by mail-pj1-f54.google.com with SMTP id z24-20020a17090acb1800b0018e87a24300so1571220pjt.0 for ; Mon, 23 Aug 2021 22:32:41 -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=nq1stbI4WMNEB9oCZjZhMI+GDmOkfUeER9KRlzxXIlA8NA7LaXzb+8jCmk5IHIbIFT i+exWnSH+/IAXGdxMBcUmdJibfcoNI/yLs+IWYcszMWQ+4koJEKWu6Su9eb635UOS3hz IPhIwFMkxqj4kGudkaJiYpj8Or0xg3XjQfO0rwkbynM0ozg83uQIz95gK0QYTi8LPda+ M4xVMhwiWfhkab+ztHjoaRYzRyc8HoXp3ATgvYvxxZ8qIX4821nJPsHK3FMbkZQ+1+Bd ZyrovYQai5sRa4Dqm+yjJ/Viec3Zj7VWHmmXurQNML2aPulp+JlH7J+MbdQ9yA6j7yeD QDBA== 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=FZbHjvujwcKN7xlOqsatJqsC6mnWLcUezKEIiHjh/STQmbXxLSHHswna4ai3p486Ax dS5wHQhZJ1VCXajTF3zgh+FStcQy8GI/tv0D6zVkScxUCUUiFmEpo7K6BxTS5YA9Jy3t 7HasynDj2Qw0xRPfGXVzzhMn4nzn7VbBPuFxqfreKy0UCw3/vkJ2GnxtUkiDu2hbYlj7 VmUwMOUfa8H+Ya1ZMwA5g5y6Dmjg80LPoYlz3HlTXbTmtWFAxH5MSGtyHAD64gXXvz+B sNhUOO/kICH4WJQL1uDiQ5sO/2uRx3ezyhSM58IHIsSCEp7kSW5LKYBcDJWfkVeYgaj+ xn4g== X-Gm-Message-State: AOAM532VyoEnNuRKGb7TMIdnhXG7rAGbVDJMeweUeBGYm0GDGm32nVZb YYMnlFj9FYnpDxybAT6esFCIS2lmw+iAJg== X-Received: by 2002:a17:90b:3748:: with SMTP id ne8mr2473985pjb.162.1629783159734; Mon, 23 Aug 2021 22:32:39 -0700 (PDT) Received: from Pavilion-x360.bbrouter ([103.157.221.236]) by smtp.googlemail.com with ESMTPSA id z12sm7095207pfe.79.2021.08.23.22.32.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Aug 2021 22:32:39 -0700 (PDT) From: Shubhanshu Saxena To: ffmpeg-devel@ffmpeg.org Date: Tue, 24 Aug 2021 11:01:48 +0530 Message-Id: <20210824053151.14305-4-shubhanshu.e01@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210824053151.14305-1-shubhanshu.e01@gmail.com> References: <20210824053151.14305-1-shubhanshu.e01@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v3 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: B/7aQ80j2NyJ 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);