aboutsummaryrefslogtreecommitdiff
path: root/src/mlia/devices/cortexa/advice_generation.py
diff options
context:
space:
mode:
authorDmitrii Agibov <dmitrii.agibov@arm.com>2022-11-09 11:23:50 +0000
committerDmitrii Agibov <dmitrii.agibov@arm.com>2022-11-15 12:55:49 +0000
commitef73bb773df214f3f33f8e4ca7d276041106cad2 (patch)
tree313d5bbcea9574dd4fa026639443548766cf2b91 /src/mlia/devices/cortexa/advice_generation.py
parentbb20d22509a304c76f849486fe15e3acd7667fb8 (diff)
downloadmlia-ef73bb773df214f3f33f8e4ca7d276041106cad2.tar.gz
MLIA-685 Warn about custom operators in SavedModel/Keras models
- Add new error types for the TensorFlow Lite compatibility check - Try to detect custom operators in SavedModel/Keras models - Add warning to the advice about models with custom operators Change-Id: I2f65474eecf2788110acc43585fa300eda80e21b
Diffstat (limited to 'src/mlia/devices/cortexa/advice_generation.py')
-rw-r--r--src/mlia/devices/cortexa/advice_generation.py38
1 files changed, 37 insertions, 1 deletions
diff --git a/src/mlia/devices/cortexa/advice_generation.py b/src/mlia/devices/cortexa/advice_generation.py
index 186f489..3d2f106 100644
--- a/src/mlia/devices/cortexa/advice_generation.py
+++ b/src/mlia/devices/cortexa/advice_generation.py
@@ -7,9 +7,11 @@ from mlia.core.advice_generation import advice_category
from mlia.core.advice_generation import FactBasedAdviceProducer
from mlia.core.common import AdviceCategory
from mlia.core.common import DataItem
+from mlia.devices.cortexa.data_analysis import ModelHasCustomOperators
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.data_analysis import TFLiteCompatibilityCheckFailed
class CortexAAdviceProducer(FactBasedAdviceProducer):
@@ -92,17 +94,25 @@ class CortexAAdviceProducer(FactBasedAdviceProducer):
"The following operators are not natively "
"supported by TensorFlow Lite: "
f"{', '.join(data_item.flex_ops)}.",
+ "Using select TensorFlow operators in TensorFlow Lite model "
+ "requires special initialization of TFLiteConverter and "
+ "TensorFlow Lite run-time.",
"Please refer to the TensorFlow documentation for more details.",
+ "Note, such models are not supported by the ML Inference Advisor.",
]
)
if data_item.custom_ops:
self.add_advice(
[
- "The following operators are custom and not natively "
+ "The following operators appears to be custom and not natively "
"supported by TensorFlow Lite: "
f"{', '.join(data_item.custom_ops)}.",
+ "Using custom operators in TensorFlow Lite model "
+ "requires special initialization of TFLiteConverter and "
+ "TensorFlow Lite run-time.",
"Please refer to the TensorFlow documentation for more details.",
+ "Note, such models are not supported by the ML Inference Advisor.",
]
)
@@ -113,3 +123,29 @@ class CortexAAdviceProducer(FactBasedAdviceProducer):
"Please refer to the table for more details.",
]
)
+
+ @produce_advice.register
+ @advice_category(AdviceCategory.ALL, AdviceCategory.OPERATORS)
+ def handle_tflite_check_failed(
+ self, _data_item: TFLiteCompatibilityCheckFailed
+ ) -> None:
+ """Advice for the failed TensorFlow Lite compatibility checks."""
+ self.add_advice(
+ [
+ "Model could not be converted into TensorFlow Lite format.",
+ "Please refer to the table for more details.",
+ ]
+ )
+
+ @produce_advice.register
+ @advice_category(AdviceCategory.ALL, AdviceCategory.OPERATORS)
+ def handle_model_has_custom_operators(
+ self, _data_item: ModelHasCustomOperators
+ ) -> None:
+ """Advice for the models with custom operators."""
+ self.add_advice(
+ [
+ "Models with custom operators require special initialization "
+ "and currently are not supported by the ML Inference Advisor.",
+ ]
+ )