get_rank Function

public function get_rank(self) result(rank)

Determines the rank of a tensor.

Type Bound

torch_tensor

Arguments

Type IntentOptional Attributes Name
class(torch_tensor), intent(in) :: self

Return Value integer(kind=int32)

rank of tensor


Source Code

  function get_rank(self) result(rank)
    class(torch_tensor), intent(in) :: self
    integer(kind=int32) :: rank  !! rank of tensor

    interface
      function torch_tensor_get_rank_c(tensor) result(rank) &
          bind(c, name = 'torch_tensor_get_rank')
        use, intrinsic :: iso_c_binding, only : c_int, c_ptr
        type(c_ptr), value, intent(in) :: tensor
        integer(c_int) :: rank
      end function torch_tensor_get_rank_c
    end interface

    rank = torch_tensor_get_rank_c(self%p)
  end function get_rank