Sym reshapes#4832
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #4832 +/- ##
===========================================
- Coverage 92.66% 92.66% -0.00%
===========================================
Files 588 590 +2
Lines 30412 30437 +25
===========================================
+ Hits 28180 28203 +23
- Misses 2232 2234 +2
🚀 New features to boost your workflow:
|
|
I would like to merge in #3753 first which unifies the reshape calculation for both reshape and reshape_lazy and it also propagates the permutation. |
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR introduces a new dim_like attribute element type (int64 or shape::dynamic_dimension) and refactors reshape operators to store dims as std::vector<dim_like>, with accompanying serialization support and tests. This is a foundational change to enable future symbolic-shape reshape support without regressing existing static-shape behavior.
Changes:
- Add
migraphx::dim_like(picked-variant) plusto_value/from_valueserialization support. - Refactor
reshape/reshape_lazyops to usestd::vector<dim_like>fordims. - Add unit tests for
dim_likebehavior and update an ONNX reshape parse test accordingly.
Reviewed changes
Copilot reviewed 7 out of 8 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
| test/onnx/parse/reshape_test.cpp | Adjust test to populate reshape::dims with the new dim_like element type. |
| test/dim_like_test.cpp | New unit tests covering construction, equality, streaming, and serialization round-trips for dim_like. |
| src/include/migraphx/op/reshape.hpp | Switch dims to std::vector<dim_like>; update shape inference logic to accommodate the new representation. |
| src/include/migraphx/op/reshape_lazy.hpp | Switch dims to std::vector<dim_like>; update lazy reshape shape inference logic accordingly. |
| src/include/migraphx/dim_like.hpp | New public header defining dim_like, stream support, and serialization declarations. |
| src/dim_like.cpp | Implements dim_like serialization (migraphx_to_value/migraphx_from_value). |
| src/CMakeLists.txt | Adds dim_like.cpp to the core library build. |
| .gitignore | Adds ignores for local caches/venv-related directories. |
|
|
||
| // Templated to hide from ADL on unrelated types: a non-template overload would | ||
| // be probed during overload resolution for things like vector<dim_like>, which | ||
| // would instantiate Picker::apply(vector<...>) and hard-fail. |
There was a problem hiding this comment.
We should update the picked_variant constructor to propagate the substitution failure instead, Picker::apply(vector<...>) is a substitution failure which is fine, but not when using the picked_variant constructor where it becomes a error(the AI says hard-fail which is a really confusing term).
Motivation
Refactor reshape ops to use dim-like variant to handle symbolic shapes. This will be required when trying to enable simplification passes for symbolic shapes.
Technical Details
Add
dim_likevariant that works out of the box for current int64 representation for static shapes but can be extended to dyn_dims for symbolic shapes to allow symbolic target dims.compute_shape will be modified in a later PR, the purpose here is to just introduce the new variant and ensure it causes no regressions with existing static shape compilation.
Later we would want to use this similarly for other ops such as slice, resize, etc. We can also consider refactoring broadcast ops to consolidate the current dual attribute implementation with out_lens and out_dyn_dims
Changelog Category
Add a
CHANGELOG.mdentry for any option other thanNot Applicable