Thanks @mbs-octoml!
Target is a compile-time concept, while device is a runtime concept. The separation design is to make sure that a target can describe a device that doesn’t exist on the host, mainly for cross compilation.
And yes, in principle, every TargetKind corresponds to a DLDeviceType, for example
- llvm (compile time) => kDLCPU (runtime)
- cuda (compile time) => kDLCUDA (runtime)
- nvptx (compile time) => kDLCUDA (runtime)
Note that device_id is not present anywhere in the Target system, because we don’t require the device to be present on the host in compile time.