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
1f13ba81
Unverified
Commit
1f13ba81
authored
May 17, 2022
by
Patrick von Platen
Committed by
GitHub
May 17, 2022
Browse files
correct opt (#17301)
parent
349f1c85
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
3 additions
and
7 deletions
+3
-7
tests/models/opt/test_modeling_opt.py
tests/models/opt/test_modeling_opt.py
+3
-7
No files found.
tests/models/opt/test_modeling_opt.py
View file @
1f13ba81
...
...
@@ -22,7 +22,7 @@ import unittest
import
timeout_decorator
# noqa
from
transformers
import
OPTConfig
,
is_torch_available
from
transformers.testing_utils
import
require_sentencepiece
,
require_tokenizers
,
require_torch
,
slow
,
torch_device
from
transformers.testing_utils
import
require_torch
,
slow
,
torch_device
from
...generation.test_generation_utils
import
GenerationTesterMixin
from
...test_configuration_common
import
ConfigTester
...
...
@@ -266,25 +266,21 @@ def _long_tensor(tok_lst):
@
require_torch
@
require_sentencepiece
@
require_tokenizers
class
OPTModelIntegrationTests
(
unittest
.
TestCase
):
@
slow
def
test_inference_no_head
(
self
):
model
=
OPTModel
.
from_pretrained
(
"facebook/opt-350m"
).
to
(
torch_device
)
input_ids
=
_long_tensor
([[
0
,
31414
,
232
,
328
,
740
,
1140
,
12695
,
69
,
46078
,
1588
,
2
]])
attention_mask
=
input_ids
.
ne
(
model
.
config
.
pad_token_id
)
with
torch
.
no_grad
():
output
=
model
(
input_ids
=
input_ids
,
attention_mask
=
attention_mask
).
last_hidden_state
output
=
model
(
input_ids
=
input_ids
).
last_hidden_state
expected_shape
=
torch
.
Size
((
1
,
11
,
512
))
self
.
assertEqual
(
output
.
shape
,
expected_shape
)
expected_slice
=
torch
.
tensor
(
[[
-
0.287
3
,
-
1.92
18
,
-
0.30
33
],
[
-
1.271
0
,
-
0.133
8
,
-
0.1
902
],
[
0.409
5
,
0.1
214
,
-
1.312
1
]],
device
=
torch_device
[[
-
0.28
6
7
,
-
1.92
56
,
-
0.30
62
],
[
-
1.271
1
,
-
0.133
7
,
-
0.1
897
],
[
0.4
1
09
,
0.1
187
,
-
1.31
4
2
]],
device
=
torch_device
)
self
.
assertTrue
(
torch
.
allclose
(
output
[:,
:
3
,
:
3
],
expected_slice
,
atol
=
1e-3
))
@
require_tokenizers
@
require_torch
@
slow
class
OPTEmbeddingsTest
(
unittest
.
TestCase
):
...
...
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