How does TVM choose the platform and device

When generating opencl code using tvm how exactly does tvm choose the platform and device during the build ?.

In src/runtime/opencl/, we can find some runtime functions that check the device information.

Hey thanks, I found the file it seems as though TVM chooses the first platform available from my understanding.

In design, TVM requires users to manually choose their target device. The TVMContext object has two structure members that are device_type and device_id.

If not specified, it’s natural to choose the first one in default.

Hey @jcf94,

I was looking into the file and noticed that depending on which context was used in the python code like (tvm.cpu, tvm.gpu, tvm.opencl) it chooses a device type and sets the dtype accordingly.

When exactly is the dtype set to the CL_DEVICE_TYPE_ACCELERATOR, is there any way to specify it with the opencl context as opencl could be targeted to either cpu or gpu ?

Also I have noticed that is is the init fucntion that is responsible for sending the device type to this function, but from what i have noticed it seems like there is no argument being passed when init is being called ?