[LayoutLowering] Ignore size-one leaves in contiguous-segment detection - #1193
Open
mustafayildirim wants to merge 5 commits into
Open
mustafayildirim wants to merge 5 commits into
mustafayildirim wants to merge 5 commits into
Conversation
findContigSegment rejected layouts with more than one stride-1 dimension without excluding size-one leaves, so a fully contiguous register tensor like (1,4):(1,1) failed to lower with 'DSLCompileError: Failure while executing pass pipeline'. Size-one leaves are contiguous with everything: skip them when counting stride-1 leaves so (1,4):(1,1) resolves to the width-4 vector instead of being flagged as ambiguous. Lit-checked: new tests/mlir/Conversion/memref_singleton_layout.mlir covers singleton-first and singleton-last layouts; memref_ops.mlir and layout_lowering.mlir still pass. Signed-off-by: mustafa <mustafa@character.ai>
Contributor
There was a problem hiding this comment.
Copilot review overview
🔵 Needs a closer look
Add coverage for all-singleton and overlapping stride-1 boundary cases.
Review effort: Lite
Findings: None
What changed in this PR
Fixes contiguous-segment detection for layouts containing static singleton dimensions.
Changes:
- Ignores size-one leaves when identifying vector segments.
- Adds MLIR load/store coverage for singleton-first and singleton-last layouts.
| File | Summary |
|---|---|
tests/mlir/Conversion/memref_singleton_layout.mlir |
Adds singleton layout lowering tests. |
lib/Dialect/Fly/Transforms/LayoutLowering.cpp |
Updates contiguous-segment detection. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Collaborator
|
Looks good ? @sjfeng1999 |
This branch has not been deployed
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.
What
findContigSegment(lib/Dialect/Fly/Transforms/LayoutLowering.cpp) rejected any layout with more than one stride-1 flat leaf, without excluding size-one dimensions. A fully contiguous register tensor like(1, 4):(1, 1)— produced bymake_rmem_tensor((1, 4), Float32)+fill(0.0)— therefore failed to lower, and the kernel died with a bareDSLCompileError: Failure while executing pass pipeline(#1165).Size-one dims are contiguous with everything: they neither define nor break the contiguous segment. The fix skips static size-1 leaves when counting stride-1 leaves, so
(1, 4):(1, 1)resolves to the width-4 vector segment instead of being flagged as ambiguous.(4, 1):(1, 1)(singleton last) resolves the same way.Genuinely overlapping layouts are still rejected:
(2, 1, 4):(1, 1, 1)keeps returningInvalid(two non-singleton stride-1 dims), and(1, 1):(1, 1)degenerates to the scalar path, which is equivalent. TheisStatic()guard runs beforegetLeafAsInt()so dynamic shape leaves (common in the GEMM path) never hit the assert inIntTupleAttr::getLeafAsInt().Testing
All on MI325X (gfx942), in-pod build of this branch against LLVM
e2a39f504fe(RelWithDebInfo):(1,4)rmem, store to global) on upstreammainDSLCompileError: Failure while executing pass pipelinetests/mlir/Conversion/memref_singleton_layout.mlir(4 cases: singleton-first/last × load/store_vec)tests/mlir, all 51 files, every RUN line)tests/language/+tests/unit/pytest (gfx942)Fixes #1165