attend op• 資料種類:tokens × tokens × tokens → tokens
• 呼叫: import fullseye as fs; fs.ledger.attention_linear(query, key, value, causal: 'bool' = False) -> 'np.ndarray'(要直接呼叫實作,import llmcore; llmcore.attention_linear(query, key, value, causal: 'bool' = False) -> 'np.ndarray';從台帳取用則 opsllmcore.get("attention_linear"))
拿掉 softmax 的注意力 → tokens。(QKᵀ)V == Q(KᵀV)——正是結合律本身。
Katharopoulos 等 2020。去掉 softmax 後即可使用矩陣乘法的結合律,不建立 (T, T), 只需 (d, dv) 的狀態即可。是同一個數的另一種加括號方式,所以答案一致(相對差 7.1e-16), 計算量從 O(T²d) 變為 O(Td²) —— 交叉點在 T == d(實測: T=d=64 時比為 0.9, T=1024 時為 14.6 倍)。★即使 T 取 2048,比也在 14.4 飽和。達不到公式所說的 32 倍 —— 因為二次的一側進入了頻寬瓶頸。
Args:
query: (T, d) float。
key: (S, d) float。
value: (S, dv) float。causal=True 時 S == T。
causal: 為 True 時以累積狀態只加「自己之前的部分」(循序 1 遍,線性時間)。
Returns:
tokens (T, dv) float: 沒有經過 softmax,所以不是列和為 1 的凸組合。
不是 attention_softmax 的替代,而是另一種注意力。
• 範例資料目錄(下載 URL / 授權) —— 2-D 用 skimage.data(BSD/公有領域)加合成圖,3-D 給出真實資料源(Stanford/PDS 等)的下載 URL。
• 運算子來歷與參考文獻 —— 該運算子族所依據的研究/方法出處。
• 演算法的正典(作者、年份)與用途見上面的族使用指南。
• poc_attention_identities — py -3.11 examples/poc_attention_identities.py
tokens 作為輸入)rms_norm · rope_rotate · attention_scores · attention_apply · attention_softmax · attention_tiled · attention_grouped · kv_cache_decode
attend)attention_softmax · attention_tiled · attention_grouped
*Provenance: llmcore.py — LLMCORE 運算子登記表。本條目由 tools/opdocs.py md 自動產生(請勿手動編輯)。*
© 2026 Kazufumi Furuse — Fullseye operator documentation. Licensed under Apache-2.0.