-
Notifications
You must be signed in to change notification settings - Fork 31.9k
Fix -1e4 as attn mask #17306
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 -1e4 as attn mask #17306
Changes from all commits
0322ea5
eda3054
78cb386
5aaa4f9
47cc6af
1cc0b23
3861fe0
217a1df
2e5c050
51a577d
3201a0f
3da95f9
b018a51
4faab4a
a2b419c
bcf7536
73b5e65
5dc2a3f
25eac91
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -728,7 +728,7 @@ def forward( | |
|
|
||
| extended_attention_mask = attention_mask.unsqueeze(1).unsqueeze(2) | ||
| extended_attention_mask = extended_attention_mask.to(dtype=self.dtype) # fp16 compatibility | ||
| extended_attention_mask = (1.0 - extended_attention_mask) * -10000.0 | ||
| extended_attention_mask = (1.0 - extended_attention_mask) * torch.finfo(self.dtype).min | ||
|
||
| head_mask = self.get_head_mask(head_mask, self.config.num_hidden_layers) | ||
|
|
||
| embedding_output = self.embeddings( | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a
dtypeargument, so we can use it inLayoutLMv3ModelUh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The other 2 changes (not shown above)
https://github.com/huggingface/transformers/blob/de8beb96c1d0d323d5d09a85438b47b47a52b0ac/src/transformers/modeling_utils.py#L729-L730
https://github.com/huggingface/transformers/blob/de8beb96c1d0d323d5d09a85438b47b47a52b0ac/src/transformers/modeling_utils.py#L744-L745