[AIMIGRAPHX-839] support symbolic shapes for broadcast ops#4819
Open
shivadbhavsar wants to merge 15 commits intosym_dot_shapesfrom
Open
[AIMIGRAPHX-839] support symbolic shapes for broadcast ops#4819shivadbhavsar wants to merge 15 commits intosym_dot_shapesfrom
shivadbhavsar wants to merge 15 commits intosym_dot_shapesfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Adds first-class symbolic-shape support for broadcast-style operators by introducing a shape::to_symbolic() conversion path, a symbolic broadcast-shape builder, and compiler-pass rewrites that canonicalize eligible 2-input broadcasts into 1-input forms carrying symbolic output dims.
Changes:
- Introduce
shape::to_symbolic()and amatch::symbolic_shape()predicate to enable symbolic-aware matching and shape promotion. - Add a symbolic overload of
make_bcast_shape(...)and updatebroadcast,multibroadcast, andbinarycompute-shape logic to support fully-symbolic shapes. - Extend
simplify_dyn_opsto rewrite fully-symbolic 2-inputbroadcast/multibroadcastandbroadcast_for_dotinto 1-input ops without_dyn_dims, plus add extensive tests.
Reviewed changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
src/shape.cpp |
Implements shape::to_symbolic() promotion logic (static → symbolic; reject range-dyn). |
src/include/migraphx/shape.hpp |
Declares the new to_symbolic() API. |
src/include/migraphx/matcher.hpp |
Adds symbolic_shape matcher predicate for symbolic output shapes. |
src/common.cpp |
Refactors broadcast-shape construction and adds symbolic make_bcast_shape overload. |
src/include/migraphx/common.hpp |
Exposes the symbolic make_bcast_shape overload and documents its contract. |
src/include/migraphx/op/broadcast.hpp |
Adds out_dyn_dims attribute and a symbolic 1-input mode; allows symbolic 2-input path. |
src/include/migraphx/op/multibroadcast.hpp |
Adds symbolic 1-input mode via fully-symbolic out_dyn_dims and bridges static inputs with to_symbolic(). |
src/include/migraphx/op/binary.hpp |
Allows fully-symbolic inputs to flow through existing broadcast/permutation logic. |
src/simplify_dyn_ops.cpp |
Adds symbolic broadcast canonicalizations in simplify_dyn_ops. |
test/shape_test.cpp |
Adds unit tests for to_symbolic() and symbolic/static make_bcast_shape. |
test/op_shape_test.cpp |
Adds shape tests for symbolic binary ops and symbolic broadcast/multibroadcast modes. |
test/simplify_dyn_ops_test.cpp |
Adds tests covering symbolic rewrites for broadcast, multibroadcast, and broadcast_for_dot. |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## sym_dot_shapes #4819 +/- ##
==================================================
- Coverage 92.80% 92.80% -0.00%
==================================================
Files 584 584
Lines 30146 30169 +23
==================================================
+ Hits 27976 27996 +20
- Misses 2170 2173 +3
🚀 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.
Motivation
Building on top of #4702: update broadcast op compute shapes to work with symbolic shapes. Symbolic shapes also mean we no longer need to pass a 2nd input for shape reference.
Technical Details
Infrastructure
matcher.hpp: newsymbolic_shapepredicate (mirrorsstatic_shape/dynamic_shape).shape.hpp/shape.cpp: newshape::to_symbolic()— promotes static lens/strides todd{sym::lit(...)}/sym::lit(...); idempotent on symbolic, throws on range-based dynamic. Centralizes "no mixing" enforcement.common.hpp/common.cpp: newmake_bcast_shape(shape, vector<dd>)overload for symbolic targets, factored over a templatedmake_bcast_shape_implshared with the static overload.Op support (compute_shape)
multibroadcast.hpp: 1-input symbolic mode — opt-in via fully-symbolicoutput_dyn_dimsattribute. Static inputs bridged viato_symbolic(); range-dyn rejected.broadcast.hpp:output_dyn_dimsattribute + 1-input symbolic mode (mirroring multibroadcast).to_symbolic(); range-dyn + symbolic combos rejected viato_symbolic()'s throw.build_outputlambda used by both the 1-input and 2-input symbolic paths.binary.hpp: symbolic inputs now fall through to the existing packed/broadcasted/permutation logic instead of throwing; routes viadyn_dims()-basedwith_lens/from_permutationoverloads.Compiler pass (
simplify_dyn_ops)find_symbolic_2in_broadcasts: rewrites a 2-inputbroadcast/multibroadcastwhose result is fully symbolic into the 1-input form by settingout_dyn_dims.find_symbolic_broadcast_for_dot: rewrites symbolicbroadcast_for_dotinto a 1-inputmultibroadcastwithout_dyn_dims.Changelog Category
Add a
CHANGELOG.mdentry for any option other thanNot Applicable