Skip to content
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

[RT-Detr] - Add RT-Detr Onnx Config #2040

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion optimum/exporters/onnx/model_configs.py
Original file line number Diff line number Diff line change
Expand Up @@ -1793,7 +1793,8 @@ class SpeechT5OnnxConfig(OnnxSeq2SeqConfigWithPast):
# so we won't support for now.
NORMALIZED_CONFIG_CLASS = NormalizedSeq2SeqConfig.with_args(
hidden_size="hidden_size",
num_attention_heads="encoder_attention_heads", # TODO: bugged in case encoder and decoder have different number of heads
num_attention_heads="encoder_attention_heads",
# TODO: bugged in case encoder and decoder have different number of heads
encoder_num_layers="encoder_layers",
decoder_num_layers="decoder_layers",
allow_new=True,
Expand Down Expand Up @@ -2310,3 +2311,15 @@ def overwrite_shape_and_generate_input(

class EncoderDecoderOnnxConfig(EncoderDecoderBaseOnnxConfig):
NORMALIZED_CONFIG_CLASS = NormalizedEncoderDecoderConfig


class RTDetrOnnxConfig(ViTOnnxConfig):
DEFAULT_ONNX_OPSET = 16
echarlaix marked this conversation as resolved.
Show resolved Hide resolved
ATOL_FOR_VALIDATION = 1e-5

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

@echarlaix echarlaix Dec 18, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is it needed ? (not needed for ViT models but might be needed for RT-DETR)

Copy link
Collaborator

@echarlaix echarlaix Dec 18, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also if needed shouldn't the height / width dimension set to dynamic as well?

}
4 changes: 4 additions & 0 deletions optimum/exporters/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -994,6 +994,10 @@ class TasksManager:
onnx="RoFormerOnnxConfig",
tflite="RoFormerTFLiteConfig",
),
"rt-detr": supported_tasks_mapping(
"object-detection",
onnx="RTDetrOnnxConfig",
),
"sam": supported_tasks_mapping(
"feature-extraction",
onnx="SamOnnxConfig",
echarlaix marked this conversation as resolved.
Show resolved Hide resolved
Expand Down