Cleanup more auto mapping names (#21909)
* fix auto 2 * fix auto 2 * fix task guide issue * fix --------- Co-authored-by: ydshieh <ydshieh@users.noreply.github.com>
This commit is contained in:
@@ -26,9 +26,6 @@ from transformers.models.auto import get_values
|
||||
from transformers.models.auto.configuration_auto import CONFIG_MAPPING_NAMES
|
||||
from transformers.models.auto.feature_extraction_auto import FEATURE_EXTRACTOR_MAPPING_NAMES
|
||||
from transformers.models.auto.image_processing_auto import IMAGE_PROCESSOR_MAPPING_NAMES
|
||||
from transformers.models.auto.modeling_auto import MODEL_MAPPING_NAMES
|
||||
from transformers.models.auto.modeling_flax_auto import FLAX_MODEL_MAPPING_NAMES
|
||||
from transformers.models.auto.modeling_tf_auto import TF_MODEL_MAPPING_NAMES
|
||||
from transformers.models.auto.processing_auto import PROCESSOR_MAPPING_NAMES
|
||||
from transformers.models.auto.tokenization_auto import TOKENIZER_MAPPING_NAMES
|
||||
from transformers.utils import ENV_VARS_TRUE_VALUES, direct_transformers_import
|
||||
@@ -617,17 +614,21 @@ def check_all_auto_object_names_being_defined():
|
||||
"""Check all names defined in auto (name) mappings exist in the library."""
|
||||
failures = []
|
||||
|
||||
mapping_to_check = {
|
||||
mappings_to_check = {
|
||||
"TOKENIZER_MAPPING_NAMES": TOKENIZER_MAPPING_NAMES,
|
||||
"IMAGE_PROCESSOR_MAPPING_NAMES": IMAGE_PROCESSOR_MAPPING_NAMES,
|
||||
"FEATURE_EXTRACTOR_MAPPING_NAMES": FEATURE_EXTRACTOR_MAPPING_NAMES,
|
||||
"PROCESSOR_MAPPING_NAMES": PROCESSOR_MAPPING_NAMES,
|
||||
"MODEL_MAPPING_NAMES": MODEL_MAPPING_NAMES,
|
||||
"TF_MODEL_MAPPING_NAMES": TF_MODEL_MAPPING_NAMES,
|
||||
"FLAX_MODEL_MAPPING_NAMES": FLAX_MODEL_MAPPING_NAMES,
|
||||
}
|
||||
|
||||
for name, mapping in mapping_to_check.items():
|
||||
# Each auto modeling files contains multiple mappings. Let's get them in a dynamic way.
|
||||
for module_name in ["modeling_auto", "modeling_tf_auto", "modeling_flax_auto"]:
|
||||
module = getattr(transformers.models.auto, module_name)
|
||||
# all mappings in a single auto modeling file
|
||||
mapping_names = [x for x in dir(module) if x.endswith("_MAPPING_NAMES")]
|
||||
mappings_to_check.update({name: getattr(module, name) for name in mapping_names})
|
||||
|
||||
for name, mapping in mappings_to_check.items():
|
||||
for model_type, class_names in mapping.items():
|
||||
if not isinstance(class_names, tuple):
|
||||
class_names = (class_names,)
|
||||
@@ -652,16 +653,20 @@ def check_all_auto_mapping_names_in_config_mapping_names():
|
||||
failures = []
|
||||
|
||||
# `TOKENIZER_PROCESSOR_MAPPING_NAMES` and `AutoTokenizer` is special, and don't need to follow the rule.
|
||||
mapping_to_check = {
|
||||
mappings_to_check = {
|
||||
"IMAGE_PROCESSOR_MAPPING_NAMES": IMAGE_PROCESSOR_MAPPING_NAMES,
|
||||
"FEATURE_EXTRACTOR_MAPPING_NAMES": FEATURE_EXTRACTOR_MAPPING_NAMES,
|
||||
"PROCESSOR_MAPPING_NAMES": PROCESSOR_MAPPING_NAMES,
|
||||
"MODEL_MAPPING_NAMES": MODEL_MAPPING_NAMES,
|
||||
"TF_MODEL_MAPPING_NAMES": TF_MODEL_MAPPING_NAMES,
|
||||
"FLAX_MODEL_MAPPING_NAMES": FLAX_MODEL_MAPPING_NAMES,
|
||||
}
|
||||
|
||||
for name, mapping in mapping_to_check.items():
|
||||
# Each auto modeling files contains multiple mappings. Let's get them in a dynamic way.
|
||||
for module_name in ["modeling_auto", "modeling_tf_auto", "modeling_flax_auto"]:
|
||||
module = getattr(transformers.models.auto, module_name)
|
||||
# all mappings in a single auto modeling file
|
||||
mapping_names = [x for x in dir(module) if x.endswith("_MAPPING_NAMES")]
|
||||
mappings_to_check.update({name: getattr(module, name) for name in mapping_names})
|
||||
|
||||
for name, mapping in mappings_to_check.items():
|
||||
for model_type, class_names in mapping.items():
|
||||
if model_type not in CONFIG_MAPPING_NAMES:
|
||||
failures.append(
|
||||
|
||||
Reference in New Issue
Block a user