MLIA-812 Show error message for unsupported functionality

Change-Id: I68fb8c4e51046e9fc2d91ad8338718ba545209cd
diff --git a/src/mlia/target/cortex_a/advisor.py b/src/mlia/target/cortex_a/advisor.py
index 5c077fb..3c127ec 100644
--- a/src/mlia/target/cortex_a/advisor.py
+++ b/src/mlia/target/cortex_a/advisor.py
@@ -44,6 +44,16 @@
         if context.category_enabled(AdviceCategory.COMPATIBILITY):
             collectors.append(CortexAOperatorCompatibility(model, target_config))
 
+        if context.category_enabled(AdviceCategory.PERFORMANCE):
+            raise Exception(
+                "Performance estimation is currently not supported for Cortex-A."
+            )
+
+        if context.category_enabled(AdviceCategory.OPTIMIZATION):
+            raise Exception(
+                "Model optimizations are currently not supported for Cortex-A."
+            )
+
         return collectors
 
     def get_analyzers(self, context: Context) -> list[DataAnalyzer]:
diff --git a/src/mlia/target/ethos_u/advisor.py b/src/mlia/target/ethos_u/advisor.py
index 0eec6aa..714d6a4 100644
--- a/src/mlia/target/ethos_u/advisor.py
+++ b/src/mlia/target/ethos_u/advisor.py
@@ -53,9 +53,9 @@
         # Decide which one to use (taking into account the model format).
         if is_tflite_model(model):
             # TensorFlow Lite models do not support optimization (only performance)!
-            if context.advice_category == AdviceCategory.OPTIMIZATION:
+            if context.category_enabled(AdviceCategory.OPTIMIZATION):
                 raise Exception(
-                    "Command 'optimization' is not supported for TensorFlow Lite files."
+                    "Optimizations are not supported for TensorFlow Lite files."
                 )
             if context.category_enabled(AdviceCategory.PERFORMANCE):
                 collectors.append(EthosUPerformance(model, target_config, backends))
diff --git a/src/mlia/target/tosa/advisor.py b/src/mlia/target/tosa/advisor.py
index 7666df4..7859eca 100644
--- a/src/mlia/target/tosa/advisor.py
+++ b/src/mlia/target/tosa/advisor.py
@@ -43,6 +43,14 @@
         if context.category_enabled(AdviceCategory.COMPATIBILITY):
             collectors.append(TOSAOperatorCompatibility(model))
 
+        if context.category_enabled(AdviceCategory.PERFORMANCE):
+            raise Exception(
+                "Performance estimation is currently not supported for TOSA."
+            )
+
+        if context.category_enabled(AdviceCategory.OPTIMIZATION):
+            raise Exception("Model optimizations are currently not supported for TOSA.")
+
         return collectors
 
     def get_analyzers(self, context: Context) -> list[DataAnalyzer]:
diff --git a/tests/test_target_cortex_a_advisor.py b/tests/test_target_cortex_a_advisor.py
index 1788a6d..9e0082f 100644
--- a/tests/test_target_cortex_a_advisor.py
+++ b/tests/test_target_cortex_a_advisor.py
@@ -1,8 +1,11 @@
-# SPDX-FileCopyrightText: Copyright 2022, Arm Limited and/or its affiliates.
+# SPDX-FileCopyrightText: Copyright 2022-2023, Arm Limited and/or its affiliates.
 # SPDX-License-Identifier: Apache-2.0
 """Tests for Cortex-A MLIA module."""
 from pathlib import Path
 
+import pytest
+
+from mlia.core.common import AdviceCategory
 from mlia.core.context import ExecutionContext
 from mlia.core.workflow import DefaultWorkflowExecutor
 from mlia.target.cortex_a.advisor import configure_and_get_cortexa_advisor
@@ -32,3 +35,30 @@
     }
 
     assert isinstance(workflow, DefaultWorkflowExecutor)
