Return the strides of the tensor
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(torch_tensor), | intent(in) | :: | self |
Tensor to get the strides of |
Pointer to tensor data
function torch_tensor_get_stride(self) result(strides) use, intrinsic :: iso_c_binding, only : c_f_pointer, c_int, c_int64_t, c_ptr class(torch_tensor), intent(in) :: self !! Tensor to get the strides of integer(kind=c_int64_t), pointer :: strides(:) !! Pointer to tensor data ! Local data integer(kind=int32) :: ndims(1) type(c_ptr) :: cptr interface function torch_tensor_get_stride_c(tensor_c) result(strides_c) & bind(c, name = 'torch_tensor_get_stride') use, intrinsic :: iso_c_binding, only : c_int, c_long, c_ptr implicit none type(c_ptr), value, intent(in) :: tensor_c type(c_ptr) :: strides_c end function torch_tensor_get_stride_c end interface if (.not. c_associated(self%p)) then write(*,*) "Error :: tensor has not been constructed so its strides are unset" stop 1 end if ndims(1) = self%get_rank() cptr = torch_tensor_get_stride_c(self%p) call c_f_pointer(cptr, strides, ndims) end function torch_tensor_get_stride