Skip to content

Conversation

@ftynse
Copy link
Contributor

@ftynse ftynse commented Jan 8, 2026

Since 93488b3, we allow null elements in the indexing map attribute, make the logic in printing and conversion from mlir to python more robust to there being a null expression in the mapping.

Drop redundant verification that was not accounting for null elements, but never actually reporting any errors since the attribute verifier had been intercepting the same cases.

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

This PR enhances the WaveIndexMappingAttr to properly handle null elements in indexing map attributes. The changes ensure that null expressions (represented as <NULL>) in the mapping's start, step, and stride fields are handled correctly throughout the codebase instead of causing crashes or errors.

Key changes:

  • Updated Python bindings to return None when encountering null AffineMap values instead of attempting to cast them
  • Modified MLIR-to-Wave converter to safely handle null map elements with proper None checks
  • Removed redundant verification logic that didn't account for null elements

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated no comments.

Show a summary per file
File Description
wave_lang/kernel/wave/mlir_converter/mlir_to_wave.py Refactored to introduce convert_map helper that safely handles null maps by returning None
water/test/Dialect/Wave/python_bindings.py Added test cases verifying null handling in start, step, and stride fields
water/test/Dialect/Wave/lower-wave-to-mlir-invalid.mlir Added test case ensuring null stride doesn't cause crashes during lowering
water/python/WaterExtensionNanobind.cpp Modified property accessors to check for null maps and return Python None instead of invalid casts
water/lib/Dialect/Wave/IR/WaveUtils.cpp Added null check for step map before attempting to evaluate it
water/lib/Dialect/Wave/IR/WaveInterfaces.cpp Removed verification code that didn't handle null elements and was redundant with attribute verifier
tests/mlir_wave_iface/mlir_to_wave_test.py Added unit tests for null handling in start, step, and stride scenarios

💡 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!

I have been looking for the addition of the parsing of <NULL>, but it seems this has been added previously. I think it would be more accurate to say that this PR adds support for null elements in the Python to MLIR conversion. The description could be clearer in that regard.
I think it would be good to document this change on the WaveIndexMappingAttr. I.e., that it supports NULL elements only for better compatibility with pywave, and this is not something we expect to be able to lower successfully.

@ftynse
Copy link
Contributor Author

ftynse commented Jan 9, 2026

I rephrased the description.

@ftynse ftynse force-pushed the users/ftynse/harden-indexing-map-null branch from 8fa36fa to f9eaa8b Compare January 9, 2026 15:58
We now allow null elements in the indexing map attribute, make the logic in
printing and python bindings more robust to there being a null expression in
the mapping.

Drop redundant verification that was not accounting for null elements, but
never actually reporting any errors since the attribute verifier had been
intercepting the same cases.

Signed-off-by: Alex Zinenko <git@ozinenko.com>
@ftynse ftynse force-pushed the users/ftynse/harden-indexing-map-null branch from f9eaa8b to 61d3f2d Compare January 9, 2026 15:59
@ftynse ftynse merged commit 3a0e8b1 into main Jan 9, 2026
14 of 15 checks passed
@ftynse ftynse deleted the users/ftynse/harden-indexing-map-null branch January 9, 2026 16:25
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.

3 participants