mirror of
https://github.com/karpathy/llm.c.git
synced 2026-07-27 20:25:09 -04:00
one more comment on attention
This commit is contained in:
parent
9710163a60
commit
d680fbad25
1 changed files with 3 additions and 0 deletions
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue