Skip to content

preserve layouts for symbolic shapes through pointwise ops#4923

Open
shivadbhavsar wants to merge 4 commits into
developfrom
sym_unary
Open

preserve layouts for symbolic shapes through pointwise ops#4923
shivadbhavsar wants to merge 4 commits into
developfrom
sym_unary

Conversation

@shivadbhavsar
Copy link
Copy Markdown
Contributor

Motivation

Layouts should be preserved for symbolic shapes in elementwise compute shape methods.

Technical Details

Follow same layout rules as static shapes for symbolic shapes for elementwise ops.

Changelog Category

Add a CHANGELOG.md entry for any option other than Not Applicable

    • Added: New functionality.
    • Changed: Changes to existing functionality.
    • Removed: Functionality or support that has been removed. (Compared to a previous release)
    • Optimized: Component performance that has been optimized or improved.
    • Resolved Issues: Known issues from a previous version that have been resolved.
    • Not Applicable: This PR is not to be included in the changelog.

@shivadbhavsar shivadbhavsar self-assigned this May 29, 2026
@shivadbhavsar shivadbhavsar requested a review from causten as a code owner May 29, 2026 18:40
Copilot AI review requested due to automatic review settings May 29, 2026 18:40
@shivadbhavsar shivadbhavsar added the simple small or simple changes label May 29, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Extends symbolic-shape layout preservation through pointwise-style operators so that elementwise ops behave consistently with static shapes. Previously, fully symbolic dynamic shapes fell through the same path as range-based dynamic shapes, losing their layout/permutation/stride information.

Changes:

  • unary and pointwise::remove_broadcasts now rebuild symbolic outputs via with_lens(dyn_dims()) / shape::from_permutation(type, dyn_dims, perm), matching the static layout rules and existing prior art in binary.hpp, prefix_scan_op.hpp, and softmax.hpp.
  • where adopts the same symbolic-vs-range-dynamic split as binary, applying packed/broadcasted layout selection when both value inputs are symbolic and keeping strict equality for mixed dynamic cases.
  • convert and bit_cast now propagate dyn_strides() for symbolic inputs, mirroring how the static path preserves layout.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/include/migraphx/op/unary.hpp Treat symbolic shapes like static for broadcast removal and with_lens rebuild; range-dynamic still passes through.
src/include/migraphx/op/where.hpp Add symbolic-aware layout selection branches; restrict strict-equality path to non-fully-symbolic dynamic inputs.
src/include/migraphx/op/pointwise.hpp Use symbolic from_permutation for broadcasted symbolic inputs in remove_broadcasts.
src/include/migraphx/op/convert.hpp Preserve symbolic dyn_strides() when only the element type changes.
src/include/migraphx/op/bit_cast.hpp Same symbolic stride preservation as convert.
test/op_shape_test.cpp Add symbolic test coverage for unary, convert, and where (packed, broadcasted, non-packed permutation, range-dyn error).

Comment thread src/include/migraphx/op/where.hpp
shivadbhavsar and others added 3 commits May 29, 2026 11:47
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
@codecov
Copy link
Copy Markdown

codecov Bot commented May 29, 2026

Codecov Report

❌ Patch coverage is 76.47059% with 4 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/include/migraphx/op/where.hpp 40.00% 3 Missing ⚠️
src/include/migraphx/op/bit_cast.hpp 66.67% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #4923      +/-   ##
===========================================
- Coverage    92.66%   92.66%   -0.00%     
===========================================
  Files          588      588              
  Lines        30412    30421       +9     
===========================================
+ Hits         28180    28187       +7     
- Misses        2232     2234       +2     
Files with missing lines Coverage Δ
src/include/migraphx/op/convert.hpp 87.10% <100.00%> (+0.89%) ⬆️
src/include/migraphx/op/pointwise.hpp 100.00% <100.00%> (ø)
src/include/migraphx/op/unary.hpp 95.65% <100.00%> (ø)
src/include/migraphx/op/bit_cast.hpp 87.50% <66.67%> (-3.41%) ⬇️
src/include/migraphx/op/where.hpp 88.24% <40.00%> (-8.43%) ⬇️

... and 1 file with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

simple small or simple changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants