From 836efd40317a397761ec8b66e3f4398faac43ad0 Mon Sep 17 00:00:00 2001 From: Annie Tallund Date: Thu, 12 Jan 2023 07:49:06 +0100 Subject: MLIA-770 List all available backends - Rely on target and backend registry for support information - Make above information less Ethos(TM)-U specific Change-Id: I8dbfb84401016412a3d719a84eb592f21d79c46b --- src/mlia/backend/corstone/performance.py | 4 ++-- src/mlia/backend/install.py | 24 +++++------------------- src/mlia/backend/registry.py | 14 +++++++++++++- 3 files changed, 20 insertions(+), 22 deletions(-) (limited to 'src/mlia/backend') diff --git a/src/mlia/backend/corstone/performance.py b/src/mlia/backend/corstone/performance.py index 5aabfa5..531f0cd 100644 --- a/src/mlia/backend/corstone/performance.py +++ b/src/mlia/backend/corstone/performance.py @@ -1,4 +1,4 @@ -# SPDX-FileCopyrightText: Copyright 2022, Arm Limited and/or its affiliates. +# SPDX-FileCopyrightText: Copyright 2022-2023, Arm Limited and/or its affiliates. # SPDX-License-Identifier: Apache-2.0 """Module for backend integration.""" from __future__ import annotations @@ -25,7 +25,7 @@ logger = logging.getLogger(__name__) class DeviceInfo: """Device information.""" - device_type: Literal["ethos-u55", "ethos-u65"] + device_type: Literal["Ethos-U55", "Ethos-U65", "ethos-u55", "ethos-u65"] mac: int diff --git a/src/mlia/backend/install.py b/src/mlia/backend/install.py index eea3403..37a277b 100644 --- a/src/mlia/backend/install.py +++ b/src/mlia/backend/install.py @@ -1,4 +1,4 @@ -# SPDX-FileCopyrightText: Copyright 2022, Arm Limited and/or its affiliates. +# SPDX-FileCopyrightText: Copyright 2022-2023, Arm Limited and/or its affiliates. # SPDX-License-Identifier: Apache-2.0 """Module for installation process.""" from __future__ import annotations @@ -26,17 +26,20 @@ from mlia.utils.filesystem import temp_directory from mlia.utils.filesystem import working_directory from mlia.utils.py_manager import get_package_manager - logger = logging.getLogger(__name__) # Mapping backend -> device_type -> system_name _SUPPORTED_SYSTEMS = { "Corstone-300": { + "Ethos-U55": "Corstone-300: Cortex-M55+Ethos-U55", + "Ethos-U65": "Corstone-300: Cortex-M55+Ethos-U65", "ethos-u55": "Corstone-300: Cortex-M55+Ethos-U55", "ethos-u65": "Corstone-300: Cortex-M55+Ethos-U65", }, "Corstone-310": { + "Ethos-U55": "Corstone-310: Cortex-M85+Ethos-U55", + "Ethos-U65": "Corstone-310: Cortex-M85+Ethos-U65", "ethos-u55": "Corstone-310: Cortex-M85+Ethos-U55", "ethos-u65": "Corstone-310: Cortex-M85+Ethos-U65", }, @@ -61,23 +64,6 @@ def get_application_name(system_name: str) -> str: return _SYSTEM_TO_APP_MAP[system_name] -def is_supported(backend: str, device_type: str | None = None) -> bool: - """Check if the backend (and optionally device type) is supported.""" - if device_type is None: - return backend in _SUPPORTED_SYSTEMS - - try: - get_system_name(backend, device_type) - return True - except KeyError: - return False - - -def supported_backends() -> list[str]: - """Get a list of all backends supported by the backend manager.""" - return list(_SUPPORTED_SYSTEMS.keys()) - - def get_all_system_names(backend: str) -> list[str]: """Get all systems supported by the backend.""" return list(_SUPPORTED_SYSTEMS.get(backend, {}).values()) diff --git a/src/mlia/backend/registry.py b/src/mlia/backend/registry.py index 6a0da74..988c8c3 100644 --- a/src/mlia/backend/registry.py +++ b/src/mlia/backend/registry.py @@ -1,4 +1,4 @@ -# SPDX-FileCopyrightText: Copyright 2022, Arm Limited and/or its affiliates. +# SPDX-FileCopyrightText: Copyright 2022-2023, Arm Limited and/or its affiliates. # SPDX-License-Identifier: Apache-2.0 """Backend module.""" from mlia.backend.config import BackendConfiguration @@ -6,3 +6,15 @@ from mlia.utils.registry import Registry # All supported targets are required to be registered here. registry = Registry[BackendConfiguration]() + + +def get_supported_backends() -> list: + """Get a list of all backends supported by the backend manager.""" + return sorted(list(registry.items.keys())) + + +def get_supported_systems() -> dict: + """Get a list of all systems supported by the backend manager.""" + return { + backend: config.supported_systems for backend, config in registry.items.items() + } -- cgit v1.2.1