[Enhancement]Support mixed-sign ramp indices in LegalizeNegativeIndex#2225
Conversation
|
👋 Hi! Thank you for contributing to the TileLang project. Please remember to run We appreciate you taking this step! Our team will review your contribution, and we look forward to your awesome work! 🚀 |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughRewriter now legalizes mixed-sign vector Ramp indices by per-lane expansion and Shuffle-based reconstruction, updates Block buffer regions to FullRegion when axis minima are provably negative, and adds tests covering vectorized load/store cases (including int64 extent preservation and Kernel context). ChangesMixed-sign ramp index legalization
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
…r mixed-sign ramp legalization
|
Thanks! |
Summary
LegalizeNegativeIndexto handle constantRampindices with mixed negative and non-negative lanes.Motivation
TileLang already legalizes Python-style negative indices in scalar and all-negative vector cases:
This PR extends the same behavior to constant mixed-sign ramps:
The current pass classifies the whole ramp as unknown-sign and leaves it unchanged, even though each lane is constant and can be legalized independently.
Kernel
This minimal circular-buffer example exercises a vectorized load whose constant ramp crosses the zero boundary.
Before this patch, the mixed-sign access remains unlegalized:
After this patch, the transform rewrites the lanes independently:
Implementation
For unknown-sign constant ramps, the rewriter now checks each lane:
buffer_extent + laneThe rewritten vector is emitted as
T.Shuffle, preserving per-lane semantics while leaving truly dynamic unknown-sign cases untouched. Existing scalar-negative and all-negative vector paths are unchanged.Summary by CodeRabbit
Bug Fixes
Tests