🔥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:
Yih-Dar
2023-02-28 19:40:57 +01:00
committed by GitHub
parent 4cb5ffa93d
commit 871c31a6f1
243 changed files with 5871 additions and 523 deletions

View File

@@ -23,6 +23,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, floats_tensor, ids_tensor, random_attention_mask
from ...test_pipeline_mixin import PipelineTesterMixin
if is_torch_available():
@@ -269,7 +270,7 @@ class LayoutLMv3ModelTester:
@require_torch
class LayoutLMv3ModelTest(ModelTesterMixin, unittest.TestCase):
class LayoutLMv3ModelTest(ModelTesterMixin, PipelineTesterMixin, unittest.TestCase):
test_pruning = False
test_torchscript = False
test_mismatched_shapes = False
@@ -284,6 +285,18 @@ class LayoutLMv3ModelTest(ModelTesterMixin, unittest.TestCase):
if is_torch_available()
else ()
)
pipeline_model_mapping = (
{
"document-question-answering": LayoutLMv3ForQuestionAnswering,
"feature-extraction": LayoutLMv3Model,
"question-answering": LayoutLMv3ForQuestionAnswering,
"text-classification": LayoutLMv3ForSequenceClassification,
"token-classification": LayoutLMv3ForTokenClassification,
"zero-shot": LayoutLMv3ForSequenceClassification,
}
if is_torch_available()
else {}
)
def setUp(self):
self.model_tester = LayoutLMv3ModelTester(self)

View File

@@ -27,6 +27,7 @@ from transformers.utils import cached_property
from ...test_configuration_common import ConfigTester
from ...test_modeling_tf_common import TFModelTesterMixin, floats_tensor, ids_tensor, random_attention_mask
from ...test_pipeline_mixin import PipelineTesterMixin
if is_tf_available():
@@ -263,7 +264,7 @@ class TFLayoutLMv3ModelTester:
@require_tf
class TFLayoutLMv3ModelTest(TFModelTesterMixin, unittest.TestCase):
class TFLayoutLMv3ModelTest(TFModelTesterMixin, PipelineTesterMixin, unittest.TestCase):
all_model_classes = (
(
TFLayoutLMv3Model,
@@ -274,6 +275,17 @@ class TFLayoutLMv3ModelTest(TFModelTesterMixin, unittest.TestCase):
if is_tf_available()
else ()
)
pipeline_model_mapping = (
{
"feature-extraction": TFLayoutLMv3Model,
"question-answering": TFLayoutLMv3ForQuestionAnswering,
"text-classification": TFLayoutLMv3ForSequenceClassification,
"token-classification": TFLayoutLMv3ForTokenClassification,
"zero-shot": TFLayoutLMv3ForSequenceClassification,
}
if is_tf_available()
else {}
)
test_pruning = False
test_resize_embeddings = False