[FEAT] Add get_leaves op and support convert dyn_tuple to py_tuple#391
Merged
[FEAT] Add get_leaves op and support convert dyn_tuple to py_tuple#391
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR introduces a new fly.get_leaves/GetLeavesOp that lowers !fly.int_tuple leaves into SSA values (optionally only dynamic leaves), and updates the Python frontend to reconstruct Python tuples from dynamic IntTuple values.
Changes:
- Add
GetLeavesOpto the Fly dialect (variadic i32/i64 results,dynamicOnlyattr) and implement return-type inference. - Implement
GetLeavesOplowering infly-layout-loweringand add MLIR tests for both “all leaves” and “dynamic-only” modes. - Update Python
IntTuple.to_py_value()and related helpers/APIs to support dynamic tuples, and refresh the tiled-copy example to usemake_layout_tv.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/mlir/Transforms/layout_lowering.mlir | Adds FileCheck coverage for GetLeavesOp lowering behavior. |
| python/flydsl/expr/typing.py | Implements dynamic IntTuple.to_py_value() reconstruction via get_leaves. |
| python/flydsl/expr/primitive.py | Updates get_leaves wrapper to use GetLeavesOp; adds tuple→tile conversions for tiled ops. |
| python/flydsl/expr/derived.py | Updates make_layout_tv to require static layouts and return Python values for tile sizes. |
| lib/Dialect/Fly/Transforms/LayoutLowering.cpp | Adds GetLeavesLowering rewrite pattern. |
| lib/Dialect/Fly/IR/FlyOps.cpp | Implements GetLeavesOp return-type inference. |
| include/flydsl/Dialect/Fly/IR/FlyOps.td | Updates GetLeavesOp signature (attr + variadic results). |
| examples/02-tiledCopy.py | Switches example to use make_layout_tv output. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
coderfeli
approved these changes
Apr 13, 2026
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.
close #323
Motivation
Technical Details
Test Plan
Test Result
Submission Checklist