This is a follow-up RFC from [RFC] TVM Target Specification
This RFC is discussed with @junrushao.
In this RFC, we propose the way to represent a composite target. The motivation is that now we have multiple codegens contributed by the community members via BYOC targeting to specialized hardware and libraries, such as ARM ACL, ARM Ethos-N, TensorRT, and Vitis-AI. The main difference between those codegens and other TVM backends (e.g., LLVM, CUDA, OpenCL, etc) is that those specialized codegens may not execute an entire Relay graph, so we need to partition the graph and only offload the supported subgraphs to the device; while keeping the rest part on LLVM or CUDA.
Currently, we require users to manually run a list of Relay passes to partition graphs to let the compile engine dispatch each Relay function to the corresponding codegen. In general, we should encapsulate the required build pipeline, including graph partitioning, to the target semantic.
We come up with two proposals to represent a composite target, so that we can make corresponding changes in the compile engine to invoke the required passes.
P1: Add an attribute accelerators
(or whatever name) to all TVM backend targets.
Example:
TVM_REGISTER_TARGET_KIND("llvm")
.add_attr_option<Array<String>>("keys")
.add_attr_option<Array<Target>>("accelerators") // Accelerator targets in order.
.add_attr_option<Array<String>>("libs")
.add_attr_option<String>("mcpu")
.add_attr_option<Array<String>>("mattr")
.add_attr_option<String>("mtriple")
.add_attr_option<String>("mfloat-abi")
.set_default_keys({"cpu"})
.set_device_type(kDLCPU);
P2: Create a separate composite target.
Example:
TVM_REGISTER_TARGET_KIND("composite")
.add_attr_option<Target>("target_host")
.add_attr_option<Array<Target>>("accelerators") // Accelerator targets in order.
For both proposals, we will also do two things for each new device target:
- Create a new accelerator target. Note that accelerator targets are not allowed to be used directly. It has to be in other target’s accelerator attribute.
TVM_REGISTER_ACCEL_TARGET_KIND("arm_acl")
.add_attr_option<...>... // arm_acl specific attributes.
- Create an alias (e.g.,
acl
in the above example) so that users do not have to know anything about the target system. In this example, user can writetarget="acl"
to replace a composite target (taking the second proposal as an example):
{
kind: composite,
target_host: { ... },
accelerators: [{kind: arm_acl, ...}]
}
Comments and suggestions are welcome.
cc @zhiics, @anijain2305, @masahi, @tqchen, @kparzysz @ramana-arm, @mbaret, @jtuyls