Function TVMBackendGetDeviceIndex#
Defined in File c_backend_api.h
Function Documentation#
-
int TVMBackendGetDeviceIndex(int device_type, int *out_device_index)#
Query the selected runtime device index on the calling host thread.
Dispatches to DeviceAPI::GetDeviceIndex without changing device selection. Getter support is optional and independent of setter support: the default implementation reports NotImplementedError, including for backends without device-selection state. RPC devices are not supported.
- Parameters:
device_type – Local DLPack device type, not an RPC session-encoded type.
out_device_index – Non-null pointer receiving the runtime device index (DLDevice::device_id), not a device type or target configuration index. Written only on success; its previous value is unchanged on failure.
- Returns:
0 on success, -1 on invalid arguments, unavailable backend, unsupported query, or backend failure. Failure records the raised TVM FFI error on the calling thread; no C++ exception crosses this C entry point.