Skip to content

broadcast_with_dims: lower-bound the dynamic output dims at 1, not 0#4927

Open
chun-wan wants to merge 1 commit into
ROCm:developfrom
chun-wan:fix/broadcast-with-dims-min-one
Open

broadcast_with_dims: lower-bound the dynamic output dims at 1, not 0#4927
chun-wan wants to merge 1 commit into
ROCm:developfrom
chun-wan:fix/broadcast-with-dims-min-one

Conversation

@chun-wan
Copy link
Copy Markdown

@chun-wan chun-wan commented Jun 1, 2026

broadcast_with_dims (ONNX Expand) returns a fully-dynamic output whose target shape is only known at runtime. It set every output dynamic dimension to {0, SIZE_MAX}, but a broadcast output dimension is always

= 1 (a tensor dimension cannot be 0, and Expand only ever grows a
size-1 axis). The 0 lower bound let a min-bound materialisation of the still-dynamic output produce a degenerate zero-sized dimension downstream (e.g. when concatenated/broadcast against a size-1 axis).

Use {1, SIZE_MAX} instead. The output is still treated as unconstrained by consumers that key off an unbounded max (e.g. concat's wildcard reconciliation), so this is a tightening with no functional regression; op_shape broadcast_with_dims tests updated to the new lower bound.

Motivation

Technical Details

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.

broadcast_with_dims (ONNX Expand) returns a fully-dynamic output whose
target shape is only known at runtime. It set every output dynamic
dimension to {0, SIZE_MAX}, but a broadcast output dimension is always
>= 1 (a tensor dimension cannot be 0, and Expand only ever grows a
size-1 axis). The 0 lower bound let a min-bound materialisation of the
still-dynamic output produce a degenerate zero-sized dimension
downstream (e.g. when concatenated/broadcast against a size-1 axis).

Use {1, SIZE_MAX} instead. The output is still treated as unconstrained
by consumers that key off an unbounded max (e.g. concat's wildcard
reconciliation), so this is a tightening with no functional regression;
op_shape broadcast_with_dims tests updated to the new lower bound.
@chun-wan chun-wan requested a review from causten as a code owner June 1, 2026 18:30
@causten causten requested review from kahmed10 and shivadbhavsar June 1, 2026 19:08
@codecov
Copy link
Copy Markdown

codecov Bot commented Jun 1, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

Additional details and impacted files
@@           Coverage Diff            @@
##           develop    #4927   +/-   ##
========================================
  Coverage    92.66%   92.66%           
========================================
  Files          588      588           
  Lines        30397    30397           
========================================
  Hits         28165    28165           
  Misses        2232     2232           
Files with missing lines Coverage Δ
src/include/migraphx/op/broadcast_with_dims.hpp 100.00% <100.00%> (ø)
🚀 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

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant