Skip to content

Commit

Permalink
Avoid all-zeor attnetion mask used in testing (#26469)
Browse files Browse the repository at this point in the history
fix

Co-authored-by: ydshieh <ydshieh@users.noreply.github.com>
  • Loading branch information
ydshieh and ydshieh authored Sep 29, 2023
1 parent 9b23d0d commit 3911774
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion tests/test_modeling_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -2960,7 +2960,8 @@ def ids_tensor(shape, vocab_size, rng=None, name=None):
def random_attention_mask(shape, rng=None, name=None):
attn_mask = ids_tensor(shape, vocab_size=2, rng=None, name=None)
# make sure that at least one token is attended to for each batch
attn_mask[:, -1] = 1
# we choose the 1st token so this property of `at least one being non-zero` still holds after applying causal mask
attn_mask[:, 0] = 1
return attn_mask


Expand Down

0 comments on commit 3911774

Please sign in to comment.