🔥Rework pipeline testing by removing PipelineTestCaseMeta 🚀 (#21516)
* Add PipelineTesterMixin * remove class PipelineTestCaseMeta * move validate_test_components * Add for ViT * Add to SPECIAL_MODULE_TO_TEST_MAP * style and quality * Add feature-extraction * update * raise instead of skip * add tiny_model_summary.json * more explicit * skip tasks not in mapping * add availability check * Add Copyright * A way to diable irrelevant tests * update with main * remove disable_irrelevant_tests * skip tests * better skip message * better skip message * Add all pipeline task tests * revert * Import PipelineTesterMixin * subclass test classes with PipelineTesterMixin * Add pipieline_model_mapping * Fix import after adding pipieline_model_mapping * Fix style and quality after adding pipieline_model_mapping * Fix one more import after adding pipieline_model_mapping * Fix style and quality after adding pipieline_model_mapping * Fix test issues * Fix import requirements * Fix mapping for MobileViTModelTest * Update * Better skip message * pipieline_model_mapping could not be None * Remove some PipelineTesterMixin * Fix typo * revert tests_fetcher.py * update * rename * revert * Remove PipelineTestCaseMeta from ZeroShotAudioClassificationPipelineTests * style and quality * test fetcher for all pipeline/model tests --------- Co-authored-by: ydshieh <ydshieh@users.noreply.github.com>
This commit is contained in:
@@ -26,6 +26,7 @@ from transformers.testing_utils import is_pt_flax_cross_test, require_soundfile,
|
||||
|
||||
from ...test_configuration_common import ConfigTester
|
||||
from ...test_modeling_common import ModelTesterMixin, _config_zero_init
|
||||
from ...test_pipeline_mixin import PipelineTesterMixin
|
||||
|
||||
|
||||
if is_torch_available():
|
||||
@@ -358,7 +359,7 @@ class Data2VecAudioModelTester:
|
||||
|
||||
|
||||
@require_torch
|
||||
class Data2VecAudioModelTest(ModelTesterMixin, unittest.TestCase):
|
||||
class Data2VecAudioModelTest(ModelTesterMixin, PipelineTesterMixin, unittest.TestCase):
|
||||
all_model_classes = (
|
||||
(
|
||||
Data2VecAudioForCTC,
|
||||
@@ -370,6 +371,15 @@ class Data2VecAudioModelTest(ModelTesterMixin, unittest.TestCase):
|
||||
if is_torch_available()
|
||||
else ()
|
||||
)
|
||||
pipeline_model_mapping = (
|
||||
{
|
||||
"audio-classification": Data2VecAudioForSequenceClassification,
|
||||
"automatic-speech-recognition": Data2VecAudioForCTC,
|
||||
"feature-extraction": Data2VecAudioModel,
|
||||
}
|
||||
if is_torch_available()
|
||||
else {}
|
||||
)
|
||||
test_pruning = False
|
||||
test_headmasking = False
|
||||
|
||||
|
||||
@@ -23,6 +23,7 @@ from transformers.testing_utils import TestCasePlus, require_torch, slow, torch_
|
||||
from ...generation.test_utils import GenerationTesterMixin
|
||||
from ...test_configuration_common import ConfigTester
|
||||
from ...test_modeling_common import ModelTesterMixin
|
||||
from ...test_pipeline_mixin import PipelineTesterMixin
|
||||
|
||||
|
||||
if is_torch_available():
|
||||
@@ -359,7 +360,7 @@ class Data2VecTextModelTester:
|
||||
|
||||
|
||||
@require_torch
|
||||
class Data2VecTextModelTest(ModelTesterMixin, GenerationTesterMixin, unittest.TestCase):
|
||||
class Data2VecTextModelTest(ModelTesterMixin, GenerationTesterMixin, PipelineTesterMixin, unittest.TestCase):
|
||||
all_model_classes = (
|
||||
(
|
||||
Data2VecTextForCausalLM,
|
||||
@@ -374,6 +375,19 @@ class Data2VecTextModelTest(ModelTesterMixin, GenerationTesterMixin, unittest.Te
|
||||
else ()
|
||||
)
|
||||
all_generative_model_classes = (Data2VecTextForCausalLM,) if is_torch_available() else ()
|
||||
pipeline_model_mapping = (
|
||||
{
|
||||
"feature-extraction": Data2VecTextModel,
|
||||
"fill-mask": Data2VecTextForMaskedLM,
|
||||
"question-answering": Data2VecTextForQuestionAnswering,
|
||||
"text-classification": Data2VecTextForSequenceClassification,
|
||||
"text-generation": Data2VecTextForCausalLM,
|
||||
"token-classification": Data2VecTextForTokenClassification,
|
||||
"zero-shot": Data2VecTextForSequenceClassification,
|
||||
}
|
||||
if is_torch_available()
|
||||
else {}
|
||||
)
|
||||
|
||||
def setUp(self):
|
||||
self.model_tester = Data2VecTextModelTester(self)
|
||||
|
||||
@@ -25,6 +25,7 @@ from transformers.utils import cached_property, is_torch_available, is_vision_av
|
||||
|
||||
from ...test_configuration_common import ConfigTester
|
||||
from ...test_modeling_common import ModelTesterMixin, _config_zero_init, floats_tensor, ids_tensor
|
||||
from ...test_pipeline_mixin import PipelineTesterMixin
|
||||
|
||||
|
||||
if is_torch_available():
|
||||
@@ -165,7 +166,7 @@ class Data2VecVisionModelTester:
|
||||
|
||||
|
||||
@require_torch
|
||||
class Data2VecVisionModelTest(ModelTesterMixin, unittest.TestCase):
|
||||
class Data2VecVisionModelTest(ModelTesterMixin, PipelineTesterMixin, unittest.TestCase):
|
||||
"""
|
||||
Here we also overwrite some of the tests of test_modeling_common.py, as Data2VecVision does not use input_ids, inputs_embeds,
|
||||
attention_mask and seq_length.
|
||||
@@ -176,6 +177,15 @@ class Data2VecVisionModelTest(ModelTesterMixin, unittest.TestCase):
|
||||
if is_torch_available()
|
||||
else ()
|
||||
)
|
||||
pipeline_model_mapping = (
|
||||
{
|
||||
"feature-extraction": Data2VecVisionModel,
|
||||
"image-classification": Data2VecVisionForImageClassification,
|
||||
"image-segmentation": Data2VecVisionForSemanticSegmentation,
|
||||
}
|
||||
if is_torch_available()
|
||||
else {}
|
||||
)
|
||||
|
||||
test_pruning = False
|
||||
test_resize_embeddings = False
|
||||
|
||||
@@ -26,6 +26,7 @@ from transformers.testing_utils import require_tf, require_vision, slow
|
||||
|
||||
from ...test_configuration_common import ConfigTester
|
||||
from ...test_modeling_tf_common import TFModelTesterMixin, floats_tensor, ids_tensor
|
||||
from ...test_pipeline_mixin import PipelineTesterMixin
|
||||
|
||||
|
||||
if is_tf_available():
|
||||
@@ -172,7 +173,7 @@ class TFData2VecVisionModelTester:
|
||||
|
||||
|
||||
@require_tf
|
||||
class TFData2VecVisionModelTest(TFModelTesterMixin, unittest.TestCase):
|
||||
class TFData2VecVisionModelTest(TFModelTesterMixin, PipelineTesterMixin, unittest.TestCase):
|
||||
"""
|
||||
Here we also overwrite some of the tests of test_modeling_common.py, as Data2VecVision does not use input_ids, inputs_embeds,
|
||||
attention_mask and seq_length.
|
||||
@@ -183,6 +184,11 @@ class TFData2VecVisionModelTest(TFModelTesterMixin, unittest.TestCase):
|
||||
if is_tf_available()
|
||||
else ()
|
||||
)
|
||||
pipeline_model_mapping = (
|
||||
{"feature-extraction": TFData2VecVisionModel, "image-classification": TFData2VecVisionForImageClassification}
|
||||
if is_tf_available()
|
||||
else {}
|
||||
)
|
||||
|
||||
test_pruning = False
|
||||
test_onnx = False
|
||||
|
||||
Reference in New Issue
Block a user