aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Klimczak <benjamin.klimczak@arm.com>2022-06-23 10:42:43 +0100
committerBenjamin Klimczak <benjamin.klimczak@arm.com>2022-06-23 10:42:43 +0100
commit7faf2c4763f299ee53b1ed100025ba50021c8313 (patch)
tree42fdcf5e24033f776153f353394308eff99b06e5
parent9097397073133ab4f61da329010839f638978462 (diff)
downloadmlia-7faf2c4763f299ee53b1ed100025ba50021c8313.tar.gz
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
-rw-r--r--src/mlia/nn/tensorflow/utils.py4
1 files changed, 2 insertions, 2 deletions
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