Sliding Window Self-Attention
2026/3/9小于 1 分钟
Sliding Window Self-Attention
题面
实现滑动窗口自注意力:位置 i 仅对区间 [i-window_size, i+window_size] 内的键值做 softmax 加权求和,窗口外不参与。
Implementation Requirements
- Use only native features (external libraries are not permitted)
- The solve function signature must remain unchanged
- 输出写入
output
Examples
见页面两组示例(window_size=1)。
Constraints
- Q,K,V: M×d;1 ≤ M ≤ 10000;1 ≤ d ≤ 128;1 ≤ window_size ≤ 32
- float32;Performance: M = 5,000