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][TVMScript]TVMScript BinOP printing refactor #14200

Merged
merged 4 commits into from
Mar 8, 2023

Conversation

cyx-6
Copy link
Contributor

@cyx-6 cyx-6 commented Mar 5, 2023

This PR fixes the output for T.Div(int, int). It will print T.Div(int, int), instead of int / int, to avoid the integer division ambiguity in parser.

And this PR refactors the logic of binary operators printing in TVMScript. The updated TVMScript printer will print the binary operator to avoid constant folding when parsing back.

@tvm-bot
Copy link
Collaborator

tvm-bot commented Mar 5, 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

@junrushao
Copy link
Member

Any updates?

This PR fixes the output for `T.Div(int, int)`. It will print `T.Div(int, int)`, instead of `int / int`, to avoid the integer division ambiguity in parser.

And this PR refactors the logic of binary operators printing in TVMScript. The updated TVMScript printer will print the binary operator to avoid constant folding when parsing back.
@cyx-6 cyx-6 changed the title [Fix][TVMScript] Print truncdiv for int div [Fix][TVMScript]TVMScript BinOP printing refactor Mar 7, 2023
@cyx-6 cyx-6 marked this pull request as ready for review March 7, 2023 07:14
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
Copy link
Member

Feel free to merge it yourself as soon as it turns green

@junrushao junrushao merged commit e59d1ef into apache:main Mar 8, 2023
Lunderberg added a commit to Lunderberg/tvm that referenced this pull request Mar 16, 2023
Avoid folding constants while parsing TVMScript.  This bug was
introduced as part of the parsing changes implemented in
apache#14200.

The operator overloads in python delegate to the C++ operator
overloads, which perform constant folding.  While useful in most
circumstances, the script parsing should avoid performing any
manipulations while parsing, as this can invalidate unit tests
that rely on known TIR inputs.

There are a few edge cases that would still be constant-folded while
parsing the TVMScript, but these only impact subexpressions that do
not contain TVM-specific constructs.  For example, `T.evaluate(1 + 2)`
would be parsed as `T.evaluate(3)`, because the `1 + 2` subexpression
is evaluated during parsing.
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