Skip to content

[Fix][Relax] Prove inverse layout maps before cancellation - #20817

Open
hiyufan wants to merge 2 commits into
apache:mainfrom
hiyufan:fix/prove-inverse-layout-maps-20594
Open

hiyufan wants to merge 2 commits into
apache:mainfrom
hiyufan:fix/prove-inverse-layout-maps-20594

Conversation

@hiyufan

@hiyufan hiyufan commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

OptimizeLayoutTransform cancels consecutive layout transforms based only on equal endpoint shapes. A transpose followed by identity on a square tensor therefore becomes return x and changes the output values.

Require the composed index maps to be provably identity over the input domain before cancelling them. Binding the source indices to their extents also preserves cancellation for maps involving bounded division/modulo, including the existing padding-reversal pattern.

Fixes #20594.

Add a matrix of transpose and merge/split maps, inverse/non-inverse pairs, and static/symbolic shapes. Each case checks CPU C-backend VM values against NumPy and checks whether cancellation occurred.

Use the current Analyzer API with an explicit ConstraintContext containing the source index ranges.

Validation against main f0267a0a3e, Python 3.11, LLVM 21.1.8 and source-built pinned TIRx/FFI dependencies:

  • test_optimize_layout_transform.py and test_transform_alter_op_impl.py: 17 passed.
  • CPU C-backend VM cases compare values with NumPy for transpose and merge/split maps, inverse/non-inverse pairs, and static/symbolic shapes. Existing padding-reversal coverage also passes.
  • File-scoped pre-commit checks passed.

Prepared with OpenAI Codex assistance. The build and validation above were executed locally.

Fresh CI results are pending.

@hiyufan
hiyufan marked this pull request as ready for review October 25, 2026 11:27
@hiyufan
hiyufan force-pushed the fix/prove-inverse-layout-maps-20594 branch from 09a34b4 to bfc8265 Compare November 15, 2026 02:51
@hiyufan
hiyufan force-pushed the fix/prove-inverse-layout-maps-20594 branch from bfc8265 to 0596d0a Compare November 15, 2026 03:38
@hiyufan
hiyufan force-pushed the fix/prove-inverse-layout-maps-20594 branch from 0596d0a to d9a61e4 Compare November 15, 2026 06:30

This branch has not been deployed

No deployments
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.

[Bug][Relax] OptimizeLayoutTransform cancels non-inverse layout transforms

1 participant