Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main' into longjie/add_automat…
Browse files Browse the repository at this point in the history
…ic_model_parallel_via_fx
  • Loading branch information
zhenglongjiepheonix committed Jul 12, 2024
2 parents 27a9bb8 + 64bc1b3 commit 473388b
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 0 deletions.
16 changes: 16 additions & 0 deletions optimum/exporters/onnx/model_configs.py
Original file line number Diff line number Diff line change
Expand Up @@ -896,6 +896,22 @@ class CLIPNormalizedConfig(NormalizedTextAndVisionConfig):
VISION_CONFIG = "vision_config"


class CLIPVisionModelOnnxConfig(VisionOnnxConfig):
NORMALIZED_CONFIG_CLASS = NormalizedVisionConfig

@property
def inputs(self) -> Dict[str, Dict[int, str]]:
return {"pixel_values": {0: "batch_size", 1: "num_channels", 2: "height", 3: "width"}}

@property
def outputs(self) -> Dict[str, Dict[int, str]]:
common_outputs = super().outputs
common_outputs["last_hidden_state"] = {0: "batch_size"}
common_outputs["pooler_output"] = {0: "batch_size"}

return common_outputs


class CLIPOnnxConfig(TextAndVisionOnnxConfig):
NORMALIZED_CONFIG_CLASS = CLIPNormalizedConfig
DEFAULT_ONNX_OPSET = 14
Expand Down
4 changes: 4 additions & 0 deletions optimum/exporters/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -448,6 +448,10 @@ class TasksManager:
"zero-shot-image-classification",
onnx="CLIPOnnxConfig",
),
"clip-vision-model": supported_tasks_mapping(
"feature-extraction",
onnx="CLIPVisionModelOnnxConfig",
),
"codegen": supported_tasks_mapping(
"feature-extraction",
"feature-extraction-with-past",
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 @@ -56,6 +56,7 @@
"bloom": "hf-internal-testing/tiny-random-BloomModel",
"camembert": "hf-internal-testing/tiny-random-camembert",
"clip": "hf-internal-testing/tiny-random-CLIPModel",
"clip-vision-model": "fxmarty/clip-vision-model-tiny",
"convbert": "hf-internal-testing/tiny-random-ConvBertModel",
"convnext": "hf-internal-testing/tiny-random-convnext",
"convnextv2": "hf-internal-testing/tiny-random-ConvNextV2Model",
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 @@ -2736,6 +2736,7 @@ class ORTModelForImageClassificationIntegrationTest(ORTModelTestMixin):
"resnet",
"segformer",
"swin",
"swin-window",
"vit",
]

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 @@ -143,6 +143,7 @@
"stable-diffusion": "hf-internal-testing/tiny-stable-diffusion-torch",
"stable-diffusion-xl": "echarlaix/tiny-random-stable-diffusion-xl",
"swin": "hf-internal-testing/tiny-random-SwinModel",
"swin-window": "yujiepan/tiny-random-swin-patch4-window7-224",
"t5": "hf-internal-testing/tiny-random-t5",
"table-transformer": "hf-internal-testing/tiny-random-TableTransformerModel",
"trocr": "microsoft/trocr-small-handwritten",
Expand Down

0 comments on commit 473388b

Please sign in to comment.