From f0aacc140bff272b12d234d598439e44074b67e4 Mon Sep 17 00:00:00 2001 From: Yih-Dar <2521628+ydshieh@users.noreply.github.com> Date: Fri, 4 Mar 2022 17:50:24 +0100 Subject: [PATCH] Do not change the output from tuple to list - to match PT's version (#15918) * Do not change the output from tuple to list - to match PT's version * Fix the same issues for 5 other models and the template Co-authored-by: ydshieh --- src/transformers/models/bart/modeling_tf_bart.py | 6 ------ .../models/blenderbot/modeling_tf_blenderbot.py | 6 ------ .../models/blenderbot_small/modeling_tf_blenderbot_small.py | 6 ------ src/transformers/models/marian/modeling_tf_marian.py | 6 ------ src/transformers/models/mbart/modeling_tf_mbart.py | 6 ------ src/transformers/models/pegasus/modeling_tf_pegasus.py | 6 ------ .../modeling_tf_{{cookiecutter.lowercase_modelname}}.py | 6 ------ 7 files changed, 42 deletions(-) diff --git a/src/transformers/models/bart/modeling_tf_bart.py b/src/transformers/models/bart/modeling_tf_bart.py index 058fdb99f2..a618b8a485 100644 --- a/src/transformers/models/bart/modeling_tf_bart.py +++ b/src/transformers/models/bart/modeling_tf_bart.py @@ -1012,12 +1012,6 @@ class TFBartDecoder(tf.keras.layers.Layer): if inputs["output_hidden_states"]: all_hidden_states += (hidden_states,) - if inputs["output_attentions"]: - all_self_attns = list(all_self_attns) - - if inputs["encoder_hidden_states"] is not None: - all_cross_attns = list(all_cross_attns) - if inputs["use_cache"]: present_key_values = (inputs["encoder_hidden_states"], present_key_values) diff --git a/src/transformers/models/blenderbot/modeling_tf_blenderbot.py b/src/transformers/models/blenderbot/modeling_tf_blenderbot.py index 65135a1d07..c0cf399212 100644 --- a/src/transformers/models/blenderbot/modeling_tf_blenderbot.py +++ b/src/transformers/models/blenderbot/modeling_tf_blenderbot.py @@ -1011,12 +1011,6 @@ class TFBlenderbotDecoder(tf.keras.layers.Layer): if inputs["output_hidden_states"]: all_hidden_states += (hidden_states,) - if inputs["output_attentions"]: - all_self_attns = list(all_self_attns) - - if inputs["encoder_hidden_states"] is not None: - all_cross_attns = list(all_cross_attns) - if inputs["use_cache"]: present_key_values = (inputs["encoder_hidden_states"], present_key_values) diff --git a/src/transformers/models/blenderbot_small/modeling_tf_blenderbot_small.py b/src/transformers/models/blenderbot_small/modeling_tf_blenderbot_small.py index 0243030a43..3c9a4b40f9 100644 --- a/src/transformers/models/blenderbot_small/modeling_tf_blenderbot_small.py +++ b/src/transformers/models/blenderbot_small/modeling_tf_blenderbot_small.py @@ -1010,12 +1010,6 @@ class TFBlenderbotSmallDecoder(tf.keras.layers.Layer): if inputs["output_hidden_states"]: all_hidden_states += (hidden_states,) - if inputs["output_attentions"]: - all_self_attns = list(all_self_attns) - - if inputs["encoder_hidden_states"] is not None: - all_cross_attns = list(all_cross_attns) - if inputs["use_cache"]: present_key_values = (inputs["encoder_hidden_states"], present_key_values) diff --git a/src/transformers/models/marian/modeling_tf_marian.py b/src/transformers/models/marian/modeling_tf_marian.py index ba094d6a0a..d81c052b6d 100644 --- a/src/transformers/models/marian/modeling_tf_marian.py +++ b/src/transformers/models/marian/modeling_tf_marian.py @@ -1050,12 +1050,6 @@ class TFMarianDecoder(tf.keras.layers.Layer): if inputs["output_hidden_states"]: all_hidden_states += (hidden_states,) - if inputs["output_attentions"]: - all_self_attns = list(all_self_attns) - - if inputs["encoder_hidden_states"] is not None: - all_cross_attns = list(all_cross_attns) - if inputs["use_cache"]: present_key_values = (inputs["encoder_hidden_states"], present_key_values) diff --git a/src/transformers/models/mbart/modeling_tf_mbart.py b/src/transformers/models/mbart/modeling_tf_mbart.py index 59e41bd694..bd11d16010 100644 --- a/src/transformers/models/mbart/modeling_tf_mbart.py +++ b/src/transformers/models/mbart/modeling_tf_mbart.py @@ -1034,12 +1034,6 @@ class TFMBartDecoder(tf.keras.layers.Layer): if inputs["output_hidden_states"]: all_hidden_states += (hidden_states,) - if inputs["output_attentions"]: - all_self_attns = list(all_self_attns) - - if inputs["encoder_hidden_states"] is not None: - all_cross_attns = list(all_cross_attns) - if inputs["use_cache"]: present_key_values = (inputs["encoder_hidden_states"], present_key_values) diff --git a/src/transformers/models/pegasus/modeling_tf_pegasus.py b/src/transformers/models/pegasus/modeling_tf_pegasus.py index cb14687406..9461fa871a 100644 --- a/src/transformers/models/pegasus/modeling_tf_pegasus.py +++ b/src/transformers/models/pegasus/modeling_tf_pegasus.py @@ -1058,12 +1058,6 @@ class TFPegasusDecoder(tf.keras.layers.Layer): if inputs["output_hidden_states"]: all_hidden_states += (hidden_states,) - if inputs["output_attentions"]: - all_self_attns = list(all_self_attns) - - if inputs["encoder_hidden_states"] is not None: - all_cross_attns = list(all_cross_attns) - if inputs["use_cache"]: present_key_values = (inputs["encoder_hidden_states"], present_key_values) diff --git a/templates/adding_a_new_model/cookiecutter-template-{{cookiecutter.modelname}}/modeling_tf_{{cookiecutter.lowercase_modelname}}.py b/templates/adding_a_new_model/cookiecutter-template-{{cookiecutter.modelname}}/modeling_tf_{{cookiecutter.lowercase_modelname}}.py index 726438c17d..bb7adc9d05 100644 --- a/templates/adding_a_new_model/cookiecutter-template-{{cookiecutter.modelname}}/modeling_tf_{{cookiecutter.lowercase_modelname}}.py +++ b/templates/adding_a_new_model/cookiecutter-template-{{cookiecutter.modelname}}/modeling_tf_{{cookiecutter.lowercase_modelname}}.py @@ -2736,12 +2736,6 @@ class TF{{cookiecutter.camelcase_modelname}}Decoder(tf.keras.layers.Layer): if inputs["output_hidden_states"]: all_hidden_states += (hidden_states,) - if inputs["output_attentions"]: - all_self_attns = list(all_self_attns) - - if inputs["encoder_hidden_states"] is not None: - all_cross_attns = list(all_cross_attns) - if inputs["use_cache"]: present_key_values = (inputs["encoder_hidden_states"], present_key_values)