Determines the device index of a tensor.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(torch_tensor), | intent(in) | :: | self |
Input tensor |
Device index of tensor
function torch_tensor_get_device_index(self) result(device_index) use, intrinsic :: iso_c_binding, only : c_int class(torch_tensor), intent(in) :: self !! 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 implicit none type(c_ptr), value, intent(in) :: tensor integer(c_int) :: device_index end function torch_tensor_get_device_index_c end interface if (.not. c_associated(self%p)) then write(*,*) "Error :: tensor has not been constructed so its device index is unset" stop 1 end if device_index = torch_tensor_get_device_index_c(self%p) end function torch_tensor_get_device_index