diff options
author | Gergely Nagy <gergely.nagy@arm.com> | 2023-11-21 12:29:38 +0000 |
---|---|---|
committer | Gergely Nagy <gergely.nagy@arm.com> | 2023-12-07 17:09:31 +0000 |
commit | 54eec806272b7574a0757c77a913a369a9ecdc70 (patch) | |
tree | 2e6484b857b2a68279a2707dbb21e5c26685f4e2 /src/mlia/nn/tensorflow/tflite_compat.py | |
parent | 7c50f1d6367186c03a282ac7ecb8fca0f905ba30 (diff) | |
download | mlia-54eec806272b7574a0757c77a913a369a9ecdc70.tar.gz |
MLIA-835 Invalid JSON output
TFLiteConverter was producing log messages in the output that was not
possible to capture and redirect to logging.
The solution/workaround is to run it as a subprocess.
This change required some refactoring around existing invocations of
the converter.
Change-Id: I394bd0d49d36e6686cfcb9d658e4aad05326cb87
Signed-off-by: Gergely Nagy <gergely.nagy@arm.com>
Diffstat (limited to 'src/mlia/nn/tensorflow/tflite_compat.py')
-rw-r--r-- | src/mlia/nn/tensorflow/tflite_compat.py | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/src/mlia/nn/tensorflow/tflite_compat.py b/src/mlia/nn/tensorflow/tflite_compat.py index 2b29879..497d5b1 100644 --- a/src/mlia/nn/tensorflow/tflite_compat.py +++ b/src/mlia/nn/tensorflow/tflite_compat.py @@ -1,4 +1,4 @@ -# 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 """Functions for checking TensorFlow Lite compatibility.""" from __future__ import annotations @@ -14,7 +14,7 @@ from typing import List import tensorflow as tf from tensorflow.lite.python import convert -from mlia.nn.tensorflow.utils import get_tflite_converter +from mlia.nn.tensorflow.tflite_convert import convert_to_tflite from mlia.utils.logging import redirect_raw_output TF_VERSION_MAJOR, TF_VERSION_MINOR, _ = (int(s) for s in tf.version.VERSION.split(".")) @@ -115,7 +115,6 @@ class TFLiteChecker: """Check TensorFlow Lite compatibility for the provided model.""" try: logger.debug("Check TensorFlow Lite compatibility for %s", model) - converter = get_tflite_converter(model, quantized=self.quantized) # there is an issue with intercepting TensorFlow output # not all output could be captured, for now just intercept @@ -123,7 +122,7 @@ class TFLiteChecker: with redirect_raw_output( logging.getLogger("tensorflow"), stdout_level=None ): - converter.convert() + convert_to_tflite(model, self.quantized) except convert.ConverterError as err: return self._process_convert_error(err) except Exception as err: # pylint: disable=broad-except |