Skip to content

[Fix][Relax] Canonicalize strided slice begin indices - #20284

Merged
tlopex merged 1 commit into
apache:mainfrom
napronald:fix-strided-slice-index-canonicalization
Sep 10, 2026
Merged

[Fix][Relax] Canonicalize strided slice begin indices#20284
tlopex merged 1 commit into
apache:mainfrom
napronald:fix-strided-slice-index-canonicalization

Conversation

@napronald

Copy link
Copy Markdown
Contributor

Summary

This fixes #20262 and #20263.

Currently, strided_slice lowering can fail when begin falls outside the input bounds. The output shape already canonicalizes begin and end when assume_inbound=False, but the generated source index could still use the original begin value. This can produces the correct output shape while reading from the wrong location or outside the input tensor.

This PR updates the affected lowering paths to use the existing CanonicalizeIndex logic when constructing source indices and handles begin == extent with a negative stride, where the canonical start is extent - 1. Existing assume_inbound=True logic is unchanged.

@napronald
napronald marked this pull request as draft September 7, 2026 07:30
@napronald
napronald force-pushed the fix-strided-slice-index-canonicalization branch from cc499e6 to 6790484 Compare September 7, 2026 08:41
@napronald
napronald marked this pull request as ready for review September 7, 2026 10:22

@tlopex tlopex left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Two different PrimVars can have the same name, so this can accidentally replace begin with extent and produce the wrong slice. Could you change the name check in DynamicCanonicalizeIndex to index.same_as(extent)?

@napronald
napronald force-pushed the fix-strided-slice-index-canonicalization branch from 6790484 to 26a9992 Compare September 8, 2026 07:18
@napronald

Copy link
Copy Markdown
Contributor Author

Updated to use index.same_as(extent) as suggested. Thanks.

@napronald
napronald force-pushed the fix-strided-slice-index-canonicalization branch from 26a9992 to 6597e06 Compare September 10, 2026 03:23
@tlopex
tlopex merged commit fa8789b into apache:main Sep 10, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants