-
Notifications
You must be signed in to change notification settings - Fork 31.1k
Fixing tests for Perceiver #14739
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
Fixing tests for Perceiver #14739
Changes from all commits
6090db5
7c8b18e
780d8c0
ff7b5c5
55d0061
d56ad2a
e81db3a
d07a4cb
d87f4b5
3d2c3c3
51a102d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -77,12 +77,15 @@ def get_tiny_config_from_class(configuration_class): | |
| model_tester = model_tester_class(parent=None) | ||
|
|
||
| if hasattr(model_tester, "get_pipeline_config"): | ||
| return model_tester.get_pipeline_config() | ||
| config = model_tester.get_pipeline_config() | ||
| elif hasattr(model_tester, "get_config"): | ||
| return model_tester.get_config() | ||
| config = model_tester.get_config() | ||
| else: | ||
| config = None | ||
| logger.warning(f"Model tester {model_tester_class.__name__} has no `get_config()`.") | ||
|
|
||
| return config | ||
|
|
||
|
|
||
| @lru_cache(maxsize=100) | ||
| def get_tiny_tokenizer_from_checkpoint(checkpoint): | ||
|
|
@@ -100,11 +103,17 @@ def get_tiny_tokenizer_from_checkpoint(checkpoint): | |
| return tokenizer | ||
|
|
||
|
|
||
| def get_tiny_feature_extractor_from_checkpoint(checkpoint, tiny_config): | ||
| def get_tiny_feature_extractor_from_checkpoint(checkpoint, tiny_config, feature_extractor_class): | ||
| try: | ||
| feature_extractor = AutoFeatureExtractor.from_pretrained(checkpoint) | ||
| except Exception: | ||
| feature_extractor = None | ||
| try: | ||
| if feature_extractor_class is not None: | ||
| feature_extractor = feature_extractor_class() | ||
| else: | ||
| feature_extractor = None | ||
| except Exception: | ||
|
||
| feature_extractor = None | ||
| if hasattr(tiny_config, "image_size") and feature_extractor: | ||
| feature_extractor = feature_extractor.__class__(size=tiny_config.image_size, crop_size=tiny_config.image_size) | ||
|
|
||
|
|
@@ -168,7 +177,9 @@ def test(self): | |
| self.skipTest(f"Ignoring {ModelClass}, cannot create a simple tokenizer") | ||
| else: | ||
| tokenizer = None | ||
| feature_extractor = get_tiny_feature_extractor_from_checkpoint(checkpoint, tiny_config) | ||
| feature_extractor = get_tiny_feature_extractor_from_checkpoint( | ||
| checkpoint, tiny_config, feature_extractor_class | ||
| ) | ||
|
|
||
| if tokenizer is None and feature_extractor is None: | ||
| self.skipTest( | ||
|
|
@@ -218,6 +229,13 @@ def data(n): | |
| if not tokenizer_classes: | ||
| # We need to test even if there are no tokenizers. | ||
| tokenizer_classes = [None] | ||
| else: | ||
| # Remove the non defined tokenizers | ||
| # ByT5 and Perceiver are bytes-level and don't define | ||
| # FastTokenizer, we can just ignore those. | ||
| tokenizer_classes = [ | ||
| tokenizer_class for tokenizer_class in tokenizer_classes if tokenizer_class is not None | ||
| ] | ||
|
Comment on lines
+232
to
+238
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There's a third bytes-level tokenizer, which is CANINE. Should this be added here too?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's a comment, I don't mind if it's not exhaustive. I think it clarifies enough the purpose of this line. Fine adding it though. |
||
|
|
||
| for tokenizer_class in tokenizer_classes: | ||
| if tokenizer_class is not None: | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.