Skip to main content

cosine_f16

Function cosine_f16 

Source
pub fn cosine_f16<Idx: Copy + Ord>(
    x_idx: &[Idx],
    x_val: &[Half],
    y_idx: &[Idx],
    y_val: &[Half],
) -> Result<f32, LengthMismatch>
Expand description

Cosine similarity for f16 operands, clamped to [-1, 1]; 0 when either norm underflows or the operands are disjoint. Values are pre-widened once and reused for the numerator and both norms.