aboutsummaryrefslogtreecommitdiff
path: root/src/mlia/core/data_collection.py
blob: 43b6d1cc53a957bbb86c12cda7c43d1bd451f75f (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
# SPDX-FileCopyrightText: Copyright 2022, Arm Limited and/or its affiliates.
# SPDX-License-Identifier: Apache-2.0
"""Module for data collection.

This module contains base classes for the first stage
of the ML Inference Advisor workflow - data collection.
"""
from abc import abstractmethod

from mlia.core.common import DataItem
from mlia.core.common import NamedEntity
from mlia.core.mixins import ContextMixin
from mlia.core.mixins import ParameterResolverMixin


class DataCollector(NamedEntity):
    """Base class for the data collection.

    Data collection is the first step in the process of the advice
    generation.

    Different implementations of this class can provide various
    information about model or device. This information is being used
    at later stages.
    """

    @abstractmethod
    def collect_data(self) -> DataItem:
        """Collect data."""


class ContextAwareDataCollector(DataCollector, ContextMixin, ParameterResolverMixin):
    """Context aware data collector.

    This class makes easier access to the Context object. Context object could
    be automatically injected during workflow configuration.
    """