Skip to content

Commit

Permalink
update util to work for additive attention mask (#86)
Browse files Browse the repository at this point in the history
Co-authored-by: Diana Liskovich <dianaml@devfair0471.h2.fair>
  • Loading branch information
dianaml0 and Diana Liskovich authored Nov 9, 2021
1 parent 03d58e1 commit cf46d43
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion xformers/components/attention/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,10 @@ def maybe_merge_masks(
if att_mask is None:
att_mask = key_padding_mask
# Assumption is that False means to mask.
att_mask = att_mask.logical_and(key_padding_mask)
elif att_mask.dtype == torch.bool:
att_mask = att_mask.logical_and(key_padding_mask)
else:
att_mask = att_mask.masked_fill(~key_padding_mask, float("-inf"))

return att_mask

Expand Down

0 comments on commit cf46d43

Please sign in to comment.