diff options
author | Dmitrii Agibov <dmitrii.agibov@arm.com> | 2022-09-08 14:24:39 +0100 |
---|---|---|
committer | Dmitrii Agibov <dmitrii.agibov@arm.com> | 2022-09-09 17:21:48 +0100 |
commit | f5b293d0927506c2a979a091bf0d07ecc78fa181 (patch) | |
tree | 4de585b7cb6ed34da8237063752270189a730a41 /src/mlia/core/performance.py | |
parent | cde0c6ee140bd108849bff40467d8f18ffc332ef (diff) | |
download | mlia-f5b293d0927506c2a979a091bf0d07ecc78fa181.tar.gz |
MLIA-386 Simplify typing in the source code
- Enable deferred annotations evaluation
- Use builtin types for type hints whenever possible
- Use | syntax for union types
- Rename mlia.core._typing into mlia.core.typing
Change-Id: I3f6ffc02fa069c589bdd9e8bddbccd504285427a
Diffstat (limited to 'src/mlia/core/performance.py')
-rw-r--r-- | src/mlia/core/performance.py | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/src/mlia/core/performance.py b/src/mlia/core/performance.py index 5433d5c..cb12918 100644 --- a/src/mlia/core/performance.py +++ b/src/mlia/core/performance.py @@ -1,30 +1,31 @@ # SPDX-FileCopyrightText: Copyright 2022, Arm Limited and/or its affiliates. # SPDX-License-Identifier: Apache-2.0 """Module for performance estimation.""" +from __future__ import annotations + from abc import abstractmethod from typing import Callable from typing import Generic -from typing import List from typing import TypeVar -ModelType = TypeVar("ModelType") # pylint: disable=invalid-name -PerfMetricsType = TypeVar("PerfMetricsType") # pylint: disable=invalid-name +M = TypeVar("M") # model type +P = TypeVar("P") # performance metrics -class PerformanceEstimator(Generic[ModelType, PerfMetricsType]): +class PerformanceEstimator(Generic[M, P]): """Base class for the performance estimation.""" @abstractmethod - def estimate(self, model: ModelType) -> PerfMetricsType: + def estimate(self, model: M) -> P: """Estimate performance.""" def estimate_performance( - original_model: ModelType, - estimator: PerformanceEstimator[ModelType, PerfMetricsType], - model_transformations: List[Callable[[ModelType], ModelType]], -) -> List[PerfMetricsType]: + original_model: M, + estimator: PerformanceEstimator[M, P], + model_transformations: list[Callable[[M], M]], +) -> list[P]: """Estimate performance impact. This function estimates performance impact on model performance after |