oa::ml::matrix::scaled_dot_product_attention

Apply standard scaled dot-product attention to [B*H, S, D/H] values. additive_mask, when present, is detached F32 [B*H*S, S] storage. Causal visibility is applied without materializing another mask. Errors Returns an error unless Q, K, and V are equal nonempty same-engine F32 rank-three matrices, the optional mask matches their flattened score rows, or runtime recording fails.

FnRust public API

Function Documentation

pub fn scaled_dot_product_attention( query: &Matrix, key: &Matrix, value: &Matrix, additive_mask: Option<&Matrix>, scale: f32, causal: bool ) -> Result<Matrix>
Apply standard scaled dot-product attention to [B*H, S, D/H] values. additive_mask, when present, is detached F32 [B*H*S, S] storage. Causal visibility is applied without materializing another mask. Errors Returns an error unless Q, K, and V are equal nonempty same-engine F32 rank-three matrices, the optional mask matches their flattened score rows, or runtime recording fails.