diff options
author | Hugues Kamba-Mpiana <hugues.kambampiana@arm.com> | 2024-03-04 16:01:55 +0000 |
---|---|---|
committer | Alex Tawse <alex.tawse@arm.com> | 2024-03-06 10:16:32 +0000 |
commit | fea932fb535e0eb07868795b7bfab08b731d98f6 (patch) | |
tree | 5ff351c3a6f0c201bd5b588870a3edaec1df5537 /build_default.py | |
parent | d95563da49c0ca626028a0afe1acf49bc81fd6d0 (diff) | |
download | ml-embedded-evaluation-kit-fea932fb535e0eb07868795b7bfab08b731d98f6.tar.gz |
use-case-resources: Enable user provided metadata
* An optional argument has been added to the
`set_up_default_resources.py` Python script to allow
passing of a user defined use case resources metadata JSON file.
This shortens the build time by only downloading the resources the
end user is interested in. It also shortens the optimization part
which takes additional minutes as it is done for all models and for
all the specified NPU configurations.
* Adding changes to comply with Pylint
* Adding --use-case argument in `set_up_default_resources.py` to
restrict setting up resources to the specified use cases.
Signed-off-by: Hugues Kamba-Mpiana <hugues.kambampiana@arm.com>
Change-Id: I8d38249d8a0b52e66c26e5e74c03657e29f979b0
Signed-off-by: Alex Tawse <alex.tawse@arm.com>
Diffstat (limited to 'build_default.py')
-rwxr-xr-x | build_default.py | 56 |
1 files changed, 30 insertions, 26 deletions
diff --git a/build_default.py b/build_default.py index 907bf4d..5adff22 100755 --- a/build_default.py +++ b/build_default.py @@ -1,5 +1,5 @@ #!/usr/bin/env python3 -# SPDX-FileCopyrightText: Copyright 2021-2023 Arm Limited and/or its affiliates <open-source-office@arm.com> +# SPDX-FileCopyrightText: Copyright 2021-2024 Arm Limited and/or its affiliates <open-source-office@arm.com> # SPDX-License-Identifier: Apache-2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -25,25 +25,36 @@ import sys import threading from argparse import ArgumentDefaultsHelpFormatter from argparse import ArgumentParser -from collections import namedtuple +from dataclasses import dataclass from pathlib import Path +from set_up_default_resources import SetupArgs from set_up_default_resources import default_npu_config_names from set_up_default_resources import get_default_npu_config_from_name from set_up_default_resources import set_up_resources from set_up_default_resources import valid_npu_config_names -BuildArgs = namedtuple( - "BuildArgs", - [ - "toolchain", - "download_resources", - "run_vela_on_models", - "npu_config_name", - "make_jobs", - "make_verbose", - ], -) + +@dataclass(frozen=True) +class BuildArgs: + """ + Args used to build the project. + + Attributes: + toolchain (str) : Specifies if 'gnu' or 'arm' toolchain needs to be used. + download_resources (bool) : Specifies if 'Download resources' step is performed. + run_vela_on_models (bool) : Only if `download_resources` is True, specifies whether to + run Vela on downloaded models. + npu_config_name (str) : Ethos-U NPU configuration name. See "valid_npu_config_names" + make_jobs (int) : The number of make jobs to use (`-j` flag). + make_verbose (bool) : Runs make with VERBOSE=1. + """ + toolchain: str + download_resources: bool + run_vela_on_models: bool + npu_config_name: str + make_jobs: int + make_verbose: bool class PipeLogging(threading.Thread): @@ -182,16 +193,7 @@ def run(args: BuildArgs): Parameters: ---------- - args (BuildArgs) : Parsed set of build args expecting: - - toolchain - - download_resources - - run_vela_on_models - - np_config_name - toolchain (str) : Specifies if 'gnu' or 'arm' toolchain needs to be used. - download_resources (bool) : Specifies if 'Download resources' step is performed. - run_vela_on_models (bool) : Only if `download_resources` is True, specifies if - run vela on downloaded models. - npu_config_name(str) : Ethos-U NPU configuration name. See "valid_npu_config_names" + args (BuildArgs) : Arguments used to build the project """ current_file_dir = Path(__file__).parent.resolve() @@ -202,11 +204,13 @@ def run(args: BuildArgs): # 2. Download models if specified if args.download_resources is True: logging.info("Downloading resources.") - env_path = set_up_resources( + setup_args = SetupArgs( run_vela_on_models=args.run_vela_on_models, - additional_npu_config_names=(args.npu_config_name,), - additional_requirements_file=current_file_dir / "scripts" / "py" / "requirements.txt" + additional_npu_config_names=[args.npu_config_name], + additional_requirements_file=current_file_dir / "scripts" / "py" / "requirements.txt", + use_case_resources_file=current_file_dir / "scripts" / "py" / "use_case_resources.json", ) + env_path = set_up_resources(setup_args) # 3. Build default configuration logging.info("Building default configuration.") |