From 7a661257b6adad0c8f53e32b42ced56a1e7d952f Mon Sep 17 00:00:00 2001 From: Benjamin Klimczak Date: Thu, 2 Feb 2023 14:02:05 +0000 Subject: MLIA-769 Expand use of target/backend registries - Use the target/backend registries to avoid hard-coded names. - Cache target profiles to avoid re-loading them Change-Id: I474b7c9ef23894e1d8a3ea06d13a37652054c62e --- src/mlia/target/ethos_u/config.py | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) (limited to 'src/mlia/target/ethos_u/config.py') diff --git a/src/mlia/target/ethos_u/config.py b/src/mlia/target/ethos_u/config.py index eb5691d..d1a2c7a 100644 --- a/src/mlia/target/ethos_u/config.py +++ b/src/mlia/target/ethos_u/config.py @@ -6,12 +6,13 @@ from __future__ import annotations import logging from typing import Any +from mlia.backend.corstone import is_corstone_backend +from mlia.backend.manager import get_available_backends from mlia.backend.vela.compiler import resolve_compiler_config from mlia.backend.vela.compiler import VelaCompilerOptions from mlia.target.config import TargetProfile from mlia.utils.filesystem import get_vela_config - logger = logging.getLogger(__name__) @@ -67,3 +68,22 @@ class EthosUConfiguration(TargetProfile): def __repr__(self) -> str: """Return string representation.""" return f"" + + +def get_default_ethos_u_backends( + supported_backends_priority_order: list[str], +) -> list[str]: + """Return default backends for Ethos-U targets.""" + available_backends = get_available_backends() + + default_backends = [] + corstone_added = False + for backend in supported_backends_priority_order: + if backend not in available_backends: + continue + if is_corstone_backend(backend): + if corstone_added: + continue # only add one Corstone backend + corstone_added = True + default_backends.append(backend) + return default_backends -- cgit v1.2.1