Skip to content

[RFC] tvm.build API for multiple device types #1752

@tqchen

Description

@tqchen

Current 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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions