concat: treat fully-unconstrained dynamic dim as a wildcard#4924
Open
chun-wan wants to merge 1 commit into
Open
concat: treat fully-unconstrained dynamic dim as a wildcard#4924chun-wan wants to merge 1 commit into
chun-wan wants to merge 1 commit into
Conversation
broadcast_with_dims (ONNX Expand) whose target shape is only known at
runtime emits a fully-unconstrained dynamic dim {0, SIZE_MAX} on every
axis. When such a tensor was concatenated with a tensor carrying a real
dynamic range (e.g. a {1, 1000} batch dim), concat::normalize_compute_shape
threw "CONCAT: all input dimensions should match in axis N" at parse time
-- before split_single_dyn_dim / simplify_dyn_ops had a chance to
constant-fold the Expand into a static multibroadcast -- crashing compile
on otherwise-valid dynamic-shape models.
Fix: in the all-dynamic branch of concat, treat {0, SIZE_MAX} as a
wildcard. On non-concat axes it matches any dim and adopts that dim's
constraint; two genuinely-different concrete dynamic dims still throw.
On the concat axis, if any input is unconstrained the summed dim is
emitted as a wildcard rather than overflowing SIZE_MAX. After the program
is specialised the Expand folds to a static multibroadcast and the exact
shape is recovered.
Adds op_shape regression test test_dyn_concat_unconstrained. Reproduced
the original crash and verified the fix end-to-end (Expand-on-dynamic +
concat ONNX model compiles for the ref target); full test_op_shape_test
(512 cases) passes.
acd0d1e to
2e90081
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #4924 +/- ##
========================================
Coverage 92.66% 92.66%
========================================
Files 588 588
Lines 30412 30422 +10
========================================
+ Hits 28180 28190 +10
Misses 2232 2232
🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
broadcast_with_dims (ONNX Expand) whose target shape is only known at runtime emits a fully-unconstrained dynamic dim {0, SIZE_MAX} on every axis. When such a tensor was concatenated with a tensor carrying a real dynamic range (e.g. a {1, 1000} batch dim), concat::normalize_compute_shape threw "CONCAT: all input dimensions should match in axis N" at parse time -- before split_single_dyn_dim / simplify_dyn_ops had a chance to constant-fold the Expand into a static multibroadcast -- crashing compile on otherwise-valid dynamic-shape models.
Fix: in the all-dynamic branch of concat, treat {0, SIZE_MAX} as a wildcard. On non-concat axes it matches any dim and adopts that dim's constraint; two genuinely-different concrete dynamic dims still throw. On the concat axis, if any input is unconstrained the summed dim is emitted as a wildcard rather than overflowing SIZE_MAX. After the program is specialised the Expand folds to a static multibroadcast and the exact shape is recovered.
Adds op_shape regression test test_dyn_concat_unconstrained. Reproduced the original crash and verified the fix end-to-end (Expand-on-dynamic + concat ONNX model compiles for the ref target); full test_op_shape_test (512 cases) passes.
Motivation
Technical Details
Changelog Category
Add a
CHANGELOG.mdentry for any option other thanNot Applicable