From 87cfc680c10c109541618280642250518f958f82 Mon Sep 17 00:00:00 2001 From: Allan Beddouk Date: Wed, 1 Feb 2023 17:52:38 +0100 Subject: [PATCH 1/3] Support Splinter exporters (#555) --- .../exporters/onnx/package_reference/configuration.mdx | 1 + optimum/exporters/onnx/model_configs.py | 4 ++++ optimum/exporters/tasks.py | 5 +++++ optimum/utils/normalized_config.py | 1 + tests/exporters/exporters_utils.py | 1 + 5 files changed, 12 insertions(+) diff --git a/docs/source/exporters/onnx/package_reference/configuration.mdx b/docs/source/exporters/onnx/package_reference/configuration.mdx index 4443a4fb18..f17b66701f 100644 --- a/docs/source/exporters/onnx/package_reference/configuration.mdx +++ b/docs/source/exporters/onnx/package_reference/configuration.mdx @@ -117,6 +117,7 @@ They specify which input generators should be used for the dummy inputs, but rem - Segformer - SEW - Speech2Text +- Splinter - SqueezeBert - Stable Diffusion - T5 diff --git a/optimum/exporters/onnx/model_configs.py b/optimum/exporters/onnx/model_configs.py index f1fcc953fd..2b4eae3d9c 100644 --- a/optimum/exporters/onnx/model_configs.py +++ b/optimum/exporters/onnx/model_configs.py @@ -107,6 +107,10 @@ class XLMOnnxConfig(BertOnnxConfig): pass +class SplinterOnnxConfig(BertOnnxConfig): + pass + + class DistilBertOnnxConfig(BertOnnxConfig): @property def inputs(self) -> Mapping[str, Mapping[int, str]]: diff --git a/optimum/exporters/tasks.py b/optimum/exporters/tasks.py index 90077a7208..ecd521460e 100644 --- a/optimum/exporters/tasks.py +++ b/optimum/exporters/tasks.py @@ -599,6 +599,11 @@ class TasksManager: "speech2seq-lm-with-past", onnx="Speech2TextOnnxConfig", ), + "splinter": supported_tasks_mapping( + "default", + "question-answering", + onnx="SplinterOnnxConfig", + ), "squeezebert": supported_tasks_mapping( "default", "masked-lm", diff --git a/optimum/utils/normalized_config.py b/optimum/utils/normalized_config.py index 900778bf9f..2edd5f09f7 100644 --- a/optimum/utils/normalized_config.py +++ b/optimum/utils/normalized_config.py @@ -198,6 +198,7 @@ class NormalizedConfigManager: "poolformer": NormalizedVisionConfig, "resnet": NormalizedVisionConfig, "roberta": NormalizedTextConfig, + "splinter": NormalizedTextConfig, "t5": T5LikeNormalizedTextConfig, "whisper": WhisperLikeNormalizedTextConfig, "xlm-roberta": NormalizedTextConfig, diff --git a/tests/exporters/exporters_utils.py b/tests/exporters/exporters_utils.py index 7c6ea9d7df..19c87f8bd2 100644 --- a/tests/exporters/exporters_utils.py +++ b/tests/exporters/exporters_utils.py @@ -176,6 +176,7 @@ "roformer": "junnyu/roformer_chinese_base", "segformer": "nvidia/segformer-b0-finetuned-ade-512-512", "squeezebert": "squeezebert/squeezebert-uncased", + "splinter": "hf-internal-testing/tiny-random-SplinterModel", "swin": "microsoft/swin-tiny-patch4-window7-224", "t5": "t5-small", "vit": "google/vit-base-patch16-224", From 3813d22d9dc8cbfbd376f223494ca251ab34c0ae Mon Sep 17 00:00:00 2001 From: Allan Beddouk Date: Fri, 3 Feb 2023 12:16:35 +0100 Subject: [PATCH 2/3] Added SplintrerModel in PYTORCH_EXPORT_MODELS_TINY dict (rightfully suggested by fxmarty) --- tests/exporters/exporters_utils.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/exporters/exporters_utils.py b/tests/exporters/exporters_utils.py index 19c87f8bd2..e1d012011b 100644 --- a/tests/exporters/exporters_utils.py +++ b/tests/exporters/exporters_utils.py @@ -83,6 +83,7 @@ "roberta": "hf-internal-testing/tiny-random-RobertaModel", "roformer": "hf-internal-testing/tiny-random-RoFormerModel", "segformer": "hf-internal-testing/tiny-random-SegformerModel", + "splinter": "hf-internal-testing/tiny-random-SplinterModel", "squeezebert": "hf-internal-testing/tiny-random-SqueezeBertModel", "swin": "hf-internal-testing/tiny-random-SwinModel", "t5": "hf-internal-testing/tiny-random-t5", From 3f5acce1960899de0178531fdf11c0a6d9004c68 Mon Sep 17 00:00:00 2001 From: Allan Beddouk Date: Fri, 3 Feb 2023 12:17:49 +0100 Subject: [PATCH 3/3] Fix alphabetized order for PYTORCH_EXPORT_MODELS_LARGE --- tests/exporters/exporters_utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/exporters/exporters_utils.py b/tests/exporters/exporters_utils.py index e1d012011b..ec698fd790 100644 --- a/tests/exporters/exporters_utils.py +++ b/tests/exporters/exporters_utils.py @@ -176,8 +176,8 @@ "roberta": "roberta-base", "roformer": "junnyu/roformer_chinese_base", "segformer": "nvidia/segformer-b0-finetuned-ade-512-512", - "squeezebert": "squeezebert/squeezebert-uncased", "splinter": "hf-internal-testing/tiny-random-SplinterModel", + "squeezebert": "squeezebert/squeezebert-uncased", "swin": "microsoft/swin-tiny-patch4-window7-224", "t5": "t5-small", "vit": "google/vit-base-patch16-224",