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
8af1970e
"...resnet50_tensorflow.git" did not exist on "14f78b2cbd9424638d76e1c8ae09390e2213e637"
Unverified
Commit
8af1970e
authored
Aug 31, 2020
by
Sam Shleifer
Committed by
GitHub
Aug 31, 2020
Browse files
Fix marian slow test (#6854)
parent
bbdba0a7
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
4 deletions
+8
-4
tests/test_modeling_marian.py
tests/test_modeling_marian.py
+8
-4
No files found.
tests/test_modeling_marian.py
View file @
8af1970e
...
...
@@ -38,6 +38,7 @@ if is_torch_available():
convert_hf_name_to_opus_name
,
convert_opus_name_to_hf_name
,
)
from
transformers.modeling_bart
import
shift_tokens_right
from
transformers.pipelines
import
TranslationPipeline
...
...
@@ -116,18 +117,21 @@ class TestMarian_EN_DE_More(MarianIntegrationTest):
expected_ids
=
[
38
,
121
,
14
,
697
,
38848
,
0
]
model_inputs
:
dict
=
self
.
tokenizer
.
prepare_seq2seq_batch
(
src
,
tgt_texts
=
tgt
).
to
(
torch_device
)
self
.
assertListEqual
(
expected_ids
,
model_inputs
.
input_ids
[
0
].
tolist
())
desired_keys
=
{
"input_ids"
,
"attention_mask"
,
"decoder_input_ids"
,
"decoder_attention_mask"
,
"labels"
,
}
self
.
assertSetEqual
(
desired_keys
,
set
(
model_inputs
.
keys
()))
model_inputs
[
"decoder_input_ids"
]
=
shift_tokens_right
(
model_inputs
.
labels
,
self
.
tokenizer
.
pad_token_id
)
model_inputs
[
"return_dict"
]
=
True
model_inputs
[
"use_cache"
]
=
False
with
torch
.
no_grad
():
logits
,
*
enc_feature
s
=
self
.
model
(
**
model_inputs
)
max_indices
=
logits
.
argmax
(
-
1
)
output
s
=
self
.
model
(
**
model_inputs
)
max_indices
=
outputs
.
logits
.
argmax
(
-
1
)
self
.
tokenizer
.
batch_decode
(
max_indices
)
def
test_unk_support
(
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