<br />

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

Performs a safe saturating cast of `value` to `dtype`.

#### View aliases


**Main aliases**

[`tf.saturate_cast`](https://www.tensorflow.org/api_docs/python/tf/dtypes/saturate_cast)
**Compat aliases for migration**

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

[`tf.compat.v1.dtypes.saturate_cast`](https://www.tensorflow.org/api_docs/python/tf/dtypes/saturate_cast), [`tf.compat.v1.saturate_cast`](https://www.tensorflow.org/api_docs/python/tf/dtypes/saturate_cast)

<br />

    tf.dtypes.saturate_cast(
        value, dtype, name=None
    )

### Used in the notebooks

| Used in the tutorials |
|---|
| - [Learned data compression](https://www.tensorflow.org/tutorials/generative/data_compression) |

This function casts the input to `dtype` without overflow. If
there is a danger that values would over or underflow in the cast, this op
applies the appropriate clamping before the cast. See [`tf.cast`](https://www.tensorflow.org/api_docs/python/tf/cast) for more
details.

<br />

<br />

<br />

| ## Args ||
|---|---|
| `value` | A `Tensor`. |
| `dtype` | The desired output `DType`. |
| `name` | A name for the operation (optional). |

<br />

<br />

<br />

<br />

| ## Returns ||
|---|---|
| `value` safely cast to `dtype`. ||

<br />