aboutsummaryrefslogtreecommitdiff
path: root/src/mlia/devices/ethosu/performance.py
diff options
context:
space:
mode:
authorDmitrii Agibov <dmitrii.agibov@arm.com>2022-11-18 16:34:03 +0000
committerDmitrii Agibov <dmitrii.agibov@arm.com>2022-11-29 14:44:13 +0000
commit37959522a805a5e23c930ed79aac84920c3cb208 (patch)
tree484af1240a93c955a72ce2e452432383b6704b56 /src/mlia/devices/ethosu/performance.py
parent5568f9f000d673ac53e710dcc8991fec6e8a5488 (diff)
downloadmlia-37959522a805a5e23c930ed79aac84920c3cb208.tar.gz
Move backends functionality into separate modules
- Move backend management/executor code into module backend_core - Create separate module for each backend in "backend" module - Move each backend into corresponding module - Split Vela wrapper into several submodules Change-Id: If01b6774aab6501951212541cc5d7f5aa7c97e95
Diffstat (limited to 'src/mlia/devices/ethosu/performance.py')
-rw-r--r--src/mlia/devices/ethosu/performance.py25
1 files changed, 15 insertions, 10 deletions
diff --git a/src/mlia/devices/ethosu/performance.py b/src/mlia/devices/ethosu/performance.py
index 431dd89..8051d6e 100644
--- a/src/mlia/devices/ethosu/performance.py
+++ b/src/mlia/devices/ethosu/performance.py
@@ -9,8 +9,13 @@ from enum import Enum
from pathlib import Path
from typing import Union
-import mlia.backend.manager as backend_manager
-import mlia.tools.vela_wrapper as vela
+import mlia.backend.vela.compiler as vela_comp
+import mlia.backend.vela.performance as vela_perf
+from mlia.backend.corstone.performance import DeviceInfo
+from mlia.backend.corstone.performance import estimate_performance
+from mlia.backend.corstone.performance import ModelInfo
+from mlia.backend.install import is_supported
+from mlia.backend.install import supported_backends
from mlia.core.context import Context
from mlia.core.performance import PerformanceEstimator
from mlia.devices.ethosu.config import EthosUConfiguration
@@ -133,7 +138,7 @@ class VelaPerformanceEstimator(
else model
)
- vela_perf_metrics = vela.estimate_performance(
+ vela_perf_metrics = vela_perf.estimate_performance(
model_path, self.device.compiler_options
)
@@ -177,17 +182,17 @@ class CorstonePerformanceEstimator(
f"{model_path.stem}_vela.tflite"
)
- vela.optimize_model(
+ vela_comp.optimize_model(
model_path, self.device.compiler_options, optimized_model_path
)
- model_info = backend_manager.ModelInfo(model_path=optimized_model_path)
- device_info = backend_manager.DeviceInfo(
+ model_info = ModelInfo(model_path=optimized_model_path)
+ device_info = DeviceInfo(
device_type=self.device.target, # type: ignore
mac=self.device.mac,
)
- corstone_perf_metrics = backend_manager.estimate_performance(
+ corstone_perf_metrics = estimate_performance(
model_info, device_info, self.backend
)
@@ -218,10 +223,10 @@ class EthosUPerformanceEstimator(
if backends is None:
backends = ["Vela"] # Only Vela is always available as default
for backend in backends:
- if backend != "Vela" and not backend_manager.is_supported(backend):
+ if backend != "Vela" and not is_supported(backend):
raise ValueError(
f"Unsupported backend '{backend}'. "
- f"Only 'Vela' and {backend_manager.supported_backends()} "
+ f"Only 'Vela' and {supported_backends()} "
"are supported."
)
self.backends = set(backends)
@@ -241,7 +246,7 @@ class EthosUPerformanceEstimator(
if backend == "Vela":
vela_estimator = VelaPerformanceEstimator(self.context, self.device)
memory_usage = vela_estimator.estimate(tflite_model)
- elif backend in backend_manager.supported_backends():
+ elif backend in supported_backends():
corstone_estimator = CorstonePerformanceEstimator(
self.context, self.device, backend
)