-
Notifications
You must be signed in to change notification settings - Fork 487
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add ONNX export support for GIT #2132
base: main
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -2621,3 +2621,23 @@ class EncoderDecoderOnnxConfig(EncoderDecoderBaseOnnxConfig): | |||||||||||||
NORMALIZED_CONFIG_CLASS = NormalizedEncoderDecoderConfig | ||||||||||||||
|
||||||||||||||
DEFAULT_ONNX_OPSET = 14 # uses SDPA in Transformers, hence opset>=14. | ||||||||||||||
|
||||||||||||||
|
||||||||||||||
class GITOnnxConfig(VisionOnnxConfig): | ||||||||||||||
NORMALIZED_CONFIG_CLASS = NormalizedVisionConfig | ||||||||||||||
DUMMY_INPUT_GENERATOR_CLASSES = (DummyTextInputGenerator, DummyVisionInputGenerator) | ||||||||||||||
|
||||||||||||||
@property | ||||||||||||||
def inputs(self) -> Dict[str, Dict[int, str]]: | ||||||||||||||
return { | ||||||||||||||
"input_ids": {0: "text_batch_size", 1: "sequence_length"}, | ||||||||||||||
"pixel_values": {0: "image_batch_size", 1: "num_channels", 2: "height", 3: "width"} | ||||||||||||||
} | ||||||||||||||
|
||||||||||||||
|
||||||||||||||
class GITVisionModelOnnxConfig(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"}} | ||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this case should be included in
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Attempted to use self.task in marcindulak@ea2321c Problems: 1. ValueError: You have to specify either input_ids or inputs_embeds
It looks like all three types of tasks "feature-extraction", "image-text-to-text", "image-to-text" want "input_ids" as input. Could it be due to the use of
2. We don't have an op for aten::full but it isn't a special case. Argument types: int[], bool, NoneType, NoneType, Device, bool
Is this the case of pytorch/pytorch#137202 |
Original file line number | Diff line number | Diff line change | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -692,6 +692,17 @@ class TasksManager: | |||||||||||
"text-classification", | ||||||||||||
onnx="GemmaOnnxConfig", | ||||||||||||
), | ||||||||||||
"git": supported_tasks_mapping( | ||||||||||||
"feature-extraction", | ||||||||||||
"image-text-to-text", | ||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The issue comes from the fact that we don't yet support the "image-text-to-text" task but can be added here optimum/optimum/exporters/tasks.py Line 203 in d21256c
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added in marcindulak@ea2321c |
||||||||||||
"image-to-text", | ||||||||||||
onnx="GITOnnxConfig", | ||||||||||||
), | ||||||||||||
"git-vision-model": supported_tasks_mapping( | ||||||||||||
"feature-extraction", | ||||||||||||
"image-to-text", | ||||||||||||
onnx="GITVisionModelOnnxConfig", | ||||||||||||
), | ||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. looks like this model type doesn't exist so can be removed
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Removed in marcindulak@ea2321c I imagined that I see |
||||||||||||
"glpn": supported_tasks_mapping( | ||||||||||||
"feature-extraction", | ||||||||||||
"depth-estimation", | ||||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The issue you're reporting
ValueError: Input image size (64*64) doesn't match model (32*32).
should be fixed if you replace the config with :as it seems that for GitConfig the
image_size
attribute needs to be taken from thevision_config
directly https://github.com/huggingface/transformers/blob/504c4d36929b6bb8a8c2ecfad0f2625f4075f22a/src/transformers/models/git/configuration_git.py#L98.What is currently happening is that before export this value is not found in the config and is default to 64
optimum/optimum/utils/input_generators.py
Line 805 in d21256c
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added in marcindulak@ea2321c