Skip to main content

sgd_nesterov_step

Function sgd_nesterov_step 

Source
pub fn sgd_nesterov_step<T: Triton, const BLOCK_SIZE: i32>(
    params_ptr: T::Pointer<f32>,
    grad_ptr: T::Pointer<f32>,
    buf_ptr: T::Pointer<f32>,
    n_elements: i32,
    lr: f32,
    momentum: f32,
    dampening: f32,
    weight_decay: f32,
)
where T::I32Tensor: Tensor<i32, 1> + Comparison<i32, BoolTensor = T::BoolTensor>, T::Pointer<f32>: AddOffsets<i32, 1, T::I32Tensor, Output = T::Tensor<T::Pointer<f32>>>,
Expand description

SGD step with Nesterov momentum.

buf   = momentum * buf + (1 - dampening) * (g + weight_decay * p)
g_nes = (g + weight_decay * p) + momentum * buf
p     = p - lr * g_nes

Grid: [ceil(n_elements / BLOCK_SIZE), 1, 1].