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] Allow use of Python builtins in script #15492

Merged
merged 3 commits into from
Aug 7, 2023

Conversation

kparzysz-quic
Copy link
Contributor

The builtins are already supported by eval (they are automatically injected in the global scope), but they are not recognized by the evaluator's checks. When the evaluator sees doc.Name, it looks it up in the current var_table, and flags an error if it's not there.

Make the evaluator also consult the current builtins before erroring out.

The builtins are already supported by `eval` (they are automatically
injected in the global scope), but they are not recognized by the
evaluator's checks. When the evaluator sees doc.Name, it looks it up
in the current `var_table`, and flags an error if it's not there.

Make the evaluator also consult the current builtins before erroring
out.
@tvm-bot
Copy link
Collaborator

tvm-bot commented Aug 6, 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

2 similar comments
@tvm-bot
Copy link
Collaborator

tvm-bot commented Aug 6, 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

@tvm-bot
Copy link
Collaborator

tvm-bot commented Aug 6, 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

@kparzysz-quic
Copy link
Contributor Author

cc: @junrushao @Hzfengsy @yzh119

Buitin functions in T.prim_func's body are evaluated when the actual
PrimFunc is created, so this test will print 'a' before generating
`T.evaluate(0)` (i.e. equivalent of an empty statement) as the body.
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! Nice addition

@MasterJH5574 MasterJH5574 merged commit 2bf127b into apache:main Aug 7, 2023
@kparzysz-quic kparzysz-quic deleted the allow-builtins branch August 7, 2023 12:30
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.

5 participants