Fix: unsqueeze k/v when dim==2
This commit is contained in:
@@ -96,8 +96,8 @@ def dsv4_attention(
|
||||
|
||||
for h in range(n_h):
|
||||
q_h = q[h:h+1] # (1, T, hd)
|
||||
k_h = k if k.dim() == 2 else k[h:h+1] # (1, N, hd)
|
||||
v_h = v if v.dim() == 2 else v[h:h+1]
|
||||
k_h = k.unsqueeze(0) if k.dim() == 2 else k[h:h+1] # (1, N, hd)
|
||||
v_h = v.unsqueeze(0) if v.dim() == 2 else v[h:h+1] # (1, N, hd)
|
||||
|
||||
o_h = _attention_single_head(
|
||||
q_h, k_h, v_h, scale=scale,
|
||||
|
||||
Reference in New Issue
Block a user