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] Add syntax sugar for T.handle and T.match_buffer #9492

Merged
merged 21 commits into from
Dec 8, 2021

Conversation

shingjan
Copy link
Contributor

@shingjan shingjan commented Nov 11, 2021

This PR intends to add syntax sugar for use of T.handle and T.match_buffer in the parameter list of TVMScript.

Previously with TVMScript:

def elementwise(
    a: T.handle,
    b: T.handle,
) -> None:
    A = T.match_buffer(a, (128, 128, 128, 128))
    B = T.match_buffer(b, (128, 128, 128, 128))
    # some computation

After this PR, user should be able to write TVMScript just below:

# can use kwargs
def elementwise(
    a: T.Buffer(shape=(128, 128, 128, 128), dtype="float32", elem_offset=xxx, ...),
    b:T.Buffer(shape=(128, 128, 128, 128), dtype="float32", elem_offset=xxx, ...),
) -> None:
    # some computation

# cannot use kwargs
def elementwise(
    a: T.Buffer[(128, 128, 128, 128), "float32"],
    b:T.Buffer[(128, 128, 128, 128), "float32"],
) -> None:
    # some computation
T.Buffer[(1, 224, 224, 3), "float32"]

cc: @vinx13 @junrushao1994

@shingjan shingjan force-pushed the tir-match-buffer-syntax-sugar branch from f3afb72 to d705401 Compare November 18, 2021 03:42
@shingjan shingjan changed the title [WIP][TVMScript] Add syntax sugar for T.handle and T.match_buffer [TVMScript] Add syntax sugar for T.handle and T.match_buffer Nov 23, 2021
@shingjan shingjan marked this pull request as ready for review November 23, 2021 19:33
python/tvm/script/parser.py Outdated Show resolved Hide resolved
python/tvm/script/parser.py Outdated Show resolved Hide resolved
python/tvm/script/tir/ty.py Outdated Show resolved Hide resolved
python/tvm/script/tir/ty.py Outdated Show resolved Hide resolved
python/tvm/script/parser.py Outdated Show resolved Hide resolved
python/tvm/script/parser.py Outdated Show resolved Hide resolved
python/tvm/script/parser.py Outdated Show resolved Hide resolved
python/tvm/script/parser.py Outdated Show resolved Hide resolved
@junrushao
Copy link
Member

What's the status of this PR? Shall we release a minor/patch version of synr and get this in?

@shingjan
Copy link
Contributor Author

@junrushao1994 My change to synr is in. Talking to Tristan about updating it to a newer version so this could in.

@vinx13
Copy link
Member

vinx13 commented Dec 2, 2021

please address CI issues

python/tvm/script/tir/ty.py Outdated Show resolved Hide resolved
@shingjan shingjan force-pushed the tir-match-buffer-syntax-sugar branch from 5182208 to 22f7d7a Compare December 8, 2021 04:56
@shingjan
Copy link
Contributor Author

shingjan commented Dec 8, 2021

@vinx13 rebased

@shingjan
Copy link
Contributor Author

shingjan commented Dec 8, 2021

@Hzfengsy can you take a quick look of the recent change? Thanks!

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.

Thanks @shingjan

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