Skip to content

Commit f2cd2cc

Browse files
add efficientnet onnx config and tiny model tests
1 parent 3adbe7c commit f2cd2cc

File tree

3 files changed

+19
-0
lines changed

3 files changed

+19
-0
lines changed

optimum/exporters/onnx/model_configs.py

+10
Original file line numberDiff line numberDiff line change
@@ -1061,6 +1061,16 @@ def patch_model_for_export(
10611061
return MgpstrModelPatcher(self, model, model_kwargs=model_kwargs)
10621062

10631063

1064+
class EfficientNetOnnxConfig(ViTOnnxConfig):
1065+
@property
1066+
def outputs(self) -> Dict[str, Dict[int, str]]:
1067+
common_outputs = super().outputs
1068+
1069+
if self.task == "image-classification":
1070+
common_outputs["logits"] = {0: "batch_size", 1: "num_classes"}
1071+
1072+
return common_outputs
1073+
10641074
class SentenceTransformersTransformerOnnxConfig(TextEncoderOnnxConfig):
10651075
NORMALIZED_CONFIG_CLASS = NormalizedTextConfig
10661076
DEFAULT_ONNX_OPSET = 14 # Some bottleneck transformers models require a specific ONNX opset to be successfully exported. We put a rather high opset here for the export to work for all architectures.

optimum/exporters/tasks.py

+5
Original file line numberDiff line numberDiff line change
@@ -639,6 +639,11 @@ class TasksManager:
639639
"semantic-segmentation",
640640
onnx="DptOnnxConfig",
641641
),
642+
"efficientnet": supported_tasks_mapping(
643+
"feature-extraction",
644+
"image-classification",
645+
onnx="EfficientNetOnnxConfig",
646+
),
642647
"electra": supported_tasks_mapping(
643648
"feature-extraction",
644649
"fill-mask",

tests/exporters/exporters_utils.py

+4
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,10 @@
7777
"detr": "hf-internal-testing/tiny-random-DetrModel",
7878
"distilbert": "hf-internal-testing/tiny-random-DistilBertModel",
7979
"dpt": "hf-internal-testing/tiny-random-DPTModel",
80+
"efficientnet": {
81+
"hf-internal-testing/tiny-random-EfficientNetModel": ["feature-extraction"],
82+
"hf-internal-testing/tiny-random-EfficientNetForImageClassification": ["image-classification"],
83+
},
8084
"electra": "hf-internal-testing/tiny-random-ElectraModel",
8185
"encoder-decoder": {
8286
"hf-internal-testing/tiny-random-EncoderDecoderModel-bert-bert": [

0 commit comments

Comments
 (0)