tvm
tvm copied to clipboard
[Driver] Single-module lowering flow in driver_api.cc
Prior to this commit, a build that used multiple targets needed to provide tvm::build
with a Map<Target, IRModule>
specifying which target should be used to compile each IRModule
. As a result, lowering passes could not introduce new targets based on a PrimFunc's content (e.g. a with T.target()
frame to delegate out to another device), nor simplify based on cross-device subroutines (e.g. simplify a host-side conditional based on the known output of a device-side internal subroutine).
This commit makes the tvm::attr::kTarget
attribute ("target"
) be the single source of truth for where a PrimFunc
will be executed. Other existing methods for specifying the target (the target
parameter for tvm.build
, the keys in a Map<Target,IRModule>
, the parameter to the pass tir::transform::BindTarget
) are still accepted as inputs, and may provide a default value for tvm::attr::kTarget
if the attribute is missing, but may not overwrite the target attribute.
This is part of a series of commits to simplify the handling of multi-target builds.
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.
- No users to tag found in teams:
driver
See #10317 for details
Generated by tvm-bot
This PR is a subset of the changes introduced in https://github.com/apache/tvm/pull/14862, split out for ease of testing and reviewing. It is currently a draft PR, as it depends on changes made in https://github.com/apache/tvm/pull/14944, and will be rebased onto main after https://github.com/apache/tvm/pull/14944 lands.
Rebased onto main now that #14944 has landed, marked as ready for review.
Converting to draft, as the fixes for the last few CI failures depend on changes in https://github.com/apache/tvm/pull/14986, and so this PR should wait until https://github.com/apache/tvm/pull/14986 has landed.
With https://github.com/apache/tvm/pull/16184 landed, this PR should (hopefully) be able to land without requiring all low-level codegen to directly support function calls. For codegens that do not yet support function calls, device-side kernels can have subroutines inlined to avoid a recurrence of https://github.com/apache/tvm/pull/16033.
Currently, this PR is rebased on top of main, but does not use of InlinePrivateFunctions
. I expect it to fail in CI for Metal codegen, and to have the same ethos-u failure modes as previously. These should be resolvable by applying InlinePrivateFunctions
, conditional on the target being used.