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
c6c9db3d
Unverified
Commit
c6c9db3d
authored
Nov 02, 2022
by
Yih-Dar
Committed by
GitHub
Nov 02, 2022
Browse files
Fix gradient checkpoint test in encoder-decoder (#20017)
Co-authored-by:
ydshieh
<
ydshieh@users.noreply.github.com
>
parent
a6b77598
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
1 deletion
+5
-1
tests/models/encoder_decoder/test_modeling_encoder_decoder.py
...s/models/encoder_decoder/test_modeling_encoder_decoder.py
+5
-1
No files found.
tests/models/encoder_decoder/test_modeling_encoder_decoder.py
View file @
c6c9db3d
...
...
@@ -618,8 +618,10 @@ class EncoderDecoderMixin:
)
model
=
EncoderDecoderModel
(
encoder
=
encoder_model
,
decoder
=
decoder_model
)
model
.
t
rain
(
)
model
.
t
o
(
torch_device
)
model
.
gradient_checkpointing_enable
()
model
.
train
()
model
.
config
.
decoder_start_token_id
=
0
model
.
config
.
pad_token_id
=
0
...
...
@@ -629,6 +631,8 @@ class EncoderDecoderMixin:
"labels"
:
inputs_dict
[
"labels"
],
"decoder_input_ids"
:
inputs_dict
[
"decoder_input_ids"
],
}
model_inputs
=
{
k
:
v
.
to
(
torch_device
)
for
k
,
v
in
model_inputs
.
items
()}
loss
=
model
(
**
model_inputs
).
loss
loss
.
backward
()
...
...
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