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
5ba2dbd9
Unverified
Commit
5ba2dbd9
authored
Dec 12, 2022
by
Yih-Dar
Committed by
GitHub
Dec 12, 2022
Browse files
Fix `AutoModelTest.test_model_from_pretrained` (#20730)
Co-authored-by:
ydshieh
<
ydshieh@users.noreply.github.com
>
parent
a3345c1f
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
2 deletions
+5
-2
tests/models/auto/test_modeling_auto.py
tests/models/auto/test_modeling_auto.py
+5
-2
No files found.
tests/models/auto/test_modeling_auto.py
View file @
5ba2dbd9
...
...
@@ -22,7 +22,7 @@ from pathlib import Path
import
pytest
from
transformers
import
BertConfig
,
GPT2Model
,
is_torch_available
from
transformers
import
BertConfig
,
GPT2Model
,
is_safetensors_available
,
is_torch_available
from
transformers.models.auto.configuration_auto
import
CONFIG_MAPPING
from
transformers.testing_utils
import
(
DUMMY_UNKNOWN_IDENTIFIER
,
...
...
@@ -102,7 +102,10 @@ class AutoModelTest(unittest.TestCase):
self
.
assertIsInstance
(
model
,
BertModel
)
self
.
assertEqual
(
len
(
loading_info
[
"missing_keys"
]),
0
)
self
.
assertEqual
(
len
(
loading_info
[
"unexpected_keys"
]),
8
)
# When using PyTorch checkpoint, the expected value is `8`. With `safetensors` checkpoint (if it is
# installed), the expected value becomes `7`.
EXPECTED_NUM_OF_UNEXPECTED_KEYS
=
7
if
is_safetensors_available
()
else
8
self
.
assertEqual
(
len
(
loading_info
[
"unexpected_keys"
]),
EXPECTED_NUM_OF_UNEXPECTED_KEYS
)
self
.
assertEqual
(
len
(
loading_info
[
"mismatched_keys"
]),
0
)
self
.
assertEqual
(
len
(
loading_info
[
"error_msgs"
]),
0
)
...
...
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