Skip to content

Commit

Permalink
correct the dimension comment of matrix multiplication (#11494)
Browse files Browse the repository at this point in the history
Co-authored-by: Frederik Bode <[email protected]>
  • Loading branch information
fredo838 and fredo838 authored Apr 30, 2021
1 parent f37f2ad commit b43e3f9
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/transformers/models/longformer/modeling_longformer.py
Original file line number Diff line number Diff line change
Expand Up @@ -814,7 +814,7 @@ def _sliding_chunks_query_key_matmul(self, query: torch.Tensor, key: torch.Tenso
# matrix multiplication
# bcxd: batch_size * num_heads x chunks x 2window_overlap x head_dim
# bcyd: batch_size * num_heads x chunks x 2window_overlap x head_dim
# bcxy: batch_size * num_heads x chunks x 2window_overlap x window_overlap
# bcxy: batch_size * num_heads x chunks x 2window_overlap x 2window_overlap
diagonal_chunked_attention_scores = torch.einsum("bcxd,bcyd->bcxy", (query, key)) # multiply

# convert diagonals into columns
Expand Down

0 comments on commit b43e3f9

Please sign in to comment.