|
STM32N6 NPU Deployment — Politecnico di Milano
1.0
Documentation for Neural Network Deployment on STM32N6 NPU - Politecnico di Milano 2024-2025
|
Functions | |
| None | _tflite_ptq_quantizer (tf.keras.Model model=None, tf.data.Dataset quantization_ds=None, bool fake=False, str output_dir=None, Optional[str] export_dir=None, tuple input_shape=None, str quantization_granularity=None, str quantization_input_type=None, str quantization_output_type=None, str quantization_split=None, str quantization_path=None) |
| str | quantize (DictConfig cfg=None, Optional[tf.data.Dataset] quantization_ds=None, Optional[bool] fake=False, Optional[str] float_model_path=None) |
|
private |
Perform post-training quantization on a TensorFlow Lite model.
Args:
model (tf.keras.Model): The TensorFlow model to be quantized.
quantization_ds (tf.data.Dataset): The quantization dataset if it's provided by the user else the training
dataset. Defaults to None
fake (bool): Whether to use fake data for representative dataset generation.
output_dir (str): Path to the output directory. Defaults to None.
export_dir (str): Name of the export directory. Defaults to None.
input_shape (tuple: The input shape of the model. Defaults to None.
quantization_granularity (str): 'per_tensor' or 'per_channel'. Defaults to None.
quantization_input_type (str): The quantization type for the input. Defaults to None.
quantization_output_type (str): The quantization type for the output. Defaults to None.
quantization_path (str): the quantization dataset path if it's provided by the user. Defaults to None.
quantization_split (str): The Fraction of the data to use for the quantization
Returns:
None
Definition at line 44 of file quantize.py.
Referenced by quantize().
| str quantize.quantize | ( | DictConfig | cfg = None, |
| Optional[tf.data.Dataset] | quantization_ds = None, |
||
| Optional[bool] | fake = False, |
||
| Optional[str] | float_model_path = None |
||
| ) |
Quantize the TensorFlow model with training data.
Args:
cfg (DictConfig): The configuration dictionary. Defaults to None.
quantization_ds (tf.data.Dataset): The quantization dataset if it's provided by the user else the training
dataset. Defaults to None.
fake (bool, optional): Whether to use fake data for representative dataset generation. Defaults to False.
float_model_path (str, optional): Model path to quantize
Returns:
quantized model path (str)
Definition at line 135 of file quantize.py.
References _tflite_ptq_quantizer(), and preprocess.apply_rescaling().