[{"id":25859,"web_url":"https://patchwork.libcamera.org/comment/25859/","msgid":"<Y315myQqG8k8oj7v@pendragon.ideasonboard.com>","date":"2022-11-23T01:38:35","subject":"Re: [libcamera-devel] [PATCH v3 03/12] utils: tuning: libtuning:\n\tImplement extensible components of libtuning","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Paul,\n\nThank you for the patch.\n\nOn Fri, Nov 11, 2022 at 02:31:45AM +0900, Paul Elder via libcamera-devel wrote:\n> Implement the extensible components of libtuning. This includes:\n> - Parsers, for supporting different types of input config file formats\n> - Generators, for supporting different types of output tuning file\n>   formats\n> - Modules, for supporting different tuning modules for different\n>   algorithms and platforms\n> \n> No parsers, generators, or modules are actually implemented. Only the\n> base classes are implemented.\n> \n> Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>\n> \n> ---\n> Changes in v3:\n> - Newly split from the first patch \"utils: tuning: libtuning: Implement\n>   the core of libtuning\"\n>   - See changelog from that patch\n> ---\n>  utils/tuning/libtuning/generators/__init__.py |  0\n>  .../tuning/libtuning/generators/generator.py  | 15 +++++++++\n>  utils/tuning/libtuning/modules/__init__.py    |  0\n>  utils/tuning/libtuning/modules/module.py      | 33 +++++++++++++++++++\n>  utils/tuning/libtuning/parsers/__init__.py    |  0\n>  utils/tuning/libtuning/parsers/parser.py      | 21 ++++++++++++\n>  6 files changed, 69 insertions(+)\n>  create mode 100644 utils/tuning/libtuning/generators/__init__.py\n>  create mode 100644 utils/tuning/libtuning/generators/generator.py\n>  create mode 100644 utils/tuning/libtuning/modules/__init__.py\n>  create mode 100644 utils/tuning/libtuning/modules/module.py\n>  create mode 100644 utils/tuning/libtuning/parsers/__init__.py\n>  create mode 100644 utils/tuning/libtuning/parsers/parser.py\n> \n> diff --git a/utils/tuning/libtuning/generators/__init__.py b/utils/tuning/libtuning/generators/__init__.py\n> new file mode 100644\n> index 00000000..e69de29b\n\nEven empty files should have a license, otherwise the reuse tool will\ncomplain.\n\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\n> diff --git a/utils/tuning/libtuning/generators/generator.py b/utils/tuning/libtuning/generators/generator.py\n> new file mode 100644\n> index 00000000..7c8c9b99\n> --- /dev/null\n> +++ b/utils/tuning/libtuning/generators/generator.py\n> @@ -0,0 +1,15 @@\n> +# SPDX-License-Identifier: GPL-2.0-or-later\n> +#\n> +# Copyright (C) 2022, Paul Elder <paul.elder@ideasonboard.com>\n> +#\n> +# generator.py - Base class for a generator to convert dict to tuning file\n> +\n> +from pathlib import Path\n> +\n> +\n> +class Generator(object):\n> +    def __init__(self):\n> +        pass\n> +\n> +    def write(self, output_path: Path, output_dict: dict, output_order: list):\n> +        raise NotImplementedError\n> diff --git a/utils/tuning/libtuning/modules/__init__.py b/utils/tuning/libtuning/modules/__init__.py\n> new file mode 100644\n> index 00000000..e69de29b\n> diff --git a/utils/tuning/libtuning/modules/module.py b/utils/tuning/libtuning/modules/module.py\n> new file mode 100644\n> index 00000000..cb213154\n> --- /dev/null\n> +++ b/utils/tuning/libtuning/modules/module.py\n> @@ -0,0 +1,33 @@\n> +# SPDX-License-Identifier: GPL-2.0-or-later\n> +#\n> +# Copyright (C) 2022, Paul Elder <paul.elder@ideasonboard.com>\n> +#\n> +# module.py - Base class for algorithm-specific tuning modules\n> +\n> +\n> +# @var type Type of the module. Defined in the base module.\n> +# @var out_name The key that will be used for the algorithm in the algorithms\n> +#               dictionary in the tuning output file\n> +# @var hr_name Human-readable module name, mostly for debugging\n> +class Module(object):\n> +    type = 'base'\n> +    hr_name = 'Base Module'\n> +    out_name = 'GenericAlgorithm'\n> +\n> +    def __init__(self):\n> +        pass\n> +\n> +    def validate_config(self, config: dict) -> bool:\n> +        raise NotImplementedError\n> +\n> +    # @brief Do the module's processing\n> +    # @param args argparse arguments\n> +    # @param config Full configuration from the input configuration file\n> +    # @param images List of images to process\n> +    # @param outputs The outputs of all modules that were executed before this\n> +    #                module. Note that this is an input parameter, and the\n> +    #                output of this module should be returned directly\n> +    # @return Result of the module's processing. It may be empty. None\n> +    #         indicates failure and that the result should not be used.\n> +    def process(self, args, config: dict, images: list, outputs: dict) -> dict:\n> +        raise NotImplementedError\n> diff --git a/utils/tuning/libtuning/parsers/__init__.py b/utils/tuning/libtuning/parsers/__init__.py\n> new file mode 100644\n> index 00000000..e69de29b\n> diff --git a/utils/tuning/libtuning/parsers/parser.py b/utils/tuning/libtuning/parsers/parser.py\n> new file mode 100644\n> index 00000000..a17d8d71\n> --- /dev/null\n> +++ b/utils/tuning/libtuning/parsers/parser.py\n> @@ -0,0 +1,21 @@\n> +# SPDX-License-Identifier: GPL-2.0-or-later\n> +#\n> +# Copyright (C) 2022, Paul Elder <paul.elder@ideasonboard.com>\n> +#\n> +# parser.py - Base class for a parser for a specific format of config file\n> +\n> +class Parser(object):\n> +    def __init__(self):\n> +        pass\n> +\n> +    # @brief Parse a config file into a config dict\n> +    # @details The config dict shall have one key 'general' with a dict value\n> +    #          for general configuration options, and all other entries shall\n> +    #          have the module as the key with its configuration options (as a\n> +    #          dict) as the value. The config dict shall prune entries that are\n> +    #          for modules that are not in @a modules.\n> +    # @param config (str) Path to config file\n> +    # @param modules (list) List of modules\n> +    # @return (dict, list) Configuration and list of modules to disable\n> +    def parse(self, config_file: str, modules: list) -> (dict, list):\n> +        raise NotImplementedError","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 17D6ABE08B\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 23 Nov 2022 01:38:54 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 838ED63314;\n\tWed, 23 Nov 2022 02:38:53 +0100 (CET)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id B951361F2B\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 23 Nov 2022 02:38:51 +0100 (CET)","from pendragon.ideasonboard.com (62-78-145-57.bb.dnainternet.fi\n\t[62.78.145.57])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 14DDB88F;\n\tWed, 23 Nov 2022 02:38:51 +0100 (CET)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1669167533;\n\tbh=kmMK6/Qxjb4thampau2odbAGqx/VTja0fVeeUxva5Bw=;\n\th=Date:To:References:In-Reply-To:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc:\n\tFrom;\n\tb=jccncjsWT7acBcxskCSAUq+vTGFrHbCGXRBSO2q+e9je+T+KB8j7cJ8vtrQ7aVHea\n\t3iIfUagkZf3ZGq8EDjWwsSQRR1qbu5j3qwEsLviq7i79cInacKmFffTMJ0XHsOwa5/\n\tJcgAGkmLxXMuktYv7ijDVI+SHMb4ckRdm9hU8A8/LWfIrt2AfKrmAhVkPmJxaTb+qD\n\tuh1gfVyntDeqfB/HDUZG6Z2jWigCJbzUXJji+/lWitE/lyOHUPJeDRhN8UMZTWjqd/\n\tuSi4/kbte8iSDhzNEP5zM14pSJrlZtK6zjb1lZDxhXUdktnv47FTcKe3KK3wgEDaHu\n\tWk6rNn+PwRdmQ==","v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1669167531;\n\tbh=kmMK6/Qxjb4thampau2odbAGqx/VTja0fVeeUxva5Bw=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=rVT9LjTxAtENPa3aKKttzv/RNMg5t0Dt7IU6AwrlIHdp+vVen7YlmYgg9xbvRIdo2\n\t0sq/kV3uc95HA3syYvwBQBUQ8KRm9+aEmCATmBm0i/pokI3HsApIP+6pJsdsSBijq+\n\t2ul9MV9ewmgjKlXj2yFwSL9qhX1a6TnSUkjcQRb8="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"rVT9LjTx\"; dkim-atps=neutral","Date":"Wed, 23 Nov 2022 03:38:35 +0200","To":"Paul Elder <paul.elder@ideasonboard.com>","Message-ID":"<Y315myQqG8k8oj7v@pendragon.ideasonboard.com>","References":"<20221110173154.488445-1-paul.elder@ideasonboard.com>\n\t<20221110173154.488445-4-paul.elder@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20221110173154.488445-4-paul.elder@ideasonboard.com>","Subject":"Re: [libcamera-devel] [PATCH v3 03/12] utils: tuning: libtuning:\n\tImplement extensible components of libtuning","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","From":"Laurent Pinchart via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>","Reply-To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]