pub fn kl_divergence(
ref_logits: &[f32],
cand_logits: &[f32],
scratch: &mut [f64],
) -> f64Expand description
KL-divergence D(reference ‖ candidate) between the two softmax distributions, in nats.
= Σ p_ref · (log p_ref − log p_cand), computed via log-softmax for stability. Non-negative.