Skip to content

Commit

Permalink
Effectively allow encoder_outputs input to be a tuple in pix2struct (
Browse files Browse the repository at this point in the history
…#23932)

consistentcy
  • Loading branch information
fxmarty authored Jun 1, 2023
1 parent 9603ef8 commit 9a35a7b
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/transformers/models/pix2struct/modeling_pix2struct.py
Original file line number Diff line number Diff line change
Expand Up @@ -1734,6 +1734,12 @@ def forward(
output_hidden_states=output_hidden_states,
return_dict=return_dict,
)
elif return_dict and not isinstance(encoder_outputs, BaseModelOutput):
encoder_outputs = BaseModelOutput(
last_hidden_state=encoder_outputs[0],
hidden_states=encoder_outputs[1] if len(encoder_outputs) > 1 else None,
attentions=encoder_outputs[2] if len(encoder_outputs) > 2 else None,
)

hidden_states = encoder_outputs[0]

Expand Down

0 comments on commit 9a35a7b

Please sign in to comment.