mlx.core.where#

mlx.core.where(condition: Union[scalar, array], x: Union[scalar, array], y: Union[scalar, array], /, *, stream: Union[None, Stream, Device] = None) array#

Select from x or y according to condition.

The condition and input arrays must be the same shape or broadcastable with each another.

Parameters:
  • condition (array) – The condition array.

  • x (array) – The input selected from where condition is True.

  • y (array) – The input selected from where condition is False.

Returns:

The output containing elements selected from x and y.

Return type:

result (array)