Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIX][TOPI][strided_slice] Fix topi.strided_slice output shape #17502

Conversation

PatrikPerssonInceptron
Copy link
Contributor

Fixed inconsistency between relax.strided_slice output shape and topi.strided_slice output shape when assume_inbound
is set to false.

I added an assume_inbound flag to topi.strided_slice. If it is false then the begin and end indices are canonicalized before the dimension length is calculated. To avoid introducing duplicate code i removed the corresponding functions from relax/../index.cc and instead reference the new functions defined in include/tvm/topi/transform.h.

I added a regression test for the case with assume_inbound = false when the end of the slice is at infinity, e.g. v[begin:], which previously caused an incorrect output shape.

relax.strided_slice given a assume_inbound flag
…is assumed

in the associated unit tests

moved misplaced function description

fixed shape error and added a assume_inbound=True to test_strided_slice_symbolic_sliced_axis

added param description for assume_inbound
Copy link
Member

@Hzfengsy Hzfengsy left a comment

Choose a reason for hiding this comment

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

General LGTM

"""relax.op.strided_slice FLegalize must support dynamic begin/end"""

@I.ir_module
class before:
Copy link
Member

Choose a reason for hiding this comment

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

You can use # fmt: off and # fmt: on to disable black for specific code (e.g. TVMScript)

@Hzfengsy Hzfengsy merged commit 0d5bde5 into apache:main Nov 12, 2024
18 checks passed
@PatrikPerssonInceptron PatrikPerssonInceptron deleted the feature/topi.strided_slice-shape-fix-v2 branch November 18, 2024 08:01
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.

2 participants