Skip to content
fn

download_gpu_to_cpu

→CpuStorage
CpuStorage download_gpu_to_cpu(const GpuStorage & gpu, const int & shape)

Download a GPU array to a freshly allocated CPU buffer.

Calls arr.eval() to force materialisation of any pending lazy MLX kernels, then memcpys the contiguous data into a new CpuStorage of the requested shape.

Parameters

gpuconst GpuStorage&
Source MLX-backed storage on the GPU stream.
shapeconst Shape&
Logical shape of the result.

Returns

CpuStorage

A fresh CPU buffer. Disjoint from the GPU source — mutations do not propagate either way.

Notes

Always synchronous from the caller's perspective. The cost is dominated by the GPU graph completion (the actual memcpy is at ~100 GB/s).