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
bc9d5d91
"test/git@developer.sourcefind.cn:OpenDAS/torchaudio.git" did not exist on "df48ba36826b838ec8d986343ad0ac42964314d0"
Commit
bc9d5d91
authored
Mar 11, 2020
by
Patrick von Platen
Browse files
make all tensors half precision
parent
a332cc9f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
2 additions
and
1 deletion
+2
-1
tests/test_modeling_bart.py
tests/test_modeling_bart.py
+2
-1
No files found.
tests/test_modeling_bart.py
View file @
bc9d5d91
...
@@ -314,7 +314,8 @@ class BartHeadTests(unittest.TestCase):
...
@@ -314,7 +314,8 @@ class BartHeadTests(unittest.TestCase):
@
unittest
.
skipIf
(
torch_device
==
"cpu"
,
"Cant do half precision"
)
@
unittest
.
skipIf
(
torch_device
==
"cpu"
,
"Cant do half precision"
)
def
test_generate_fp16
(
self
):
def
test_generate_fp16
(
self
):
config
,
input_ids
,
batch_size
=
self
.
_get_config_and_data
(
output_past
=
True
)
config
,
input_ids
,
batch_size
=
self
.
_get_config_and_data
(
output_past
=
True
)
attention_mask
=
input_ids
.
ne
(
1
)
input_ids
=
input_ids
.
half
()
attention_mask
=
input_ids
.
ne
(
1
).
to
(
torch_device
).
half
()
lm_model
=
BartForConditionalGeneration
(
config
).
eval
().
to
(
torch_device
).
half
()
lm_model
=
BartForConditionalGeneration
(
config
).
eval
().
to
(
torch_device
).
half
()
lm_model
.
generate
(
input_ids
,
attention_mask
=
attention_mask
)
lm_model
.
generate
(
input_ids
,
attention_mask
=
attention_mask
)
...
...
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