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
cb966e64
Unverified
Commit
cb966e64
authored
Nov 04, 2020
by
Patrick von Platen
Committed by
GitHub
Nov 04, 2020
Browse files
[Generate Test] fix greedy generate test (#8293)
* fix greedy generate test * delet ipdb
parent
734afa37
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
4 deletions
+7
-4
tests/test_generation_utils.py
tests/test_generation_utils.py
+7
-4
No files found.
tests/test_generation_utils.py
View file @
cb966e64
...
@@ -140,10 +140,6 @@ class GenerationTesterMixin:
...
@@ -140,10 +140,6 @@ class GenerationTesterMixin:
# check `generate()` and `greedy_search()` are equal
# check `generate()` and `greedy_search()` are equal
kwargs
=
{}
kwargs
=
{}
if
model
.
config
.
is_encoder_decoder
:
if
model
.
config
.
is_encoder_decoder
:
encoder_outputs
,
input_ids
,
attention_mask
=
self
.
_get_encoder_outputs
(
model
,
input_ids
,
attention_mask
)
kwargs
[
"encoder_outputs"
]
=
encoder_outputs
max_length
=
4
max_length
=
4
output_ids_generate
=
model
.
generate
(
output_ids_generate
=
model
.
generate
(
...
@@ -154,6 +150,13 @@ class GenerationTesterMixin:
...
@@ -154,6 +150,13 @@ class GenerationTesterMixin:
max_length
=
max_length
,
max_length
=
max_length
,
**
logits_process_kwargs
,
**
logits_process_kwargs
,
)
)
if
model
.
config
.
is_encoder_decoder
:
encoder_outputs
,
input_ids
,
attention_mask
=
self
.
_get_encoder_outputs
(
model
,
input_ids
,
attention_mask
)
kwargs
[
"encoder_outputs"
]
=
encoder_outputs
with
torch
.
no_grad
():
with
torch
.
no_grad
():
output_ids_greedy
=
model
.
greedy_search
(
output_ids_greedy
=
model
.
greedy_search
(
input_ids
,
input_ids
,
...
...
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