Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix attn_mask shape in MHA docstrings #441

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions torchmultimodal/modules/layers/multi_head_attention.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,9 @@ def forward(
"""
Args:
query (Tensor): input query of shape bsz x seq_len x embed_dim
attn_mask (optional Tensor): attention mask of shape bsz x seq_len x seq_len. Two types of masks are supported.
attn_mask (optional Tensor): attention mask of shape bsz x num_heads x seq_len x seq_len.
Note that the num_heads dimension can equal 1 and the mask will be broadcasted to all heads.
Two types of masks are supported.
A boolean mask where a value of True indicates that the element should take part in attention.
A float mask of the same type as query that is added to the attention score.
is_causal (bool): If true, does causal attention masking. attn_mask should be set to None if this is set to True
Expand Down Expand Up @@ -124,7 +126,8 @@ def forward(
query (Tensor): input query of shape bsz x target_seq_len x embed_dim
key (Tensor): key of shape bsz x source_seq_len x embed_dim
value (Tensor): value of shape bsz x source_seq_len x embed_dim
attn_mask (optional Tensor): Attention mask of shape bsz x target_seq_len x source_seq_len.
attn_mask (optional Tensor): Attention mask of shape bsz x num_heads x target_seq_len x source_seq_len.
Note that the num_heads dimension can equal 1 and the mask will be broadcasted to all heads.
Two types of masks are supported. A boolean mask where a value of True
indicates that the element *should* take part in attention.
A float mask of the same type as query, key, value that is added to the attention score.
Expand Down
Loading