From 9323b2526c2fe3fa7c139f4998c6f27bd71b50bb Mon Sep 17 00:00:00 2001 From: Jong Wook Kim Date: Thu, 29 Dec 2022 23:53:31 -0700 Subject: [PATCH] Revert "saving the qk matrix in the attention module for convenience" This reverts commit 68e44bd83ce6c3e352f74b266aa39d8b649af9e3. --- whisper/model.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/whisper/model.py b/whisper/model.py index 820d3c105..ca3928eca 100644 --- a/whisper/model.py +++ b/whisper/model.py @@ -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, @@ -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)