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

[TVMScript] Represent ramp as index slice #11308

Conversation

wrongtest-intellif
Copy link
Contributor

Hi there, the PR propose to represent tir.RampNode in buffer access index just as python slice. I believe this could be a more user friendly way for script users on SIMD-based target, since it just mimic usages in various python numerical libraries like numpy.

For example:
A[T.ramp(0, 1, 1024)] => A[0:1024]
A[T.ramp(i*32, 1, 32)] => A[i*32:i*32+32]
A[T.ramp(i*4, 4, 32)] => A[i*4:i*4+128:4]

The syntax sugar is only available for constant stride and lanes. Also please correct me on two points:

  • TIR lowering actually do not support vectorized index in non-last axes, but it is not checked by current change.
  • Slice with non-trivial step is only allowed in buffer indices, we may want to ensure all other usages should check step==1.

cc @junrushao1994 @Hzfengsy @Lunderberg

@wrongtest-intellif wrongtest-intellif force-pushed the support_ramp_sugar_as_index_slice branch from 1ceb8b3 to 3cc3dc8 Compare May 13, 2022 11:47
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.

Overall LGTM

T.evaluate(T.call_extern("strided_compute", dtype=""))


def strided_buffer_region(A: T.handle):
Copy link
Member

Choose a reason for hiding this comment

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

the duplicated test



def access_non_const_slice(A: T.handle):
# do not allow reversed slice step
Copy link
Member

Choose a reason for hiding this comment

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

error comment?

@junrushao
Copy link
Member

CC @yelite would you mind taking a look as well?

@wrongtest-intellif wrongtest-intellif merged commit 9ab3a11 into apache:main May 16, 2022
mehrdadh pushed a commit to mehrdadh/tvm that referenced this pull request May 16, 2022
* support represent ramp as index slice in tvmscript

* fix testcase's comment, check slice lanes instead of extent
shtinsa pushed a commit to Deelvin/tvm that referenced this pull request May 17, 2022
* support represent ramp as index slice in tvmscript

* fix testcase's comment, check slice lanes instead of extent
shingjan pushed a commit to shingjan/tvm that referenced this pull request May 17, 2022
* support represent ramp as index slice in tvmscript

* fix testcase's comment, check slice lanes instead of extent
@junrushao junrushao mentioned this pull request Jul 16, 2022
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.

4 participants