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
59499bbe
Unverified
Commit
59499bbe
authored
Nov 27, 2023
by
NielsRogge
Committed by
GitHub
Nov 27, 2023
Browse files
Update forward signature test for vision models (#27681)
* Update forward signature * Empty-Commit
parent
1d7f406e
Changes
48
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
1 addition
and
92 deletions
+1
-92
tests/models/vit/test_modeling_vit.py
tests/models/vit/test_modeling_vit.py
+0
-13
tests/models/vit_hybrid/test_modeling_vit_hybrid.py
tests/models/vit_hybrid/test_modeling_vit_hybrid.py
+0
-13
tests/models/vit_mae/test_modeling_vit_mae.py
tests/models/vit_mae/test_modeling_vit_mae.py
+0
-13
tests/models/vit_msn/test_modeling_vit_msn.py
tests/models/vit_msn/test_modeling_vit_msn.py
+0
-13
tests/models/vitdet/test_modeling_vitdet.py
tests/models/vitdet/test_modeling_vitdet.py
+0
-13
tests/models/vitmatte/test_modeling_vitmatte.py
tests/models/vitmatte/test_modeling_vitmatte.py
+0
-13
tests/models/yolos/test_modeling_yolos.py
tests/models/yolos/test_modeling_yolos.py
+0
-13
tests/test_modeling_common.py
tests/test_modeling_common.py
+1
-1
No files found.
tests/models/vit/test_modeling_vit.py
View file @
59499bbe
...
...
@@ -15,7 +15,6 @@
""" Testing suite for the PyTorch ViT model. """
import
inspect
import
unittest
from
transformers
import
ViTConfig
...
...
@@ -224,18 +223,6 @@ class ViTModelTest(ModelTesterMixin, PipelineTesterMixin, unittest.TestCase):
x
=
model
.
get_output_embeddings
()
self
.
assertTrue
(
x
is
None
or
isinstance
(
x
,
nn
.
Linear
))
def
test_forward_signature
(
self
):
config
,
_
=
self
.
model_tester
.
prepare_config_and_inputs_for_common
()
for
model_class
in
self
.
all_model_classes
:
model
=
model_class
(
config
)
signature
=
inspect
.
signature
(
model
.
forward
)
# signature.parameters is an OrderedDict => so arg_names order is deterministic
arg_names
=
[
*
signature
.
parameters
.
keys
()]
expected_arg_names
=
[
"pixel_values"
]
self
.
assertListEqual
(
arg_names
[:
1
],
expected_arg_names
)
def
test_model
(
self
):
config_and_inputs
=
self
.
model_tester
.
prepare_config_and_inputs
()
self
.
model_tester
.
create_and_check_model
(
*
config_and_inputs
)
...
...
tests/models/vit_hybrid/test_modeling_vit_hybrid.py
View file @
59499bbe
...
...
@@ -15,7 +15,6 @@
""" Testing suite for the PyTorch ViT Hybrid model. """
import
inspect
import
unittest
from
transformers
import
ViTHybridConfig
...
...
@@ -185,18 +184,6 @@ class ViTHybridModelTest(ModelTesterMixin, PipelineTesterMixin, unittest.TestCas
x
=
model
.
get_output_embeddings
()
self
.
assertTrue
(
x
is
None
or
isinstance
(
x
,
nn
.
Linear
))
def
test_forward_signature
(
self
):
config
,
_
=
self
.
model_tester
.
prepare_config_and_inputs_for_common
()
for
model_class
in
self
.
all_model_classes
:
model
=
model_class
(
config
)
signature
=
inspect
.
signature
(
model
.
forward
)
# signature.parameters is an OrderedDict => so arg_names order is deterministic
arg_names
=
[
*
signature
.
parameters
.
keys
()]
expected_arg_names
=
[
"pixel_values"
]
self
.
assertListEqual
(
arg_names
[:
1
],
expected_arg_names
)
def
test_model
(
self
):
config_and_inputs
=
self
.
model_tester
.
prepare_config_and_inputs
()
self
.
model_tester
.
create_and_check_model
(
*
config_and_inputs
)
...
...
tests/models/vit_mae/test_modeling_vit_mae.py
View file @
59499bbe
...
...
@@ -15,7 +15,6 @@
""" Testing suite for the PyTorch ViTMAE model. """
import
inspect
import
math
import
tempfile
import
unittest
...
...
@@ -192,18 +191,6 @@ class ViTMAEModelTest(ModelTesterMixin, PipelineTesterMixin, unittest.TestCase):
x
=
model
.
get_output_embeddings
()
self
.
assertTrue
(
x
is
None
or
isinstance
(
x
,
nn
.
Linear
))
def
test_forward_signature
(
self
):
config
,
_
=
self
.
model_tester
.
prepare_config_and_inputs_for_common
()
for
model_class
in
self
.
all_model_classes
:
model
=
model_class
(
config
)
signature
=
inspect
.
signature
(
model
.
forward
)
# signature.parameters is an OrderedDict => so arg_names order is deterministic
arg_names
=
[
*
signature
.
parameters
.
keys
()]
expected_arg_names
=
[
"pixel_values"
]
self
.
assertListEqual
(
arg_names
[:
1
],
expected_arg_names
)
def
test_model
(
self
):
config_and_inputs
=
self
.
model_tester
.
prepare_config_and_inputs
()
self
.
model_tester
.
create_and_check_model
(
*
config_and_inputs
)
...
...
tests/models/vit_msn/test_modeling_vit_msn.py
View file @
59499bbe
...
...
@@ -15,7 +15,6 @@
""" Testing suite for the PyTorch ViTMSN model. """
import
inspect
import
unittest
from
transformers
import
ViTMSNConfig
...
...
@@ -183,18 +182,6 @@ class ViTMSNModelTest(ModelTesterMixin, PipelineTesterMixin, unittest.TestCase):
x
=
model
.
get_output_embeddings
()
self
.
assertTrue
(
x
is
None
or
isinstance
(
x
,
nn
.
Linear
))
def
test_forward_signature
(
self
):
config
,
_
=
self
.
model_tester
.
prepare_config_and_inputs_for_common
()
for
model_class
in
self
.
all_model_classes
:
model
=
model_class
(
config
)
signature
=
inspect
.
signature
(
model
.
forward
)
# signature.parameters is an OrderedDict => so arg_names order is deterministic
arg_names
=
[
*
signature
.
parameters
.
keys
()]
expected_arg_names
=
[
"pixel_values"
]
self
.
assertListEqual
(
arg_names
[:
1
],
expected_arg_names
)
def
test_model
(
self
):
config_and_inputs
=
self
.
model_tester
.
prepare_config_and_inputs
()
self
.
model_tester
.
create_and_check_model
(
*
config_and_inputs
)
...
...
tests/models/vitdet/test_modeling_vitdet.py
View file @
59499bbe
...
...
@@ -15,7 +15,6 @@
""" Testing suite for the PyTorch ViTDet model. """
import
inspect
import
unittest
from
transformers
import
VitDetConfig
...
...
@@ -210,18 +209,6 @@ class VitDetModelTest(ModelTesterMixin, PipelineTesterMixin, unittest.TestCase):
x
=
model
.
get_output_embeddings
()
self
.
assertTrue
(
x
is
None
or
isinstance
(
x
,
nn
.
Linear
))
def
test_forward_signature
(
self
):
config
,
_
=
self
.
model_tester
.
prepare_config_and_inputs_for_common
()
for
model_class
in
self
.
all_model_classes
:
model
=
model_class
(
config
)
signature
=
inspect
.
signature
(
model
.
forward
)
# signature.parameters is an OrderedDict => so arg_names order is deterministic
arg_names
=
[
*
signature
.
parameters
.
keys
()]
expected_arg_names
=
[
"pixel_values"
]
self
.
assertListEqual
(
arg_names
[:
1
],
expected_arg_names
)
def
test_model
(
self
):
config_and_inputs
=
self
.
model_tester
.
prepare_config_and_inputs
()
self
.
model_tester
.
create_and_check_model
(
*
config_and_inputs
)
...
...
tests/models/vitmatte/test_modeling_vitmatte.py
View file @
59499bbe
...
...
@@ -15,7 +15,6 @@
""" Testing suite for the PyTorch VitMatte model. """
import
inspect
import
unittest
from
huggingface_hub
import
hf_hub_download
...
...
@@ -189,18 +188,6 @@ class VitMatteModelTest(ModelTesterMixin, PipelineTesterMixin, unittest.TestCase
def
test_model_common_attributes
(
self
):
pass
def
test_forward_signature
(
self
):
config
,
_
=
self
.
model_tester
.
prepare_config_and_inputs_for_common
()
for
model_class
in
self
.
all_model_classes
:
model
=
model_class
(
config
)
signature
=
inspect
.
signature
(
model
.
forward
)
# signature.parameters is an OrderedDict => so arg_names order is deterministic
arg_names
=
[
*
signature
.
parameters
.
keys
()]
expected_arg_names
=
[
"pixel_values"
]
self
.
assertListEqual
(
arg_names
[:
1
],
expected_arg_names
)
def
test_model
(
self
):
config_and_inputs
=
self
.
model_tester
.
prepare_config_and_inputs
()
self
.
model_tester
.
create_and_check_model
(
*
config_and_inputs
)
...
...
tests/models/yolos/test_modeling_yolos.py
View file @
59499bbe
...
...
@@ -15,7 +15,6 @@
""" Testing suite for the PyTorch YOLOS model. """
import
inspect
import
unittest
from
transformers
import
YolosConfig
...
...
@@ -217,18 +216,6 @@ class YolosModelTest(ModelTesterMixin, PipelineTesterMixin, unittest.TestCase):
x
=
model
.
get_output_embeddings
()
self
.
assertTrue
(
x
is
None
or
isinstance
(
x
,
nn
.
Linear
))
def
test_forward_signature
(
self
):
config
,
_
=
self
.
model_tester
.
prepare_config_and_inputs_for_common
()
for
model_class
in
self
.
all_model_classes
:
model
=
model_class
(
config
)
signature
=
inspect
.
signature
(
model
.
forward
)
# signature.parameters is an OrderedDict => so arg_names order is deterministic
arg_names
=
[
*
signature
.
parameters
.
keys
()]
expected_arg_names
=
[
"pixel_values"
]
self
.
assertListEqual
(
arg_names
[:
1
],
expected_arg_names
)
def
test_model
(
self
):
config_and_inputs
=
self
.
model_tester
.
prepare_config_and_inputs
()
self
.
model_tester
.
create_and_check_model
(
*
config_and_inputs
)
...
...
tests/test_modeling_common.py
View file @
59499bbe
...
...
@@ -543,7 +543,7 @@ class ModelTesterMixin:
)
self
.
assertListEqual
(
arg_names
[:
len
(
expected_arg_names
)],
expected_arg_names
)
else
:
expected_arg_names
=
[
"
input_
ids"
]
expected_arg_names
=
[
model
.
main_
input_
name
]
self
.
assertListEqual
(
arg_names
[:
1
],
expected_arg_names
)
def
check_training_gradient_checkpointing
(
self
,
gradient_checkpointing_kwargs
=
None
):
...
...
Prev
1
2
3
Next
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