From 7faf2c4763f299ee53b1ed100025ba50021c8313 Mon Sep 17 00:00:00 2001 From: Benjamin Klimczak Date: Thu, 23 Jun 2022 10:42:43 +0100 Subject: MLIA-545 Make quantization non-strict Use TFLITE_BUILTINS instead of TFLITE_BUILTINS_INT8 to make the quantization non-strict. Note: De facto this does not change the behavior of MLIA because the TFLITE_BUILTINS_INT8 is not correctly applied with the new quantizer. See: https://github.com/tensorflow/tensorflow/issues/56535 Change-Id: Ia0782ba22c5e9223fa10fec71c16aee60b79bb57 --- src/mlia/nn/tensorflow/utils.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/mlia') diff --git a/src/mlia/nn/tensorflow/utils.py b/src/mlia/nn/tensorflow/utils.py index 4abf6cd..b1034d9 100644 --- a/src/mlia/nn/tensorflow/utils.py +++ b/src/mlia/nn/tensorflow/utils.py @@ -71,7 +71,7 @@ def convert_to_tflite(model: tf.keras.Model, quantized: bool = False) -> Interpr if quantized: converter.optimizations = [tf.lite.Optimize.DEFAULT] converter.representative_dataset = representative_dataset(model) - converter.target_spec.supported_ops = [tf.lite.OpsSet.TFLITE_BUILTINS_INT8] + converter.target_spec.supported_ops = [tf.lite.OpsSet.TFLITE_BUILTINS] converter.inference_input_type = tf.int8 converter.inference_output_type = tf.int8 @@ -91,7 +91,7 @@ def convert_tf_to_tflite(model: str, quantized: bool = False) -> Interpreter: if quantized: converter.optimizations = [tf.lite.Optimize.DEFAULT] converter.representative_dataset = representative_tf_dataset(model) - converter.target_spec.supported_ops = [tf.lite.OpsSet.TFLITE_BUILTINS_INT8] + converter.target_spec.supported_ops = [tf.lite.OpsSet.TFLITE_BUILTINS] converter.inference_input_type = tf.int8 converter.inference_output_type = tf.int8 -- cgit v1.2.1