Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Effectively allow encoder_outputs input to be a tuple in pix2struct #23932

Conversation

fxmarty
Copy link
Contributor

@fxmarty fxmarty commented Jun 1, 2023

Be consistent with the type hint

encoder_outputs: Optional[Tuple[Tuple[torch.FloatTensor]]] = None,
(which should rather be Optional[Union[Tuple[Tuple[torch.FloatTensor]], OrderedDict]] IMO) and follow what is done with other architectures.

Otherwise, currently, with return_dict=True, an error is raised as we later try to access encoder_outputs.last_hidden_state:

if not return_dict:
return decoder_outputs + encoder_outputs
return Seq2SeqLMOutput(
loss=decoder_outputs.loss,
logits=decoder_outputs.logits,
past_key_values=decoder_outputs.past_key_values,
decoder_hidden_states=decoder_outputs.hidden_states,
decoder_attentions=decoder_outputs.attentions,
cross_attentions=decoder_outputs.cross_attentions,
encoder_last_hidden_state=encoder_outputs.last_hidden_state,
encoder_hidden_states=encoder_outputs.hidden_states,
encoder_attentions=encoder_outputs.attentions,
)

This is blocking for the ONNX export support.

@fxmarty fxmarty requested review from younesbelkada and sgugger June 1, 2023 09:00
@fxmarty fxmarty changed the title Allow encoder_outputs to be a tuple in pix2struct Effectively allow encoder_outputs input to be a tuple in pix2struct Jun 1, 2023
@HuggingFaceDocBuilderDev
Copy link

HuggingFaceDocBuilderDev commented Jun 1, 2023

The documentation is not available anymore as the PR was closed or merged.

Copy link
Contributor

@younesbelkada younesbelkada left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for fixing!

Copy link
Collaborator

@sgugger sgugger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@sgugger sgugger merged commit 9a35a7b into huggingface:main Jun 1, 2023
gojiteji pushed a commit to gojiteji/transformers that referenced this pull request Jun 5, 2023
novice03 pushed a commit to novice03/transformers that referenced this pull request Jun 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants