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
Show whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
0 additions
and
260 deletions
+0
-260
tests/models/maskformer/test_modeling_maskformer_swin.py
tests/models/maskformer/test_modeling_maskformer_swin.py
+0
-13
tests/models/mgp_str/test_modeling_mgp_str.py
tests/models/mgp_str/test_modeling_mgp_str.py
+0
-13
tests/models/mobilenet_v1/test_modeling_mobilenet_v1.py
tests/models/mobilenet_v1/test_modeling_mobilenet_v1.py
+0
-13
tests/models/mobilenet_v2/test_modeling_mobilenet_v2.py
tests/models/mobilenet_v2/test_modeling_mobilenet_v2.py
+0
-13
tests/models/mobilevit/test_modeling_mobilevit.py
tests/models/mobilevit/test_modeling_mobilevit.py
+0
-13
tests/models/mobilevitv2/test_modeling_mobilevitv2.py
tests/models/mobilevitv2/test_modeling_mobilevitv2.py
+0
-13
tests/models/nat/test_modeling_nat.py
tests/models/nat/test_modeling_nat.py
+0
-13
tests/models/poolformer/test_modeling_poolformer.py
tests/models/poolformer/test_modeling_poolformer.py
+0
-13
tests/models/pvt/test_modeling_pvt.py
tests/models/pvt/test_modeling_pvt.py
+0
-13
tests/models/regnet/test_modeling_regnet.py
tests/models/regnet/test_modeling_regnet.py
+0
-13
tests/models/resnet/test_modeling_resnet.py
tests/models/resnet/test_modeling_resnet.py
+0
-13
tests/models/sam/test_modeling_sam.py
tests/models/sam/test_modeling_sam.py
+0
-13
tests/models/segformer/test_modeling_segformer.py
tests/models/segformer/test_modeling_segformer.py
+0
-13
tests/models/swiftformer/test_modeling_swiftformer.py
tests/models/swiftformer/test_modeling_swiftformer.py
+0
-13
tests/models/swin/test_modeling_swin.py
tests/models/swin/test_modeling_swin.py
+0
-13
tests/models/swin2sr/test_modeling_swin2sr.py
tests/models/swin2sr/test_modeling_swin2sr.py
+0
-13
tests/models/swinv2/test_modeling_swinv2.py
tests/models/swinv2/test_modeling_swinv2.py
+0
-13
tests/models/timesformer/test_modeling_timesformer.py
tests/models/timesformer/test_modeling_timesformer.py
+0
-13
tests/models/upernet/test_modeling_upernet.py
tests/models/upernet/test_modeling_upernet.py
+0
-13
tests/models/videomae/test_modeling_videomae.py
tests/models/videomae/test_modeling_videomae.py
+0
-13
No files found.
tests/models/maskformer/test_modeling_maskformer_swin.py
View file @
59499bbe
...
...
@@ -15,7 +15,6 @@
""" Testing suite for the PyTorch MaskFormer Swin model. """
import
collections
import
inspect
import
unittest
from
typing
import
Dict
,
List
,
Tuple
...
...
@@ -234,18 +233,6 @@ class MaskFormerSwinModelTest(ModelTesterMixin, PipelineTesterMixin, unittest.Te
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
)
@
unittest
.
skip
(
reason
=
"MaskFormerSwin is only used as backbone and doesn't support output_attentions"
)
def
test_attention_outputs
(
self
):
pass
...
...
tests/models/mgp_str/test_modeling_mgp_str.py
View file @
59499bbe
...
...
@@ -14,7 +14,6 @@
# limitations under the License.
""" Testing suite for the PyTorch MGP-STR model. """
import
inspect
import
unittest
import
requests
...
...
@@ -151,18 +150,6 @@ class MgpstrModelTest(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
)
@
unittest
.
skip
(
reason
=
"MgpstrModel does not support feedforward chunking"
)
def
test_feed_forward_chunking
(
self
):
pass
...
...
tests/models/mobilenet_v1/test_modeling_mobilenet_v1.py
View file @
59499bbe
...
...
@@ -15,7 +15,6 @@
""" Testing suite for the PyTorch MobileNetV1 model. """
import
inspect
import
unittest
from
transformers
import
MobileNetV1Config
...
...
@@ -177,18 +176,6 @@ class MobileNetV1ModelTest(ModelTesterMixin, PipelineTesterMixin, unittest.TestC
def
test_attention_outputs
(
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/mobilenet_v2/test_modeling_mobilenet_v2.py
View file @
59499bbe
...
...
@@ -15,7 +15,6 @@
""" Testing suite for the PyTorch MobileNetV2 model. """
import
inspect
import
unittest
from
transformers
import
MobileNetV2Config
...
...
@@ -228,18 +227,6 @@ class MobileNetV2ModelTest(ModelTesterMixin, PipelineTesterMixin, unittest.TestC
def
test_attention_outputs
(
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/mobilevit/test_modeling_mobilevit.py
View file @
59499bbe
...
...
@@ -15,7 +15,6 @@
""" Testing suite for the PyTorch MobileViT model. """
import
inspect
import
unittest
from
transformers
import
MobileViTConfig
...
...
@@ -221,18 +220,6 @@ class MobileViTModelTest(ModelTesterMixin, PipelineTesterMixin, unittest.TestCas
def
test_attention_outputs
(
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/mobilevitv2/test_modeling_mobilevitv2.py
View file @
59499bbe
...
...
@@ -15,7 +15,6 @@
""" Testing suite for the PyTorch MobileViTV2 model. """
import
inspect
import
unittest
from
transformers
import
MobileViTV2Config
...
...
@@ -228,18 +227,6 @@ class MobileViTV2ModelTest(ModelTesterMixin, PipelineTesterMixin, unittest.TestC
def
test_multi_gpu_data_parallel_forward
(
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/nat/test_modeling_nat.py
View file @
59499bbe
...
...
@@ -15,7 +15,6 @@
""" Testing suite for the PyTorch Nat model. """
import
collections
import
inspect
import
unittest
from
transformers
import
NatConfig
...
...
@@ -261,18 +260,6 @@ class NatModelTest(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_attention_outputs
(
self
):
self
.
skipTest
(
"Nat's attention operation is handled entirely by NATTEN."
)
...
...
tests/models/poolformer/test_modeling_poolformer.py
View file @
59499bbe
...
...
@@ -15,7 +15,6 @@
""" Testing suite for the PyTorch PoolFormer model. """
import
inspect
import
unittest
from
transformers
import
is_torch_available
,
is_vision_available
...
...
@@ -208,18 +207,6 @@ class PoolFormerModelTest(ModelTesterMixin, PipelineTesterMixin, unittest.TestCa
loss
=
model
(
**
inputs
).
loss
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
)
@
slow
def
test_model_from_pretrained
(
self
):
for
model_name
in
POOLFORMER_PRETRAINED_MODEL_ARCHIVE_LIST
[:
1
]:
...
...
tests/models/pvt/test_modeling_pvt.py
View file @
59499bbe
...
...
@@ -15,7 +15,6 @@
""" Testing suite for the PyTorch Pvt model. """
import
inspect
import
unittest
from
transformers
import
is_torch_available
,
is_vision_available
...
...
@@ -253,18 +252,6 @@ class PvtModelTest(ModelTesterMixin, PipelineTesterMixin, unittest.TestCase):
loss
=
model
(
**
inputs
).
loss
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
)
@
slow
def
test_model_from_pretrained
(
self
):
for
model_name
in
PVT_PRETRAINED_MODEL_ARCHIVE_LIST
[:
1
]:
...
...
tests/models/regnet/test_modeling_regnet.py
View file @
59499bbe
...
...
@@ -15,7 +15,6 @@
""" Testing suite for the PyTorch RegNet model. """
import
inspect
import
unittest
from
transformers
import
RegNetConfig
...
...
@@ -161,18 +160,6 @@ class RegNetModelTest(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/resnet/test_modeling_resnet.py
View file @
59499bbe
...
...
@@ -15,7 +15,6 @@
""" Testing suite for the PyTorch ResNet model. """
import
inspect
import
unittest
from
transformers
import
ResNetConfig
...
...
@@ -206,18 +205,6 @@ class ResNetModelTest(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/sam/test_modeling_sam.py
View file @
59499bbe
...
...
@@ -16,7 +16,6 @@
import
gc
import
inspect
import
unittest
import
requests
...
...
@@ -338,18 +337,6 @@ class SamModelTest(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/segformer/test_modeling_segformer.py
View file @
59499bbe
...
...
@@ -15,7 +15,6 @@
""" Testing suite for the PyTorch SegFormer model. """
import
inspect
import
unittest
from
transformers
import
SegformerConfig
,
is_torch_available
,
is_vision_available
...
...
@@ -212,18 +211,6 @@ class SegformerModelTest(ModelTesterMixin, PipelineTesterMixin, unittest.TestCas
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_attention_outputs
(
self
):
config
,
inputs_dict
=
self
.
model_tester
.
prepare_config_and_inputs_for_common
()
config
.
return_dict
=
True
...
...
tests/models/swiftformer/test_modeling_swiftformer.py
View file @
59499bbe
...
...
@@ -16,7 +16,6 @@
import
copy
import
inspect
import
unittest
from
transformers
import
PretrainedConfig
,
SwiftFormerConfig
...
...
@@ -177,18 +176,6 @@ class SwiftFormerModelTest(ModelTesterMixin, PipelineTesterMixin, unittest.TestC
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/swin/test_modeling_swin.py
View file @
59499bbe
...
...
@@ -15,7 +15,6 @@
""" Testing suite for the PyTorch Swin model. """
import
collections
import
inspect
import
unittest
from
transformers
import
SwinConfig
...
...
@@ -300,18 +299,6 @@ class SwinModelTest(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_attention_outputs
(
self
):
config
,
inputs_dict
=
self
.
model_tester
.
prepare_config_and_inputs_for_common
()
config
.
return_dict
=
True
...
...
tests/models/swin2sr/test_modeling_swin2sr.py
View file @
59499bbe
...
...
@@ -13,7 +13,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.
""" Testing suite for the PyTorch Swin2SR model. """
import
inspect
import
unittest
from
transformers
import
Swin2SRConfig
...
...
@@ -232,18 +231,6 @@ class Swin2SRModelTest(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
)
@
slow
def
test_model_from_pretrained
(
self
):
for
model_name
in
SWIN2SR_PRETRAINED_MODEL_ARCHIVE_LIST
[:
1
]:
...
...
tests/models/swinv2/test_modeling_swinv2.py
View file @
59499bbe
...
...
@@ -14,7 +14,6 @@
# limitations under the License.
""" Testing suite for the PyTorch Swinv2 model. """
import
collections
import
inspect
import
unittest
from
transformers
import
Swinv2Config
...
...
@@ -220,18 +219,6 @@ class Swinv2ModelTest(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_attention_outputs
(
self
):
config
,
inputs_dict
=
self
.
model_tester
.
prepare_config_and_inputs_for_common
()
config
.
return_dict
=
True
...
...
tests/models/timesformer/test_modeling_timesformer.py
View file @
59499bbe
...
...
@@ -16,7 +16,6 @@
import
copy
import
inspect
import
unittest
import
numpy
as
np
...
...
@@ -204,18 +203,6 @@ class TimesformerModelTest(ModelTesterMixin, PipelineTesterMixin, unittest.TestC
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/upernet/test_modeling_upernet.py
View file @
59499bbe
...
...
@@ -15,7 +15,6 @@
""" Testing suite for the PyTorch UperNet framework. """
import
inspect
import
unittest
from
huggingface_hub
import
hf_hub_download
...
...
@@ -170,18 +169,6 @@ class UperNetModelTest(ModelTesterMixin, PipelineTesterMixin, unittest.TestCase)
def
create_and_test_config_common_properties
(
self
):
return
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_semantic_segmentation
(
self
):
config_and_inputs
=
self
.
model_tester
.
prepare_config_and_inputs
()
self
.
model_tester
.
create_and_check_for_semantic_segmentation
(
*
config_and_inputs
)
...
...
tests/models/videomae/test_modeling_videomae.py
View file @
59499bbe
...
...
@@ -16,7 +16,6 @@
import
copy
import
inspect
import
unittest
import
numpy
as
np
...
...
@@ -228,18 +227,6 @@ class VideoMAEModelTest(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
)
...
...
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