mlx.core.clip

Contents

mlx.core.clip#

clip(a: array, /, a_min: scalar | array | None, a_max: scalar | array | None, *, stream: None | Stream | Device = None) array#

Clip the values of the array between the given minimum and maximum.

If either a_min or a_max are None, then corresponding edge is ignored. At least one of a_min and a_max cannot be None. The input a and the limits must broadcast with one another.

Parameters:
  • a (array) – Input array.

  • a_min (scalar or array or None) – Minimum value to clip to.

  • a_max (scalar or array or None) – Maximum value to clip to.

Returns:

The clipped array.

Return type:

array