torch_tensor Derived Type

type, public :: torch_tensor

Type for holding a Torch tensor.


Components

Type Visibility Attributes Name Initial
type(c_ptr), public :: p = c_null_ptr

pointer to the tensor in memory


Finalization Procedures

final :: torch_tensor_delete

  • public subroutine torch_tensor_delete(tensor)

    Deallocates a tensor.

    Arguments

    Type IntentOptional Attributes Name
    type(torch_tensor), intent(inout) :: tensor

Type-Bound Procedures

procedure, public :: get_device_index => torch_tensor_get_device_index

  • public function torch_tensor_get_device_index(self) result(device_index)

    Determines the device index of a tensor.

    Arguments

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

    Input tensor

    Return Value integer(kind=c_int)

    Device index of tensor

procedure, public :: get_device_type => torch_tensor_get_device_type

  • public function torch_tensor_get_device_type(self) result(device_type)

    Returns the device type of a tensor.

    Arguments

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

    Input tensor

    Return Value integer(kind=c_int)

    Device type of tensor

procedure, public :: get_dtype => torch_tensor_get_dtype

  • public function torch_tensor_get_dtype(self) result(dtype)

    Returns the data type of a tensor.

    Arguments

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

    Input tensor

    Return Value integer(kind=c_int)

    Data type of tensor

procedure, public :: get_rank => torch_tensor_get_rank

  • public function torch_tensor_get_rank(self) result(rank)

    Determines the rank of a tensor.

    Arguments

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

    Return Value integer(kind=int32)

    rank of tensor

procedure, public :: get_shape => torch_tensor_get_shape

  • public function torch_tensor_get_shape(self) result(sizes)

    Determines the shape of a tensor.

    Arguments

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

    Return Value integer(kind=c_long), pointer, (:)

    Pointer to tensor data

procedure, public :: requires_grad => torch_tensor_requires_grad

  • public function torch_tensor_requires_grad(self) result(requires_grad)

    Determines whether a tensor requires the autograd module.

    Arguments

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

    Return Value logical

Source Code

  type torch_tensor
    type(c_ptr) :: p = c_null_ptr  !! pointer to the tensor in memory
  contains
    procedure :: get_rank => torch_tensor_get_rank
    procedure :: get_shape => torch_tensor_get_shape
    procedure :: get_dtype => torch_tensor_get_dtype
    procedure :: get_device_type => torch_tensor_get_device_type
    procedure :: get_device_index => torch_tensor_get_device_index
    procedure :: requires_grad => torch_tensor_requires_grad
    final :: torch_tensor_delete
  end type torch_tensor