Determines the device index of a tensor.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(torch_tensor), | intent(in) | :: | tensor |
Input tensor |
Device index of tensor
function torch_tensor_get_device_index(tensor) result(device_index) use, intrinsic :: iso_c_binding, only : c_int type(torch_tensor), intent(in) :: tensor !! Input tensor integer(c_int) :: device_index !! Device index of tensor interface function torch_tensor_get_device_index_c(tensor) result(device_index) & bind(c, name = 'torch_tensor_get_device_index') use, intrinsic :: iso_c_binding, only : c_int, c_ptr type(c_ptr), value, intent(in) :: tensor integer(c_int) :: device_index end function torch_tensor_get_device_index_c end interface device_index = torch_tensor_get_device_index_c(tensor%p) end function torch_tensor_get_device_index