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
7bb6933b
Unverified
Commit
7bb6933b
authored
Jun 13, 2023
by
Joao Gante
Committed by
GitHub
Jun 13, 2023
Browse files
TF: standardize `test_model_common_attributes` for language models (#23457)
parent
4ed07528
Changes
21
Hide whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
10 additions
and
348 deletions
+10
-348
src/transformers/models/ctrl/modeling_tf_ctrl.py
src/transformers/models/ctrl/modeling_tf_ctrl.py
+5
-0
src/transformers/models/transfo_xl/modeling_tf_transfo_xl.py
src/transformers/models/transfo_xl/modeling_tf_transfo_xl.py
+5
-0
templates/adding_a_new_model/cookiecutter-template-{{cookiecutter.modelname}}/test_modeling_tf_{{cookiecutter.lowercase_modelname}}.py
.../test_modeling_tf_{{cookiecutter.lowercase_modelname}}.py
+0
-20
tests/models/albert/test_modeling_tf_albert.py
tests/models/albert/test_modeling_tf_albert.py
+0
-21
tests/models/bart/test_modeling_tf_bart.py
tests/models/bart/test_modeling_tf_bart.py
+0
-20
tests/models/bert/test_modeling_tf_bert.py
tests/models/bert/test_modeling_tf_bert.py
+0
-21
tests/models/blenderbot/test_modeling_tf_blenderbot.py
tests/models/blenderbot/test_modeling_tf_blenderbot.py
+0
-20
tests/models/blenderbot_small/test_modeling_tf_blenderbot_small.py
...els/blenderbot_small/test_modeling_tf_blenderbot_small.py
+0
-20
tests/models/gpt2/test_modeling_tf_gpt2.py
tests/models/gpt2/test_modeling_tf_gpt2.py
+0
-18
tests/models/gptj/test_modeling_tf_gptj.py
tests/models/gptj/test_modeling_tf_gptj.py
+0
-18
tests/models/led/test_modeling_tf_led.py
tests/models/led/test_modeling_tf_led.py
+0
-20
tests/models/lxmert/test_modeling_tf_lxmert.py
tests/models/lxmert/test_modeling_tf_lxmert.py
+0
-21
tests/models/marian/test_modeling_tf_marian.py
tests/models/marian/test_modeling_tf_marian.py
+0
-20
tests/models/mbart/test_modeling_tf_mbart.py
tests/models/mbart/test_modeling_tf_mbart.py
+0
-20
tests/models/mobilebert/test_modeling_tf_mobilebert.py
tests/models/mobilebert/test_modeling_tf_mobilebert.py
+0
-21
tests/models/openai/test_modeling_tf_openai.py
tests/models/openai/test_modeling_tf_openai.py
+0
-18
tests/models/opt/test_modeling_tf_opt.py
tests/models/opt/test_modeling_tf_opt.py
+0
-14
tests/models/pegasus/test_modeling_tf_pegasus.py
tests/models/pegasus/test_modeling_tf_pegasus.py
+0
-20
tests/models/t5/test_modeling_tf_t5.py
tests/models/t5/test_modeling_tf_t5.py
+0
-18
tests/models/xglm/test_modeling_tf_xglm.py
tests/models/xglm/test_modeling_tf_xglm.py
+0
-18
No files found.
src/transformers/models/ctrl/modeling_tf_ctrl.py
View file @
7bb6933b
...
@@ -725,6 +725,11 @@ class TFCTRLForSequenceClassification(TFCTRLPreTrainedModel, TFSequenceClassific
...
@@ -725,6 +725,11 @@ class TFCTRLForSequenceClassification(TFCTRLPreTrainedModel, TFSequenceClassific
self
.
transformer
=
TFCTRLMainLayer
(
config
,
name
=
"transformer"
)
self
.
transformer
=
TFCTRLMainLayer
(
config
,
name
=
"transformer"
)
def
get_output_embeddings
(
self
):
def
get_output_embeddings
(
self
):
# Remove after transformers v4.32. Fix this model's `test_model_common_attributes` test too.
logger
.
warning
(
"Sequence classification models do not have output embeddings. `.get_output_embeddings` will be removed "
"in transformers v4.32."
)
return
self
.
transformer
.
w
return
self
.
transformer
.
w
@
unpack_inputs
@
unpack_inputs
...
...
src/transformers/models/transfo_xl/modeling_tf_transfo_xl.py
View file @
7bb6933b
...
@@ -1032,6 +1032,11 @@ class TFTransfoXLForSequenceClassification(TFTransfoXLPreTrainedModel, TFSequenc
...
@@ -1032,6 +1032,11 @@ class TFTransfoXLForSequenceClassification(TFTransfoXLPreTrainedModel, TFSequenc
self
.
transformer
=
TFTransfoXLMainLayer
(
config
,
name
=
"transformer"
)
self
.
transformer
=
TFTransfoXLMainLayer
(
config
,
name
=
"transformer"
)
def
get_output_embeddings
(
self
):
def
get_output_embeddings
(
self
):
# Remove after transformers v4.32. Fix this model's `test_model_common_attributes` test too.
logger
.
warning
(
"Sequence classification models do not have output embeddings. `.get_output_embeddings` will be removed "
"in transformers v4.32."
)
return
self
.
transformer
.
word_emb
return
self
.
transformer
.
word_emb
@
unpack_inputs
@
unpack_inputs
...
...
templates/adding_a_new_model/cookiecutter-template-{{cookiecutter.modelname}}/test_modeling_tf_{{cookiecutter.lowercase_modelname}}.py
View file @
7bb6933b
...
@@ -869,26 +869,6 @@ class TF{{cookiecutter.camelcase_modelname}}ModelTest(TFModelTesterMixin, unitte
...
@@ -869,26 +869,6 @@ class TF{{cookiecutter.camelcase_modelname}}ModelTest(TFModelTesterMixin, unitte
config_and_inputs
=
self
.
model_tester
.
prepare_config_and_inputs_for_common
()
config_and_inputs
=
self
.
model_tester
.
prepare_config_and_inputs_for_common
()
self
.
model_tester
.
check_decoder_model_past_large_inputs
(
*
config_and_inputs
)
self
.
model_tester
.
check_decoder_model_past_large_inputs
(
*
config_and_inputs
)
def
test_model_common_attributes
(
self
):
config
,
inputs_dict
=
self
.
model_tester
.
prepare_config_and_inputs_for_common
()
for
model_class
in
self
.
all_model_classes
:
model
=
model_class
(
config
)
assert
isinstance
(
model
.
get_input_embeddings
(),
tf
.
keras
.
layers
.
Layer
)
if
model_class
in
self
.
all_generative_model_classes
:
x
=
model
.
get_output_embeddings
()
assert
isinstance
(
x
,
tf
.
keras
.
layers
.
Layer
)
name
=
model
.
get_bias
()
assert
isinstance
(
name
,
dict
)
for
k
,
v
in
name
.
items
():
assert
isinstance
(
v
,
tf
.
Variable
)
else
:
x
=
model
.
get_output_embeddings
()
assert
x
is
None
name
=
model
.
get_bias
()
assert
name
is
None
@
unittest
.
skip
(
reason
=
"Template classes interact badly with this test."
)
@
unittest
.
skip
(
reason
=
"Template classes interact badly with this test."
)
def
test_keras_fit
(
self
):
def
test_keras_fit
(
self
):
pass
pass
...
...
tests/models/albert/test_modeling_tf_albert.py
View file @
7bb6933b
...
@@ -300,27 +300,6 @@ class TFAlbertModelTest(TFModelTesterMixin, PipelineTesterMixin, unittest.TestCa
...
@@ -300,27 +300,6 @@ class TFAlbertModelTest(TFModelTesterMixin, PipelineTesterMixin, unittest.TestCa
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_albert_for_question_answering
(
*
config_and_inputs
)
self
.
model_tester
.
create_and_check_albert_for_question_answering
(
*
config_and_inputs
)
def
test_model_common_attributes
(
self
):
config
,
inputs_dict
=
self
.
model_tester
.
prepare_config_and_inputs_for_common
()
list_lm_models
=
[
TFAlbertForPreTraining
,
TFAlbertForMaskedLM
]
for
model_class
in
self
.
all_model_classes
:
model
=
model_class
(
config
)
assert
isinstance
(
model
.
get_input_embeddings
(),
tf
.
keras
.
layers
.
Layer
)
if
model_class
in
list_lm_models
:
x
=
model
.
get_output_embeddings
()
assert
isinstance
(
x
,
tf
.
keras
.
layers
.
Layer
)
name
=
model
.
get_bias
()
assert
isinstance
(
name
,
dict
)
for
k
,
v
in
name
.
items
():
assert
isinstance
(
v
,
tf
.
Variable
)
else
:
x
=
model
.
get_output_embeddings
()
assert
x
is
None
name
=
model
.
get_bias
()
assert
name
is
None
@
slow
@
slow
def
test_model_from_pretrained
(
self
):
def
test_model_from_pretrained
(
self
):
for
model_name
in
TF_ALBERT_PRETRAINED_MODEL_ARCHIVE_LIST
[:
1
]:
for
model_name
in
TF_ALBERT_PRETRAINED_MODEL_ARCHIVE_LIST
[:
1
]:
...
...
tests/models/bart/test_modeling_tf_bart.py
View file @
7bb6933b
...
@@ -225,26 +225,6 @@ class TFBartModelTest(TFModelTesterMixin, TFCoreModelTesterMixin, PipelineTester
...
@@ -225,26 +225,6 @@ class TFBartModelTest(TFModelTesterMixin, TFCoreModelTesterMixin, PipelineTester
config_and_inputs
=
self
.
model_tester
.
prepare_config_and_inputs_for_common
()
config_and_inputs
=
self
.
model_tester
.
prepare_config_and_inputs_for_common
()
self
.
model_tester
.
check_decoder_model_past_large_inputs
(
*
config_and_inputs
)
self
.
model_tester
.
check_decoder_model_past_large_inputs
(
*
config_and_inputs
)
def
test_model_common_attributes
(
self
):
config
,
inputs_dict
=
self
.
model_tester
.
prepare_config_and_inputs_for_common
()
for
model_class
in
self
.
all_model_classes
:
model
=
model_class
(
config
)
assert
isinstance
(
model
.
get_input_embeddings
(),
tf
.
keras
.
layers
.
Layer
)
if
model_class
in
self
.
all_generative_model_classes
:
x
=
model
.
get_output_embeddings
()
assert
isinstance
(
x
,
tf
.
keras
.
layers
.
Layer
)
name
=
model
.
get_bias
()
assert
isinstance
(
name
,
dict
)
for
k
,
v
in
name
.
items
():
assert
isinstance
(
v
,
tf
.
Variable
)
else
:
x
=
model
.
get_output_embeddings
()
assert
x
is
None
name
=
model
.
get_bias
()
assert
name
is
None
@
tooslow
@
tooslow
def
test_saved_model_creation
(
self
):
def
test_saved_model_creation
(
self
):
pass
pass
...
...
tests/models/bert/test_modeling_tf_bert.py
View file @
7bb6933b
...
@@ -726,27 +726,6 @@ class TFBertModelTest(TFModelTesterMixin, TFCoreModelTesterMixin, PipelineTester
...
@@ -726,27 +726,6 @@ class TFBertModelTest(TFModelTesterMixin, TFCoreModelTesterMixin, PipelineTester
model
=
TFBertModel
.
from_pretrained
(
"jplu/tiny-tf-bert-random"
)
model
=
TFBertModel
.
from_pretrained
(
"jplu/tiny-tf-bert-random"
)
self
.
assertIsNotNone
(
model
)
self
.
assertIsNotNone
(
model
)
def
test_model_common_attributes
(
self
):
config
,
inputs_dict
=
self
.
model_tester
.
prepare_config_and_inputs_for_common
()
list_lm_models
=
[
TFBertForMaskedLM
,
TFBertForPreTraining
,
TFBertLMHeadModel
]
for
model_class
in
self
.
all_model_classes
:
model
=
model_class
(
config
)
assert
isinstance
(
model
.
get_input_embeddings
(),
tf
.
keras
.
layers
.
Layer
)
if
model_class
in
list_lm_models
:
x
=
model
.
get_output_embeddings
()
assert
isinstance
(
x
,
tf
.
keras
.
layers
.
Layer
)
name
=
model
.
get_bias
()
assert
isinstance
(
name
,
dict
)
for
k
,
v
in
name
.
items
():
assert
isinstance
(
v
,
tf
.
Variable
)
else
:
x
=
model
.
get_output_embeddings
()
assert
x
is
None
name
=
model
.
get_bias
()
assert
name
is
None
def
test_custom_load_tf_weights
(
self
):
def
test_custom_load_tf_weights
(
self
):
model
,
output_loading_info
=
TFBertForTokenClassification
.
from_pretrained
(
model
,
output_loading_info
=
TFBertForTokenClassification
.
from_pretrained
(
"jplu/tiny-tf-bert-random"
,
output_loading_info
=
True
"jplu/tiny-tf-bert-random"
,
output_loading_info
=
True
...
...
tests/models/blenderbot/test_modeling_tf_blenderbot.py
View file @
7bb6933b
...
@@ -207,26 +207,6 @@ class TFBlenderbotModelTest(TFModelTesterMixin, PipelineTesterMixin, unittest.Te
...
@@ -207,26 +207,6 @@ class TFBlenderbotModelTest(TFModelTesterMixin, PipelineTesterMixin, unittest.Te
config_and_inputs
=
self
.
model_tester
.
prepare_config_and_inputs_for_common
()
config_and_inputs
=
self
.
model_tester
.
prepare_config_and_inputs_for_common
()
self
.
model_tester
.
check_decoder_model_past_large_inputs
(
*
config_and_inputs
)
self
.
model_tester
.
check_decoder_model_past_large_inputs
(
*
config_and_inputs
)
def
test_model_common_attributes
(
self
):
config
,
inputs_dict
=
self
.
model_tester
.
prepare_config_and_inputs_for_common
()
for
model_class
in
self
.
all_model_classes
:
model
=
model_class
(
config
)
assert
isinstance
(
model
.
get_input_embeddings
(),
tf
.
keras
.
layers
.
Layer
)
if
model_class
in
self
.
all_generative_model_classes
:
x
=
model
.
get_output_embeddings
()
assert
isinstance
(
x
,
tf
.
keras
.
layers
.
Layer
)
name
=
model
.
get_bias
()
assert
isinstance
(
name
,
dict
)
for
k
,
v
in
name
.
items
():
assert
isinstance
(
v
,
tf
.
Variable
)
else
:
x
=
model
.
get_output_embeddings
()
assert
x
is
None
name
=
model
.
get_bias
()
assert
name
is
None
@
tooslow
@
tooslow
def
test_saved_model_creation
(
self
):
def
test_saved_model_creation
(
self
):
pass
pass
...
...
tests/models/blenderbot_small/test_modeling_tf_blenderbot_small.py
View file @
7bb6933b
...
@@ -209,26 +209,6 @@ class TFBlenderbotSmallModelTest(TFModelTesterMixin, PipelineTesterMixin, unitte
...
@@ -209,26 +209,6 @@ class TFBlenderbotSmallModelTest(TFModelTesterMixin, PipelineTesterMixin, unitte
config_and_inputs
=
self
.
model_tester
.
prepare_config_and_inputs_for_common
()
config_and_inputs
=
self
.
model_tester
.
prepare_config_and_inputs_for_common
()
self
.
model_tester
.
check_decoder_model_past_large_inputs
(
*
config_and_inputs
)
self
.
model_tester
.
check_decoder_model_past_large_inputs
(
*
config_and_inputs
)
def
test_model_common_attributes
(
self
):
config
,
inputs_dict
=
self
.
model_tester
.
prepare_config_and_inputs_for_common
()
for
model_class
in
self
.
all_model_classes
:
model
=
model_class
(
config
)
assert
isinstance
(
model
.
get_input_embeddings
(),
tf
.
keras
.
layers
.
Layer
)
if
model_class
in
self
.
all_generative_model_classes
:
x
=
model
.
get_output_embeddings
()
assert
isinstance
(
x
,
tf
.
keras
.
layers
.
Layer
)
name
=
model
.
get_bias
()
assert
isinstance
(
name
,
dict
)
for
k
,
v
in
name
.
items
():
assert
isinstance
(
v
,
tf
.
Variable
)
else
:
x
=
model
.
get_output_embeddings
()
assert
x
is
None
name
=
model
.
get_bias
()
assert
name
is
None
@
tooslow
@
tooslow
def
test_saved_model_creation
(
self
):
def
test_saved_model_creation
(
self
):
pass
pass
...
...
tests/models/gpt2/test_modeling_tf_gpt2.py
View file @
7bb6933b
...
@@ -416,24 +416,6 @@ class TFGPT2ModelTest(TFModelTesterMixin, TFCoreModelTesterMixin, PipelineTester
...
@@ -416,24 +416,6 @@ class TFGPT2ModelTest(TFModelTesterMixin, TFCoreModelTesterMixin, PipelineTester
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_gpt2_double_head
(
*
config_and_inputs
)
self
.
model_tester
.
create_and_check_gpt2_double_head
(
*
config_and_inputs
)
def
test_model_common_attributes
(
self
):
config
,
inputs_dict
=
self
.
model_tester
.
prepare_config_and_inputs_for_common
()
for
model_class
in
self
.
all_model_classes
:
model
=
model_class
(
config
)
assert
isinstance
(
model
.
get_input_embeddings
(),
tf
.
keras
.
layers
.
Layer
)
if
model_class
in
self
.
all_generative_model_classes
:
x
=
model
.
get_output_embeddings
()
assert
isinstance
(
x
,
tf
.
keras
.
layers
.
Layer
)
name
=
model
.
get_bias
()
assert
name
is
None
else
:
x
=
model
.
get_output_embeddings
()
assert
x
is
None
name
=
model
.
get_bias
()
assert
name
is
None
def
test_gpt2_sequence_classification_model
(
self
):
def
test_gpt2_sequence_classification_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_gpt2_for_sequence_classification
(
*
config_and_inputs
)
self
.
model_tester
.
create_and_check_gpt2_for_sequence_classification
(
*
config_and_inputs
)
...
...
tests/models/gptj/test_modeling_tf_gptj.py
View file @
7bb6933b
...
@@ -363,24 +363,6 @@ class TFGPTJModelTest(TFModelTesterMixin, TFCoreModelTesterMixin, PipelineTester
...
@@ -363,24 +363,6 @@ class TFGPTJModelTest(TFModelTesterMixin, TFCoreModelTesterMixin, PipelineTester
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_gptj_lm_head_model
(
*
config_and_inputs
)
self
.
model_tester
.
create_and_check_gptj_lm_head_model
(
*
config_and_inputs
)
def
test_model_common_attributes
(
self
):
config
,
inputs_dict
=
self
.
model_tester
.
prepare_config_and_inputs_for_common
()
for
model_class
in
self
.
all_model_classes
:
model
=
model_class
(
config
)
assert
isinstance
(
model
.
get_input_embeddings
(),
tf
.
keras
.
layers
.
Layer
)
if
model_class
in
self
.
all_generative_model_classes
:
x
=
model
.
get_output_embeddings
()
assert
isinstance
(
x
,
tf
.
keras
.
layers
.
Layer
)
name
=
model
.
get_bias
()
assert
name
is
None
else
:
x
=
model
.
get_output_embeddings
()
assert
x
is
None
name
=
model
.
get_bias
()
assert
name
is
None
@
slow
@
slow
@
unittest
.
skipIf
(
@
unittest
.
skipIf
(
not
is_tf_available
()
or
len
(
tf
.
config
.
list_physical_devices
(
"GPU"
))
>
0
,
not
is_tf_available
()
or
len
(
tf
.
config
.
list_physical_devices
(
"GPU"
))
>
0
,
...
...
tests/models/led/test_modeling_tf_led.py
View file @
7bb6933b
...
@@ -222,26 +222,6 @@ class TFLEDModelTest(TFModelTesterMixin, PipelineTesterMixin, unittest.TestCase)
...
@@ -222,26 +222,6 @@ class TFLEDModelTest(TFModelTesterMixin, PipelineTesterMixin, unittest.TestCase)
config_and_inputs
=
self
.
model_tester
.
prepare_config_and_inputs_for_common
()
config_and_inputs
=
self
.
model_tester
.
prepare_config_and_inputs_for_common
()
self
.
model_tester
.
check_decoder_model_past_large_inputs
(
*
config_and_inputs
)
self
.
model_tester
.
check_decoder_model_past_large_inputs
(
*
config_and_inputs
)
def
test_model_common_attributes
(
self
):
config
,
inputs_dict
=
self
.
model_tester
.
prepare_config_and_inputs_for_common
()
for
model_class
in
self
.
all_model_classes
:
model
=
model_class
(
config
)
assert
isinstance
(
model
.
get_input_embeddings
(),
tf
.
keras
.
layers
.
Layer
)
if
model_class
in
self
.
all_generative_model_classes
:
x
=
model
.
get_output_embeddings
()
assert
isinstance
(
x
,
tf
.
keras
.
layers
.
Layer
)
name
=
model
.
get_bias
()
assert
isinstance
(
name
,
dict
)
for
k
,
v
in
name
.
items
():
assert
isinstance
(
v
,
tf
.
Variable
)
else
:
x
=
model
.
get_output_embeddings
()
assert
x
is
None
name
=
model
.
get_bias
()
assert
name
is
None
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
()
inputs_dict
[
"global_attention_mask"
]
=
tf
.
zeros_like
(
inputs_dict
[
"attention_mask"
])
inputs_dict
[
"global_attention_mask"
]
=
tf
.
zeros_like
(
inputs_dict
[
"attention_mask"
])
...
...
tests/models/lxmert/test_modeling_tf_lxmert.py
View file @
7bb6933b
...
@@ -581,27 +581,6 @@ class TFLxmertModelTest(TFModelTesterMixin, PipelineTesterMixin, unittest.TestCa
...
@@ -581,27 +581,6 @@ class TFLxmertModelTest(TFModelTesterMixin, PipelineTesterMixin, unittest.TestCa
extended_model
=
tf
.
keras
.
Model
(
inputs
=
[
input_ids
,
visual_feats
,
visual_pos
],
outputs
=
[
outputs
])
extended_model
=
tf
.
keras
.
Model
(
inputs
=
[
input_ids
,
visual_feats
,
visual_pos
],
outputs
=
[
outputs
])
extended_model
.
compile
(
optimizer
=
optimizer
,
loss
=
loss
,
metrics
=
[
metric
])
extended_model
.
compile
(
optimizer
=
optimizer
,
loss
=
loss
,
metrics
=
[
metric
])
def
test_model_common_attributes
(
self
):
config
,
inputs_dict
=
self
.
model_tester
.
prepare_config_and_inputs_for_common
()
list_lm_models
=
[
TFLxmertForPreTraining
]
for
model_class
in
self
.
all_model_classes
:
model
=
model_class
(
config
)
assert
isinstance
(
model
.
get_input_embeddings
(),
tf
.
keras
.
layers
.
Layer
)
if
model_class
in
list_lm_models
:
x
=
model
.
get_output_embeddings
()
assert
isinstance
(
x
,
tf
.
keras
.
layers
.
Layer
)
name
=
model
.
get_bias
()
assert
isinstance
(
name
,
dict
)
for
k
,
v
in
name
.
items
():
assert
isinstance
(
v
,
tf
.
Variable
)
else
:
x
=
model
.
get_output_embeddings
()
assert
x
is
None
name
=
model
.
get_bias
()
assert
name
is
None
@
tooslow
@
tooslow
def
test_saved_model_creation
(
self
):
def
test_saved_model_creation
(
self
):
pass
pass
...
...
tests/models/marian/test_modeling_tf_marian.py
View file @
7bb6933b
...
@@ -240,26 +240,6 @@ class TFMarianModelTest(TFModelTesterMixin, PipelineTesterMixin, unittest.TestCa
...
@@ -240,26 +240,6 @@ class TFMarianModelTest(TFModelTesterMixin, PipelineTesterMixin, unittest.TestCa
extended_model
=
tf
.
keras
.
Model
(
inputs
=
[
input_ids
],
outputs
=
[
outputs
])
extended_model
=
tf
.
keras
.
Model
(
inputs
=
[
input_ids
],
outputs
=
[
outputs
])
extended_model
.
compile
(
optimizer
=
optimizer
,
loss
=
loss
,
metrics
=
[
metric
])
extended_model
.
compile
(
optimizer
=
optimizer
,
loss
=
loss
,
metrics
=
[
metric
])
def
test_model_common_attributes
(
self
):
config
,
inputs_dict
=
self
.
model_tester
.
prepare_config_and_inputs_for_common
()
for
model_class
in
self
.
all_model_classes
:
model
=
model_class
(
config
)
assert
isinstance
(
model
.
get_input_embeddings
(),
tf
.
keras
.
layers
.
Layer
)
if
model_class
in
self
.
all_generative_model_classes
:
x
=
model
.
get_output_embeddings
()
assert
isinstance
(
x
,
tf
.
keras
.
layers
.
Layer
)
name
=
model
.
get_bias
()
assert
isinstance
(
name
,
dict
)
for
k
,
v
in
name
.
items
():
assert
isinstance
(
v
,
tf
.
Variable
)
else
:
x
=
model
.
get_output_embeddings
()
assert
x
is
None
name
=
model
.
get_bias
()
assert
name
is
None
@
tooslow
@
tooslow
def
test_saved_model_creation
(
self
):
def
test_saved_model_creation
(
self
):
pass
pass
...
...
tests/models/mbart/test_modeling_tf_mbart.py
View file @
7bb6933b
...
@@ -222,26 +222,6 @@ class TFMBartModelTest(TFModelTesterMixin, PipelineTesterMixin, unittest.TestCas
...
@@ -222,26 +222,6 @@ class TFMBartModelTest(TFModelTesterMixin, PipelineTesterMixin, unittest.TestCas
config_and_inputs
=
self
.
model_tester
.
prepare_config_and_inputs_for_common
()
config_and_inputs
=
self
.
model_tester
.
prepare_config_and_inputs_for_common
()
self
.
model_tester
.
check_decoder_model_past_large_inputs
(
*
config_and_inputs
)
self
.
model_tester
.
check_decoder_model_past_large_inputs
(
*
config_and_inputs
)
def
test_model_common_attributes
(
self
):
config
,
inputs_dict
=
self
.
model_tester
.
prepare_config_and_inputs_for_common
()
for
model_class
in
self
.
all_model_classes
:
model
=
model_class
(
config
)
assert
isinstance
(
model
.
get_input_embeddings
(),
tf
.
keras
.
layers
.
Layer
)
if
model_class
in
self
.
all_generative_model_classes
:
x
=
model
.
get_output_embeddings
()
assert
isinstance
(
x
,
tf
.
keras
.
layers
.
Layer
)
name
=
model
.
get_bias
()
assert
isinstance
(
name
,
dict
)
for
k
,
v
in
name
.
items
():
assert
isinstance
(
v
,
tf
.
Variable
)
else
:
x
=
model
.
get_output_embeddings
()
assert
x
is
None
name
=
model
.
get_bias
()
assert
name
is
None
@
tooslow
@
tooslow
def
test_saved_model_creation
(
self
):
def
test_saved_model_creation
(
self
):
pass
pass
...
...
tests/models/mobilebert/test_modeling_tf_mobilebert.py
View file @
7bb6933b
...
@@ -311,27 +311,6 @@ class TFMobileBertModelTest(TFModelTesterMixin, PipelineTesterMixin, unittest.Te
...
@@ -311,27 +311,6 @@ class TFMobileBertModelTest(TFModelTesterMixin, PipelineTesterMixin, unittest.Te
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_mobilebert_for_token_classification
(
*
config_and_inputs
)
self
.
model_tester
.
create_and_check_mobilebert_for_token_classification
(
*
config_and_inputs
)
def
test_model_common_attributes
(
self
):
config
,
inputs_dict
=
self
.
model_tester
.
prepare_config_and_inputs_for_common
()
list_lm_models
=
[
TFMobileBertForMaskedLM
,
TFMobileBertForPreTraining
]
for
model_class
in
self
.
all_model_classes
:
model
=
model_class
(
config
)
assert
isinstance
(
model
.
get_input_embeddings
(),
tf
.
keras
.
layers
.
Layer
)
if
model_class
in
list_lm_models
:
x
=
model
.
get_output_embeddings
()
assert
isinstance
(
x
,
tf
.
keras
.
layers
.
Layer
)
name
=
model
.
get_bias
()
assert
isinstance
(
name
,
dict
)
for
k
,
v
in
name
.
items
():
assert
isinstance
(
v
,
tf
.
Variable
)
else
:
x
=
model
.
get_output_embeddings
()
assert
x
is
None
name
=
model
.
get_bias
()
assert
name
is
None
@
slow
@
slow
def
test_keras_fit
(
self
):
def
test_keras_fit
(
self
):
# Override as it is a slow test on this model
# Override as it is a slow test on this model
...
...
tests/models/openai/test_modeling_tf_openai.py
View file @
7bb6933b
...
@@ -247,24 +247,6 @@ class TFOpenAIGPTModelTest(TFModelTesterMixin, PipelineTesterMixin, unittest.Tes
...
@@ -247,24 +247,6 @@ class TFOpenAIGPTModelTest(TFModelTesterMixin, PipelineTesterMixin, unittest.Tes
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_openai_gpt_double_head
(
*
config_and_inputs
)
self
.
model_tester
.
create_and_check_openai_gpt_double_head
(
*
config_and_inputs
)
def
test_model_common_attributes
(
self
):
config
,
inputs_dict
=
self
.
model_tester
.
prepare_config_and_inputs_for_common
()
for
model_class
in
self
.
all_model_classes
:
model
=
model_class
(
config
)
assert
isinstance
(
model
.
get_input_embeddings
(),
tf
.
keras
.
layers
.
Layer
)
if
model_class
in
self
.
all_generative_model_classes
:
x
=
model
.
get_output_embeddings
()
assert
isinstance
(
x
,
tf
.
keras
.
layers
.
Layer
)
name
=
model
.
get_bias
()
assert
name
is
None
else
:
x
=
model
.
get_output_embeddings
()
assert
x
is
None
name
=
model
.
get_bias
()
assert
name
is
None
def
test_openai_gpt_sequence_classification_model
(
self
):
def
test_openai_gpt_sequence_classification_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_openai_gpt_for_sequence_classification
(
*
config_and_inputs
)
self
.
model_tester
.
create_and_check_openai_gpt_for_sequence_classification
(
*
config_and_inputs
)
...
...
tests/models/opt/test_modeling_tf_opt.py
View file @
7bb6933b
...
@@ -171,20 +171,6 @@ class TFOPTModelTest(TFModelTesterMixin, PipelineTesterMixin, unittest.TestCase)
...
@@ -171,20 +171,6 @@ class TFOPTModelTest(TFModelTesterMixin, PipelineTesterMixin, unittest.TestCase)
config_and_inputs
=
self
.
model_tester
.
prepare_config_and_inputs_for_common
()
config_and_inputs
=
self
.
model_tester
.
prepare_config_and_inputs_for_common
()
self
.
model_tester
.
check_decoder_model_past_large_inputs
(
*
config_and_inputs
)
self
.
model_tester
.
check_decoder_model_past_large_inputs
(
*
config_and_inputs
)
def
test_model_common_attributes
(
self
):
config
,
inputs_dict
=
self
.
model_tester
.
prepare_config_and_inputs_for_common
()
for
model_class
in
self
.
all_model_classes
:
model
=
model_class
(
config
)
assert
isinstance
(
model
.
get_input_embeddings
(),
tf
.
keras
.
layers
.
Layer
)
if
model_class
in
self
.
all_generative_model_classes
:
x
=
model
.
get_output_embeddings
()
assert
isinstance
(
x
,
tf
.
keras
.
layers
.
Layer
)
else
:
x
=
model
.
get_output_embeddings
()
assert
x
is
None
def
test_resize_token_embeddings
(
self
):
def
test_resize_token_embeddings
(
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
()
...
...
tests/models/pegasus/test_modeling_tf_pegasus.py
View file @
7bb6933b
...
@@ -238,26 +238,6 @@ class TFPegasusModelTest(TFModelTesterMixin, PipelineTesterMixin, unittest.TestC
...
@@ -238,26 +238,6 @@ class TFPegasusModelTest(TFModelTesterMixin, PipelineTesterMixin, unittest.TestC
extended_model
=
tf
.
keras
.
Model
(
inputs
=
[
input_ids
],
outputs
=
[
outputs
])
extended_model
=
tf
.
keras
.
Model
(
inputs
=
[
input_ids
],
outputs
=
[
outputs
])
extended_model
.
compile
(
optimizer
=
optimizer
,
loss
=
loss
,
metrics
=
[
metric
])
extended_model
.
compile
(
optimizer
=
optimizer
,
loss
=
loss
,
metrics
=
[
metric
])
def
test_model_common_attributes
(
self
):
config
,
inputs_dict
=
self
.
model_tester
.
prepare_config_and_inputs_for_common
()
for
model_class
in
self
.
all_model_classes
:
model
=
model_class
(
config
)
assert
isinstance
(
model
.
get_input_embeddings
(),
tf
.
keras
.
layers
.
Layer
)
if
model_class
in
self
.
all_generative_model_classes
:
x
=
model
.
get_output_embeddings
()
assert
isinstance
(
x
,
tf
.
keras
.
layers
.
Layer
)
name
=
model
.
get_bias
()
assert
isinstance
(
name
,
dict
)
for
k
,
v
in
name
.
items
():
assert
isinstance
(
v
,
tf
.
Variable
)
else
:
x
=
model
.
get_output_embeddings
()
assert
x
is
None
name
=
model
.
get_bias
()
assert
name
is
None
@
tooslow
@
tooslow
def
test_saved_model_creation
(
self
):
def
test_saved_model_creation
(
self
):
pass
pass
...
...
tests/models/t5/test_modeling_tf_t5.py
View file @
7bb6933b
...
@@ -300,24 +300,6 @@ class TFT5ModelTest(TFModelTesterMixin, PipelineTesterMixin, unittest.TestCase):
...
@@ -300,24 +300,6 @@ class TFT5ModelTest(TFModelTesterMixin, PipelineTesterMixin, unittest.TestCase):
self
.
model_tester
.
create_and_check_t5_decoder_model_past_large_inputs
(
*
config_and_inputs
)
self
.
model_tester
.
create_and_check_t5_decoder_model_past_large_inputs
(
*
config_and_inputs
)
def
test_model_common_attributes
(
self
):
config
,
inputs_dict
=
self
.
model_tester
.
prepare_config_and_inputs_for_common
()
for
model_class
in
self
.
all_model_classes
:
model
=
model_class
(
config
)
assert
isinstance
(
model
.
get_input_embeddings
(),
tf
.
keras
.
layers
.
Layer
)
if
model_class
in
self
.
all_generative_model_classes
:
x
=
model
.
get_output_embeddings
()
assert
isinstance
(
x
,
tf
.
keras
.
layers
.
Layer
)
name
=
model
.
get_bias
()
assert
name
is
None
else
:
x
=
model
.
get_output_embeddings
()
assert
x
is
None
name
=
model
.
get_bias
()
assert
name
is
None
@
tooslow
@
tooslow
def
test_saved_model_creation
(
self
):
def
test_saved_model_creation
(
self
):
pass
pass
...
...
tests/models/xglm/test_modeling_tf_xglm.py
View file @
7bb6933b
...
@@ -160,24 +160,6 @@ class TFXGLMModelTest(TFModelTesterMixin, PipelineTesterMixin, unittest.TestCase
...
@@ -160,24 +160,6 @@ class TFXGLMModelTest(TFModelTesterMixin, PipelineTesterMixin, unittest.TestCase
def
test_config
(
self
):
def
test_config
(
self
):
self
.
config_tester
.
run_common_tests
()
self
.
config_tester
.
run_common_tests
()
def
test_model_common_attributes
(
self
):
config
,
inputs_dict
=
self
.
model_tester
.
prepare_config_and_inputs_for_common
()
for
model_class
in
self
.
all_model_classes
:
model
=
model_class
(
config
)
assert
isinstance
(
model
.
get_input_embeddings
(),
tf
.
keras
.
layers
.
Layer
)
if
model_class
in
self
.
all_generative_model_classes
:
x
=
model
.
get_output_embeddings
()
assert
isinstance
(
x
,
tf
.
keras
.
layers
.
Layer
)
name
=
model
.
get_bias
()
assert
name
is
None
else
:
x
=
model
.
get_output_embeddings
()
assert
x
is
None
name
=
model
.
get_bias
()
assert
name
is
None
@
slow
@
slow
def
test_model_from_pretrained
(
self
):
def
test_model_from_pretrained
(
self
):
for
model_name
in
TF_XGLM_PRETRAINED_MODEL_ARCHIVE_LIST
[:
1
]:
for
model_name
in
TF_XGLM_PRETRAINED_MODEL_ARCHIVE_LIST
[:
1
]:
...
...
Prev
1
2
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