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
c8ed1b8b
Unverified
Commit
c8ed1b8b
authored
Jul 26, 2022
by
Sylvain Gugger
Committed by
GitHub
Jul 26, 2022
Browse files
Replace false parameter by a buffer (#18259)
parent
2844c5de
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
2 additions
and
6 deletions
+2
-6
src/transformers/models/m2m_100/modeling_m2m_100.py
src/transformers/models/m2m_100/modeling_m2m_100.py
+1
-3
src/transformers/models/xglm/modeling_xglm.py
src/transformers/models/xglm/modeling_xglm.py
+1
-3
No files found.
src/transformers/models/m2m_100/modeling_m2m_100.py
View file @
c8ed1b8b
...
@@ -131,9 +131,7 @@ class M2M100SinusoidalPositionalEmbedding(nn.Module):
...
@@ -131,9 +131,7 @@ class M2M100SinusoidalPositionalEmbedding(nn.Module):
# in forward put the weights on the correct dtype and device of the param
# in forward put the weights on the correct dtype and device of the param
emb_weights
=
emb_weights
.
to
(
dtype
=
self
.
weights
.
dtype
,
device
=
self
.
weights
.
device
)
emb_weights
=
emb_weights
.
to
(
dtype
=
self
.
weights
.
dtype
,
device
=
self
.
weights
.
device
)
self
.
weights
=
nn
.
Parameter
(
emb_weights
)
self
.
register_buffer
(
"weights"
,
emb_weights
)
self
.
weights
.
requires_grad
=
False
self
.
weights
.
detach_
()
@
staticmethod
@
staticmethod
def
get_embedding
(
num_embeddings
:
int
,
embedding_dim
:
int
,
padding_idx
:
Optional
[
int
]
=
None
):
def
get_embedding
(
num_embeddings
:
int
,
embedding_dim
:
int
,
padding_idx
:
Optional
[
int
]
=
None
):
...
...
src/transformers/models/xglm/modeling_xglm.py
View file @
c8ed1b8b
...
@@ -173,9 +173,7 @@ class XGLMSinusoidalPositionalEmbedding(nn.Module):
...
@@ -173,9 +173,7 @@ class XGLMSinusoidalPositionalEmbedding(nn.Module):
# in forward put the weights on the correct dtype and device of the param
# in forward put the weights on the correct dtype and device of the param
emb_weights
=
emb_weights
.
to
(
dtype
=
self
.
weights
.
dtype
,
device
=
self
.
weights
.
device
)
emb_weights
=
emb_weights
.
to
(
dtype
=
self
.
weights
.
dtype
,
device
=
self
.
weights
.
device
)
self
.
weights
=
nn
.
Parameter
(
emb_weights
)
self
.
register_buffer
(
"weights"
,
emb_weights
)
self
.
weights
.
requires_grad
=
False
self
.
weights
.
detach_
()
@
staticmethod
@
staticmethod
def
get_embedding
(
num_embeddings
:
int
,
embedding_dim
:
int
,
padding_idx
:
Optional
[
int
]
=
None
):
def
get_embedding
(
num_embeddings
:
int
,
embedding_dim
:
int
,
padding_idx
:
Optional
[
int
]
=
None
):
...
...
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