one more comment on attention

This commit is contained in:
Andrej Karpathy 2024-04-11 21:49:14 +00:00
parent 9710163a60
commit d680fbad25

View file

@ -221,6 +221,9 @@ void attention_forward(float* out, float* preatt, float* att,
// preatt, att are (B, NH, T, T). NH = number of heads, T = sequence length
// that holds the pre-attention and post-attention scores (used in backward)
// output is (B, T, C)
// attention is the only layer that mixes information across time
// every other operation is applied at every (b,t) position independently
// (and of course, no layer mixes information across batch)
int C3 = C*3;
int hs = C / NH; // head size
float scale = 1.0 / sqrtf(hs);