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
224bde91
Unverified
Commit
224bde91
authored
Jun 10, 2022
by
Yih-Dar
Committed by
GitHub
Jun 10, 2022
Browse files
Avoid GPU OOM for a TF Rag test (#17638)
Co-authored-by:
ydshieh
<
ydshieh@users.noreply.github.com
>
parent
39e14614
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
8 deletions
+15
-8
tests/models/rag/test_modeling_tf_rag.py
tests/models/rag/test_modeling_tf_rag.py
+15
-8
No files found.
tests/models/rag/test_modeling_tf_rag.py
View file @
224bde91
...
@@ -838,13 +838,6 @@ class TFRagModelIntegrationTests(unittest.TestCase):
...
@@ -838,13 +838,6 @@ class TFRagModelIntegrationTests(unittest.TestCase):
input_ids
=
input_dict
.
input_ids
input_ids
=
input_dict
.
input_ids
attention_mask
=
input_dict
.
attention_mask
attention_mask
=
input_dict
.
attention_mask
output_ids
=
rag_token
.
generate
(
input_ids
,
attention_mask
=
attention_mask
,
)
outputs
=
tokenizer
.
batch_decode
(
output_ids
,
skip_special_tokens
=
True
)
EXPECTED_OUTPUTS
=
[
EXPECTED_OUTPUTS
=
[
" albert einstein"
,
" albert einstein"
,
" september 22, 2017"
,
" september 22, 2017"
,
...
@@ -855,7 +848,21 @@ class TFRagModelIntegrationTests(unittest.TestCase):
...
@@ -855,7 +848,21 @@ class TFRagModelIntegrationTests(unittest.TestCase):
" 7.1. 2"
,
" 7.1. 2"
,
" 13"
,
" 13"
,
]
]
self
.
assertListEqual
(
outputs
,
EXPECTED_OUTPUTS
)
# Split into 2 batches of 4 examples to avoid GPU OOM.
output_ids
=
rag_token
.
generate
(
input_ids
[:
4
],
attention_mask
=
attention_mask
[:
4
],
)
outputs
=
tokenizer
.
batch_decode
(
output_ids
,
skip_special_tokens
=
True
)
self
.
assertListEqual
(
outputs
,
EXPECTED_OUTPUTS
[:
4
])
output_ids
=
rag_token
.
generate
(
input_ids
[
4
:],
attention_mask
=
attention_mask
[
4
:],
)
outputs
=
tokenizer
.
batch_decode
(
output_ids
,
skip_special_tokens
=
True
)
self
.
assertListEqual
(
outputs
,
EXPECTED_OUTPUTS
[
4
:])
@
slow
@
slow
def
test_rag_sequence_generate_batch
(
self
):
def
test_rag_sequence_generate_batch
(
self
):
...
...
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