![]() |
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.
Args | |
---|---|
optimizations
|
A list of optimizations to apply when converting the model.
If not set, use [Optimize.DEFAULT] by default.
|
representative_data
|
A DataLoader holding representative data 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. Allows
for a different type for input arrays. Defaults to None. If set, must be
be {tf.float32, tf.uint8, tf.int8} .
|
inference_output_type
|
Target data type of real-number output arrays.
Allows for a different type for output arrays. Defaults to None. If set,
must be {tf.float32, tf.uint8, tf.int8} .
|
supported_ops
|
Set of OpsSet options supported by the device. Used to Set converter.target_spec.supported_ops. |
supported_types
|
List of types for constant values on the target device. Supported values are types exported by lite.constants. Frequently, an optimization choice is driven by the most compact (i.e. smallest) type in this list (default [constants.FLOAT]). |
experimental_new_quantizer
|
Whether to enable experimental new quantizer. |
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.