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
3ec7d4cf
"docs/vscode:/vscode.git/clone" did not exist on "9a2dabae7002258e41419491c73dd43ad61b5de7"
Unverified
Commit
3ec7d4cf
authored
Jun 27, 2022
by
Younes Belkada
Committed by
GitHub
Jun 27, 2022
Browse files
fix mask (#17837)
parent
ee0d001d
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
11 deletions
+11
-11
src/transformers/models/bloom/modeling_bloom.py
src/transformers/models/bloom/modeling_bloom.py
+11
-11
No files found.
src/transformers/models/bloom/modeling_bloom.py
View file @
3ec7d4cf
...
...
@@ -292,7 +292,9 @@ class BloomScaledSoftmax(nn.Module):
if
self
.
scale
is
not
None
:
input
=
input
*
self
.
scale
if
mask
is
not
None
:
if
mask
is
None
:
mask
=
torch
.
ones
(
input
.
shape
[
0
],
max_positions
,
dtype
=
torch
.
bool
,
device
=
input
.
device
)
mask
=
mask
.
to
(
input
.
device
)
causal_mask
=
(
torch
.
tril
(
torch
.
ones
((
max_positions
,
max_positions
),
dtype
=
torch
.
bool
))
...
...
@@ -301,8 +303,6 @@ class BloomScaledSoftmax(nn.Module):
)
mask_output
,
padded_causal_mask
=
self
.
mask_func
(
input
,
mask
,
causal_mask
)
probs
=
nn
.
functional
.
softmax
(
mask_output
,
dim
=-
1
,
dtype
=
softmax_dtype
)
*
(
~
padded_causal_mask
)
else
:
probs
=
nn
.
functional
.
softmax
(
input
,
dim
=-
1
,
dtype
=
softmax_dtype
)
if
input_in_16bit
and
self
.
softmax_in_fp32
:
probs
=
probs
.
to
(
dtype
=
input_dtype
)
...
...
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