Skip to main content

select_and_gather_add

Function select_and_gather_add 

Source
pub fn select_and_gather_add<T: Element>(
    tangents: &[T],
    operand: &[T],
    shape: &[usize],
    w: &Window<'_>,
    ge: bool,
) -> Vec<T>
Expand description

select_and_gather_add: for each window of operand, the element of tangents at the position of the selected element of operand (ge: the first maximum, otherwise the first minimum), or 0 if the window covers no element.

Each window is reduced from (identity, 0) in row-major order, keeping the accumulated pair when select(acc, x) holds and taking the element otherwise, as JAX’s lowering to a reduce_window of pairs does; padding and holes are skipped.