Skip to main content

sgd_momentum_step

Function sgd_momentum_step 

Source
pub fn sgd_momentum_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 momentum (non-Nesterov).

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

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