Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions tests/test_modeling_tf_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ class TFModelTesterMixin:
test_resize_embeddings = True
test_head_masking = True
is_encoder_decoder = False
has_attentions = True

def _prepare_for_class(self, inputs_dict, model_class, return_labels=False) -> dict:
inputs_dict = copy.deepcopy(inputs_dict)
Expand Down Expand Up @@ -539,9 +540,7 @@ def check_pt_tf_models(tf_model, pt_model):

# Output all for aggressive testing
config.output_hidden_states = True
# Pure convolutional models have no attention
# TODO: use a better and general criteria
if "TFConvNext" not in model_class.__name__:
if self.has_attentions:
config.output_attentions = True

for k in ["attention_mask", "encoder_attention_mask", "decoder_attention_mask"]:
Expand All @@ -567,8 +566,6 @@ def check_pt_tf_models(tf_model, pt_model):
pt_model_class_name = model_class.__name__[2:] # Skip the "TF" at the beginning
pt_model_class = getattr(transformers, pt_model_class_name)

config.output_hidden_states = True

tf_model = model_class(config)
pt_model = pt_model_class(config)

Expand Down