Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
chenpangpang
transformers
Commits
e9d51387
Unverified
Commit
e9d51387
authored
Jun 08, 2022
by
Joao Gante
Committed by
GitHub
Jun 08, 2022
Browse files
TF: Merge PT and TF behavior for Bart when no decoder_input_ids are passed (#17593)
* Merge PT and TF behavior
parent
e160a5dd
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
6 deletions
+8
-6
src/transformers/models/bart/modeling_tf_bart.py
src/transformers/models/bart/modeling_tf_bart.py
+8
-6
No files found.
src/transformers/models/bart/modeling_tf_bart.py
View file @
e9d51387
...
...
@@ -1073,14 +1073,16 @@ class TFBartMainLayer(tf.keras.layers.Layer):
**
kwargs
)
->
Union
[
TFSeq2SeqModelOutput
,
Tuple
[
tf
.
Tensor
]]:
# different to other models, Bart automatically creates decoder_input_ids from
# input_ids if no decoder_input_ids are provided
if
decoder_input_ids
is
None
and
decoder_inputs_embeds
is
None
:
use_cache
=
False
output_hidden_states
=
(
output_hidden_states
if
output_hidden_states
is
not
None
else
self
.
config
.
output_hidden_states
)
if
input_ids
is
None
:
raise
ValueError
(
"If no `decoder_input_ids` or `decoder_inputs_embeds` are "
"passed, `input_ids` cannot be `None`. Please pass either "
"`input_ids` or `decoder_input_ids` or `decoder_inputs_embeds`."
)
if
decoder_input_ids
is
None
and
input_ids
is
not
None
:
decoder_input_ids
=
shift_tokens_right
(
input_ids
,
self
.
config
.
pad_token_id
,
self
.
config
.
decoder_start_token_id
)
...
...
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