onnxruntime
737328ba - [ORT] Extend reshape fusion (#29027)

Commit
22 days ago
[ORT] Extend reshape fusion (#29027) Enable reshape fusion for models with symbolic (dynamic) dimensions, covering patterns found in MobileNetV2, vision encoders, and SLMs. Changes: - Match_Shape: allow dimension matching by symbolic dim_param, not just static values. Needed for SLMs (e.g. Qwen) where `position_ids` takes `Shape` from `input_ids` — same `dim_param` names, no static values. - Match_Shape: allow matching when only the gathered dimension agrees between `Shape` source and reshape root. Needed for vision encoders (e.g. moondream2) where `Shape` is taken from pre-projection tensor but `Reshape` operates on post-projection output. - Match_Shape: add `GlobalAveragePool` passthrough — accept `Shape` from pre-pool input when gathering batch dim. Needed for MobileNetV2. - ReshapeHelper: handle zero-dim shapes (`allow_zero=true`) by computing unknown dim from non-zero dimension product only. Needed for MobileNetV2 reshape fusion output. - Add corresponding unit tests.
Author
Parents
Loading