[RFC] tvm.build API for multiple device types
See original GitHub issueCurrent Signature
There are two usages of build:
- Directly takes in a schedule and lower and build a single function
- Takes in list of LoweredFunc and build a module that support on kind of on device code.
def build(inputs, args=None, target=None, target_host=None, name=None, binds=None):
pass
The problem of current interface is that it does not support combining module devices code into a single module. Here are some possible API proposals to solve this issue.
Note
Ideally we want to keep API backward compatible, intuitive and concise to use
Proposal 1
Introduce another possible signature handling of build. Allow list of device target and lowered function list being passed, and the build will run the build and combine. The old behavior is always supported for backward compatible reasons.
def build([(device1, lowered_f_list1), (device2, lowered_f_list2)], target_host=target_host):
passs
Proposal 2
Same as proposal one, but allow input of dict {device : list_of_lowered_f}.
Proposal 3
Add a flag to build to allow it return a pair of (host_code_list, device_module). Run the device module later.
def build(inputs, target, target_host=target_host, delay_host_codegen=True):
passs
Then the combination codegen and import can happen manually. Please also feel free to put your two cents on what do you think the API should be
Issue Analytics
- State:
- Created 5 years ago
- Comments:5 (5 by maintainers)
Top GitHub Comments
I will take this up. I had some preliminary implementation using proposal 3. It looks that proposal 2 is more user-friendly. Let me change to it.
I think there would be more discussions about how we should pass multiple targets to GraphCompile and how a node should take the device information, etc. I will update here when the PR is out.
closed by #1773 we are not converged to use proposal 2