请按照下方说明实现 linear_attention()。
B, H <= 2;S <= 32;D ∈ {8, 16},全为 float32。
基础用例
正确性调用
linear_attention(tensor[1, 1, 8, 8] [-0.291792, 0.652902, -0.419756, 0.043179, -0.969664, 1.63643, …], tensor[1, 1, 8, 8] [0.234659, -0.765131, -0.989625, -0.112521, -0.294496, 0.855219, …], tensor[1, 1, 8, 8] [-1.17137, -0.171715, -1.22916, 0.257945, -1.27142, 0.679378, …])
预期结果
tensor[1, 1, 8, 8] [0.285565, 0.06861, -0.495318, -0.326552, -0.647164, 0.296067, …]
运行会检查可见示例,提交会运行完整的隐藏测试。
登录并提交后,你的提交记录会显示在这里。