aboutsummaryrefslogtreecommitdiff
path: root/src/mlia/target/cortex_a/config.py
blob: 4f33f3d178197ba88545729bcc2004f652475225 (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
# SPDX-FileCopyrightText: Copyright 2022-2023, Arm Limited and/or its affiliates.
# SPDX-License-Identifier: Apache-2.0
"""Cortex-A configuration."""
from __future__ import annotations

from typing import Any

from mlia.backend.armnn_tflite_delegate.compat import ARMNN_TFLITE_DELEGATE
from mlia.target.config import TargetProfile


class CortexAConfiguration(TargetProfile):
    """Cortex-A configuration."""

    def __init__(self, **kwargs: Any) -> None:
        """Init Cortex-A target configuration."""
        target = kwargs["target"]
        backend_config = kwargs.get("backend")
        super().__init__(target, backend_config)

        self.armnn_tflite_delegate_version = self.backend_config[
            "armnn-tflite-delegate"
        ]["version"]

    def verify(self) -> None:
        """Check the parameters."""
        super().verify()
        if self.target != "cortex-a":
            raise ValueError(f"Wrong target {self.target} for Cortex-A configuration.")

        if not self.armnn_tflite_delegate_version:
            raise ValueError("No version for ArmNN TensorFlow Lite delegate specified.")
        if self.armnn_tflite_delegate_version not in ARMNN_TFLITE_DELEGATE["ops"]:
            raise ValueError(
                f"Version '{self.armnn_tflite_delegate_version}' of "
                f"backend {ARMNN_TFLITE_DELEGATE['backend']} is not supported. "
                f"Choose from: {', '.join(ARMNN_TFLITE_DELEGATE['ops'])}"
            )