Optimum
  • 🌍OVERVIEW
    • Optimum
    • Installation
    • Quick tour
    • Notebooks
    • 🌍CONCEPTUAL GUIDES
      • Quantization
  • 🌍HABANA
    • BOINC AI Optimum Habana
    • Installation
    • Quickstart
    • 🌍TUTORIALS
      • Overview
      • Single-HPU Training
      • Distributed Training
      • Run Inference
      • Stable Diffusion
      • LDM3D
    • 🌍HOW-TO GUIDES
      • Overview
      • Pretraining Transformers
      • Accelerating Training
      • Accelerating Inference
      • How to use DeepSpeed
      • Multi-node Training
    • 🌍CONCEPTUAL GUIDES
      • What are Habana's Gaudi and HPUs?
    • 🌍REFERENCE
      • Gaudi Trainer
      • Gaudi Configuration
      • Gaudi Stable Diffusion Pipeline
      • Distributed Runner
  • 🌍INTEL
    • BOINC AI Optimum Intel
    • Installation
    • 🌍NEURAL COMPRESSOR
      • Optimization
      • Distributed Training
      • Reference
    • 🌍OPENVINO
      • Models for inference
      • Optimization
      • Reference
  • 🌍AWS TRAINIUM/INFERENTIA
    • BOINC AI Optimum Neuron
  • 🌍FURIOSA
    • BOINC AI Optimum Furiosa
    • Installation
    • 🌍HOW-TO GUIDES
      • Overview
      • Modeling
      • Quantization
    • 🌍REFERENCE
      • Models
      • Configuration
      • Quantization
  • 🌍ONNX RUNTIME
    • Overview
    • Quick tour
    • 🌍HOW-TO GUIDES
      • Inference pipelines
      • Models for inference
      • How to apply graph optimization
      • How to apply dynamic and static quantization
      • How to accelerate training
      • Accelerated inference on NVIDIA GPUs
    • 🌍CONCEPTUAL GUIDES
      • ONNX And ONNX Runtime
    • 🌍REFERENCE
      • ONNX Runtime Models
      • Configuration
      • Optimization
      • Quantization
      • Trainer
  • 🌍EXPORTERS
    • Overview
    • The TasksManager
    • 🌍ONNX
      • Overview
      • 🌍HOW-TO GUIDES
        • Export a model to ONNX
        • Add support for exporting an architecture to ONNX
      • 🌍REFERENCE
        • ONNX configurations
        • Export functions
    • 🌍TFLITE
      • Overview
      • 🌍HOW-TO GUIDES
        • Export a model to TFLite
        • Add support for exporting an architecture to TFLite
      • 🌍REFERENCE
        • TFLite configurations
        • Export functions
  • 🌍TORCH FX
    • Overview
    • 🌍HOW-TO GUIDES
      • Optimization
    • 🌍CONCEPTUAL GUIDES
      • Symbolic tracer
    • 🌍REFERENCE
      • Optimization
  • 🌍BETTERTRANSFORMER
    • Overview
    • 🌍TUTORIALS
      • Convert Transformers models to use BetterTransformer
      • How to add support for new architectures?
  • 🌍LLM QUANTIZATION
    • GPTQ quantization
  • 🌍UTILITIES
    • Dummy input generators
    • Normalized configurations
Powered by GitBook
On this page
  • Configuration classes for TFLite export
  • Base classes
  • Middle-end classes
  1. EXPORTERS
  2. TFLITE
  3. REFERENCE

TFLite configurations

PreviousREFERENCENextExport functions

Last updated 1 year ago

Configuration classes for TFLite export

Base classes

class optimum.exporters.tflite.TFLiteConfig

