std :: ml::gpu_mps
Function std::mps_sum_f32
int mps_sum_f32([]const float a, []float out)out[0] = sum(a[0..n)) -- two-stage parallel reduction (grid-stride accumulate + threadgroup tree reduction, see gpu_mps_kernels.metal's sum_kernel comment), with the small per-threadgroup partial-sums array combined on the CPU after one readback. Batch-aware like mps_sub_f32/ mps_relu_f32 above: under an open batch, the CPU-side partial-sum combine can't run until mps_batch_end()'s single wait, so it's deferred into a registered finalize callback instead of happening inline here — see gpu_mps.sc's implementation comment.