Skip to content

Conversation

@gante
Copy link
Contributor

@gante gante commented Jul 11, 2022

What does this PR do?

Removes a very old if branch related to boolean options, as TF graph mode can handle both branches with no issues -- it passes core tests for the models I tried.

It also unblocks @sayakpaul in the demo he's building for the TF SegFormer (#17910), which requires setting output_hidden_states in graph mode.

@gante gante requested review from Rocketknight1 and sgugger July 11, 2022 16:40
)
final_booleans["return_dict"] = (
kwargs["return_dict"] if kwargs["return_dict"] is not None else config.return_dict
# Pure conv models (such as ConvNext) do not have `output_attentions`. If the signature has
Copy link
Contributor Author

Choose a reason for hiding this comment

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

(The if branch in the old code was kept with no changes, the else was deleted)

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.

LGTM but ultimately defers to @Rocketknight1 :-)

@HuggingFaceDocBuilderDev
Copy link

HuggingFaceDocBuilderDev commented Jul 11, 2022

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

@Rocketknight1
Copy link
Member

LGTM! All code of this type should be removed imo - it's an artifact of TF 1.x. Modern TF code is compiled by tracing and recompiled if Python flags are changed and can handle all kinds of weird Python flow control as a result.

@gante gante merged commit fcefa20 into huggingface:main Jul 12, 2022
@gante gante deleted the graph_mode_config branch July 12, 2022 18:05
viclzhu pushed a commit to viclzhu/transformers that referenced this pull request Jul 18, 2022
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