mlx.core.ones

Contents

mlx.core.ones#

ones(shape: int | Sequence[int], dtype: Dtype | None = float32, *, stream: None | Stream | Device = None) array#

Construct an array of ones.

Parameters:
  • shape (int or list(int)) – The shape of the output array.

  • dtype (Dtype, optional) – Data type of the output array. If unspecified the output type defaults to float32.

Returns:

The array of ones with the specified shape.

Return type:

array