-
Notifications
You must be signed in to change notification settings - Fork 3.7k
[Relax] Add Python function support and BasePyModule for PyTorch integration #18229
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
|
cc @MasterJH5574 |
@tlopex Likely the docker image for wasm CI doesn't come with torch. Can we change to lazy import torch, i.e. import torch inside where it is used? |
MasterJH5574
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.
Overall looks very good, thank you @tlopex! Would be great to add an example of “IRModule with pyfunc” in the PR description, and you can also reply the example to the forum discussion thread after this PR is merged.
Overview
This PR implements native Python function support in TVM Relax through the
@I.pyfuncdecorator andBasePyModule, which enable seamless integration between TVM's compilation pipeline and Python/PyTorch runtime environments. This enhancement allows users to write Python functions directly in TVMScript that can interoperate with Relax and TIR functions that provides enhanced debugging capabilities and leveraging existing PyTorch operator libraries.Key Features
TVMScript Parser Enhancement
@I.pyfuncdecorator: Marks Python functions for integration into IRModulesComplete BasePyModule Implementation
Future Work
Example: IRModule with pyfunc