-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[testing][py_converter] Enhance py_converter to better support entire…
… modules (#13769) This PR makes a few improvements to py_converter to 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 to mod["main"]) and to correct two bugs in the previous implementation: Previously, it was not possible to insert a function into a runtime container object like an ADT. This was because the converter was simply compiling Relay functions into Python functions. This change solves this problem by registering the functions into PackedFuncs. However, another fix was also needed: Even though PackedFunc is an ObjectRef in C++, the Python bindings do not recognize PackedFuncs as Objects, so the code now calls the FFI API tuple constructor directly. The implementation relied on IRModule.from_expr to wrap passed in expressions in a module. However, from_expr will not overwrite the main function if one is passed in via the functions argument. Thus, if the user passed in a module that already had a main function defined, the wrapping would be done incorrectly and result in the main being copied many times. This PR corrects this error by not assuming that the name main will 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)
- Loading branch information
1 parent
f6cebb5
commit e516eaa
Showing
3 changed files
with
129 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters