[water] verify index expr step/stride are positive#1051
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Adds verification to reject semantically undefined Wave index mappings by requiring index-expression step and stride to be strictly positive when they can be folded to a concrete value (with hyperparameters substituted), improving correctness for dependence analysis.
Changes:
- Add Wave dialect verification for strictly-positive
step/strideand retain “at most one non-unit step” enforcement when foldable. - Add MLIR negative tests covering zero/negative
stepandstride. - Update ElementsPerThread inference commentary and adjust an inference test setup.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
water/lib/Dialect/Wave/IR/WaveDialect.cpp |
Introduces verifier helpers to enforce positive step/stride and integrates them into dialect verification flow. |
water/test/Dialect/Wave/ops-invalid.mlir |
Adds invalid IR tests asserting new verifier diagnostics for zero/negative step/stride. |
water/lib/Dialect/Wave/Transforms/InferTypes.cpp |
Updates TODO commentary around redundancy with verifiers and hyperparameter presence. |
water/test/Dialect/Wave/propagate-elements-per-thread.mlir |
Adjusts a test function’s attributes related to hyperparameters for inference-pass behavior. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
martin-luecke
approved these changes
Mar 5, 2026
Contributor
martin-luecke
left a comment
There was a problem hiding this comment.
LGTM, just typos
- typo in PR title: strire → stride
- typo in body: deterimental → detrimental
Add a verifier that index expression step and stride are strictly positive to avoid semantically undefined behavior (what does it mean to have a 0-element piece of the tensor? stride zero is hidden broadcasting, negative stride is hidden reversal, both are deterimental to dependence analysis). Closes #1012. Signed-off-by: Alex Zinenko <git@ozinenko.com>
727ec44 to
b24c0ca
Compare
nirmie
pushed a commit
to nirmie/wave
that referenced
this pull request
Mar 9, 2026
Add a verifier that index expression step and stride are strictly positive to avoid semantically undefined behavior (what does it mean to have a 0-element piece of the tensor? stride zero is hidden broadcasting, negative stride is hidden reversal, both are detrimental to dependence analysis). Closes iree-org#1012. Signed-off-by: Alex Zinenko <git@ozinenko.com>
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.
Add a verifier that index expression step and stride are strictly
positive to avoid semantically undefined behavior (what does it mean to
have a 0-element piece of the tensor? stride zero is hidden
broadcasting, negative stride is hidden reversal, both are detrimental
to dependence analysis).
Closes #1012.