-
Notifications
You must be signed in to change notification settings - Fork 3.8k
[testing][py_converter] Enhance py_converter to better support entire modules #13769
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
Conversation
|
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 |
|
Please review @junrushao (or tag other reviewers) |
|
Hm, this test worked in my fork. Wonder why it fails in mainline |
|
The problem seems to be that this cast on mainline will not convince Python that the result is an opaque Object rather than a PackedFunc. Not sure how to change it: TVM_REGISTER_GLOBAL("runtime.CastPackedFuncToObject").set_body_typed([](const PackedFunc& pf) {
return Downcast<ObjectRef>(pf);
});Any advice? |
|
@tqchen helpfully advised that the issue stems from passing a list containing a PackedFunc to the constructor. Calling the |
|
The CI error appears to be spurious. |
|
@tvm-bot rerun |
|
I think there's been another spurious failure. |
|
@tvm-bot rerun |
c7ee534 to
edd3ee3
Compare
|
CC @Hzfengsy would you like to review this PR? Thanks! |
Hzfengsy
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Thanks a lot, @slyubomirsky!
This PR makes a few improvements to
py_converterto make it more useful for fuzz testing, especially when running larger modules.In particular, these changes are to support returning the definition of a global var directly (e.g., if you do
run_as_python(main_var, mod=mod), the result will be a function corresponding tomod["main"]) and to correct two bugs in the previous implementation:PackedFuncs. However, another fix was also needed: Even thoughPackedFuncis anObjectRefin C++, the Python bindings do not recognizePackedFuncs asObjects, so the code now calls the FFI API tuple constructor directly.IRModule.from_exprto wrap passed in expressions in a module. However,from_exprwill not overwrite themainfunction if one is passed in via thefunctionsargument. Thus, if the user passed in a module that already had amainfunction defined, the wrapping would be done incorrectly and result in themainbeing copied many times. This PR corrects this error by not assuming that the namemainwill be available and instead constructing a new module with a reserved name for the target.None of the cases above had been tested before (there are now tests included)