Skip to content
fn

wrap_mlx_array

→GpuStorage
GpuStorage wrap_mlx_array(::mlx::core::array && arr, Dtype dtype)

Wrap a caller-owned mlx::core::array into a tracked GpuStorage.

Takes ownership of arr (moves it) and packages it as a GpuStorage registered with the MemoryTracker. Used by every op method in GpuBackend to return MLX results back to Lucid.

Parameters

arrmlx::core::array&&
The MLX array to wrap. Moved-from on return.
dtypeDtype
The Lucid dtype tag to associate with the result (must match arr's MLX dtype via from_mlx_dtype).

Returns

GpuStorage

The wrapped array tracked by Python-side memory accounting.