From patchwork Sat Aug 21 07:59:03 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shubhanshu Saxena X-Patchwork-Id: 29661 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6602:2a4a:0:0:0:0 with SMTP id k10csp331290iov; Sat, 21 Aug 2021 01:00:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxeeWceGDm5qc37gcHuRzrJMFYNwFfBzI91CvnCLpwcei7J3O/S5xp/MLcD7pgLIIEjD0Xy X-Received: by 2002:a05:6402:50c6:: with SMTP id h6mr18339493edb.3.1629532806040; Sat, 21 Aug 2021 01:00:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629532806; cv=none; d=google.com; s=arc-20160816; b=H6g1ZcPaA4Krwnt4IIq9uwNwiDIudHxhROMKeyfsmeVVOg0fHYKSW7bwuqrfqL9MnW 2q6A0NEU5XzQKua43H+mwxONPKFtBxWEuBAB3JmeOkH9dQHHSkd4y33VO5zq75FbGo6n UDRPjmszAqeS2Bwzrp7zdlKgLiuzmyuB1CyOXDtabsIemIEfubVRwSgieRm5H3ydPLJN wska0E7ZZHiMPVrczlPe4xBfubaaWKjZ7f5jJhsGKBfGqmqjOL5tOcUBIBPQzU4h8sVc IS5mlrEVWyPqDQrfkcFCXC1jFdJTim1IcFx3EsnmnN6kwtXhhqPBVfKj8ynDkMswVKtq RSmA== 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=k0kmrE/IIfPoS9DTZHJ5VSZR/Up6vD2+XXVCS5/uXT4=; b=AMoASrKIikEOgorhcIXGrYqakxGBtQLrnUEwy4Wytr9llKwSQPENFw1lU6aSGPNw9S bQ/nj7Ji+CWn94miW2FwlR5znjbS10eL+xkjA4f9jcL2kpWFy4+khXlFnyT43DQ4vDvu fPAqZv4wQUf3k7IJA8BVOxsiSYJgzOmFnwrwC5BCpJE0LWqGfoIKNcdbeUODeYDb8eSU UYjiPD6Qg4WsG6Q96ZTInd+qFoaQ0L36mrqOp+yolKkvay1DRj9vUXcaBeCtNaLAoubJ tn1dULeCarMbcJdvJaILlvw1GgIuU/XunEfC/0mKBgb9ZyXvgsc8g11BAP1H0S0/hHqc ygVA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20161025 header.b=oRofFkiI; 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 o24si8144261edr.546.2021.08.21.01.00.05; Sat, 21 Aug 2021 01:00:06 -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=oRofFkiI; 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 9ED1268A41C; Sat, 21 Aug 2021 10:59:37 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-pl1-f174.google.com (mail-pl1-f174.google.com [209.85.214.174]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 1F64C68A41C for ; Sat, 21 Aug 2021 10:59:31 +0300 (EEST) Received: by mail-pl1-f174.google.com with SMTP id o10so7331356plg.0 for ; Sat, 21 Aug 2021 00:59:31 -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=KkQ9KUeoi1jMlISyzZYntIzJ2/tzZWnF27ESfOXQp2o=; b=oRofFkiImZOFkGzA586mJVU7NhiuPDqrOJQFqsgxyUGfUTgxfOqE8Tj/+So52cpNX0 72HP6guXwwH/SaJNTr3v6q+bhmCwasEBf5Dk3wqCibT/y7WTXmsP4PAVQqiir72zQX48 NeScuVqQShL29CprGqeqUmr/buM6Y/+RCwoGGJZqzpZ/9c6HlJqg/5I5L1J1NWpt2eqh R64gyWdWJJ79LV8Tl6e362i/kCK0wcrgC4Gr4wcmfMy8An/SFkJgdk/9I6UgKWq2XVdR XR4Fb/rNvibmcNYp0PEGX/wmPujge2jzpI5ywTR1gB6qzCq0grxqba+5yQ5FraipjHNQ GpFQ== 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=KkQ9KUeoi1jMlISyzZYntIzJ2/tzZWnF27ESfOXQp2o=; b=PpddcXAvc/cZ6FdqQnOf3YQVFGPLhXHc8x2sxW9MrFyPCmBAPha6VE+2HgJR/BpNDj m7fmuV+0yx6tl4ZVHnAH5Kq8istjtx4vknxSGWgyw9ySDEfSH37ylt57NF1CbSCKxFxF uRhgrwdllnPBMARMw6FZ3Y8T8uJFzTQh4apLDV3kGt00px7fqQJiwo5V34/uy0+PtV3G wTyODXzL7s/6r4mkmuy9IiytO5dhhYldkuSYHI8pd4nx7skiaJVHs5kKfFQQulp6JU4y sCss46ViCpwdSjuOuMOXOGZwTBKEgiVWiYHewM4Mwpq8iw3TKCyXjoMJeXp4VAWNFXxl m1rw== X-Gm-Message-State: AOAM532oSGirbwdHzGmMC99WugngioHKTWFiLAaOJuhsunXQa5Alb1VQ mh2JYQiGI/4GVJP6vJ92YSBJRQSbe+c7dw== X-Received: by 2002:a17:90b:b0e:: with SMTP id bf14mr6044821pjb.80.1629532769432; Sat, 21 Aug 2021 00:59:29 -0700 (PDT) Received: from Pavilion-x360.bbrouter ([103.157.220.198]) by smtp.googlemail.com with ESMTPSA id z20sm8565295pjq.14.2021.08.21.00.59.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 21 Aug 2021 00:59:29 -0700 (PDT) From: Shubhanshu Saxena To: ffmpeg-devel@ffmpeg.org Date: Sat, 21 Aug 2021 13:29:03 +0530 Message-Id: <20210821075905.12850-4-shubhanshu.e01@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210821075905.12850-1-shubhanshu.e01@gmail.com> References: <20210821075905.12850-1-shubhanshu.e01@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v2 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: /Rg+485h4uzu 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 a5752c4d6e..f7b6b61f4c 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);