From patchwork Thu Apr 29 13:36:54 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Guo, Yejun" X-Patchwork-Id: 27478 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a11:4023:0:0:0:0 with SMTP id ky35csp1492813pxb; Thu, 29 Apr 2021 06:49:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxY3/paJBmNoqI852SntZjj9V/YRyAqWOJlnZ5A0X6hefaGnl6Hc5MqFXAIlYFmBR47dMQ6 X-Received: by 2002:a05:6402:2713:: with SMTP id y19mr18230248edd.347.1619704186759; Thu, 29 Apr 2021 06:49:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1619704186; cv=none; d=google.com; s=arc-20160816; b=cqyXChODaNW/SDFK1U8P/3gY+owEo579u0M22I51pCeXb2SQBOFhfRQi+vP4rHjh7/ pCqMX0+sI9J4GozPZYO0mqaYdlQFMPF4JrKkUB3nHJ9ryFfsP2WnCrfb6mLFpAZ55wv9 IC+qgAa6nBhUQ0OVdhwdc7x0pFNa2rtX6zPD0AKHD66PiJxHP8+B7VmuVraCWMrWmZcc U8Ay3fc1PwatbB5ncZ2oIEtqD8HrCJf4DpoBEHZLm+xPS6maf+6VvyTj/CC3i6eHRCsh xpR1VPImVy2j644DgVJpC4O4u9eZgFQrAeZQl7BJmH2iG8cq3eG2ol6v8XhEFL2hJAhD cELQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:references:in-reply-to:message-id:date :to:from:ironport-sdr:ironport-sdr:delivered-to; bh=hBzuAfd/+PczA5GR0+SRSP8TDQxuKKK6VChxLXX4pgU=; b=gV7+giwNj0zQYGp+BYg7f62RbftmqG0GZUGs/dyu3LIIjmH41GPFup+LLDau/5t/H2 naqg5lbygFjHOCTlboXReKFnHpmE30qK9MNCmC236L3XErftBN+gTT+n+7VBDhqVy0zm OylNXS9+Xr1iA/Z9LWFHbMQgjiVIK0erQ2DF+pg95o6uSdSOVSg5aaJeXFa2Ogj4Nexu +TulJ7LM9vgtQyi00gCZWBI+4zRSNrqcfUsEY+HgNfcyytWpXlHSydKZeo/tRPyRgv1u NBORkvIqk3mXLaLJHlPuw8yyjfJlM6pJg4pjZI9GbpjAAaPUkDFfW9j5EZoRk8I1ayLa ruiQ== ARC-Authentication-Results: i=1; mx.google.com; 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=NONE dis=NONE) header.from=intel.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id e6si3177301edz.445.2021.04.29.06.49.45; Thu, 29 Apr 2021 06:49:46 -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; 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=NONE dis=NONE) header.from=intel.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 4C7F768A0F0; Thu, 29 Apr 2021 16:49:26 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id EBB78689F86 for ; Thu, 29 Apr 2021 16:49:18 +0300 (EEST) IronPort-SDR: upxuubUYxNJn6sBnNn9YDp1DbXZDG+JJ4xoYGnGpbWFdZlTbtdzDP4B7SjjLbl6QkUazuoN/Qi jWTZ1B8hktMw== X-IronPort-AV: E=McAfee;i="6200,9189,9969"; a="260956497" X-IronPort-AV: E=Sophos;i="5.82,259,1613462400"; d="scan'208";a="260956497" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Apr 2021 06:49:10 -0700 IronPort-SDR: Es0KJUylLsdTwsJmtvnzR9nGMZM2kw2/PDoquxodGy/ctJxHzo9KUmKRRygp1KJLDWeiStEquY r7fEuJSsmSfw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.82,259,1613462400"; d="scan'208";a="424096056" Received: from yguo18-skl-u1604.sh.intel.com ([10.239.159.53]) by fmsmga008.fm.intel.com with ESMTP; 29 Apr 2021 06:49:09 -0700 From: "Guo, Yejun" To: ffmpeg-devel@ffmpeg.org Date: Thu, 29 Apr 2021 21:36:54 +0800 Message-Id: <20210429133657.23076-3-yejun.guo@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210429133657.23076-1-yejun.guo@intel.com> References: <20210429133657.23076-1-yejun.guo@intel.com> Subject: [FFmpeg-devel] [PATCH V2 3/6] lavfi/dnn_backend_openvino.c: move the logic for batch mode earlier 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: yejun.guo@intel.com MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: +uyOGg/U5dR7 --- libavfilter/dnn/dnn_backend_openvino.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/libavfilter/dnn/dnn_backend_openvino.c b/libavfilter/dnn/dnn_backend_openvino.c index a8a02d7589..9f3c696e0a 100644 --- a/libavfilter/dnn/dnn_backend_openvino.c +++ b/libavfilter/dnn/dnn_backend_openvino.c @@ -432,13 +432,6 @@ static DNNReturnType execute_model_ov(RequestItem *request, Queue *inferenceq) ctx = &task->ov_model->ctx; if (task->async) { - if (ff_queue_size(inferenceq) < ctx->options.batch_size) { - if (ff_safe_queue_push_front(task->ov_model->request_queue, request) < 0) { - av_log(ctx, AV_LOG_ERROR, "Failed to push back request_queue.\n"); - return DNN_ERROR; - } - return DNN_SUCCESS; - } ret = fill_model_input_ov(task->ov_model, request); if (ret != DNN_SUCCESS) { return ret; @@ -793,6 +786,11 @@ DNNReturnType ff_dnn_execute_model_async_ov(const DNNModel *model, const char *i return DNN_ERROR; } + if (ff_queue_size(ov_model->inference_queue) < ctx->options.batch_size) { + // not enough inference items queued for a batch + return DNN_SUCCESS; + } + request = ff_safe_queue_pop_front(ov_model->request_queue); if (!request) { av_log(ctx, AV_LOG_ERROR, "unable to get infer request.\n");