aboutsummaryrefslogtreecommitdiff
path: root/tests/test_devices_cortexa_advice_generation.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/test_devices_cortexa_advice_generation.py')
-rw-r--r--tests/test_devices_cortexa_advice_generation.py76
1 files changed, 70 insertions, 6 deletions
diff --git a/tests/test_devices_cortexa_advice_generation.py b/tests/test_devices_cortexa_advice_generation.py
index ead8ae6..0446f38 100644
--- a/tests/test_devices_cortexa_advice_generation.py
+++ b/tests/test_devices_cortexa_advice_generation.py
@@ -13,27 +13,91 @@ from mlia.devices.cortexa.advice_generation import CortexAAdviceProducer
from mlia.devices.cortexa.data_analysis import ModelIsCortexACompatible
from mlia.devices.cortexa.data_analysis import ModelIsNotCortexACompatible
from mlia.devices.cortexa.data_analysis import ModelIsNotTFLiteCompatible
+from mlia.devices.cortexa.operator_compatibility import ARMNN_TFLITE_DELEGATE
+from mlia.nn.tensorflow.tflite_graph import TFL_ACTIVATION_FUNCTION
+
+BACKEND_INFO = (
+ f"{ARMNN_TFLITE_DELEGATE['metadata']['backend']} "
+ f"{ARMNN_TFLITE_DELEGATE['metadata']['version']}"
+)
@pytest.mark.parametrize(
"input_data, advice_category, expected_advice",
[
[
- ModelIsNotCortexACompatible(),
+ ModelIsNotCortexACompatible(BACKEND_INFO, {"UNSUPPORTED_OP"}, {}),
AdviceCategory.OPERATORS,
[
Advice(
[
- "Some operators in the model are not compatible with Cortex-A. "
- "Please, refer to the operators table for more information."
+ "The following operators are not supported by "
+ f"{BACKEND_INFO} and will fall back to the TensorFlow "
+ "Lite runtime:",
+ " - UNSUPPORTED_OP",
]
- )
+ ),
+ Advice(
+ [
+ "Please, refer to the full table of operators above "
+ "for more information.",
+ CortexAAdviceProducer.cortex_a_disclaimer,
+ ]
+ ),
+ ],
+ ],
+ [
+ ModelIsNotCortexACompatible(
+ BACKEND_INFO,
+ {"UNSUPPORTED_OP"},
+ {
+ "CONV_2D": ModelIsNotCortexACompatible.ActivationFunctionSupport(
+ used_unsupported={TFL_ACTIVATION_FUNCTION.SIGN_BIT.name},
+ supported={"RELU"},
+ )
+ },
+ ),
+ AdviceCategory.OPERATORS,
+ [
+ Advice(
+ [
+ "The following operators are not supported by "
+ f"{BACKEND_INFO} and will fall back to the TensorFlow "
+ "Lite runtime:",
+ " - UNSUPPORTED_OP",
+ ]
+ ),
+ Advice(
+ [
+ "The fused activation functions of the following "
+ f"operators are not supported by {BACKEND_INFO}. "
+ "Please consider using one of the supported activation "
+ "functions instead:",
+ " - CONV_2D\n"
+ " - Used unsupported: {'SIGN_BIT'}\n"
+ " - Supported: {'RELU'}",
+ ]
+ ),
+ Advice(
+ [
+ "Please, refer to the full table of operators above "
+ "for more information.",
+ CortexAAdviceProducer.cortex_a_disclaimer,
+ ]
+ ),
],
],
[
- ModelIsCortexACompatible(),
+ ModelIsCortexACompatible(BACKEND_INFO),
AdviceCategory.OPERATORS,
- [Advice(["Model is fully compatible with Cortex-A."])],
+ [
+ Advice(
+ [
+ f"Model is fully compatible with {BACKEND_INFO} for Cortex-A.",
+ CortexAAdviceProducer.cortex_a_disclaimer,
+ ]
+ )
+ ],
],
[
ModelIsNotTFLiteCompatible(