mlx.core.asarray

Contents

mlx.core.asarray#

asarray(a: scalar | array | Sequence | DLPackCompatible, dtype: Dtype | None = None, *, copy: bool | None = None) array#

Convert the input to an array.

Parameters:
  • a – Input data.

  • dtype (Dtype, optional) – The desired data-type for the array.

  • copy (bool, optional) – Whether to copy the input. If True, always copy. If False, never copy. If None, share memory when possible and copy otherwise. Zero-copy DLPack imports preserve the DLPack strides.

Returns:

An array interpretation of the input.

Return type:

array

Raises:

ValueError – If copy is False and a copy is required.