Skip to content

[AIRADSW-852] Fixing regression with slice-squeeze rewrite for scalar inputs - #5192

Open
urpetkov-amd wants to merge 5 commits into
developfrom
fix_slice_scalar
Open

[AIRADSW-852] Fixing regression with slice-squeeze rewrite for scalar inputs#5192
urpetkov-amd wants to merge 5 commits into
developfrom
fix_slice_scalar

Conversation

@urpetkov-amd

Copy link
Copy Markdown
Collaborator

Motivation

This PR #5004 caused a regression.

Fix a simplify_reshapes compilation failure for graphs containing a
slice -> squeeze -> pointwise sequence with a scalar companion input.

The find_slice_squeeze rewrite moves the squeeze after the pointwise
operation and restores the removed dimension on the operation's other inputs.
It previously handled every companion input with unsqueeze. For scalar
inputs, this did not produce dimensions compatible with the unsqueezed slice,
so pointwise shape validation failed with:

same_dims: mul: Dimensions do not match

This prevented affected ONNX models from compiling.

Technical Details

  • Detect scalar companion inputs in the find_slice_squeeze rewrite.
  • Restore scalar inputs with multibroadcast using the sliced input's output
    dimensions.
  • Continue using unsqueeze for non-scalar companion inputs.
  • Add the slice_squeeze_binary_scalar regression test to cover a
    slice -> squeeze -> mul(scalar) graph and verify its final canonical form.

This corrects the scalar edge case in the slice/squeeze matcher added by
PR #5004.

Testing

  • Compiled cpe-v2-fp16-384x672.onnx successfully with
    migraphx-driver compile.
  • Ran test_simplify_reshapes_test.exe: all 205 tests passed.

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.

Follow the LLVM AI Tool Use Policy for contributions using AI.

@urpetkov-amd
urpetkov-amd requested a review from causten as a code owner August 26, 2026 16:23
@urpetkov-amd
urpetkov-amd requested a review from a team as a code owner August 26, 2026 16:27
@urpetkov-amd urpetkov-amd added Windows Related changes for Windows Environments bugfix Fixes a bug found in the code. labels Aug 26, 2026
@urpetkov-amd urpetkov-amd changed the title Fixing regression with video ai models [AIRADSW-852] Fixing regression with video ai models Aug 26, 2026
@urpetkov-amd urpetkov-amd changed the title [AIRADSW-852] Fixing regression with video ai models [AIRADSW-852] Fixing regression with slice-squeeze rewrite for scalar inputs Aug 26, 2026
Comment thread test/simplify_reshapes_test.cpp Outdated
@urpetkov-amd
urpetkov-amd requested a review from CharlieL7 August 27, 2026 11:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bugfix Fixes a bug found in the code. Windows Related changes for Windows Environments

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants