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
CpuStorageA 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).