Skip to content

Commit

Permalink
Add convnextv2 onnx export (#1560)
Browse files Browse the repository at this point in the history
  • Loading branch information
xenova authored Dec 5, 2023
1 parent 3dfd00f commit 600dc51
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 1 deletion.
1 change: 1 addition & 0 deletions docs/source/exporters/onnx/overview.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ Supported architectures:
- CodeGen
- ConvBert
- ConvNext
- ConvNextV2
- Data2VecAudio
- Data2VecText
- Data2VecVision
Expand Down
4 changes: 4 additions & 0 deletions optimum/exporters/onnx/model_configs.py
Original file line number Diff line number Diff line change
Expand Up @@ -704,6 +704,10 @@ class ConvNextOnnxConfig(ViTOnnxConfig):
pass


class ConvNextV2OnnxConfig(ViTOnnxConfig):
pass


class MobileViTOnnxConfig(ViTOnnxConfig):
ATOL_FOR_VALIDATION = 1e-4

Expand Down
5 changes: 5 additions & 0 deletions optimum/exporters/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,11 @@ class TasksManager:
"image-classification",
onnx="ConvNextOnnxConfig",
),
"convnextv2": supported_tasks_mapping(
"feature-extraction",
"image-classification",
onnx="ConvNextV2OnnxConfig",
),
"cvt": supported_tasks_mapping("feature-extraction", "image-classification", onnx="CvTOnnxConfig"),
"data2vec-text": supported_tasks_mapping(
"feature-extraction",
Expand Down
2 changes: 1 addition & 1 deletion optimum/onnxruntime/modeling_ort.py
Original file line number Diff line number Diff line change
Expand Up @@ -1534,7 +1534,7 @@ def forward(
@add_end_docstrings(ONNX_MODEL_END_DOCSTRING)
class ORTModelForImageClassification(ORTModel):
"""
ONNX Model for image-classification tasks. This class officially supports beit, convnext, data2vec_vision, deit, levit, mobilenet_v1, mobilenet_v2, mobilevit, poolformer, resnet, segformer, swin, vit.
ONNX Model for image-classification tasks. This class officially supports beit, convnext, convnextv2, data2vec_vision, deit, levit, mobilenet_v1, mobilenet_v2, mobilevit, poolformer, resnet, segformer, swin, vit.
"""

auto_model_class = AutoModelForImageClassification
Expand Down
1 change: 1 addition & 0 deletions optimum/utils/normalized_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ class NormalizedConfigManager:
'clip',
'convbert',
'convnext',
'convnextv2',
'data2vec-text',
'data2vec-vision',
'detr',
Expand Down
1 change: 1 addition & 0 deletions tests/exporters/exporters_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
"clip": "hf-internal-testing/tiny-random-CLIPModel",
"convbert": "hf-internal-testing/tiny-random-ConvBertModel",
"convnext": "hf-internal-testing/tiny-random-convnext",
"convnextv2": "hf-internal-testing/tiny-random-ConvNextV2Model",
"codegen": "hf-internal-testing/tiny-random-CodeGenModel",
"cvt": "hf-internal-testing/tiny-random-CvTModel",
"data2vec-text": "hf-internal-testing/tiny-random-Data2VecTextModel",
Expand Down
1 change: 1 addition & 0 deletions tests/onnxruntime/test_modeling.py
Original file line number Diff line number Diff line change
Expand Up @@ -2699,6 +2699,7 @@ class ORTModelForImageClassificationIntegrationTest(ORTModelTestMixin):
SUPPORTED_ARCHITECTURES = [
"beit",
"convnext",
"convnextv2",
"data2vec_vision",
"deit",
"levit",
Expand Down
1 change: 1 addition & 0 deletions tests/onnxruntime/utils_onnxruntime_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
"clip": "hf-internal-testing/tiny-random-CLIPModel",
"convbert": "hf-internal-testing/tiny-random-ConvBertModel",
"convnext": "hf-internal-testing/tiny-random-convnext",
"convnextv2": "hf-internal-testing/tiny-random-ConvNextV2Model",
"codegen": "hf-internal-testing/tiny-random-CodeGenForCausalLM",
"data2vec_text": "hf-internal-testing/tiny-random-Data2VecTextModel",
"data2vec_vision": "hf-internal-testing/tiny-random-Data2VecVisionModel",
Expand Down

0 comments on commit 600dc51

Please sign in to comment.