( config: PretrainedConfigtask: strbatch_size: int = 1sequence_length: typing.Optional[int] = Nonenum_choices: typing.Optional[int] = Nonewidth: typing.Optional[int] = Noneheight: typing.Optional[int] = Nonenum_channels: typing.Optional[int] = Nonefeature_size: typing.Optional[int] = Nonenb_max_frames: typing.Optional[int] = Noneaudio_sequence_length: typing.Optional[int] = Nonepoint_batch_size: typing.Optional[int] = Nonenb_points_per_image: typing.Optional[int] = None )

Parameters

  • config (transformers.PretrainedConfig) β€” The model configuration.

  • task (str, defaults to "feature-extraction") β€” The task the model should be exported for.

  • The rest of the arguments are used to specify the shape of the inputs the model can take. β€”

  • They are required or not depending on the model the TFLiteConfig is designed for. β€”

Base class for TFLite exportable model describing metadata on how to export the model through the TFLite format.

Class attributes:

  • NORMALIZED_CONFIG_CLASS (Type) β€” A class derived from specifying how to normalize the model config.

  • DUMMY_INPUT_GENERATOR_CLASSES (Tuple[Type]) β€” A tuple of classes derived from specifying how to create dummy inputs.

  • ATOL_FOR_VALIDATION (Union[float, Dict[str, float]]) β€” A float or a dictionary mapping task names to float, where the float values represent the absolute tolerance value to use during model conversion validation.

  • MANDATORY_AXES (Tuple[Union[str, Tuple[Union[str, Tuple[str]]]]]) β€” A tuple where each element is either:

    • An axis name, for instance β€œbatch_size” or β€œsequence_length”, that indicates that the axis dimension is needed to export the model,

    • Or a tuple containing two elements:

      • The first one is either a string or a tuple of strings and specifies for which task(s) the axis is needed

      • The second one is the axis name.

    For example: MANDATORY_AXES = ("batch_size", "sequence_length", ("multiple-choice", "num_choices")) means that to export the model, the batch size and sequence length values always need to be specified, and that a value for the number of possible choices is needed when the task is multiple-choice.

inputs

( ) β†’ List[str]

Returns

List[str]

A list of input names.

List containing the names of the inputs the exported model should take.

outputs

( ) β†’ List[str]

Returns

List[str]

A list of output names.

List containing the names of the outputs the exported model should have.

generate_dummy_inputs

( ) β†’ Dict[str, tf.Tensor]

Returns

Dict[str, tf.Tensor]

A dictionary mapping input names to dummy tensors.

Generates dummy inputs that the exported model should be able to process. This method is actually used to determine the input specs that are needed for the export.

Middle-end classes

class optimum.exporters.tflite.config.TextEncoderTFliteConfig

( config: PretrainedConfigtask: strbatch_size: int = 1sequence_length: typing.Optional[int] = Nonenum_choices: typing.Optional[int] = Nonewidth: typing.Optional[int] = Noneheight: typing.Optional[int] = Nonenum_channels: typing.Optional[int] = Nonefeature_size: typing.Optional[int] = Nonenb_max_frames: typing.Optional[int] = Noneaudio_sequence_length: typing.Optional[int] = Nonepoint_batch_size: typing.Optional[int] = Nonenb_points_per_image: typing.Optional[int] = None )

Handles encoder-based text architectures.

class optimum.exporters.tflite.config.VisionTFLiteConfig

( config: PretrainedConfigtask: strbatch_size: int = 1sequence_length: typing.Optional[int] = Nonenum_choices: typing.Optional[int] = Nonewidth: typing.Optional[int] = Noneheight: typing.Optional[int] = Nonenum_channels: typing.Optional[int] = Nonefeature_size: typing.Optional[int] = Nonenb_max_frames: typing.Optional[int] = Noneaudio_sequence_length: typing.Optional[int] = Nonepoint_batch_size: typing.Optional[int] = Nonenb_points_per_image: typing.Optional[int] = None )

Handles vision architectures.

🌍
🌍
🌍
<source>
NormalizedConfig
DummyInputGenerator
<source>
<source>
<source>
<source>
<source>