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
1c9648c4
Unverified
Commit
1c9648c4
authored
Feb 01, 2022
by
Suraj Patil
Committed by
GitHub
Feb 01, 2022
Browse files
[M2M100, XGLM] fix positional emb resize (#15444)
parent
2ca62683
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
2 additions
and
2 deletions
+2
-2
src/transformers/models/m2m_100/modeling_m2m_100.py
src/transformers/models/m2m_100/modeling_m2m_100.py
+1
-1
src/transformers/models/xglm/modeling_xglm.py
src/transformers/models/xglm/modeling_xglm.py
+1
-1
No files found.
src/transformers/models/m2m_100/modeling_m2m_100.py
View file @
1c9648c4
...
...
@@ -170,7 +170,7 @@ class M2M100SinusoidalPositionalEmbedding(nn.Module):
position_ids
=
self
.
create_position_ids_from_inputs_embeds
(
inputs_embeds
)
# expand embeddings if needed
max_pos
=
self
.
padding_idx
+
1
+
seq_len
max_pos
=
self
.
padding_idx
+
1
+
seq_len
+
past_key_values_length
if
max_pos
>
self
.
weights
.
size
(
0
):
self
.
make_weights
(
max_pos
+
self
.
offset
,
self
.
embedding_dim
,
self
.
padding_idx
)
...
...
src/transformers/models/xglm/modeling_xglm.py
View file @
1c9648c4
...
...
@@ -214,7 +214,7 @@ class XGLMSinusoidalPositionalEmbedding(nn.Module):
position_ids
=
self
.
create_position_ids_from_inputs_embeds
(
inputs_embeds
)
# expand embeddings if needed
max_pos
=
self
.
padding_idx
+
1
+
seq_len
max_pos
=
self
.
padding_idx
+
1
+
seq_len
+
past_key_values_length
if
max_pos
>
self
.
weights
.
size
(
0
):
self
.
make_weights
(
max_pos
+
self
.
offset
,
self
.
embedding_dim
,
self
.
padding_idx
)
...
...
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