Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
chenpangpang
transformers
Commits
63c5e27e
Unverified
Commit
63c5e27e
authored
Apr 18, 2024
by
fxmarty
Committed by
GitHub
Apr 18, 2024
Browse files
Do not drop mask with SDPA for more cases (#30311)
* overlooked * style * cleaner
parent
acab997b
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
2 deletions
+6
-2
src/transformers/modeling_attn_mask_utils.py
src/transformers/modeling_attn_mask_utils.py
+6
-2
No files found.
src/transformers/modeling_attn_mask_utils.py
View file @
63c5e27e
...
@@ -319,8 +319,12 @@ def _prepare_4d_causal_attention_mask_for_sdpa(
...
@@ -319,8 +319,12 @@ def _prepare_4d_causal_attention_mask_for_sdpa(
ignore_causal_mask
=
False
ignore_causal_mask
=
False
if
attention_mask
is
None
:
if
attention_mask
is
None
:
if
sliding_window
is
None
or
key_value_length
<
sliding_window
:
if
(
ignore_causal_mask
=
not
is_tracing
not
is_tracing
and
(
query_length
==
1
or
key_value_length
==
query_length
)
and
(
sliding_window
is
None
or
key_value_length
<
sliding_window
)
):
ignore_causal_mask
=
True
elif
sliding_window
is
None
or
key_value_length
<
sliding_window
:
elif
sliding_window
is
None
or
key_value_length
<
sliding_window
:
# 4d mask is passed through
# 4d mask is passed through
if
len
(
attention_mask
.
shape
)
==
4
:
if
len
(
attention_mask
.
shape
)
==
4
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment