Fix hierarchical reduced predicates in copy layout lowering - #912
Open
HydraQYH wants to merge 1 commit into
Open
Fix hierarchical reduced predicates in copy layout lowering#912HydraQYH wants to merge 1 commit into
HydraQYH wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
Fix copy layout lowering for reduced predicates when
ATOM_RESThas a hierarchical shape.Technical Details
A reduced copy predicate contains one boolean value per copy atom, so its shape intentionally omits
ATOM_V. The source and predicate shapes follow this contract:The previous lowering detected reduced predicates using:
This assumes that removing
ATOM_Valways reduces the rank by one. That is not true whenATOM_RESTis hierarchical.For example:
Both shapes have rank 2, so the old condition does not recognize the predicate as reduced.
The subsequent recursive copy expansion slices the predicate according to the source hierarchy and eventually generates an invalid operation:
Changes
(ATOM_REST, REST...)to((1, ATOM_REST), REST...);ATOM_REST=(2,2).Minimal reproduction
Starting from examples/01-vectorAdd.py, make the following changes:
Apply the same copy-atom change in the JIT function and change the value layout:
The existing predicate construction remains unchanged:
This produces:
Before this fix, compiling the example fails with the out-of-bounds
vector.extract_strided_slicedescribed above.Fix
The lowering now derives the expected reduced predicate shape structurally:
((ATOM_V, ATOM_REST), REST...)
↓
(ATOM_REST, REST...)
When the actual predicate shape matches this structure, its layout is normalized before recursive copy expansion:
(ATOM_REST, REST...)
-> (1, ATOM_REST, REST...)
-> ((1, ATOM_REST), REST...)
The inserted unit mode uses zero stride:
1:0
This preserves one predicate per copy atom without allocating or copying predicate data. It only aligns the predicate layout hierarchy with the source hierarchy.
Test Plan
Test Result
The reproducer ran successfully on gfx950/MI355X and reported: PASS
Submission Checklist