Skip to content

Commit

Permalink
Revert "saving the qk matrix in the attention module for convenience"
Browse files Browse the repository at this point in the history
This reverts commit 68e44bd.
  • Loading branch information
jongwook committed Dec 30, 2022
1 parent 68e44bd commit 9323b25
Showing 1 changed file with 0 additions and 3 deletions.
3 changes: 0 additions & 3 deletions whisper/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ def __init__(self, n_state: int, n_head: int):
self.key = Linear(n_state, n_state, bias=False)
self.value = Linear(n_state, n_state)
self.out = Linear(n_state, n_state)
self.last_qk = None

def forward(
self,
Expand Down Expand Up @@ -97,8 +96,6 @@ def qkv_attention(self, q: Tensor, k: Tensor, v: Tensor, mask: Optional[Tensor]
if mask is not None:
qk = qk + mask[:n_ctx, :n_ctx]

self.last_qk = qk.detach()

w = F.softmax(qk.float(), dim=-1).to(q.dtype)
return (w @ v).permute(0, 2, 1, 3).flatten(start_dim=2)

Expand Down

0 comments on commit 9323b25

Please sign in to comment.