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] T.match_buffer syntax sugar in arguments for TVMScript printer #13801

Merged
merged 3 commits into from
Jan 20, 2023

Conversation

cyx-6
Copy link
Contributor

@cyx-6 cyx-6 commented Jan 18, 2023

This PR implements the syntax sugar of T.match_buffer for new TVMScript printer. This syntax sugar will replace the T.handle in T.prim_func arguments, with matched simple buffer. For example, it will change

@T.prim_func
def func(a: T.handle, b: T.handle, c: T.handle):
  A = T.match_buffer(a, [128], dtype="float32")
  B = T.match_buffer(b, [128, 128], dtype="int32")
  C = T.match_buffer(c, [128, 128, 128], dtype="uint8")

into

@T.prim_func
def main(A: T.Buffer[(128,)], B: T.Buffer[(128, 128), "int32"], C: T.Buffer[(128, 128, 128), "uint8"]):
  T.evaluate(0)

@tvm-bot
Copy link
Collaborator

tvm-bot commented Jan 18, 2023

Thanks for contributing to TVM! Please refer to the contributing guidelines https://tvm.apache.org/docs/contribute/ for useful information and tips. Please request code reviews from Reviewers by @-ing them in a comment.

Generated by tvm-bot

fix outdated code

fix outdated unittest

`match_buffer` syntax sugar

fix

fix bugs
Copy link
Member

@junrushao junrushao left a comment

Choose a reason for hiding this comment

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

LGTM!

@junrushao junrushao merged commit 6c2d485 into apache:main Jan 20, 2023
fzi-peccia pushed a commit to fzi-peccia/tvm that referenced this pull request Mar 27, 2023
…printer (apache#13801)

This PR implements the syntax sugar of `T.match_buffer` for new TVMScript printer. This syntax sugar will replace the `T.handle` in `T.prim_func` arguments, with matched simple buffer. For example, it will change
```python
@T.prim_func
def func(a: T.handle, b: T.handle, c: T.handle):
  A = T.match_buffer(a, [128], dtype="float32")
  B = T.match_buffer(b, [128, 128], dtype="int32")
  C = T.match_buffer(c, [128, 128, 128], dtype="uint8")
```
into
```python
@T.prim_func
def main(A: T.Buffer[(128,)], B: T.Buffer[(128, 128), "int32"], C: T.Buffer[(128, 128, 128), "uint8"]):
  T.evaluate(0)
```

Co-authored-by: Junru Shao <[email protected]>
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