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] Fix printing of rank 0 buffer access #8215

Merged
merged 4 commits into from
Jun 16, 2021

Conversation

tkonolige
Copy link
Contributor

I also improved error messages and fixed min/max/Select.

@junrushao1994 @Hzfengsy @vinx13 @MasterJH5574 @tqchen

Also improve error messages and fix min/max/Select.
@@ -180,6 +185,11 @@ def opaque_axis(begin, end, span):
return get_axis(begin, end, "opaque", span)


@register
def Select(cond, if_body, else_body, span): # pylint: disable=invalid-name
Copy link
Member

Choose a reason for hiding this comment

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

Could you please explain why you use capital S here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm using the capital S because it matches the definition in tir (tir.Select). The reason we do this is so that people's editors do not complain about undefined functions and so that go to definition still works.

Copy link
Member

Choose a reason for hiding this comment

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

I recall that pylint would complain unexpected-keyword-arg if arguments mismatch occurs between TVM script and TIR node creation, for example:

tir.if_then_else(1 <= h and h < 15 and 1 <= w and w < 15,
                 A[n, h - 1, w - 1, i, nn, ii],
                 tir.float16(0),
                 dtype="float16")
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
pylint(unexpected-keyword-arg): Unexpected keyword argument 'dtype' in function call

Copy link
Member

Choose a reason for hiding this comment

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

Thanks for the explanation. But I still personally prefer select since most of the existing Python APIs are using lower case (e.g. tir.min, tir. if_then_else)

On the other side, Select looks OK for me if you still persist on it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@tqchen What do you think?

Copy link
Member

Choose a reason for hiding this comment

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

I think we should stick with lower cases “tir.select”, given uncased ones are used as a convention (so far) in tvm script.

On the other hand, we should think about addressing pylint complaints about undefined functions and mismatched arguments more systematically

Copy link
Contributor

@zackcquic zackcquic left a comment

Choose a reason for hiding this comment

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

Thanks a lot @tkonolige

LGTM, some nits:

  1. Capital S in Select as @Hzfengsy pointed out.
  2. Print in test cases


def test_rank0_blocks():
func = rank0_block
print(tvm.script.asscript(func, True))
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it necessary to print here?
Perhaps you want to check the output with string and assert?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Totally forgot to remove the print statements. Done.

Copy link
Member

@jroesch jroesch left a comment

Choose a reason for hiding this comment

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

@junrushao1994 I am going to merge since @Hzfengsy approved, feel free to follow up if you want more changes.

@jroesch jroesch merged commit 96a7a58 into apache:main Jun 16, 2021
trevor-m pushed a commit to trevor-m/tvm that referenced this pull request Jun 17, 2021
* [TVMSCRIPT] Fix printing of rank 0 buffer access

Also improve error messages and fix min/max/Select.

* fixes

* return fix

* remove print
trevor-m pushed a commit to neo-ai/tvm that referenced this pull request Jun 17, 2021
* [TVMSCRIPT] Fix printing of rank 0 buffer access

Also improve error messages and fix min/max/Select.

* fixes

* return fix

* remove print
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants