aboutsummaryrefslogtreecommitdiff
path: root/src/mlia/target/cortex_a/handlers.py
diff options
context:
space:
mode:
authorDmitrii Agibov <dmitrii.agibov@arm.com>2022-11-18 17:21:09 +0000
committerDmitrii Agibov <dmitrii.agibov@arm.com>2022-11-29 14:44:13 +0000
commit6a88ee5315b4ce5b023370c1e55e48bf9f2b6f67 (patch)
tree88edabf90228724f4fe2944b0ab23859d824a880 /src/mlia/target/cortex_a/handlers.py
parenta34163c9d9a5cc0416bcaea2ebf8383bda9d505c (diff)
downloadmlia-6a88ee5315b4ce5b023370c1e55e48bf9f2b6f67.tar.gz
Rename modules
- Rename module "mlia.devices" into "mlia.target" - Rename module "mlia.target.ethosu" into "mlia.target.ethos_u" - Rename module "mlia.target.cortexa" into "mlia.target.cortex_a" - Rename and update tests Change-Id: I6dca7c8646d881f739fb6b5914d1cc7e45e63dc2
Diffstat (limited to 'src/mlia/target/cortex_a/handlers.py')
-rw-r--r--src/mlia/target/cortex_a/handlers.py39
1 files changed, 39 insertions, 0 deletions
diff --git a/src/mlia/target/cortex_a/handlers.py b/src/mlia/target/cortex_a/handlers.py
new file mode 100644
index 0000000..b2d5faa
--- /dev/null
+++ b/src/mlia/target/cortex_a/handlers.py
@@ -0,0 +1,39 @@
+# SPDX-FileCopyrightText: Copyright 2022, Arm Limited and/or its affiliates.
+# SPDX-License-Identifier: Apache-2.0
+"""Event handler."""
+from __future__ import annotations
+
+import logging
+
+from mlia.core.events import CollectedDataEvent
+from mlia.core.handlers import WorkflowEventsHandler
+from mlia.core.typing import PathOrFileLike
+from mlia.nn.tensorflow.tflite_compat import TFLiteCompatibilityInfo
+from mlia.target.cortex_a.events import CortexAAdvisorEventHandler
+from mlia.target.cortex_a.events import CortexAAdvisorStartedEvent
+from mlia.target.cortex_a.operators import CortexACompatibilityInfo
+from mlia.target.cortex_a.reporters import cortex_a_formatters
+
+logger = logging.getLogger(__name__)
+
+
+class CortexAEventHandler(WorkflowEventsHandler, CortexAAdvisorEventHandler):
+ """CLI event handler."""
+
+ def __init__(self, output: PathOrFileLike | None = None) -> None:
+ """Init event handler."""
+ super().__init__(cortex_a_formatters, output)
+
+ def on_collected_data(self, event: CollectedDataEvent) -> None:
+ """Handle CollectedDataEvent event."""
+ data_item = event.data_item
+
+ if isinstance(data_item, CortexACompatibilityInfo):
+ self.reporter.submit(data_item.operators, delay_print=True)
+
+ if isinstance(data_item, TFLiteCompatibilityInfo) and not data_item.compatible:
+ self.reporter.submit(data_item, delay_print=True)
+
+ def on_cortex_a_advisor_started(self, event: CortexAAdvisorStartedEvent) -> None:
+ """Handle CortexAAdvisorStarted event."""
+ self.reporter.submit(event.device)