aboutsummaryrefslogtreecommitdiff
path: root/src/mlia/core/common.py
diff options
context:
space:
mode:
authorDiego Russo <diego.russo@arm.com>2022-05-30 13:34:14 +0100
committerDiego Russo <diego.russo@arm.com>2022-05-30 13:34:14 +0100
commit0efca3cadbad5517a59884576ddb90cfe7ac30f8 (patch)
treeabed6cb6fbf3c439fc8d947f505b6a53d5daeb1e /src/mlia/core/common.py
parent0777092695c143c3a54680b5748287d40c914c35 (diff)
downloadmlia-0efca3cadbad5517a59884576ddb90cfe7ac30f8.tar.gz
Add MLIA codebase0.3.0-rc.1
Add MLIA codebase including sources and tests. Change-Id: Id41707559bd721edd114793618d12ccd188d8dbd
Diffstat (limited to 'src/mlia/core/common.py')
-rw-r--r--src/mlia/core/common.py47
1 files changed, 47 insertions, 0 deletions
diff --git a/src/mlia/core/common.py b/src/mlia/core/common.py
new file mode 100644
index 0000000..5fbad42
--- /dev/null
+++ b/src/mlia/core/common.py
@@ -0,0 +1,47 @@
+# SPDX-FileCopyrightText: Copyright 2022, Arm Limited and/or its affiliates.
+# SPDX-License-Identifier: Apache-2.0
+"""Common module.
+
+This module contains common interfaces/classess shared across
+core module.
+"""
+from abc import ABC
+from abc import abstractmethod
+from enum import Enum
+from typing import Any
+
+# This type is used as type alias for the items which are being passed around
+# in advisor workflow. There are no restrictions on the type of the
+# object. This alias used only to emphasize the nature of the input/output
+# arguments.
+DataItem = Any
+
+
+class AdviceCategory(Enum):
+ """Advice category.
+
+ Enumeration of advice categories supported by ML Inference Advisor.
+ """
+
+ OPERATORS = 1
+ PERFORMANCE = 2
+ OPTIMIZATION = 3
+ ALL = 4
+
+ @classmethod
+ def from_string(cls, value: str) -> "AdviceCategory":
+ """Resolve enum value from string value."""
+ category_names = [item.name for item in AdviceCategory]
+ if not value or value.upper() not in category_names:
+ raise Exception(f"Invalid advice category {value}")
+
+ return AdviceCategory[value.upper()]
+
+
+class NamedEntity(ABC):
+ """Entity with a name and description."""
+
+ @classmethod
+ @abstractmethod
+ def name(cls) -> str:
+ """Return name of the entity."""