std :: ml::gpu_mps
Function std::mps_sgd_update_f32_chained
int mps_sgd_update_f32_chained(
struct MpsBuf bufW,
struct MpsBuf bufGrad,
float lr,
unsigned long n,
)In-place SGD step against a persistent device buffer: w[i] -= lr* grad[i]. Both 'bufW' and 'bufGrad' are already device buffers (bufW typically from MpsBuf::upload, bufGrad typically another op's still-pending output from the same batch's backward pass) -- no 'out' parameter, since the whole point is that the updated weight never leaves the GPU. See gpu_mps.sc's comment and gpu_mps_kernels.metal's sgd_update_kernel.