Export functions
Last updated
Last updated
optimum.exporters.tflite.export
( model: TFPreTrainedModelconfig: TFLiteConfigoutput: Pathtask: typing.Optional[str] = Nonepreprocessor: typing.Union[transformers.tokenization_utils_base.PreTrainedTokenizerBase, transformers.image_processing_utils.BaseImageProcessor, NoneType] = Nonequantization_config: typing.Optional[ForwardRef('TFLiteQuantizationConfig')] = None ) β Tuple[List[str], List[str]]
Parameters
model (TFPreTrainedModel
) β The model to export.
config () β The TFLite configuration associated with the exported model.
output (Path
) β Directory to store the exported TFLite model.
task (Optional[str]
, defaults to None
) β The task of the model. If left unspecified the task will be inferred automatically. Only needed for static quantization.
preprocessor (Optional[Preprocessor]
, defaults to None
) β The preprocessor associated to the model. This is used for preprocessing the dataset before feeding data to the model during calibration.
quantization_config (Optional[TFLiteQuantizationConfig]
, defaults to None
) β The dataclass containing all the needed information to perform quantization.
Returns
Tuple[List[str], List[str]]
A tuple with an ordered list of the modelβs inputs, and the named inputs from the TFLite configuration.
Exports a TensorFlow model to a TensorFlow Lite model.
optimum.exporters.tflite.validate_model_outputs
( config: TFLiteConfigreference_model: TFPreTrainedModeltflite_model_path: Pathtflite_named_outputs: typing.List[str]atol: typing.Optional[float] = None )
Parameters
reference_model (~TFPreTrainedModel
) β The model used for the export.
tflite_model_path (Path
) β The path to the exported model.
tflite_named_outputs (List[str]
) β The names of the outputs to check.
atol (Optional[float]
, defaults to None
) β The absolute tolerance in terms of outputs difference between the reference and the exported model.
Raises
ValueError
ValueError
β If the outputs shapes or values do not match between the reference and the exported model.
Validates the export by checking that the outputs from both the reference and the exported model match.
config ( β The configuration used to export the model.