From 869774174cd4b79abcfdd328af22e4a1a1a4dec4 Mon Sep 17 00:00:00 2001 From: srimanth98 Date: Tue, 28 Feb 2023 18:46:15 -0500 Subject: [PATCH 1/5] Add RegNetOnnxConfig step 1 --- .../exporters/onnx/package_reference/configuration.mdx | 1 + optimum/exporters/onnx/model_configs.py | 5 +++++ tests/exporters/exporters_utils.py | 1 + 3 files changed, 7 insertions(+) diff --git a/docs/source/exporters/onnx/package_reference/configuration.mdx b/docs/source/exporters/onnx/package_reference/configuration.mdx index 68507af670c..523615f23cd 100644 --- a/docs/source/exporters/onnx/package_reference/configuration.mdx +++ b/docs/source/exporters/onnx/package_reference/configuration.mdx @@ -111,6 +111,7 @@ They specify which input generators should be used for the dummy inputs, but rem - Perceiver - PoolFormer - ResNet +- RegNet - Roberta - Roformer - Segformer diff --git a/optimum/exporters/onnx/model_configs.py b/optimum/exporters/onnx/model_configs.py index 590ea9526b2..a074df4deb4 100644 --- a/optimum/exporters/onnx/model_configs.py +++ b/optimum/exporters/onnx/model_configs.py @@ -526,6 +526,11 @@ class ResNetOnnxConfig(ViTOnnxConfig): ATOL_FOR_VALIDATION = 1e-3 +class RegNetOnnxConfig(ViTOnnxConfig): + # This config has the same inputs as ViTOnnxConfig + pass + + class DetrOnnxConfig(ViTOnnxConfig): DEFAULT_ONNX_OPSET = 12 diff --git a/tests/exporters/exporters_utils.py b/tests/exporters/exporters_utils.py index 12541bd61ec..7c315b4c13e 100644 --- a/tests/exporters/exporters_utils.py +++ b/tests/exporters/exporters_utils.py @@ -82,6 +82,7 @@ # "rembert": "google/rembert", "poolformer": "hf-internal-testing/tiny-random-PoolFormerModel", "resnet": "hf-internal-testing/tiny-random-resnet", + "regnet": "hf-internal-testing/tiny-random-RegNet", "roberta": "hf-internal-testing/tiny-random-RobertaModel", "roformer": "hf-internal-testing/tiny-random-RoFormerModel", "segformer": "hf-internal-testing/tiny-random-SegformerModel", From 510845f8cd5622db4e6222d7165d49efbfd86ad1 Mon Sep 17 00:00:00 2001 From: srimanth98 Date: Tue, 28 Feb 2023 18:56:13 -0500 Subject: [PATCH 2/5] Add RegNetOnnxConfig step 2 - Alphabetical order --- .../exporters/onnx/package_reference/configuration.mdx | 2 +- optimum/exporters/onnx/model_configs.py | 8 ++++---- optimum/exporters/tasks.py | 5 +++++ optimum/utils/normalized_config.py | 1 + tests/exporters/exporters_utils.py | 2 +- 5 files changed, 12 insertions(+), 6 deletions(-) diff --git a/docs/source/exporters/onnx/package_reference/configuration.mdx b/docs/source/exporters/onnx/package_reference/configuration.mdx index 523615f23cd..b0237c27ae3 100644 --- a/docs/source/exporters/onnx/package_reference/configuration.mdx +++ b/docs/source/exporters/onnx/package_reference/configuration.mdx @@ -110,8 +110,8 @@ They specify which input generators should be used for the dummy inputs, but rem - Pegasus - Perceiver - PoolFormer -- ResNet - RegNet +- ResNet - Roberta - Roformer - Segformer diff --git a/optimum/exporters/onnx/model_configs.py b/optimum/exporters/onnx/model_configs.py index a074df4deb4..5eaa7404b24 100644 --- a/optimum/exporters/onnx/model_configs.py +++ b/optimum/exporters/onnx/model_configs.py @@ -522,15 +522,15 @@ class MobileViTOnnxConfig(ViTOnnxConfig): pass -class ResNetOnnxConfig(ViTOnnxConfig): - ATOL_FOR_VALIDATION = 1e-3 - - class RegNetOnnxConfig(ViTOnnxConfig): # This config has the same inputs as ViTOnnxConfig pass +class ResNetOnnxConfig(ViTOnnxConfig): + ATOL_FOR_VALIDATION = 1e-3 + + class DetrOnnxConfig(ViTOnnxConfig): DEFAULT_ONNX_OPSET = 12 diff --git a/optimum/exporters/tasks.py b/optimum/exporters/tasks.py index e1c5da760bf..9f080b2962c 100644 --- a/optimum/exporters/tasks.py +++ b/optimum/exporters/tasks.py @@ -581,6 +581,11 @@ class TasksManager: "image-classification", onnx="PoolFormerOnnxConfig", ), + "regnet": supported_tasks_mapping( + "default", + "image-classification", + onnx="RegNetOnnxConfig", + ), "resnet": supported_tasks_mapping( "default", "image-classification", diff --git a/optimum/utils/normalized_config.py b/optimum/utils/normalized_config.py index c29441eb599..f4d6b54b89e 100644 --- a/optimum/utils/normalized_config.py +++ b/optimum/utils/normalized_config.py @@ -203,6 +203,7 @@ class NormalizedConfigManager: "nystromformer": NormalizedTextConfig, "pegasus": BartLikeNormalizedTextConfig, "poolformer": NormalizedVisionConfig, + "regnet": NormalizedVisionConfig, "resnet": NormalizedVisionConfig, "roberta": NormalizedTextConfig, "splinter": NormalizedTextConfig, diff --git a/tests/exporters/exporters_utils.py b/tests/exporters/exporters_utils.py index 7c315b4c13e..8d2a5b24695 100644 --- a/tests/exporters/exporters_utils.py +++ b/tests/exporters/exporters_utils.py @@ -81,8 +81,8 @@ }, # "rembert": "google/rembert", "poolformer": "hf-internal-testing/tiny-random-PoolFormerModel", - "resnet": "hf-internal-testing/tiny-random-resnet", "regnet": "hf-internal-testing/tiny-random-RegNet", + "resnet": "hf-internal-testing/tiny-random-resnet", "roberta": "hf-internal-testing/tiny-random-RobertaModel", "roformer": "hf-internal-testing/tiny-random-RoFormerModel", "segformer": "hf-internal-testing/tiny-random-SegformerModel", From 7524c4e859e3e484be7b31f927fd99a07ec3eb4d Mon Sep 17 00:00:00 2001 From: srimanth98 Date: Wed, 1 Mar 2023 19:02:33 -0500 Subject: [PATCH 3/5] Add RegNetOnnxConfig step 3 - change export URL to facebook/regnet-y-040 --- 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 8d2a5b24695..e4c432f59c0 100644 --- a/tests/exporters/exporters_utils.py +++ b/tests/exporters/exporters_utils.py @@ -81,7 +81,7 @@ }, # "rembert": "google/rembert", "poolformer": "hf-internal-testing/tiny-random-PoolFormerModel", - "regnet": "hf-internal-testing/tiny-random-RegNet", + "regnet": "facebook/regnet-y-040", "resnet": "hf-internal-testing/tiny-random-resnet", "roberta": "hf-internal-testing/tiny-random-RobertaModel", "roformer": "hf-internal-testing/tiny-random-RoFormerModel", From 448ed0499059790b0674afe8941635c2e0433fa7 Mon Sep 17 00:00:00 2001 From: srimanth98 Date: Fri, 3 Mar 2023 18:07:49 -0500 Subject: [PATCH 4/5] Add RegNetOnnxConfig step 4 - tiny to hf-internal-testing/tiny-random-RegNetModel, large to facebook/regnet-y-040 --- .../onnx/package_reference/configuration.mdx | 72 +------------------ tests/exporters/exporters_utils.py | 3 +- 2 files changed, 3 insertions(+), 72 deletions(-) diff --git a/docs/source/exporters/onnx/package_reference/configuration.mdx b/docs/source/exporters/onnx/package_reference/configuration.mdx index b0237c27ae3..49891ba0c50 100644 --- a/docs/source/exporters/onnx/package_reference/configuration.mdx +++ b/docs/source/exporters/onnx/package_reference/configuration.mdx @@ -60,74 +60,4 @@ They specify which input generators should be used for the dummy inputs, but rem ### Multi-modal -[[autodoc]] exporters.onnx.config.TextAndVisionOnnxConfig - -## Supported architectures - -- Audio Spectrogram Transformer -- Albert -- Bart -- Beit -- Bert -- BigBirdSmall -- BlenderBot -- Bloom -- CLIP -- Camembert -- CodeGen -- ConvBert -- ConvNext -- Data2VecAudio -- Data2VecText -- Data2VecVision -- Deberta -- Deberta-v2 -- Deit -- Detr -- DistilBert -- Electra -- Flaubert -- GPT-2 -- GPT-J -- GPT-Neo -- GPT-NeoX -- GroupVit -- Hubert -- IBert -- LayoutLM -- LayoutLM-v3 -- Levit -- LongT5 -- M2-M100 -- MBart -- MT5 -- Marian -- MobileBert -- MobileVit -- MPNet -- Nystromformer -- OwlVit -- Pegasus -- Perceiver -- PoolFormer -- RegNet -- ResNet -- Roberta -- Roformer -- Segformer -- SEW -- Speech2Text -- Splinter -- SqueezeBert -- Stable Diffusion -- T5 -- UniSpeech -- UniSpeech SAT -- Vit -- Wav2Vec2 -- Wav2Vec2 Conformer -- WavLM -- Whisper -- XLM -- XLM-Roberta -- Yolos +[[autodoc]] exporters.onnx.config.TextAndVisionOnnxConfig \ No newline at end of file diff --git a/tests/exporters/exporters_utils.py b/tests/exporters/exporters_utils.py index e4c432f59c0..aa36606ec31 100644 --- a/tests/exporters/exporters_utils.py +++ b/tests/exporters/exporters_utils.py @@ -81,7 +81,7 @@ }, # "rembert": "google/rembert", "poolformer": "hf-internal-testing/tiny-random-PoolFormerModel", - "regnet": "facebook/regnet-y-040", + "regnet": "hf-internal-testing/tiny-random-RegNetModel", "resnet": "hf-internal-testing/tiny-random-resnet", "roberta": "hf-internal-testing/tiny-random-RobertaModel", "roformer": "hf-internal-testing/tiny-random-RoFormerModel", @@ -176,6 +176,7 @@ "perceiver": "hf-internal-testing/tiny-random-PerceiverModel", # Not using deepmind/language-perceiver because it takes too much time for testing. # "rembert": "google/rembert", "poolformer": "hf-internal-testing/tiny-random-PoolFormerModel", + "regnet": "facebook/regnet-y-040", "resnet": "microsoft/resnet-50", "roberta": "roberta-base", "roformer": "junnyu/roformer_chinese_base", From 92b8facf35b659520ab4a6a2effe855ffe709b6f Mon Sep 17 00:00:00 2001 From: srimanth98 Date: Fri, 3 Mar 2023 18:16:02 -0500 Subject: [PATCH 5/5] Add RegNetOnnxConfig step 5 - Documentation changes --- docs/source/exporters/onnx/overview.mdx | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/source/exporters/onnx/overview.mdx b/docs/source/exporters/onnx/overview.mdx index 4fdc1031b79..18719bd69a5 100644 --- a/docs/source/exporters/onnx/overview.mdx +++ b/docs/source/exporters/onnx/overview.mdx @@ -65,6 +65,7 @@ Supported architectures: - Pegasus - Perceiver - PoolFormer +- RegNet - ResNet - Roberta - Roformer