mlx.core.from_dlpack

Contents

mlx.core.from_dlpack#

from_dlpack(x: DLPackCompatible, /, *, copy: bool | None = None) array#

Create an array from an object that supports DLPack.

Parameters:
  • x – Input object implementing __dlpack__ and __dlpack_device__.

  • 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 imports preserve the DLPack strides.

Returns:

An array containing the input data.

Return type:

array