Skip to content

[water] verify index expr step/stride are positive#1051

Merged
ftynse merged 1 commit intomainfrom
users/ftynse/positive-step
Mar 9, 2026
Merged

[water] verify index expr step/stride are positive#1051
ftynse merged 1 commit intomainfrom
users/ftynse/positive-step

Conversation

@ftynse
Copy link
Contributor

@ftynse ftynse commented Mar 5, 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 #1012.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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/stride and retain “at most one non-unit step” enforcement when foldable.
  • Add MLIR negative tests covering zero/negative step and stride.
  • 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.

Copy link
Contributor

@martin-luecke martin-luecke left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, just typos

  • typo in PR title: strire → stride
  • typo in body: deterimental → detrimental

Base automatically changed from users/ftynse/non-unit-step to main March 6, 2026 10:16
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>
@ftynse ftynse force-pushed the users/ftynse/positive-step branch from 727ec44 to b24c0ca Compare March 6, 2026 10:35
@ftynse ftynse changed the title [water] verify index expr step/strire are positive [water] verify index expr step/stride are positive Mar 9, 2026
@ftynse ftynse merged commit bea2232 into main Mar 9, 2026
17 checks passed
@ftynse ftynse deleted the users/ftynse/positive-step branch March 9, 2026 09:24
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[water] verify that index expression step/size is strictly positive

3 participants