Skip to content

Commit

Permalink
CLI: Properly detect encoder-decoder models (huggingface#17605)
Browse files Browse the repository at this point in the history
  • Loading branch information
gante authored Jun 8, 2022
1 parent ee82c86 commit 7d0b6fc
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/transformers/commands/pt_to_tf.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ def run(self):
tf_from_pt_model = tf_class.from_pretrained(self._local_dir, from_pt=True)

# Extra input requirements, in addition to the input modality
if hasattr(pt_model, "encoder") and hasattr(pt_model, "decoder"):
if config.is_encoder_decoder or (hasattr(pt_model, "encoder") and hasattr(pt_model, "decoder")):
decoder_input_ids = np.asarray([[1], [1]], dtype=int) * pt_model.config.decoder_start_token_id
pt_input.update({"decoder_input_ids": torch.tensor(decoder_input_ids)})
tf_input.update({"decoder_input_ids": tf.convert_to_tensor(decoder_input_ids)})
Expand Down

0 comments on commit 7d0b6fc

Please sign in to comment.