std1.0.0-beta-7 SafeC docs

std :: ml::attention

Function std::attention_forward

#include <std/ml/attention.h> source ยท definition

&FloatTensor attention_forward(
    const &FloatTensor Q,
    const &FloatTensor K,
    const &FloatTensor V,
)

Single-head scaled dot-product attention: softmax(Q @ K^T / sqrt(headDim)) @ V. Q: [seqLen, headDim], K/V: [kvLen, headDim] -> result: [seqLen, headDim].