View source on GitHub |
Configuration for post-training quantization.
tflite_model_maker.config.QuantizationConfig(
optimizations=None,
representative_data=None,
quantization_steps=None,
inference_input_type=None,
inference_output_type=None,
supported_ops=None,
supported_types=None,
experimental_new_quantizer=None
)
Used in the notebooks
Used in the tutorials |
---|
Refer to https://www.tensorflow.org/lite/performance/post_training_quantization for different post-training quantization options.
Methods
for_dynamic
@classmethod
for_dynamic()
Creates configuration for dynamic range quantization.
for_float16
@classmethod
for_float16()
Creates configuration for float16 quantization.
for_int8
@classmethod
for_int8( representative_data, quantization_steps=DEFAULT_QUANTIZATION_STEPS, inference_input_type=tf.uint8, inference_output_type=tf.uint8, supported_ops=tf.lite.OpsSet.TFLITE_BUILTINS_INT8 )
Creates configuration for full integer quantization.
Args | |
---|---|
representative_data
|
Representative data used for post-training quantization. |
quantization_steps
|
Number of post-training quantization calibration steps to run. |
inference_input_type
|
Target data type of real-number input arrays. Used
only when is_integer_only is True. Must be in {tf.uint8, tf.int8} .
|
inference_output_type
|
Target data type of real-number output arrays. Used
only when is_integer_only is True. Must be in {tf.uint8, tf.int8} .
|
supported_ops
|
Set of tf.lite.OpsSet options, where each option
represents a set of operators supported by the target device.
|
Returns | |
---|---|
QuantizationConfig. |
get_converter_with_quantization
get_converter_with_quantization(
converter, **kwargs
)
Gets TFLite converter with settings for quantization.