+
+
+@pytest.mark.parametrize(
+    "category, expected_error",
+    [
+        [
+            AdviceCategory.PERFORMANCE,
+            "Performance estimation is currently not supported for Cortex-A.",
+        ],
+        [
+            AdviceCategory.OPTIMIZATION,
+            "Model optimizations are currently not supported for Cortex-A.",
+        ],
+    ],
+)
+def test_unsupported_advice_categories(
+    tmp_path: Path,
+    category: AdviceCategory,
+    expected_error: str,
+    test_tflite_model: Path,
+) -> None:
+    """Test that advisor should throw an exception for unsupported categories."""
+    with pytest.raises(Exception, match=expected_error):
+        ctx = ExecutionContext(output_dir=tmp_path, advice_category={category})
+
+        advisor = configure_and_get_cortexa_advisor(ctx, "cortex-a", test_tflite_model)
+        advisor.configure(ctx)
diff --git a/tests/test_target_ethos_u_advisor.py b/tests/test_target_ethos_u_advisor.py
index fb68800..11aefc7 100644
--- a/tests/test_target_ethos_u_advisor.py
+++ b/tests/test_target_ethos_u_advisor.py
@@ -1,9 +1,31 @@
-# SPDX-FileCopyrightText: Copyright 2022, Arm Limited and/or its affiliates.
+# SPDX-FileCopyrightText: Copyright 2022-2023, Arm Limited and/or its affiliates.
 # SPDX-License-Identifier: Apache-2.0
 """Tests for Ethos-U MLIA module."""
+from pathlib import Path
+
+import pytest
+
+from mlia.core.common import AdviceCategory
+from mlia.core.context import ExecutionContext
+from mlia.target.ethos_u.advisor import configure_and_get_ethosu_advisor
 from mlia.target.ethos_u.advisor import EthosUInferenceAdvisor
 
 
 def test_advisor_metadata() -> None:
     """Test advisor metadata."""
     assert EthosUInferenceAdvisor.name() == "ethos_u_inference_advisor"
+
+
+def test_unsupported_advice_categories(tmp_path: Path, test_tflite_model: Path) -> None:
+    """Test that advisor should throw an exception for unsupported categories."""
+    with pytest.raises(
+        Exception, match="Optimizations are not supported for TensorFlow Lite files."
+    ):
+        ctx = ExecutionContext(
+            output_dir=tmp_path, advice_category={AdviceCategory.OPTIMIZATION}
+        )
+
+        advisor = configure_and_get_ethosu_advisor(
+            ctx, "ethos-u55-256", str(test_tflite_model)
+        )
+        advisor.configure(ctx)
diff --git a/tests/test_target_tosa_advisor.py b/tests/test_target_tosa_advisor.py
index 9646c96..f4f1e36 100644
--- a/tests/test_target_tosa_advisor.py
+++ b/tests/test_target_tosa_advisor.py
@@ -6,6 +6,7 @@
 
 import pytest
 
+from mlia.core.common import AdviceCategory
 from mlia.core.context import ExecutionContext
 from mlia.core.workflow import DefaultWorkflowExecutor
 from mlia.target.tosa.advisor import configure_and_get_tosa_advisor
@@ -38,3 +39,30 @@
     }
 
     assert isinstance(workflow, DefaultWorkflowExecutor)
+
+
+@pytest.mark.parametrize(
+    "category, expected_error",
+    [
+        [
+            AdviceCategory.PERFORMANCE,
+            "Performance estimation is currently not supported for TOSA.",
+        ],
+        [
+            AdviceCategory.OPTIMIZATION,
+            "Model optimizations are currently not supported for TOSA.",
+        ],
+    ],
+)
+def test_unsupported_advice_categories(
+    tmp_path: Path,
+    category: AdviceCategory,
+    expected_error: str,
+    test_tflite_model: Path,
+) -> None:
+    """Test that advisor should throw an exception for unsupported categories."""
+    with pytest.raises(Exception, match=expected_error):
+        ctx = ExecutionContext(output_dir=tmp_path, advice_category={category})
+
+        advisor = configure_and_get_tosa_advisor(ctx, "tosa", test_tflite_model)
+        advisor.configure(ctx)