<br />

<button value="stable" default="">See Stable</button> <button value="nightly">See Nightly</button>

<br />

|---|
| [![](https://www.tensorflow.org/images/GitHub-Mark-32px.png) View source on GitHub](https://github.com/tensorflow/tensorflow/blob/v2.21.0/tensorflow/lite/python/lite.py#L112-L167) |

Enum defining the optimizations to apply when generating a tflite model.

#### View aliases


**Compat aliases for migration**

See
[Migration guide](https://www.tensorflow.org/guide/migrate) for
more details.

[`tf.compat.v1.lite.Optimize`](https://www.tensorflow.org/api_docs/python/tf/lite/Optimize.md.txt)

<br />

DEFAULT
The default optimization strategy that enables post-training quantization.
The type of post-training quantization that will be used is dependent on
the other converter options supplied. Refer to the
[documentation](https://ai.google.dev/edge/litert/models/post_training_quantization)
for further information on the types available and how to use them.

OPTIMIZE_FOR_SIZE
Deprecated. Does the same as DEFAULT.

OPTIMIZE_FOR_LATENCY
Deprecated. Does the same as DEFAULT.

EXPERIMENTAL_SPARSITY
Experimental flag, subject to change.

```python
Enable optimization by taking advantage of the sparse model weights
trained with pruning.

The converter will inspect the sparsity pattern of the model weights and
do its best to improve size and latency.
The flag can be used alone to optimize float32 models with sparse weights.
It can also be used together with the DEFAULT optimization mode to
optimize quantized models with sparse weights.
```

<br />

<br />

<br />

| ## Class Variables ||
|---|---|
| DEFAULT | `<Optimize.DEFAULT: 'DEFAULT'>` |
| EXPERIMENTAL_SPARSITY | `<Optimize.EXPERIMENTAL_SPARSITY: 'EXPERIMENTAL_SPARSITY'>` |
| OPTIMIZE_FOR_LATENCY | `<Optimize.OPTIMIZE_FOR_LATENCY: 'OPTIMIZE_FOR_LATENCY'>` |
| OPTIMIZE_FOR_SIZE | `<Optimize.OPTIMIZE_FOR_SIZE: 'OPTIMIZE_FOR_SIZE'>` |

<br />