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
20 changed files
with
0 additions
and
260 deletions
+0
-260
tests/models/beit/test_modeling_beit.py
tests/models/beit/test_modeling_beit.py
+0
-13
tests/models/bit/test_modeling_bit.py
tests/models/bit/test_modeling_bit.py
+0
-13
tests/models/convnext/test_modeling_convnext.py
tests/models/convnext/test_modeling_convnext.py
+0
-13
tests/models/convnextv2/test_modeling_convnextv2.py
tests/models/convnextv2/test_modeling_convnextv2.py
+0
-13
tests/models/cvt/test_modeling_cvt.py
tests/models/cvt/test_modeling_cvt.py
+0
-13
tests/models/data2vec/test_modeling_data2vec_vision.py
tests/models/data2vec/test_modeling_data2vec_vision.py
+0
-13
tests/models/deit/test_modeling_deit.py
tests/models/deit/test_modeling_deit.py
+0
-13
tests/models/dinat/test_modeling_dinat.py
tests/models/dinat/test_modeling_dinat.py
+0
-13
tests/models/dinov2/test_modeling_dinov2.py
tests/models/dinov2/test_modeling_dinov2.py
+0
-13
tests/models/donut/test_modeling_donut_swin.py
tests/models/donut/test_modeling_donut_swin.py
+0
-13
tests/models/dpt/test_modeling_dpt.py
tests/models/dpt/test_modeling_dpt.py
+0
-13
tests/models/dpt/test_modeling_dpt_auto_backbone.py
tests/models/dpt/test_modeling_dpt_auto_backbone.py
+0
-13
tests/models/dpt/test_modeling_dpt_hybrid.py
tests/models/dpt/test_modeling_dpt_hybrid.py
+0
-13
tests/models/efficientformer/test_modeling_efficientformer.py
...s/models/efficientformer/test_modeling_efficientformer.py
+0
-13
tests/models/efficientnet/test_modeling_efficientnet.py
tests/models/efficientnet/test_modeling_efficientnet.py
+0
-13
tests/models/focalnet/test_modeling_focalnet.py
tests/models/focalnet/test_modeling_focalnet.py
+0
-13
tests/models/glpn/test_modeling_glpn.py
tests/models/glpn/test_modeling_glpn.py
+0
-13
tests/models/levit/test_modeling_levit.py
tests/models/levit/test_modeling_levit.py
+0
-13
tests/models/mask2former/test_modeling_mask2former.py
tests/models/mask2former/test_modeling_mask2former.py
+0
-13
tests/models/maskformer/test_modeling_maskformer.py
tests/models/maskformer/test_modeling_maskformer.py
+0
-13
No files found.
tests/models/beit/test_modeling_beit.py
View file @
59499bbe
...
@@ -15,7 +15,6 @@
...
@@ -15,7 +15,6 @@
""" Testing suite for the PyTorch BEiT model. """
""" Testing suite for the PyTorch BEiT model. """
import
inspect
import
unittest
import
unittest
from
datasets
import
load_dataset
from
datasets
import
load_dataset
...
@@ -236,18 +235,6 @@ class BeitModelTest(ModelTesterMixin, PipelineTesterMixin, unittest.TestCase):
...
@@ -236,18 +235,6 @@ class BeitModelTest(ModelTesterMixin, PipelineTesterMixin, unittest.TestCase):
x
=
model
.
get_output_embeddings
()
x
=
model
.
get_output_embeddings
()
self
.
assertTrue
(
x
is
None
or
isinstance
(
x
,
nn
.
Linear
))
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
):
def
test_model
(
self
):
config_and_inputs
=
self
.
model_tester
.
prepare_config_and_inputs
()
config_and_inputs
=
self
.
model_tester
.
prepare_config_and_inputs
()
self
.
model_tester
.
create_and_check_model
(
*
config_and_inputs
)
self
.
model_tester
.
create_and_check_model
(
*
config_and_inputs
)
...
...
tests/models/bit/test_modeling_bit.py
View file @
59499bbe
...
@@ -15,7 +15,6 @@
...
@@ -15,7 +15,6 @@
""" Testing suite for the PyTorch Bit model. """
""" Testing suite for the PyTorch Bit model. """
import
inspect
import
unittest
import
unittest
from
transformers
import
BitConfig
from
transformers
import
BitConfig
...
@@ -202,18 +201,6 @@ class BitModelTest(ModelTesterMixin, PipelineTesterMixin, unittest.TestCase):
...
@@ -202,18 +201,6 @@ class BitModelTest(ModelTesterMixin, PipelineTesterMixin, unittest.TestCase):
def
test_model_common_attributes
(
self
):
def
test_model_common_attributes
(
self
):
pass
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
):
def
test_model
(
self
):
config_and_inputs
=
self
.
model_tester
.
prepare_config_and_inputs
()
config_and_inputs
=
self
.
model_tester
.
prepare_config_and_inputs
()
self
.
model_tester
.
create_and_check_model
(
*
config_and_inputs
)
self
.
model_tester
.
create_and_check_model
(
*
config_and_inputs
)
...
...
tests/models/convnext/test_modeling_convnext.py
View file @
59499bbe
...
@@ -15,7 +15,6 @@
...
@@ -15,7 +15,6 @@
""" Testing suite for the PyTorch ConvNext model. """
""" Testing suite for the PyTorch ConvNext model. """
import
inspect
import
unittest
import
unittest
from
transformers
import
ConvNextConfig
from
transformers
import
ConvNextConfig
...
@@ -212,18 +211,6 @@ class ConvNextModelTest(ModelTesterMixin, PipelineTesterMixin, unittest.TestCase
...
@@ -212,18 +211,6 @@ class ConvNextModelTest(ModelTesterMixin, PipelineTesterMixin, unittest.TestCase
def
test_feed_forward_chunking
(
self
):
def
test_feed_forward_chunking
(
self
):
pass
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
):
def
test_model
(
self
):
config_and_inputs
=
self
.
model_tester
.
prepare_config_and_inputs
()
config_and_inputs
=
self
.
model_tester
.
prepare_config_and_inputs
()
self
.
model_tester
.
create_and_check_model
(
*
config_and_inputs
)
self
.
model_tester
.
create_and_check_model
(
*
config_and_inputs
)
...
...
tests/models/convnextv2/test_modeling_convnextv2.py
View file @
59499bbe
...
@@ -15,7 +15,6 @@
...
@@ -15,7 +15,6 @@
""" Testing suite for the PyTorch ConvNextV2 model. """
""" Testing suite for the PyTorch ConvNextV2 model. """
import
inspect
import
unittest
import
unittest
from
transformers
import
ConvNextV2Config
from
transformers
import
ConvNextV2Config
...
@@ -265,18 +264,6 @@ class ConvNextV2ModelTest(ModelTesterMixin, PipelineTesterMixin, unittest.TestCa
...
@@ -265,18 +264,6 @@ class ConvNextV2ModelTest(ModelTesterMixin, PipelineTesterMixin, unittest.TestCa
loss
=
model
(
**
inputs
).
loss
loss
=
model
(
**
inputs
).
loss
loss
.
backward
()
loss
.
backward
()
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
):
def
test_model
(
self
):
config_and_inputs
=
self
.
model_tester
.
prepare_config_and_inputs
()
config_and_inputs
=
self
.
model_tester
.
prepare_config_and_inputs
()
self
.
model_tester
.
create_and_check_model
(
*
config_and_inputs
)
self
.
model_tester
.
create_and_check_model
(
*
config_and_inputs
)
...
...
tests/models/cvt/test_modeling_cvt.py
View file @
59499bbe
...
@@ -15,7 +15,6 @@
...
@@ -15,7 +15,6 @@
""" Testing suite for the PyTorch CvT model. """
""" Testing suite for the PyTorch CvT model. """
import
inspect
import
unittest
import
unittest
from
math
import
floor
from
math
import
floor
...
@@ -191,18 +190,6 @@ class CvtModelTest(ModelTesterMixin, PipelineTesterMixin, unittest.TestCase):
...
@@ -191,18 +190,6 @@ class CvtModelTest(ModelTesterMixin, PipelineTesterMixin, unittest.TestCase):
def
test_model_common_attributes
(
self
):
def
test_model_common_attributes
(
self
):
pass
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
):
def
test_model
(
self
):
config_and_inputs
=
self
.
model_tester
.
prepare_config_and_inputs
()
config_and_inputs
=
self
.
model_tester
.
prepare_config_and_inputs
()
self
.
model_tester
.
create_and_check_model
(
*
config_and_inputs
)
self
.
model_tester
.
create_and_check_model
(
*
config_and_inputs
)
...
...
tests/models/data2vec/test_modeling_data2vec_vision.py
View file @
59499bbe
...
@@ -15,7 +15,6 @@
...
@@ -15,7 +15,6 @@
""" Testing suite for the PyTorch Data2VecVision model. """
""" Testing suite for the PyTorch Data2VecVision model. """
import
inspect
import
unittest
import
unittest
from
transformers
import
Data2VecVisionConfig
from
transformers
import
Data2VecVisionConfig
...
@@ -220,18 +219,6 @@ class Data2VecVisionModelTest(ModelTesterMixin, PipelineTesterMixin, unittest.Te
...
@@ -220,18 +219,6 @@ class Data2VecVisionModelTest(ModelTesterMixin, PipelineTesterMixin, unittest.Te
x
=
model
.
get_output_embeddings
()
x
=
model
.
get_output_embeddings
()
self
.
assertTrue
(
x
is
None
or
isinstance
(
x
,
nn
.
Linear
))
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
):
def
test_model
(
self
):
config_and_inputs
=
self
.
model_tester
.
prepare_config_and_inputs
()
config_and_inputs
=
self
.
model_tester
.
prepare_config_and_inputs
()
self
.
model_tester
.
create_and_check_model
(
*
config_and_inputs
)
self
.
model_tester
.
create_and_check_model
(
*
config_and_inputs
)
...
...
tests/models/deit/test_modeling_deit.py
View file @
59499bbe
...
@@ -15,7 +15,6 @@
...
@@ -15,7 +15,6 @@
""" Testing suite for the PyTorch DeiT model. """
""" Testing suite for the PyTorch DeiT model. """
import
inspect
import
unittest
import
unittest
import
warnings
import
warnings
...
@@ -238,18 +237,6 @@ class DeiTModelTest(ModelTesterMixin, PipelineTesterMixin, unittest.TestCase):
...
@@ -238,18 +237,6 @@ class DeiTModelTest(ModelTesterMixin, PipelineTesterMixin, unittest.TestCase):
x
=
model
.
get_output_embeddings
()
x
=
model
.
get_output_embeddings
()
self
.
assertTrue
(
x
is
None
or
isinstance
(
x
,
nn
.
Linear
))
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
):
def
test_model
(
self
):
config_and_inputs
=
self
.
model_tester
.
prepare_config_and_inputs
()
config_and_inputs
=
self
.
model_tester
.
prepare_config_and_inputs
()
self
.
model_tester
.
create_and_check_model
(
*
config_and_inputs
)
self
.
model_tester
.
create_and_check_model
(
*
config_and_inputs
)
...
...
tests/models/dinat/test_modeling_dinat.py
View file @
59499bbe
...
@@ -15,7 +15,6 @@
...
@@ -15,7 +15,6 @@
""" Testing suite for the PyTorch Dinat model. """
""" Testing suite for the PyTorch Dinat model. """
import
collections
import
collections
import
inspect
import
unittest
import
unittest
from
transformers
import
DinatConfig
from
transformers
import
DinatConfig
...
@@ -264,18 +263,6 @@ class DinatModelTest(ModelTesterMixin, PipelineTesterMixin, unittest.TestCase):
...
@@ -264,18 +263,6 @@ class DinatModelTest(ModelTesterMixin, PipelineTesterMixin, unittest.TestCase):
x
=
model
.
get_output_embeddings
()
x
=
model
.
get_output_embeddings
()
self
.
assertTrue
(
x
is
None
or
isinstance
(
x
,
nn
.
Linear
))
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_attention_outputs
(
self
):
def
test_attention_outputs
(
self
):
self
.
skipTest
(
"Dinat's attention operation is handled entirely by NATTEN."
)
self
.
skipTest
(
"Dinat's attention operation is handled entirely by NATTEN."
)
...
...
tests/models/dinov2/test_modeling_dinov2.py
View file @
59499bbe
...
@@ -15,7 +15,6 @@
...
@@ -15,7 +15,6 @@
""" Testing suite for the PyTorch Dinov2 model. """
""" Testing suite for the PyTorch Dinov2 model. """
import
inspect
import
unittest
import
unittest
from
transformers
import
Dinov2Config
from
transformers
import
Dinov2Config
...
@@ -265,18 +264,6 @@ class Dinov2ModelTest(ModelTesterMixin, PipelineTesterMixin, unittest.TestCase):
...
@@ -265,18 +264,6 @@ class Dinov2ModelTest(ModelTesterMixin, PipelineTesterMixin, unittest.TestCase):
x
=
model
.
get_output_embeddings
()
x
=
model
.
get_output_embeddings
()
self
.
assertTrue
(
x
is
None
or
isinstance
(
x
,
nn
.
Linear
))
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
):
def
test_model
(
self
):
config_and_inputs
=
self
.
model_tester
.
prepare_config_and_inputs
()
config_and_inputs
=
self
.
model_tester
.
prepare_config_and_inputs
()
self
.
model_tester
.
create_and_check_model
(
*
config_and_inputs
)
self
.
model_tester
.
create_and_check_model
(
*
config_and_inputs
)
...
...
tests/models/donut/test_modeling_donut_swin.py
View file @
59499bbe
...
@@ -15,7 +15,6 @@
...
@@ -15,7 +15,6 @@
""" Testing suite for the PyTorch Donut Swin model. """
""" Testing suite for the PyTorch Donut Swin model. """
import
collections
import
collections
import
inspect
import
unittest
import
unittest
from
transformers
import
DonutSwinConfig
from
transformers
import
DonutSwinConfig
...
@@ -186,18 +185,6 @@ class DonutSwinModelTest(ModelTesterMixin, PipelineTesterMixin, unittest.TestCas
...
@@ -186,18 +185,6 @@ class DonutSwinModelTest(ModelTesterMixin, PipelineTesterMixin, unittest.TestCas
x
=
model
.
get_output_embeddings
()
x
=
model
.
get_output_embeddings
()
self
.
assertTrue
(
x
is
None
or
isinstance
(
x
,
nn
.
Linear
))
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_attention_outputs
(
self
):
def
test_attention_outputs
(
self
):
config
,
inputs_dict
=
self
.
model_tester
.
prepare_config_and_inputs_for_common
()
config
,
inputs_dict
=
self
.
model_tester
.
prepare_config_and_inputs_for_common
()
config
.
return_dict
=
True
config
.
return_dict
=
True
...
...
tests/models/dpt/test_modeling_dpt.py
View file @
59499bbe
...
@@ -15,7 +15,6 @@
...
@@ -15,7 +15,6 @@
""" Testing suite for the PyTorch DPT model. """
""" Testing suite for the PyTorch DPT model. """
import
inspect
import
unittest
import
unittest
from
transformers
import
DPTConfig
from
transformers
import
DPTConfig
...
@@ -195,18 +194,6 @@ class DPTModelTest(ModelTesterMixin, PipelineTesterMixin, unittest.TestCase):
...
@@ -195,18 +194,6 @@ class DPTModelTest(ModelTesterMixin, PipelineTesterMixin, unittest.TestCase):
x
=
model
.
get_output_embeddings
()
x
=
model
.
get_output_embeddings
()
self
.
assertTrue
(
x
is
None
or
isinstance
(
x
,
nn
.
Linear
))
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
):
def
test_model
(
self
):
config_and_inputs
=
self
.
model_tester
.
prepare_config_and_inputs
()
config_and_inputs
=
self
.
model_tester
.
prepare_config_and_inputs
()
self
.
model_tester
.
create_and_check_model
(
*
config_and_inputs
)
self
.
model_tester
.
create_and_check_model
(
*
config_and_inputs
)
...
...
tests/models/dpt/test_modeling_dpt_auto_backbone.py
View file @
59499bbe
...
@@ -15,7 +15,6 @@
...
@@ -15,7 +15,6 @@
""" Testing suite for the PyTorch DPT model. """
""" Testing suite for the PyTorch DPT model. """
import
inspect
import
unittest
import
unittest
from
transformers
import
Dinov2Config
,
DPTConfig
from
transformers
import
Dinov2Config
,
DPTConfig
...
@@ -154,18 +153,6 @@ class DPTModelTest(ModelTesterMixin, PipelineTesterMixin, unittest.TestCase):
...
@@ -154,18 +153,6 @@ class DPTModelTest(ModelTesterMixin, PipelineTesterMixin, unittest.TestCase):
def
test_inputs_embeds
(
self
):
def
test_inputs_embeds
(
self
):
pass
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_for_depth_estimation
(
self
):
def
test_for_depth_estimation
(
self
):
config_and_inputs
=
self
.
model_tester
.
prepare_config_and_inputs
()
config_and_inputs
=
self
.
model_tester
.
prepare_config_and_inputs
()
self
.
model_tester
.
create_and_check_for_depth_estimation
(
*
config_and_inputs
)
self
.
model_tester
.
create_and_check_for_depth_estimation
(
*
config_and_inputs
)
...
...
tests/models/dpt/test_modeling_dpt_hybrid.py
View file @
59499bbe
...
@@ -15,7 +15,6 @@
...
@@ -15,7 +15,6 @@
""" Testing suite for the PyTorch DPT model. """
""" Testing suite for the PyTorch DPT model. """
import
inspect
import
unittest
import
unittest
from
transformers
import
DPTConfig
from
transformers
import
DPTConfig
...
@@ -209,18 +208,6 @@ class DPTModelTest(ModelTesterMixin, PipelineTesterMixin, unittest.TestCase):
...
@@ -209,18 +208,6 @@ class DPTModelTest(ModelTesterMixin, PipelineTesterMixin, unittest.TestCase):
x
=
model
.
get_output_embeddings
()
x
=
model
.
get_output_embeddings
()
self
.
assertTrue
(
x
is
None
or
isinstance
(
x
,
nn
.
Linear
))
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
):
def
test_model
(
self
):
config_and_inputs
=
self
.
model_tester
.
prepare_config_and_inputs
()
config_and_inputs
=
self
.
model_tester
.
prepare_config_and_inputs
()
self
.
model_tester
.
create_and_check_model
(
*
config_and_inputs
)
self
.
model_tester
.
create_and_check_model
(
*
config_and_inputs
)
...
...
tests/models/efficientformer/test_modeling_efficientformer.py
View file @
59499bbe
...
@@ -15,7 +15,6 @@
...
@@ -15,7 +15,6 @@
""" Testing suite for the PyTorch EfficientFormer model. """
""" Testing suite for the PyTorch EfficientFormer model. """
import
inspect
import
unittest
import
unittest
import
warnings
import
warnings
from
typing
import
List
from
typing
import
List
...
@@ -223,18 +222,6 @@ class EfficientFormerModelTest(ModelTesterMixin, PipelineTesterMixin, unittest.T
...
@@ -223,18 +222,6 @@ class EfficientFormerModelTest(ModelTesterMixin, PipelineTesterMixin, unittest.T
def
test_model_common_attributes
(
self
):
def
test_model_common_attributes
(
self
):
pass
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_hidden_states_output
(
self
):
def
test_hidden_states_output
(
self
):
def
check_hidden_states_output
(
inputs_dict
,
config
,
model_class
):
def
check_hidden_states_output
(
inputs_dict
,
config
,
model_class
):
model
=
model_class
(
config
)
model
=
model_class
(
config
)
...
...
tests/models/efficientnet/test_modeling_efficientnet.py
View file @
59499bbe
...
@@ -15,7 +15,6 @@
...
@@ -15,7 +15,6 @@
""" Testing suite for the PyTorch EfficientNet model. """
""" Testing suite for the PyTorch EfficientNet model. """
import
inspect
import
unittest
import
unittest
from
transformers
import
EfficientNetConfig
from
transformers
import
EfficientNetConfig
...
@@ -172,18 +171,6 @@ class EfficientNetModelTest(ModelTesterMixin, PipelineTesterMixin, unittest.Test
...
@@ -172,18 +171,6 @@ class EfficientNetModelTest(ModelTesterMixin, PipelineTesterMixin, unittest.Test
def
test_feed_forward_chunking
(
self
):
def
test_feed_forward_chunking
(
self
):
pass
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
):
def
test_model
(
self
):
config_and_inputs
=
self
.
model_tester
.
prepare_config_and_inputs
()
config_and_inputs
=
self
.
model_tester
.
prepare_config_and_inputs
()
self
.
model_tester
.
create_and_check_model
(
*
config_and_inputs
)
self
.
model_tester
.
create_and_check_model
(
*
config_and_inputs
)
...
...
tests/models/focalnet/test_modeling_focalnet.py
View file @
59499bbe
...
@@ -15,7 +15,6 @@
...
@@ -15,7 +15,6 @@
""" Testing suite for the PyTorch FocalNet model. """
""" Testing suite for the PyTorch FocalNet model. """
import
collections
import
collections
import
inspect
import
unittest
import
unittest
from
transformers
import
FocalNetConfig
from
transformers
import
FocalNetConfig
...
@@ -299,18 +298,6 @@ class FocalNetModelTest(ModelTesterMixin, PipelineTesterMixin, unittest.TestCase
...
@@ -299,18 +298,6 @@ class FocalNetModelTest(ModelTesterMixin, PipelineTesterMixin, unittest.TestCase
x
=
model
.
get_output_embeddings
()
x
=
model
.
get_output_embeddings
()
self
.
assertTrue
(
x
is
None
or
isinstance
(
x
,
nn
.
Linear
))
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
[:
-
1
]:
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
check_hidden_states_output
(
self
,
inputs_dict
,
config
,
model_class
,
image_size
):
def
check_hidden_states_output
(
self
,
inputs_dict
,
config
,
model_class
,
image_size
):
model
=
model_class
(
config
)
model
=
model_class
(
config
)
model
.
to
(
torch_device
)
model
.
to
(
torch_device
)
...
...
tests/models/glpn/test_modeling_glpn.py
View file @
59499bbe
...
@@ -15,7 +15,6 @@
...
@@ -15,7 +15,6 @@
""" Testing suite for the PyTorch GLPN model. """
""" Testing suite for the PyTorch GLPN model. """
import
inspect
import
unittest
import
unittest
from
transformers
import
is_torch_available
,
is_vision_available
from
transformers
import
is_torch_available
,
is_vision_available
...
@@ -177,18 +176,6 @@ class GLPNModelTest(ModelTesterMixin, PipelineTesterMixin, unittest.TestCase):
...
@@ -177,18 +176,6 @@ class GLPNModelTest(ModelTesterMixin, PipelineTesterMixin, unittest.TestCase):
def
test_model_common_attributes
(
self
):
def
test_model_common_attributes
(
self
):
pass
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_attention_outputs
(
self
):
def
test_attention_outputs
(
self
):
config
,
inputs_dict
=
self
.
model_tester
.
prepare_config_and_inputs_for_common
()
config
,
inputs_dict
=
self
.
model_tester
.
prepare_config_and_inputs_for_common
()
config
.
return_dict
=
True
config
.
return_dict
=
True
...
...
tests/models/levit/test_modeling_levit.py
View file @
59499bbe
...
@@ -15,7 +15,6 @@
...
@@ -15,7 +15,6 @@
""" Testing suite for the PyTorch LeViT model. """
""" Testing suite for the PyTorch LeViT model. """
import
inspect
import
unittest
import
unittest
import
warnings
import
warnings
from
math
import
ceil
,
floor
from
math
import
ceil
,
floor
...
@@ -218,18 +217,6 @@ class LevitModelTest(ModelTesterMixin, PipelineTesterMixin, unittest.TestCase):
...
@@ -218,18 +217,6 @@ class LevitModelTest(ModelTesterMixin, PipelineTesterMixin, unittest.TestCase):
def
test_attention_outputs
(
self
):
def
test_attention_outputs
(
self
):
pass
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_hidden_states_output
(
self
):
def
test_hidden_states_output
(
self
):
def
check_hidden_states_output
(
inputs_dict
,
config
,
model_class
):
def
check_hidden_states_output
(
inputs_dict
,
config
,
model_class
):
model
=
model_class
(
config
)
model
=
model_class
(
config
)
...
...
tests/models/mask2former/test_modeling_mask2former.py
View file @
59499bbe
...
@@ -14,7 +14,6 @@
...
@@ -14,7 +14,6 @@
# limitations under the License.
# limitations under the License.
""" Testing suite for the PyTorch Mask2Former model. """
""" Testing suite for the PyTorch Mask2Former model. """
import
inspect
import
unittest
import
unittest
import
numpy
as
np
import
numpy
as
np
...
@@ -242,18 +241,6 @@ class Mask2FormerModelTest(ModelTesterMixin, PipelineTesterMixin, unittest.TestC
...
@@ -242,18 +241,6 @@ class Mask2FormerModelTest(ModelTesterMixin, PipelineTesterMixin, unittest.TestC
def
test_multi_gpu_data_parallel_forward
(
self
):
def
test_multi_gpu_data_parallel_forward
(
self
):
pass
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
)
@
slow
@
slow
def
test_model_from_pretrained
(
self
):
def
test_model_from_pretrained
(
self
):
for
model_name
in
[
"facebook/mask2former-swin-small-coco-instance"
]:
for
model_name
in
[
"facebook/mask2former-swin-small-coco-instance"
]:
...
...
tests/models/maskformer/test_modeling_maskformer.py
View file @
59499bbe
...
@@ -15,7 +15,6 @@
...
@@ -15,7 +15,6 @@
""" Testing suite for the PyTorch MaskFormer model. """
""" Testing suite for the PyTorch MaskFormer model. """
import
copy
import
copy
import
inspect
import
unittest
import
unittest
import
numpy
as
np
import
numpy
as
np
...
@@ -266,18 +265,6 @@ class MaskFormerModelTest(ModelTesterMixin, PipelineTesterMixin, unittest.TestCa
...
@@ -266,18 +265,6 @@ class MaskFormerModelTest(ModelTesterMixin, PipelineTesterMixin, unittest.TestCa
def
test_multi_gpu_data_parallel_forward
(
self
):
def
test_multi_gpu_data_parallel_forward
(
self
):
pass
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
)
@
slow
@
slow
def
test_model_from_pretrained
(
self
):
def
test_model_from_pretrained
(
self
):
for
model_name
in
[
"facebook/maskformer-swin-small-coco"
]:
for
model_name
in
[
"facebook/maskformer-swin-small-coco"
]:
...
...
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