aboutsummaryrefslogtreecommitdiff
path: root/src/mlia/backend/corstone/__init__.py
blob: c6c222712153d5d1ad6e744a7e6ca811c0335376 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# SPDX-FileCopyrightText: Copyright 2022-2024, Arm Limited and/or its affiliates.
# SPDX-License-Identifier: Apache-2.0
"""Corstone backend module."""
from mlia.backend.config import BackendConfiguration
from mlia.backend.config import BackendType
from mlia.backend.config import System
from mlia.backend.corstone.install import get_corstone_300_installation
from mlia.backend.corstone.install import get_corstone_310_installation
from mlia.backend.registry import registry
from mlia.core.common import AdviceCategory

# List of mutually exclusive Corstone backends ordered by priority
CORSTONE_PRIORITY = {
    "Corstone-310": get_corstone_310_installation(),
    "Corstone-300": get_corstone_300_installation(),
}


for corstone_name, installation in CORSTONE_PRIORITY.items():
    registry.register(
        corstone_name.lower(),
        BackendConfiguration(
            supported_advice=[
                AdviceCategory.COMPATIBILITY,
                AdviceCategory.PERFORMANCE,
                AdviceCategory.OPTIMIZATION,
            ],
            supported_systems=[System.LINUX_AMD64, System.LINUX_AARCH64],
            backend_type=BackendType.CUSTOM,
            installation=installation,
        ),
        pretty_name=corstone_name,
    )


def is_corstone_backend(backend_name: str) -> bool:
    """Check if backend belongs to Corstone."""
    return any(
        name in CORSTONE_PRIORITY
        for name in (backend_name, registry.pretty_name(backend_name))
    )