KEMBAR78
Replace dict/BatchEncoding instance checks by Mapping by sgugger · Pull Request #17014 · huggingface/transformers · GitHub
Skip to content

Conversation

@sgugger
Copy link
Collaborator

@sgugger sgugger commented Apr 29, 2022

What does this PR do?

We have several instance checks in the code base for (dict, BatchEncoding) (because BatchEncoding is a UserDict which is not an instance of dict). Those all miss the newer BatchFeatures (which is another UserDict) as was pointed out in #16983

In Accelerate we use the more general Mapping from collections.abc for those checks (which catches any kind of dict), this PR suggest to do this here too.

@sgugger sgugger requested a review from LysandreJik April 29, 2022 20:44
Copy link
Member

@LysandreJik LysandreJik left a comment

Choose a reason for hiding this comment

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

Nice, cleaner to use Mapping indeed!

@HuggingFaceDocBuilderDev
Copy link

HuggingFaceDocBuilderDev commented Apr 29, 2022

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

@sgugger sgugger merged commit 18df440 into main Apr 29, 2022
@sgugger sgugger deleted the batch_feature_support branch April 29, 2022 21:20
stevhliu pushed a commit to stevhliu/transformers that referenced this pull request May 3, 2022
)

* Replace dict/BatchEncoding instance checks by Mapping

* Typo
elusenji pushed a commit to elusenji/transformers that referenced this pull request Jun 12, 2022
)

* Replace dict/BatchEncoding instance checks by Mapping

* Typo
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.

3 participants