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
7375758b
Unverified
Commit
7375758b
authored
Dec 09, 2021
by
NielsRogge
Committed by
GitHub
Dec 09, 2021
Browse files
Fix tests (#14703)
parent
68e53e6f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
5 deletions
+6
-5
tests/test_modeling_perceiver.py
tests/test_modeling_perceiver.py
+3
-2
tests/test_tokenization_perceiver.py
tests/test_tokenization_perceiver.py
+3
-3
No files found.
tests/test_modeling_perceiver.py
View file @
7375758b
...
@@ -860,7 +860,8 @@ class PerceiverModelIntegrationTest(unittest.TestCase):
...
@@ -860,7 +860,8 @@ class PerceiverModelIntegrationTest(unittest.TestCase):
self
.
assertEqual
(
logits
.
shape
,
expected_shape
)
self
.
assertEqual
(
logits
.
shape
,
expected_shape
)
expected_slice
=
torch
.
tensor
(
expected_slice
=
torch
.
tensor
(
[[
-
10.8609
,
-
10.7651
,
-
10.9187
],
[
-
12.1689
,
-
11.9389
,
-
12.1479
],
[
-
12.1518
,
-
11.9707
,
-
12.2073
]]
[[
-
10.8609
,
-
10.7651
,
-
10.9187
],
[
-
12.1689
,
-
11.9389
,
-
12.1479
],
[
-
12.1518
,
-
11.9707
,
-
12.2073
]],
device
=
torch_device
,
)
)
self
.
assertTrue
(
torch
.
allclose
(
logits
[
0
,
:
3
,
:
3
],
expected_slice
,
atol
=
1e-4
))
self
.
assertTrue
(
torch
.
allclose
(
logits
[
0
,
:
3
,
:
3
],
expected_slice
,
atol
=
1e-4
))
...
@@ -970,7 +971,7 @@ class PerceiverModelIntegrationTest(unittest.TestCase):
...
@@ -970,7 +971,7 @@ class PerceiverModelIntegrationTest(unittest.TestCase):
# forward pass
# forward pass
with
torch
.
no_grad
():
with
torch
.
no_grad
():
outputs
=
model
(
inputs
=
patches
)
outputs
=
model
(
inputs
=
patches
.
to
(
torch_device
)
)
logits
=
outputs
.
logits
logits
=
outputs
.
logits
# verify logits
# verify logits
...
...
tests/test_tokenization_perceiver.py
View file @
7375758b
...
@@ -99,17 +99,17 @@ class PerceiverTokenizationTest(TokenizerTesterMixin, unittest.TestCase):
...
@@ -99,17 +99,17 @@ class PerceiverTokenizationTest(TokenizerTesterMixin, unittest.TestCase):
# decoding
# decoding
decoded
=
tokenizer
.
decode
(
encoded_ids
)
decoded
=
tokenizer
.
decode
(
encoded_ids
)
self
.
assertEqual
(
decoded
,
"
<cls>
Unicode €.
<sep>
"
)
self
.
assertEqual
(
decoded
,
"
[CLS]
Unicode €.
[SEP]
"
)
encoded
=
tokenizer
(
"e è é ê ë"
)
encoded
=
tokenizer
(
"e è é ê ë"
)
encoded_ids
=
[
4
,
107
,
38
,
201
,
174
,
38
,
201
,
175
,
38
,
201
,
176
,
38
,
201
,
177
,
5
]
encoded_ids
=
[
4
,
107
,
38
,
201
,
174
,
38
,
201
,
175
,
38
,
201
,
176
,
38
,
201
,
177
,
5
]
self
.
assertEqual
(
encoded
[
"input_ids"
],
encoded_ids
)
self
.
assertEqual
(
encoded
[
"input_ids"
],
encoded_ids
)
# decoding
# decoding
decoded
=
tokenizer
.
decode
(
encoded_ids
)
decoded
=
tokenizer
.
decode
(
encoded_ids
)
self
.
assertEqual
(
decoded
,
"
<cls>
e è é ê ë
<sep>
"
)
self
.
assertEqual
(
decoded
,
"
[CLS]
e è é ê ë
[SEP]
"
)
# encode/decode, but with `encode` instead of `__call__`
# encode/decode, but with `encode` instead of `__call__`
self
.
assertEqual
(
tokenizer
.
decode
(
tokenizer
.
encode
(
"e è é ê ë"
)),
"
<cls>
e è é ê ë
<sep>
"
)
self
.
assertEqual
(
tokenizer
.
decode
(
tokenizer
.
encode
(
"e è é ê ë"
)),
"
[CLS]
e è é ê ë
[SEP]
"
)
def
test_prepare_batch_integration
(
self
):
def
test_prepare_batch_integration
(
self
):
tokenizer
=
self
.
perceiver_tokenizer
tokenizer
=
self
.
perceiver_tokenizer
...
...
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