parse_where: broadcast dynamic ternary inputs via add_common_op#4925
Open
chun-wan wants to merge 1 commit into
Open
parse_where: broadcast dynamic ternary inputs via add_common_op#4925chun-wan wants to merge 1 commit into
chun-wan wants to merge 1 commit into
Conversation
The ONNX Where parser had a long-standing limitation: for all-dynamic
inputs it inserted the where op directly with no broadcasting and threw
outright on a static/dynamic mix. That meant a dynamic Where whose
inputs were not already identically shaped (e.g. one input is a
broadcast_with_dims / ONNX Expand output {0, SIZE_MAX}) failed at parse
with "same_dims: where: Dimensions do not match".
Route the three inputs through add_common_op (common_type=false so the
bool condition and the data-type branches keep their own types), exactly
as binary ops already do. This handles static, dynamic, and mixed inputs
uniformly; the dynamic path goes through compute_common_dyn_dims so
unconstrained inputs intersect with their peers instead of requiring an
exact shape match. A fast path keeps the common same-dims case (including
all-dynamic identical shapes) as a bare where op, so existing IR is
unchanged there.
Tests:
- where_test (static broadcast) and where_dyn_test (identical dynamic):
unchanged, still pass.
- where_mixed_test: previously asserted "throws"; now asserts the mixed
static+dynamic inputs broadcast to the expected {3,2,2} result.
Full test_onnx_test (882 cases) and ref where verify tests pass.
e0502d3 to
72ae166
Compare
72ae166 to
3c1ae00
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #4925 +/- ##
===========================================
- Coverage 92.66% 92.66% -0.00%
===========================================
Files 588 588
Lines 30412 30402 -10
===========================================
- Hits 28180 28170 -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.
The ONNX Where parser had a long-standing limitation: for all-dynamic inputs it inserted the where op directly with no broadcasting and threw outright on a static/dynamic mix. That meant a dynamic Where whose inputs were not already identically shaped (e.g. one input is a broadcast_with_dims / ONNX Expand output {0, SIZE_MAX}) failed at parse with "same_dims: where: Dimensions do not match".
Route the three inputs through add_common_op (common_type=false so the bool condition and the data-type branches keep their own types), exactly as binary ops already do. This handles static, dynamic, and mixed inputs uniformly; the dynamic path goes through compute_common_dyn_dims so unconstrained inputs intersect with their peers instead of requiring an exact shape match. A fast path keeps the common same-dims case (including all-dynamic identical shapes) as a bare where op, so existing IR is unchanged there.
Tests:
Motivation
Technical Details
Changelog Category
Add a
CHANGELOG.mdentry for any option other thanNot Applicable