From patchwork Fri May 28 09:24:54 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shubhanshu Saxena X-Patchwork-Id: 27963 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:b214:0:0:0:0:0 with SMTP id b20csp368767iof; Fri, 28 May 2021 02:26:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxsviZln4iRQcfjXdANFbLU8CWhwuLDZBFkJkk1oWae0/dxnocJxbJcsDe92uLQf37fs5wQ X-Received: by 2002:a17:906:7696:: with SMTP id o22mr7813555ejm.298.1622194019479; Fri, 28 May 2021 02:26:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622194019; cv=none; d=google.com; s=arc-20160816; b=uTbZMVCQbzTDYlruBYhLkoPlEjF0cGe6SMbNvXZeTzTF2pXD3rDhdDbxJ1DVMC8J+e shIhB9cY+38UHBu7mi/fT35c4aRxduZDD3dVum10sb8fdNFZ1pTZ/O3b40CXY5sYFFqN dryHFEksh5zCPSCkCqpCs8XRtfgOaA0jJQBlfTXY8uP8c4Aos8ITl5yF+ewh4D6WN55E q36+HDt8v3ZL0GVeQP9KKKWcEKT/hoo+nkz+JYZwpQlI7TznXPgAdHiHoZoMIJZuUrvQ aDT1JuDOUBeG4sVT27EH2xoIqYrXj1P5usfpJvqzQMMjUjQ0eaHgHIhdD7gnTfknWEzZ ZStw== 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=QGTPrxVKJS7d9CAOXJFpkKQ5oeM+//NykkEqZDjzdhI=; b=txXQYJt8iLHDiwQbGoT6h9PZCj9tfjbrSmLHWj4QyM5sWJQsbQeMKrj2mhUf3oBezB wfRTowAMxoI9HtWb1Bzg0BJwX4yEstgwV+qY43fj4MeqM+weMNfaKJN2lqlwZdAgLoyu v8Ov6BjM0JzLgQYjxWvMEJj92fX3Ts9ZVnFt9vDdjlS4iYjjWhXfA+4AYbBdaYM3KMRu bPontiHSK13H48XkhX3pLAjOSW72NNdDqzk3PtSInlbgFZenmxbSaqcACPg496gNUSHE f9fOVkXOQu0hELC9PRndShT+IIUoozytNtQIx4R2I0oexVhpGBB8GKcTMcj6AJUNtMSx a/GA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20161025 header.b=eO6lUMyx; 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 dv20si4434113ejb.404.2021.05.28.02.26.59; Fri, 28 May 2021 02:26:59 -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=eO6lUMyx; 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 CC11668A0C5; Fri, 28 May 2021 12:26:09 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-pj1-f49.google.com (mail-pj1-f49.google.com [209.85.216.49]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 64C96680B73 for ; Fri, 28 May 2021 12:26:06 +0300 (EEST) Received: by mail-pj1-f49.google.com with SMTP id f3-20020a17090a4a83b02901619627235bso3485pjh.1 for ; Fri, 28 May 2021 02:26:06 -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=7ELBHTE0auQak5nvJfoL4lGznJ8OzJrQ/EFWfA4V0nA=; b=eO6lUMyxRGnra0ksCdZ/FvKtCC0hXlOiGFzbGGOs/ohPwMd0alhZz8aOfQNKUmbSj6 F/Bihcg94o+qtguPDINs8e+haFntQVEH69hkGNSxtKLvfNLuREzelcapltlDtF0a4bOW tjBR6eZ7sLVDaQ4AgFNbLAyAKauRL68i01QWH7d4DQQG7pllDYWHmeWOmKy3OwLdp49m Ta6YFS/fQs/KR3Gm6cGbYD080j3VIFupQUoyeSacbno3qUbm/q3ZlFkgoNVU4VZZ3IDH NuLGxnKAZs7ElY7xyqoFdzSvZESSwW6woZus0XwVnmhNWadcEX1cB4hWbAOpt4QKZYwh CFCw== 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=7ELBHTE0auQak5nvJfoL4lGznJ8OzJrQ/EFWfA4V0nA=; b=a+k7b1RLGghBTuuEFCVUmhh5pe/o6gS9NIIRwD07HuMQ03lvI53x3qZt4rwgrvCS4+ 1JHLhUpuYZRNW0YQf3OhaExbmfhipm9P2EDDKJwrnTZbI4Er4E65PJMKX3GuKea8N4aV ZPhEnTA2rpLKA90fo9Z9EofRTMLogmqT6D6SNnoLt04NLRmVy1i6BzUPlqWvSKDJzON4 bV3+MIWFMGAE4PtpR7vE/MTvm+l9zufB/gM44Pab22cEh9Lq3cEf11ca9qIMsC1SR5IG W7zvqFQAlQC+Hg35rrvMdGDueJZwIAmVx8RYI1kB7jYQY1cbrwG+KYCp9xjVlXE0K7gg Bo1g== X-Gm-Message-State: AOAM5334m7F+utdgMNkCYqwv+DujAGNlPJfxQJKcDaA8daNP3S7IGJD8 4kOCeVVMtHtd1CuXTMDn3IS+qqtvSH0LwQ== X-Received: by 2002:a17:90a:a386:: with SMTP id x6mr3555250pjp.193.1622193964647; Fri, 28 May 2021 02:26:04 -0700 (PDT) Received: from Pavilion-x360.bbrouter ([103.133.121.241]) by smtp.googlemail.com with ESMTPSA id q24sm3846892pgk.32.2021.05.28.02.26.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 May 2021 02:26:04 -0700 (PDT) From: Shubhanshu Saxena To: ffmpeg-devel@ffmpeg.org Date: Fri, 28 May 2021 14:54:54 +0530 Message-Id: <20210528092454.31874-10-shubhanshu.e01@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210528092454.31874-1-shubhanshu.e01@gmail.com> References: <20210528092454.31874-1-shubhanshu.e01@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 10/10] lavfi/dnn_backend_tf.c: Documentation for tf_infer_request functions 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: uYl3fav9cUGY Documentation for functions related to tf_infer_request Signed-off-by: Shubhanshu Saxena --- libavfilter/dnn/dnn_backend_tf.c | 41 ++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/libavfilter/dnn/dnn_backend_tf.c b/libavfilter/dnn/dnn_backend_tf.c index 296604461b..8a74b11cf5 100644 --- a/libavfilter/dnn/dnn_backend_tf.c +++ b/libavfilter/dnn/dnn_backend_tf.c @@ -95,6 +95,13 @@ static void free_buffer(void *data, size_t length) av_freep(&data); } +/** + * Free the contents of TensorFlow inference request. + * It does not free the tf_infer_request instance. + * + * @param request pointer to tf_infer_request instance. + * NULL pointer is allowed. + */ static void tf_free_request(tf_infer_request *request) { if (!request) @@ -108,6 +115,12 @@ static void tf_free_request(tf_infer_request *request) av_freep(&request->output_tensors); } +/** + * Create a TensorFlow inference request. All properties + * are initially unallocated and set as NULL. + * + * @return pointer to the allocated tf_infer_request instance. + */ static tf_infer_request* tf_create_inference_request(void) { tf_infer_request* infer_request = av_malloc(sizeof(tf_infer_request)); @@ -118,8 +131,17 @@ static tf_infer_request* tf_create_inference_request(void) return infer_request; } +/** + * Start synchronous inference for the TensorFlow model. + * It does not check for the status of the operation. + * Check using tf_model->status. + * + * @param request pointer to the RequestItem for inference + */ static void tf_start_inference(RequestItem *request) { + if (!request) + return; tf_infer_request *infer_request = request->infer_request; InferenceItem *inference = request->inference; TaskItem *task = inference->task; @@ -132,6 +154,12 @@ static void tf_start_inference(RequestItem *request) tf_model->status); } +/** + * Thread routine for async inference. It calls completion + * callback on completion of inference. + * + * @param arg pointer to RequestItem instance for inference + */ static void *tf_thread_routine(void *arg) { RequestItem *request = arg; @@ -142,8 +170,21 @@ static void *tf_thread_routine(void *arg) #endif } +/** + * Start asynchronous inference routine for the TensorFlow + * model on a detached thread. It calls the completion callback + * after the inference completes. + * In case pthreads aren't supported, the execution rolls back + * to synchronous mode, calling completion callback after inference. + * + * @param request pointer to the RequestItem for inference + * @retval DNN_SUCCESS on the start of async inference. + * @retval DNN_ERROR in case async inference cannot be started + */ static DNNReturnType tf_start_inference_async(RequestItem *request) { + if (!request) + return DNN_ERROR; InferenceItem *inference = request->inference; TaskItem *task = inference->task; TFModel *tf_model = task->model;