ftorch Module

Main module for FTorch containing types and procedures. Generated from ftorch.fypp using the fypp Fortran preprocessor.

  • License FTorch is released under an MIT license. See the LICENSE file for details.


Variables

Type Visibility Attributes Name Initial
integer, public, parameter :: ftorch_int = int32

Enumerations

enum, bind(c)

Enumerators

enumerator:: torch_kUInt8 = 0
enumerator:: torch_kInt8 = 1
enumerator:: torch_kInt16 = 2
enumerator:: torch_kInt32 = 3
enumerator:: torch_kInt64 = 4
enumerator:: torch_kFloat16 = 5
enumerator:: torch_kFloat32 = 6
enumerator:: torch_kFloat64 = 7

Description

Enumerator for Torch data types From c_torch.h (torch_data_t) Note that 0 torch_kUInt8 and 5 torch_kFloat16 are not sypported in Fortran

enum, bind(c)

Enumerators

enumerator:: torch_kCPU = 0
enumerator:: torch_kCUDA = 1

Description

Enumerator for Torch devices From c_torch.h (torch_device_t)


Interfaces

public interface assignment (=)

  • public subroutine torch_tensor_assign(output, input)

    Overloads assignment operator for tensors.

    Arguments

    Type IntentOptional Attributes Name
    type(torch_tensor), intent(out) :: output
    type(torch_tensor), intent(in) :: input

public interface operator (*)

  • public function torch_tensor_multiply(tensor1, tensor2) result(output)

    Overloads multiplication operator for two tensors.

    Arguments

    Type IntentOptional Attributes Name
    type(torch_tensor), intent(in) :: tensor1
    type(torch_tensor), intent(in) :: tensor2

    Return Value type(torch_tensor)

  • public function torch_tensor_premultiply_int8(scalar, tensor) result(output)

    Overloads multiplication operator for a scalar of type int8 and a tensor.

    Arguments

    Type IntentOptional Attributes Name
    integer(kind=int8), intent(in) :: scalar
    type(torch_tensor), intent(in) :: tensor

    Return Value type(torch_tensor)

  • public function torch_tensor_postmultiply_int8(tensor, scalar) result(output)

    Overloads multiplication operator for a tensor and a scalar of type int8.

    Arguments

    Type IntentOptional Attributes Name
    type(torch_tensor), intent(in) :: tensor
    integer(kind=int8), intent(in) :: scalar

    Return Value type(torch_tensor)

  • public function torch_tensor_premultiply_int16(scalar, tensor) result(output)

    Overloads multiplication operator for a scalar of type int16 and a tensor.

    Arguments

    Type IntentOptional Attributes Name
    integer(kind=int16), intent(in) :: scalar
    type(torch_tensor), intent(in) :: tensor

    Return Value type(torch_tensor)

  • public function torch_tensor_postmultiply_int16(tensor, scalar) result(output)

    Overloads multiplication operator for a tensor and a scalar of type int16.

    Arguments

    Type IntentOptional Attributes Name
    type(torch_tensor), intent(in) :: tensor
    integer(kind=int16), intent(in) :: scalar

    Return Value type(torch_tensor)

  • public function torch_tensor_premultiply_int32(scalar, tensor) result(output)

    Overloads multiplication operator for a scalar of type int32 and a tensor.

    Arguments

    Type IntentOptional Attributes Name
    integer(kind=int32), intent(in) :: scalar
    type(torch_tensor), intent(in) :: tensor

    Return Value type(torch_tensor)

  • public function torch_tensor_postmultiply_int32(tensor, scalar) result(output)

    Overloads multiplication operator for a tensor and a scalar of type int32.

    Arguments

    Type IntentOptional Attributes Name
    type(torch_tensor), intent(in) :: tensor
    integer(kind=int32), intent(in) :: scalar

    Return Value type(torch_tensor)

  • public function torch_tensor_premultiply_int64(scalar, tensor) result(output)

    Overloads multiplication operator for a scalar of type int64 and a tensor.

    Arguments

    Type IntentOptional Attributes Name
    integer(kind=int64), intent(in) :: scalar
    type(torch_tensor), intent(in) :: tensor

    Return Value type(torch_tensor)

  • public function torch_tensor_postmultiply_int64(tensor, scalar) result(output)

    Overloads multiplication operator for a tensor and a scalar of type int64.

    Arguments

    Type IntentOptional Attributes Name
    type(torch_tensor), intent(in) :: tensor
    integer(kind=int64), intent(in) :: scalar

    Return Value type(torch_tensor)

  • public function torch_tensor_premultiply_real32(scalar, tensor) result(output)

    Overloads multiplication operator for a scalar of type real32 and a tensor.

    Arguments

    Type IntentOptional Attributes Name
    real(kind=real32), intent(in) :: scalar
    type(torch_tensor), intent(in) :: tensor

    Return Value type(torch_tensor)

  • public function torch_tensor_postmultiply_real32(tensor, scalar) result(output)

    Overloads multiplication operator for a tensor and a scalar of type real32.

    Arguments

    Type IntentOptional Attributes Name
    type(torch_tensor), intent(in) :: tensor
    real(kind=real32), intent(in) :: scalar

    Return Value type(torch_tensor)

  • public function torch_tensor_premultiply_real64(scalar, tensor) result(output)

    Overloads multiplication operator for a scalar of type real64 and a tensor.

    Arguments

    Type IntentOptional Attributes Name
    real(kind=real64), intent(in) :: scalar
    type(torch_tensor), intent(in) :: tensor

    Return Value type(torch_tensor)

  • public function torch_tensor_postmultiply_real64(tensor, scalar) result(output)

    Overloads multiplication operator for a tensor and a scalar of type real64.

    Arguments

    Type IntentOptional Attributes Name
    type(torch_tensor), intent(in) :: tensor
    real(kind=real64), intent(in) :: scalar

    Return Value type(torch_tensor)

public interface operator (**)

  • public function torch_tensor_power_int8(tensor, power) result(output)

    Overloads exponentiation operator for a tensor and a scalar of type int8

    Arguments

    Type IntentOptional Attributes Name
    type(torch_tensor), intent(in) :: tensor
    integer(kind=int8), intent(in) :: power

    Return Value type(torch_tensor)

  • public function torch_tensor_power_int16(tensor, power) result(output)

    Overloads exponentiation operator for a tensor and a scalar of type int16

    Arguments

    Type IntentOptional Attributes Name
    type(torch_tensor), intent(in) :: tensor
    integer(kind=int16), intent(in) :: power

    Return Value type(torch_tensor)

  • public function torch_tensor_power_int32(tensor, power) result(output)

    Overloads exponentiation operator for a tensor and a scalar of type int32

    Arguments

    Type IntentOptional Attributes Name
    type(torch_tensor), intent(in) :: tensor
    integer(kind=int32), intent(in) :: power

    Return Value type(torch_tensor)

  • public function torch_tensor_power_int64(tensor, power) result(output)

    Overloads exponentiation operator for a tensor and a scalar of type int64

    Arguments

    Type IntentOptional Attributes Name
    type(torch_tensor), intent(in) :: tensor
    integer(kind=int64), intent(in) :: power

    Return Value type(torch_tensor)

  • public function torch_tensor_power_real32(tensor, power) result(output)

    Overloads exponentiation operator for a tensor and a scalar of type real32

    Arguments

    Type IntentOptional Attributes Name
    type(torch_tensor), intent(in) :: tensor
    real(kind=real32), intent(in) :: power

    Return Value type(torch_tensor)

  • public function torch_tensor_power_real64(tensor, power) result(output)

    Overloads exponentiation operator for a tensor and a scalar of type real64

    Arguments

    Type IntentOptional Attributes Name
    type(torch_tensor), intent(in) :: tensor
    real(kind=real64), intent(in) :: power

    Return Value type(torch_tensor)

public interface operator (+)

  • public function torch_tensor_add(tensor1, tensor2) result(output)

    Overloads addition operator for two tensors.

    Arguments

    Type IntentOptional Attributes Name
    type(torch_tensor), intent(in) :: tensor1
    type(torch_tensor), intent(in) :: tensor2

    Return Value type(torch_tensor)

public interface operator (-)

public interface operator (/)

  • public function torch_tensor_divide(tensor1, tensor2) result(output)

    Overloads division operator for two tensors.

    Arguments

    Type IntentOptional Attributes Name
    type(torch_tensor), intent(in) :: tensor1
    type(torch_tensor), intent(in) :: tensor2

    Return Value type(torch_tensor)

  • public function torch_tensor_postdivide_int8(tensor, scalar) result(output)

    Overloads division operator for a tensor and a scalar of type int8.

    Arguments

    Type IntentOptional Attributes Name
    type(torch_tensor), intent(in) :: tensor
    integer(kind=int8), intent(in) :: scalar

    Return Value type(torch_tensor)

  • public function torch_tensor_postdivide_int16(tensor, scalar) result(output)

    Overloads division operator for a tensor and a scalar of type int16.

    Arguments

    Type IntentOptional Attributes Name
    type(torch_tensor), intent(in) :: tensor
    integer(kind=int16), intent(in) :: scalar

    Return Value type(torch_tensor)

  • public function torch_tensor_postdivide_int32(tensor, scalar) result(output)

    Overloads division operator for a tensor and a scalar of type int32.

    Arguments

    Type IntentOptional Attributes Name
    type(torch_tensor), intent(in) :: tensor
    integer(kind=int32), intent(in) :: scalar

    Return Value type(torch_tensor)

  • public function torch_tensor_postdivide_int64(tensor, scalar) result(output)

    Overloads division operator for a tensor and a scalar of type int64.

    Arguments

    Type IntentOptional Attributes Name
    type(torch_tensor), intent(in) :: tensor
    integer(kind=int64), intent(in) :: scalar

    Return Value type(torch_tensor)

  • public function torch_tensor_postdivide_real32(tensor, scalar) result(output)

    Overloads division operator for a tensor and a scalar of type real32.

    Arguments

    Type IntentOptional Attributes Name
    type(torch_tensor), intent(in) :: tensor
    real(kind=real32), intent(in) :: scalar

    Return Value type(torch_tensor)

  • public function torch_tensor_postdivide_real64(tensor, scalar) result(output)

    Overloads division operator for a tensor and a scalar of type real64.

    Arguments

    Type IntentOptional Attributes Name
    type(torch_tensor), intent(in) :: tensor
    real(kind=real64), intent(in) :: scalar

    Return Value type(torch_tensor)

public interface torch_delete

Interface for deleting generic torch objects

  • public subroutine torch_model_delete(model)

    Deallocates a TorchScript model

    Arguments

    Type IntentOptional Attributes Name
    type(torch_model), intent(in) :: model

    Torch Model to deallocate

  • public subroutine torch_tensor_delete(tensor)

    Deallocates a tensor.

    Arguments

    Type IntentOptional Attributes Name
    type(torch_tensor), intent(inout) :: tensor
  • public subroutine torch_tensor_array_delete(tensor_array)

    Deallocates an array of tensors.

    Arguments

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

interface

  • public function torch_from_blob_c(data, ndims, tensor_shape, strides, dtype, device_type, device_index, requires_grad) result(tensor_p) bind(c, name = 'torch_from_blob')

    Arguments

    Type IntentOptional Attributes Name
    type(c_ptr), intent(in), value :: data
    integer(kind=c_int), intent(in), value :: ndims
    integer(kind=c_int64_t), intent(in) :: tensor_shape(*)
    integer(kind=c_int64_t), intent(in) :: strides(*)
    integer(kind=c_int), intent(in), value :: dtype
    integer(kind=c_int), intent(in), value :: device_type
    integer(kind=c_int), intent(in), value :: device_index
    logical(kind=c_bool), intent(in), value :: requires_grad

    Return Value type(c_ptr)

public interface torch_tensor_from_array

Interface for directing torch_tensor_from_array to possible input types and ranks

  • public subroutine torch_tensor_from_array_int8_1d(tensor, data_in, layout, device_type, device_index, requires_grad)

    Return a Torch tensor pointing to data_in array of rank 1 containing data of type int8

    Arguments

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

    Returned tensor

    integer(kind=int8), intent(in), target :: data_in(:)

    Input data that tensor will point at

    integer(kind=ftorch_int), intent(in) :: layout(1)

    Control order of indices

    integer(kind=c_int), intent(in) :: device_type

    Device type the tensor will live on (torch_kCPU or torch_kCUDA)

    integer(kind=c_int), intent(in), optional :: device_index

    device index to use for torch_kCUDA case

    logical, intent(in), optional :: requires_grad

    Whether gradients need to be computed for the created tensor

  • public subroutine torch_tensor_from_array_int8_2d(tensor, data_in, layout, device_type, device_index, requires_grad)

    Return a Torch tensor pointing to data_in array of rank 2 containing data of type int8

    Arguments

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

    Returned tensor

    integer(kind=int8), intent(in), target :: data_in(:,:)

    Input data that tensor will point at

    integer(kind=ftorch_int), intent(in) :: layout(2)

    Control order of indices

    integer(kind=c_int), intent(in) :: device_type

    Device type the tensor will live on (torch_kCPU or torch_kCUDA)

    integer(kind=c_int), intent(in), optional :: device_index

    device index to use for torch_kCUDA case

    logical, intent(in), optional :: requires_grad

    Whether gradients need to be computed for the created tensor

  • public subroutine torch_tensor_from_array_int8_3d(tensor, data_in, layout, device_type, device_index, requires_grad)

    Return a Torch tensor pointing to data_in array of rank 3 containing data of type int8

    Arguments

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

    Returned tensor

    integer(kind=int8), intent(in), target :: data_in(:,:,:)

    Input data that tensor will point at

    integer(kind=ftorch_int), intent(in) :: layout(3)

    Control order of indices

    integer(kind=c_int), intent(in) :: device_type

    Device type the tensor will live on (torch_kCPU or torch_kCUDA)

    integer(kind=c_int), intent(in), optional :: device_index

    device index to use for torch_kCUDA case

    logical, intent(in), optional :: requires_grad

    Whether gradients need to be computed for the created tensor

  • public subroutine torch_tensor_from_array_int8_4d(tensor, data_in, layout, device_type, device_index, requires_grad)

    Return a Torch tensor pointing to data_in array of rank 4 containing data of type int8

    Arguments

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

    Returned tensor

    integer(kind=int8), intent(in), target :: data_in(:,:,:,:)

    Input data that tensor will point at

    integer(kind=ftorch_int), intent(in) :: layout(4)

    Control order of indices

    integer(kind=c_int), intent(in) :: device_type

    Device type the tensor will live on (torch_kCPU or torch_kCUDA)

    integer(kind=c_int), intent(in), optional :: device_index

    device index to use for torch_kCUDA case

    logical, intent(in), optional :: requires_grad

    Whether gradients need to be computed for the created tensor

  • public subroutine torch_tensor_from_array_int8_5d(tensor, data_in, layout, device_type, device_index, requires_grad)

    Return a Torch tensor pointing to data_in array of rank 5 containing data of type int8

    Arguments

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

    Returned tensor

    integer(kind=int8), intent(in), target :: data_in(:,:,:,:,:)

    Input data that tensor will point at

    integer(kind=ftorch_int), intent(in) :: layout(5)

    Control order of indices

    integer(kind=c_int), intent(in) :: device_type

    Device type the tensor will live on (torch_kCPU or torch_kCUDA)

    integer(kind=c_int), intent(in), optional :: device_index

    device index to use for torch_kCUDA case

    logical, intent(in), optional :: requires_grad

    Whether gradients need to be computed for the created tensor

  • public subroutine torch_tensor_from_array_int16_1d(tensor, data_in, layout, device_type, device_index, requires_grad)

    Return a Torch tensor pointing to data_in array of rank 1 containing data of type int16

    Arguments

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

    Returned tensor

    integer(kind=int16), intent(in), target :: data_in(:)

    Input data that tensor will point at

    integer(kind=ftorch_int), intent(in) :: layout(1)

    Control order of indices

    integer(kind=c_int), intent(in) :: device_type

    Device type the tensor will live on (torch_kCPU or torch_kCUDA)

    integer(kind=c_int), intent(in), optional :: device_index

    device index to use for torch_kCUDA case

    logical, intent(in), optional :: requires_grad

    Whether gradients need to be computed for the created tensor

  • public subroutine torch_tensor_from_array_int16_2d(tensor, data_in, layout, device_type, device_index, requires_grad)

    Return a Torch tensor pointing to data_in array of rank 2 containing data of type int16

    Arguments

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

    Returned tensor

    integer(kind=int16), intent(in), target :: data_in(:,:)

    Input data that tensor will point at

    integer(kind=ftorch_int), intent(in) :: layout(2)

    Control order of indices

    integer(kind=c_int), intent(in) :: device_type

    Device type the tensor will live on (torch_kCPU or torch_kCUDA)

    integer(kind=c_int), intent(in), optional :: device_index

    device index to use for torch_kCUDA case

    logical, intent(in), optional :: requires_grad

    Whether gradients need to be computed for the created tensor

  • public subroutine torch_tensor_from_array_int16_3d(tensor, data_in, layout, device_type, device_index, requires_grad)

    Return a Torch tensor pointing to data_in array of rank 3 containing data of type int16

    Arguments

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

    Returned tensor

    integer(kind=int16), intent(in), target :: data_in(:,:,:)

    Input data that tensor will point at

    integer(kind=ftorch_int), intent(in) :: layout(3)

    Control order of indices

    integer(kind=c_int), intent(in) :: device_type

    Device type the tensor will live on (torch_kCPU or torch_kCUDA)

    integer(kind=c_int), intent(in), optional :: device_index

    device index to use for torch_kCUDA case

    logical, intent(in), optional :: requires_grad

    Whether gradients need to be computed for the created tensor

  • public subroutine torch_tensor_from_array_int16_4d(tensor, data_in, layout, device_type, device_index, requires_grad)

    Return a Torch tensor pointing to data_in array of rank 4 containing data of type int16

    Arguments

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

    Returned tensor

    integer(kind=int16), intent(in), target :: data_in(:,:,:,:)

    Input data that tensor will point at

    integer(kind=ftorch_int), intent(in) :: layout(4)

    Control order of indices

    integer(kind=c_int), intent(in) :: device_type

    Device type the tensor will live on (torch_kCPU or torch_kCUDA)

    integer(kind=c_int), intent(in), optional :: device_index

    device index to use for torch_kCUDA case

    logical, intent(in), optional :: requires_grad

    Whether gradients need to be computed for the created tensor

  • public subroutine torch_tensor_from_array_int16_5d(tensor, data_in, layout, device_type, device_index, requires_grad)

    Return a Torch tensor pointing to data_in array of rank 5 containing data of type int16

    Arguments

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

    Returned tensor

    integer(kind=int16), intent(in), target :: data_in(:,:,:,:,:)

    Input data that tensor will point at

    integer(kind=ftorch_int), intent(in) :: layout(5)

    Control order of indices

    integer(kind=c_int), intent(in) :: device_type

    Device type the tensor will live on (torch_kCPU or torch_kCUDA)

    integer(kind=c_int), intent(in), optional :: device_index

    device index to use for torch_kCUDA case

    logical, intent(in), optional :: requires_grad

    Whether gradients need to be computed for the created tensor

  • public subroutine torch_tensor_from_array_int32_1d(tensor, data_in, layout, device_type, device_index, requires_grad)

    Return a Torch tensor pointing to data_in array of rank 1 containing data of type int32

    Arguments

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

    Returned tensor

    integer(kind=int32), intent(in), target :: data_in(:)

    Input data that tensor will point at

    integer(kind=ftorch_int), intent(in) :: layout(1)

    Control order of indices

    integer(kind=c_int), intent(in) :: device_type

    Device type the tensor will live on (torch_kCPU or torch_kCUDA)

    integer(kind=c_int), intent(in), optional :: device_index

    device index to use for torch_kCUDA case

    logical, intent(in), optional :: requires_grad

    Whether gradients need to be computed for the created tensor

  • public subroutine torch_tensor_from_array_int32_2d(tensor, data_in, layout, device_type, device_index, requires_grad)

    Return a Torch tensor pointing to data_in array of rank 2 containing data of type int32

    Arguments

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

    Returned tensor

    integer(kind=int32), intent(in), target :: data_in(:,:)

    Input data that tensor will point at

    integer(kind=ftorch_int), intent(in) :: layout(2)

    Control order of indices

    integer(kind=c_int), intent(in) :: device_type

    Device type the tensor will live on (torch_kCPU or torch_kCUDA)

    integer(kind=c_int), intent(in), optional :: device_index

    device index to use for torch_kCUDA case

    logical, intent(in), optional :: requires_grad

    Whether gradients need to be computed for the created tensor

  • public subroutine torch_tensor_from_array_int32_3d(tensor, data_in, layout, device_type, device_index, requires_grad)

    Return a Torch tensor pointing to data_in array of rank 3 containing data of type int32

    Arguments

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

    Returned tensor

    integer(kind=int32), intent(in), target :: data_in(:,:,:)

    Input data that tensor will point at

    integer(kind=ftorch_int), intent(in) :: layout(3)

    Control order of indices

    integer(kind=c_int), intent(in) :: device_type

    Device type the tensor will live on (torch_kCPU or torch_kCUDA)

    integer(kind=c_int), intent(in), optional :: device_index

    device index to use for torch_kCUDA case

    logical, intent(in), optional :: requires_grad

    Whether gradients need to be computed for the created tensor

  • public subroutine torch_tensor_from_array_int32_4d(tensor, data_in, layout, device_type, device_index, requires_grad)

    Return a Torch tensor pointing to data_in array of rank 4 containing data of type int32

    Arguments

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

    Returned tensor

    integer(kind=int32), intent(in), target :: data_in(:,:,:,:)

    Input data that tensor will point at

    integer(kind=ftorch_int), intent(in) :: layout(4)

    Control order of indices

    integer(kind=c_int), intent(in) :: device_type

    Device type the tensor will live on (torch_kCPU or torch_kCUDA)

    integer(kind=c_int), intent(in), optional :: device_index

    device index to use for torch_kCUDA case

    logical, intent(in), optional :: requires_grad

    Whether gradients need to be computed for the created tensor

  • public subroutine torch_tensor_from_array_int32_5d(tensor, data_in, layout, device_type, device_index, requires_grad)

    Return a Torch tensor pointing to data_in array of rank 5 containing data of type int32

    Arguments

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

    Returned tensor

    integer(kind=int32), intent(in), target :: data_in(:,:,:,:,:)

    Input data that tensor will point at

    integer(kind=ftorch_int), intent(in) :: layout(5)

    Control order of indices

    integer(kind=c_int), intent(in) :: device_type

    Device type the tensor will live on (torch_kCPU or torch_kCUDA)

    integer(kind=c_int), intent(in), optional :: device_index

    device index to use for torch_kCUDA case

    logical, intent(in), optional :: requires_grad

    Whether gradients need to be computed for the created tensor

  • public subroutine torch_tensor_from_array_int64_1d(tensor, data_in, layout, device_type, device_index, requires_grad)

    Return a Torch tensor pointing to data_in array of rank 1 containing data of type int64

    Arguments

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

    Returned tensor

    integer(kind=int64), intent(in), target :: data_in(:)

    Input data that tensor will point at

    integer(kind=ftorch_int), intent(in) :: layout(1)

    Control order of indices

    integer(kind=c_int), intent(in) :: device_type

    Device type the tensor will live on (torch_kCPU or torch_kCUDA)

    integer(kind=c_int), intent(in), optional :: device_index

    device index to use for torch_kCUDA case

    logical, intent(in), optional :: requires_grad

    Whether gradients need to be computed for the created tensor

  • public subroutine torch_tensor_from_array_int64_2d(tensor, data_in, layout, device_type, device_index, requires_grad)

    Return a Torch tensor pointing to data_in array of rank 2 containing data of type int64

    Arguments

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

    Returned tensor

    integer(kind=int64), intent(in), target :: data_in(:,:)

    Input data that tensor will point at

    integer(kind=ftorch_int), intent(in) :: layout(2)

    Control order of indices

    integer(kind=c_int), intent(in) :: device_type

    Device type the tensor will live on (torch_kCPU or torch_kCUDA)

    integer(kind=c_int), intent(in), optional :: device_index

    device index to use for torch_kCUDA case

    logical, intent(in), optional :: requires_grad

    Whether gradients need to be computed for the created tensor

  • public subroutine torch_tensor_from_array_int64_3d(tensor, data_in, layout, device_type, device_index, requires_grad)

    Return a Torch tensor pointing to data_in array of rank 3 containing data of type int64

    Arguments

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

    Returned tensor

    integer(kind=int64), intent(in), target :: data_in(:,:,:)

    Input data that tensor will point at

    integer(kind=ftorch_int), intent(in) :: layout(3)

    Control order of indices

    integer(kind=c_int), intent(in) :: device_type

    Device type the tensor will live on (torch_kCPU or torch_kCUDA)

    integer(kind=c_int), intent(in), optional :: device_index

    device index to use for torch_kCUDA case

    logical, intent(in), optional :: requires_grad

    Whether gradients need to be computed for the created tensor

  • public subroutine torch_tensor_from_array_int64_4d(tensor, data_in, layout, device_type, device_index, requires_grad)

    Return a Torch tensor pointing to data_in array of rank 4 containing data of type int64

    Arguments

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

    Returned tensor

    integer(kind=int64), intent(in), target :: data_in(:,:,:,:)

    Input data that tensor will point at

    integer(kind=ftorch_int), intent(in) :: layout(4)

    Control order of indices

    integer(kind=c_int), intent(in) :: device_type

    Device type the tensor will live on (torch_kCPU or torch_kCUDA)

    integer(kind=c_int), intent(in), optional :: device_index

    device index to use for torch_kCUDA case

    logical, intent(in), optional :: requires_grad

    Whether gradients need to be computed for the created tensor

  • public subroutine torch_tensor_from_array_int64_5d(tensor, data_in, layout, device_type, device_index, requires_grad)

    Return a Torch tensor pointing to data_in array of rank 5 containing data of type int64

    Arguments

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

    Returned tensor

    integer(kind=int64), intent(in), target :: data_in(:,:,:,:,:)

    Input data that tensor will point at

    integer(kind=ftorch_int), intent(in) :: layout(5)

    Control order of indices

    integer(kind=c_int), intent(in) :: device_type

    Device type the tensor will live on (torch_kCPU or torch_kCUDA)

    integer(kind=c_int), intent(in), optional :: device_index

    device index to use for torch_kCUDA case

    logical, intent(in), optional :: requires_grad

    Whether gradients need to be computed for the created tensor

  • public subroutine torch_tensor_from_array_real32_1d(tensor, data_in, layout, device_type, device_index, requires_grad)

    Return a Torch tensor pointing to data_in array of rank 1 containing data of type real32

    Arguments

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

    Returned tensor

    real(kind=real32), intent(in), target :: data_in(:)

    Input data that tensor will point at

    integer(kind=ftorch_int), intent(in) :: layout(1)

    Control order of indices

    integer(kind=c_int), intent(in) :: device_type

    Device type the tensor will live on (torch_kCPU or torch_kCUDA)

    integer(kind=c_int), intent(in), optional :: device_index

    device index to use for torch_kCUDA case

    logical, intent(in), optional :: requires_grad

    Whether gradients need to be computed for the created tensor

  • public subroutine torch_tensor_from_array_real32_2d(tensor, data_in, layout, device_type, device_index, requires_grad)

    Return a Torch tensor pointing to data_in array of rank 2 containing data of type real32

    Arguments

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

    Returned tensor

    real(kind=real32), intent(in), target :: data_in(:,:)

    Input data that tensor will point at

    integer(kind=ftorch_int), intent(in) :: layout(2)

    Control order of indices

    integer(kind=c_int), intent(in) :: device_type

    Device type the tensor will live on (torch_kCPU or torch_kCUDA)

    integer(kind=c_int), intent(in), optional :: device_index

    device index to use for torch_kCUDA case

    logical, intent(in), optional :: requires_grad

    Whether gradients need to be computed for the created tensor

  • public subroutine torch_tensor_from_array_real32_3d(tensor, data_in, layout, device_type, device_index, requires_grad)

    Return a Torch tensor pointing to data_in array of rank 3 containing data of type real32

    Arguments

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

    Returned tensor

    real(kind=real32), intent(in), target :: data_in(:,:,:)

    Input data that tensor will point at

    integer(kind=ftorch_int), intent(in) :: layout(3)

    Control order of indices

    integer(kind=c_int), intent(in) :: device_type

    Device type the tensor will live on (torch_kCPU or torch_kCUDA)

    integer(kind=c_int), intent(in), optional :: device_index

    device index to use for torch_kCUDA case

    logical, intent(in), optional :: requires_grad

    Whether gradients need to be computed for the created tensor

  • public subroutine torch_tensor_from_array_real32_4d(tensor, data_in, layout, device_type, device_index, requires_grad)

    Return a Torch tensor pointing to data_in array of rank 4 containing data of type real32

    Arguments

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

    Returned tensor

    real(kind=real32), intent(in), target :: data_in(:,:,:,:)

    Input data that tensor will point at

    integer(kind=ftorch_int), intent(in) :: layout(4)

    Control order of indices

    integer(kind=c_int), intent(in) :: device_type

    Device type the tensor will live on (torch_kCPU or torch_kCUDA)

    integer(kind=c_int), intent(in), optional :: device_index

    device index to use for torch_kCUDA case

    logical, intent(in), optional :: requires_grad

    Whether gradients need to be computed for the created tensor

  • public subroutine torch_tensor_from_array_real32_5d(tensor, data_in, layout, device_type, device_index, requires_grad)

    Return a Torch tensor pointing to data_in array of rank 5 containing data of type real32

    Arguments

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

    Returned tensor

    real(kind=real32), intent(in), target :: data_in(:,:,:,:,:)

    Input data that tensor will point at

    integer(kind=ftorch_int), intent(in) :: layout(5)

    Control order of indices

    integer(kind=c_int), intent(in) :: device_type

    Device type the tensor will live on (torch_kCPU or torch_kCUDA)

    integer(kind=c_int), intent(in), optional :: device_index

    device index to use for torch_kCUDA case

    logical, intent(in), optional :: requires_grad

    Whether gradients need to be computed for the created tensor

  • public subroutine torch_tensor_from_array_real64_1d(tensor, data_in, layout, device_type, device_index, requires_grad)

    Return a Torch tensor pointing to data_in array of rank 1 containing data of type real64

    Arguments

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

    Returned tensor

    real(kind=real64), intent(in), target :: data_in(:)

    Input data that tensor will point at

    integer(kind=ftorch_int), intent(in) :: layout(1)

    Control order of indices

    integer(kind=c_int), intent(in) :: device_type

    Device type the tensor will live on (torch_kCPU or torch_kCUDA)

    integer(kind=c_int), intent(in), optional :: device_index

    device index to use for torch_kCUDA case

    logical, intent(in), optional :: requires_grad

    Whether gradients need to be computed for the created tensor

  • public subroutine torch_tensor_from_array_real64_2d(tensor, data_in, layout, device_type, device_index, requires_grad)

    Return a Torch tensor pointing to data_in array of rank 2 containing data of type real64

    Arguments

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

    Returned tensor

    real(kind=real64), intent(in), target :: data_in(:,:)

    Input data that tensor will point at

    integer(kind=ftorch_int), intent(in) :: layout(2)

    Control order of indices

    integer(kind=c_int), intent(in) :: device_type

    Device type the tensor will live on (torch_kCPU or torch_kCUDA)

    integer(kind=c_int), intent(in), optional :: device_index

    device index to use for torch_kCUDA case

    logical, intent(in), optional :: requires_grad

    Whether gradients need to be computed for the created tensor

  • public subroutine torch_tensor_from_array_real64_3d(tensor, data_in, layout, device_type, device_index, requires_grad)

    Return a Torch tensor pointing to data_in array of rank 3 containing data of type real64

    Arguments

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

    Returned tensor

    real(kind=real64), intent(in), target :: data_in(:,:,:)

    Input data that tensor will point at

    integer(kind=ftorch_int), intent(in) :: layout(3)

    Control order of indices

    integer(kind=c_int), intent(in) :: device_type

    Device type the tensor will live on (torch_kCPU or torch_kCUDA)

    integer(kind=c_int), intent(in), optional :: device_index

    device index to use for torch_kCUDA case

    logical, intent(in), optional :: requires_grad

    Whether gradients need to be computed for the created tensor

  • public subroutine torch_tensor_from_array_real64_4d(tensor, data_in, layout, device_type, device_index, requires_grad)

    Return a Torch tensor pointing to data_in array of rank 4 containing data of type real64

    Arguments

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

    Returned tensor

    real(kind=real64), intent(in), target :: data_in(:,:,:,:)

    Input data that tensor will point at

    integer(kind=ftorch_int), intent(in) :: layout(4)

    Control order of indices

    integer(kind=c_int), intent(in) :: device_type

    Device type the tensor will live on (torch_kCPU or torch_kCUDA)

    integer(kind=c_int), intent(in), optional :: device_index

    device index to use for torch_kCUDA case

    logical, intent(in), optional :: requires_grad

    Whether gradients need to be computed for the created tensor

  • public subroutine torch_tensor_from_array_real64_5d(tensor, data_in, layout, device_type, device_index, requires_grad)

    Return a Torch tensor pointing to data_in array of rank 5 containing data of type real64

    Arguments

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

    Returned tensor

    real(kind=real64), intent(in), target :: data_in(:,:,:,:,:)

    Input data that tensor will point at

    integer(kind=ftorch_int), intent(in) :: layout(5)

    Control order of indices

    integer(kind=c_int), intent(in) :: device_type

    Device type the tensor will live on (torch_kCPU or torch_kCUDA)

    integer(kind=c_int), intent(in), optional :: device_index

    device index to use for torch_kCUDA case

    logical, intent(in), optional :: requires_grad

    Whether gradients need to be computed for the created tensor

public interface torch_tensor_to_array

Interface for directing torch_tensor_to_array to possible input types and ranks

  • public subroutine torch_tensor_to_array_int8_1d(tensor, data_out, sizes)

    Return the array data associated with a Torch tensor of rank 1 and data type int8

    Arguments

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

    Returned tensor

    integer(kind=int8), intent(out), pointer :: data_out(:)

    Pointer to tensor data

    integer, intent(in), optional :: sizes(1)

    Number of entries for each rank

  • public subroutine torch_tensor_to_array_int8_2d(tensor, data_out, sizes)

    Return the array data associated with a Torch tensor of rank 2 and data type int8

    Arguments

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

    Returned tensor

    integer(kind=int8), intent(out), pointer :: data_out(:,:)

    Pointer to tensor data

    integer, intent(in), optional :: sizes(2)

    Number of entries for each rank

  • public subroutine torch_tensor_to_array_int8_3d(tensor, data_out, sizes)

    Return the array data associated with a Torch tensor of rank 3 and data type int8

    Arguments

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

    Returned tensor

    integer(kind=int8), intent(out), pointer :: data_out(:,:,:)

    Pointer to tensor data

    integer, intent(in), optional :: sizes(3)

    Number of entries for each rank

  • public subroutine torch_tensor_to_array_int8_4d(tensor, data_out, sizes)

    Return the array data associated with a Torch tensor of rank 4 and data type int8

    Arguments

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

    Returned tensor

    integer(kind=int8), intent(out), pointer :: data_out(:,:,:,:)

    Pointer to tensor data

    integer, intent(in), optional :: sizes(4)

    Number of entries for each rank

  • public subroutine torch_tensor_to_array_int8_5d(tensor, data_out, sizes)

    Return the array data associated with a Torch tensor of rank 5 and data type int8

    Arguments

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

    Returned tensor

    integer(kind=int8), intent(out), pointer :: data_out(:,:,:,:,:)

    Pointer to tensor data

    integer, intent(in), optional :: sizes(5)

    Number of entries for each rank

  • public subroutine torch_tensor_to_array_int16_1d(tensor, data_out, sizes)

    Return the array data associated with a Torch tensor of rank 1 and data type int16

    Arguments

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

    Returned tensor

    integer(kind=int16), intent(out), pointer :: data_out(:)

    Pointer to tensor data

    integer, intent(in), optional :: sizes(1)

    Number of entries for each rank

  • public subroutine torch_tensor_to_array_int16_2d(tensor, data_out, sizes)

    Return the array data associated with a Torch tensor of rank 2 and data type int16

    Arguments

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

    Returned tensor

    integer(kind=int16), intent(out), pointer :: data_out(:,:)

    Pointer to tensor data

    integer, intent(in), optional :: sizes(2)

    Number of entries for each rank

  • public subroutine torch_tensor_to_array_int16_3d(tensor, data_out, sizes)

    Return the array data associated with a Torch tensor of rank 3 and data type int16

    Arguments

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

    Returned tensor

    integer(kind=int16), intent(out), pointer :: data_out(:,:,:)

    Pointer to tensor data

    integer, intent(in), optional :: sizes(3)

    Number of entries for each rank

  • public subroutine torch_tensor_to_array_int16_4d(tensor, data_out, sizes)

    Return the array data associated with a Torch tensor of rank 4 and data type int16

    Arguments

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

    Returned tensor

    integer(kind=int16), intent(out), pointer :: data_out(:,:,:,:)

    Pointer to tensor data

    integer, intent(in), optional :: sizes(4)

    Number of entries for each rank

  • public subroutine torch_tensor_to_array_int16_5d(tensor, data_out, sizes)

    Return the array data associated with a Torch tensor of rank 5 and data type int16

    Arguments

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

    Returned tensor

    integer(kind=int16), intent(out), pointer :: data_out(:,:,:,:,:)

    Pointer to tensor data

    integer, intent(in), optional :: sizes(5)

    Number of entries for each rank

  • public subroutine torch_tensor_to_array_int32_1d(tensor, data_out, sizes)

    Return the array data associated with a Torch tensor of rank 1 and data type int32

    Arguments

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

    Returned tensor

    integer(kind=int32), intent(out), pointer :: data_out(:)

    Pointer to tensor data

    integer, intent(in), optional :: sizes(1)

    Number of entries for each rank

  • public subroutine torch_tensor_to_array_int32_2d(tensor, data_out, sizes)

    Return the array data associated with a Torch tensor of rank 2 and data type int32

    Arguments

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

    Returned tensor

    integer(kind=int32), intent(out), pointer :: data_out(:,:)

    Pointer to tensor data

    integer, intent(in), optional :: sizes(2)

    Number of entries for each rank

  • public subroutine torch_tensor_to_array_int32_3d(tensor, data_out, sizes)

    Return the array data associated with a Torch tensor of rank 3 and data type int32

    Arguments

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

    Returned tensor

    integer(kind=int32), intent(out), pointer :: data_out(:,:,:)

    Pointer to tensor data

    integer, intent(in), optional :: sizes(3)

    Number of entries for each rank

  • public subroutine torch_tensor_to_array_int32_4d(tensor, data_out, sizes)

    Return the array data associated with a Torch tensor of rank 4 and data type int32

    Arguments

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

    Returned tensor

    integer(kind=int32), intent(out), pointer :: data_out(:,:,:,:)

    Pointer to tensor data

    integer, intent(in), optional :: sizes(4)

    Number of entries for each rank

  • public subroutine torch_tensor_to_array_int32_5d(tensor, data_out, sizes)

    Return the array data associated with a Torch tensor of rank 5 and data type int32

    Arguments

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

    Returned tensor

    integer(kind=int32), intent(out), pointer :: data_out(:,:,:,:,:)

    Pointer to tensor data

    integer, intent(in), optional :: sizes(5)

    Number of entries for each rank

  • public subroutine torch_tensor_to_array_int64_1d(tensor, data_out, sizes)

    Return the array data associated with a Torch tensor of rank 1 and data type int64

    Arguments

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

    Returned tensor

    integer(kind=int64), intent(out), pointer :: data_out(:)

    Pointer to tensor data

    integer, intent(in), optional :: sizes(1)

    Number of entries for each rank

  • public subroutine torch_tensor_to_array_int64_2d(tensor, data_out, sizes)

    Return the array data associated with a Torch tensor of rank 2 and data type int64

    Arguments

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

    Returned tensor

    integer(kind=int64), intent(out), pointer :: data_out(:,:)

    Pointer to tensor data

    integer, intent(in), optional :: sizes(2)

    Number of entries for each rank

  • public subroutine torch_tensor_to_array_int64_3d(tensor, data_out, sizes)

    Return the array data associated with a Torch tensor of rank 3 and data type int64

    Arguments

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

    Returned tensor

    integer(kind=int64), intent(out), pointer :: data_out(:,:,:)

    Pointer to tensor data

    integer, intent(in), optional :: sizes(3)

    Number of entries for each rank

  • public subroutine torch_tensor_to_array_int64_4d(tensor, data_out, sizes)

    Return the array data associated with a Torch tensor of rank 4 and data type int64

    Arguments

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

    Returned tensor

    integer(kind=int64), intent(out), pointer :: data_out(:,:,:,:)

    Pointer to tensor data

    integer, intent(in), optional :: sizes(4)

    Number of entries for each rank

  • public subroutine torch_tensor_to_array_int64_5d(tensor, data_out, sizes)

    Return the array data associated with a Torch tensor of rank 5 and data type int64

    Arguments

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

    Returned tensor

    integer(kind=int64), intent(out), pointer :: data_out(:,:,:,:,:)

    Pointer to tensor data

    integer, intent(in), optional :: sizes(5)

    Number of entries for each rank

  • public subroutine torch_tensor_to_array_real32_1d(tensor, data_out, sizes)

    Return the array data associated with a Torch tensor of rank 1 and data type real32

    Arguments

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

    Returned tensor

    real(kind=real32), intent(out), pointer :: data_out(:)

    Pointer to tensor data

    integer, intent(in), optional :: sizes(1)

    Number of entries for each rank

  • public subroutine torch_tensor_to_array_real32_2d(tensor, data_out, sizes)

    Return the array data associated with a Torch tensor of rank 2 and data type real32

    Arguments

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

    Returned tensor

    real(kind=real32), intent(out), pointer :: data_out(:,:)

    Pointer to tensor data

    integer, intent(in), optional :: sizes(2)

    Number of entries for each rank

  • public subroutine torch_tensor_to_array_real32_3d(tensor, data_out, sizes)

    Return the array data associated with a Torch tensor of rank 3 and data type real32

    Arguments

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

    Returned tensor

    real(kind=real32), intent(out), pointer :: data_out(:,:,:)

    Pointer to tensor data

    integer, intent(in), optional :: sizes(3)

    Number of entries for each rank

  • public subroutine torch_tensor_to_array_real32_4d(tensor, data_out, sizes)

    Return the array data associated with a Torch tensor of rank 4 and data type real32

    Arguments

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

    Returned tensor

    real(kind=real32), intent(out), pointer :: data_out(:,:,:,:)

    Pointer to tensor data

    integer, intent(in), optional :: sizes(4)

    Number of entries for each rank

  • public subroutine torch_tensor_to_array_real32_5d(tensor, data_out, sizes)

    Return the array data associated with a Torch tensor of rank 5 and data type real32

    Arguments

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

    Returned tensor

    real(kind=real32), intent(out), pointer :: data_out(:,:,:,:,:)

    Pointer to tensor data

    integer, intent(in), optional :: sizes(5)

    Number of entries for each rank

  • public subroutine torch_tensor_to_array_real64_1d(tensor, data_out, sizes)

    Return the array data associated with a Torch tensor of rank 1 and data type real64

    Arguments

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

    Returned tensor

    real(kind=real64), intent(out), pointer :: data_out(:)

    Pointer to tensor data

    integer, intent(in), optional :: sizes(1)

    Number of entries for each rank

  • public subroutine torch_tensor_to_array_real64_2d(tensor, data_out, sizes)

    Return the array data associated with a Torch tensor of rank 2 and data type real64

    Arguments

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

    Returned tensor

    real(kind=real64), intent(out), pointer :: data_out(:,:)

    Pointer to tensor data

    integer, intent(in), optional :: sizes(2)

    Number of entries for each rank

  • public subroutine torch_tensor_to_array_real64_3d(tensor, data_out, sizes)

    Return the array data associated with a Torch tensor of rank 3 and data type real64

    Arguments

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

    Returned tensor

    real(kind=real64), intent(out), pointer :: data_out(:,:,:)

    Pointer to tensor data

    integer, intent(in), optional :: sizes(3)

    Number of entries for each rank

  • public subroutine torch_tensor_to_array_real64_4d(tensor, data_out, sizes)

    Return the array data associated with a Torch tensor of rank 4 and data type real64

    Arguments

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

    Returned tensor

    real(kind=real64), intent(out), pointer :: data_out(:,:,:,:)

    Pointer to tensor data

    integer, intent(in), optional :: sizes(4)

    Number of entries for each rank

  • public subroutine torch_tensor_to_array_real64_5d(tensor, data_out, sizes)

    Return the array data associated with a Torch tensor of rank 5 and data type real64

    Arguments

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

    Returned tensor

    real(kind=real64), intent(out), pointer :: data_out(:,:,:,:,:)

    Pointer to tensor data

    integer, intent(in), optional :: sizes(5)

    Number of entries for each rank

interface

  • public function torch_to_blob_c(tensor, dtype) result(data) bind(c, name = 'torch_to_blob')

    Arguments

    Type IntentOptional Attributes Name
    type(c_ptr), intent(in), value :: tensor
    integer(kind=c_int), intent(in), value :: dtype

    Return Value type(c_ptr)


Derived Types

type, public ::  torch_model

Type for holding a torch neural net (nn.Module).

Components

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

pointer to the neural net in memory

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

Type-Bound Procedures

procedure, public :: get_rank
procedure, public :: get_shape

Functions

public function 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

public function 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_long), pointer, (:)

Pointer to tensor data

public function torch_tensor_add(tensor1, tensor2) result(output)

Overloads addition operator for two tensors.

Arguments

Type IntentOptional Attributes Name
type(torch_tensor), intent(in) :: tensor1
type(torch_tensor), intent(in) :: tensor2

Return Value type(torch_tensor)

public function torch_tensor_divide(tensor1, tensor2) result(output)

Overloads division operator for two tensors.

Arguments

Type IntentOptional Attributes Name
type(torch_tensor), intent(in) :: tensor1
type(torch_tensor), intent(in) :: tensor2

Return Value type(torch_tensor)

public function torch_tensor_get_device_index(tensor) result(device_index)

Determines the device index of a tensor.

Arguments

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

Input tensor

Return Value integer(kind=c_int)

Device index of tensor

public function torch_tensor_multiply(tensor1, tensor2) result(output)

Overloads multiplication operator for two tensors.

Arguments

Type IntentOptional Attributes Name
type(torch_tensor), intent(in) :: tensor1
type(torch_tensor), intent(in) :: tensor2

Return Value type(torch_tensor)

public function torch_tensor_postdivide_int16(tensor, scalar) result(output)

Overloads division operator for a tensor and a scalar of type int16.

Arguments

Type IntentOptional Attributes Name
type(torch_tensor), intent(in) :: tensor
integer(kind=int16), intent(in) :: scalar

Return Value type(torch_tensor)

public function torch_tensor_postdivide_int32(tensor, scalar) result(output)

Overloads division operator for a tensor and a scalar of type int32.

Arguments

Type IntentOptional Attributes Name
type(torch_tensor), intent(in) :: tensor
integer(kind=int32), intent(in) :: scalar

Return Value type(torch_tensor)

public function torch_tensor_postdivide_int64(tensor, scalar) result(output)

Overloads division operator for a tensor and a scalar of type int64.

Arguments

Type IntentOptional Attributes Name
type(torch_tensor), intent(in) :: tensor
integer(kind=int64), intent(in) :: scalar

Return Value type(torch_tensor)

public function torch_tensor_postdivide_int8(tensor, scalar) result(output)

Overloads division operator for a tensor and a scalar of type int8.

Arguments

Type IntentOptional Attributes Name
type(torch_tensor), intent(in) :: tensor
integer(kind=int8), intent(in) :: scalar

Return Value type(torch_tensor)

public function torch_tensor_postdivide_real32(tensor, scalar) result(output)

Overloads division operator for a tensor and a scalar of type real32.

Arguments

Type IntentOptional Attributes Name
type(torch_tensor), intent(in) :: tensor
real(kind=real32), intent(in) :: scalar

Return Value type(torch_tensor)

public function torch_tensor_postdivide_real64(tensor, scalar) result(output)

Overloads division operator for a tensor and a scalar of type real64.

Arguments

Type IntentOptional Attributes Name
type(torch_tensor), intent(in) :: tensor
real(kind=real64), intent(in) :: scalar

Return Value type(torch_tensor)

public function torch_tensor_postmultiply_int16(tensor, scalar) result(output)

Overloads multiplication operator for a tensor and a scalar of type int16.

Arguments

Type IntentOptional Attributes Name
type(torch_tensor), intent(in) :: tensor
integer(kind=int16), intent(in) :: scalar

Return Value type(torch_tensor)

public function torch_tensor_postmultiply_int32(tensor, scalar) result(output)

Overloads multiplication operator for a tensor and a scalar of type int32.

Arguments

Type IntentOptional Attributes Name
type(torch_tensor), intent(in) :: tensor
integer(kind=int32), intent(in) :: scalar

Return Value type(torch_tensor)

public function torch_tensor_postmultiply_int64(tensor, scalar) result(output)

Overloads multiplication operator for a tensor and a scalar of type int64.

Arguments

Type IntentOptional Attributes Name
type(torch_tensor), intent(in) :: tensor
integer(kind=int64), intent(in) :: scalar

Return Value type(torch_tensor)

public function torch_tensor_postmultiply_int8(tensor, scalar) result(output)

Overloads multiplication operator for a tensor and a scalar of type int8.

Arguments

Type IntentOptional Attributes Name
type(torch_tensor), intent(in) :: tensor
integer(kind=int8), intent(in) :: scalar

Return Value type(torch_tensor)

public function torch_tensor_postmultiply_real32(tensor, scalar) result(output)

Overloads multiplication operator for a tensor and a scalar of type real32.

Arguments

Type IntentOptional Attributes Name
type(torch_tensor), intent(in) :: tensor
real(kind=real32), intent(in) :: scalar

Return Value type(torch_tensor)

public function torch_tensor_postmultiply_real64(tensor, scalar) result(output)

Overloads multiplication operator for a tensor and a scalar of type real64.

Arguments

Type IntentOptional Attributes Name
type(torch_tensor), intent(in) :: tensor
real(kind=real64), intent(in) :: scalar

Return Value type(torch_tensor)

public function torch_tensor_power_int16(tensor, power) result(output)

Overloads exponentiation operator for a tensor and a scalar of type int16

Arguments

Type IntentOptional Attributes Name
type(torch_tensor), intent(in) :: tensor
integer(kind=int16), intent(in) :: power

Return Value type(torch_tensor)

public function torch_tensor_power_int32(tensor, power) result(output)

Overloads exponentiation operator for a tensor and a scalar of type int32

Arguments

Type IntentOptional Attributes Name
type(torch_tensor), intent(in) :: tensor
integer(kind=int32), intent(in) :: power

Return Value type(torch_tensor)

public function torch_tensor_power_int64(tensor, power) result(output)

Overloads exponentiation operator for a tensor and a scalar of type int64

Arguments

Type IntentOptional Attributes Name
type(torch_tensor), intent(in) :: tensor
integer(kind=int64), intent(in) :: power

Return Value type(torch_tensor)

public function torch_tensor_power_int8(tensor, power) result(output)

Overloads exponentiation operator for a tensor and a scalar of type int8

Arguments

Type IntentOptional Attributes Name
type(torch_tensor), intent(in) :: tensor
integer(kind=int8), intent(in) :: power

Return Value type(torch_tensor)

public function torch_tensor_power_real32(tensor, power) result(output)

Overloads exponentiation operator for a tensor and a scalar of type real32

Arguments

Type IntentOptional Attributes Name
type(torch_tensor), intent(in) :: tensor
real(kind=real32), intent(in) :: power

Return Value type(torch_tensor)

public function torch_tensor_power_real64(tensor, power) result(output)

Overloads exponentiation operator for a tensor and a scalar of type real64

Arguments

Type IntentOptional Attributes Name
type(torch_tensor), intent(in) :: tensor
real(kind=real64), intent(in) :: power

Return Value type(torch_tensor)

public function torch_tensor_premultiply_int16(scalar, tensor) result(output)

Overloads multiplication operator for a scalar of type int16 and a tensor.

Arguments

Type IntentOptional Attributes Name
integer(kind=int16), intent(in) :: scalar
type(torch_tensor), intent(in) :: tensor

Return Value type(torch_tensor)

public function torch_tensor_premultiply_int32(scalar, tensor) result(output)

Overloads multiplication operator for a scalar of type int32 and a tensor.

Arguments

Type IntentOptional Attributes Name
integer(kind=int32), intent(in) :: scalar
type(torch_tensor), intent(in) :: tensor

Return Value type(torch_tensor)

public function torch_tensor_premultiply_int64(scalar, tensor) result(output)

Overloads multiplication operator for a scalar of type int64 and a tensor.

Arguments

Type IntentOptional Attributes Name
integer(kind=int64), intent(in) :: scalar
type(torch_tensor), intent(in) :: tensor

Return Value type(torch_tensor)

public function torch_tensor_premultiply_int8(scalar, tensor) result(output)

Overloads multiplication operator for a scalar of type int8 and a tensor.

Arguments

Type IntentOptional Attributes Name
integer(kind=int8), intent(in) :: scalar
type(torch_tensor), intent(in) :: tensor

Return Value type(torch_tensor)

public function torch_tensor_premultiply_real32(scalar, tensor) result(output)

Overloads multiplication operator for a scalar of type real32 and a tensor.

Arguments

Type IntentOptional Attributes Name
real(kind=real32), intent(in) :: scalar
type(torch_tensor), intent(in) :: tensor

Return Value type(torch_tensor)

public function torch_tensor_premultiply_real64(scalar, tensor) result(output)

Overloads multiplication operator for a scalar of type real64 and a tensor.

Arguments

Type IntentOptional Attributes Name
real(kind=real64), intent(in) :: scalar
type(torch_tensor), intent(in) :: tensor

Return Value type(torch_tensor)

public function torch_tensor_subtract(tensor1, tensor2) result(output)

Overloads subtraction operator for two tensors.

Arguments

Type IntentOptional Attributes Name
type(torch_tensor), intent(in) :: tensor1
type(torch_tensor), intent(in) :: tensor2

Return Value type(torch_tensor)


Subroutines

public subroutine torch_model_delete(model)

Deallocates a TorchScript model

Arguments

Type IntentOptional Attributes Name
type(torch_model), intent(in) :: model

Torch Model to deallocate

public subroutine torch_model_forward(model, input_tensors, output_tensors, requires_grad)

Performs a forward pass of the model with the input tensors

Arguments

Type IntentOptional Attributes Name
type(torch_model), intent(in) :: model

Model

type(torch_tensor), intent(in), dimension(:) :: input_tensors

Array of Input tensors

type(torch_tensor), intent(in), dimension(:) :: output_tensors

Returned output tensors

logical, intent(in), optional :: requires_grad

Whether gradients need to be computed for the created tensor

public subroutine torch_model_load(model, filename, device_type, device_index, requires_grad, is_training)

Loads a TorchScript nn.module (pre-trained PyTorch model saved with TorchScript)

Arguments

Type IntentOptional Attributes Name
type(torch_model), intent(out) :: model

Returned deserialized model

character(len=*), intent(in) :: filename

Filename of saved TorchScript model

integer(kind=c_int), intent(in), optional :: device_type

Device type the tensor will live on (torch_kCPU or torch_kCUDA)

integer(kind=c_int), intent(in), optional :: device_index

device index to use for torch_kCUDA case

logical, intent(in), optional :: requires_grad

Whether gradients need to be computed for the created tensor

logical, intent(in), optional :: is_training

Whether gradients need to be computed for the created tensor

public subroutine torch_tensor_array_delete(tensor_array)

Deallocates an array of tensors.

Arguments

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

public subroutine torch_tensor_assign(output, input)

Overloads assignment operator for tensors.

Arguments

Type IntentOptional Attributes Name
type(torch_tensor), intent(out) :: output
type(torch_tensor), intent(in) :: input

public subroutine torch_tensor_delete(tensor)

Deallocates a tensor.

Arguments

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

public subroutine torch_tensor_from_array_int16_1d(tensor, data_in, layout, device_type, device_index, requires_grad)

Return a Torch tensor pointing to data_in array of rank 1 containing data of type int16

Arguments

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

Returned tensor

integer(kind=int16), intent(in), target :: data_in(:)

Input data that tensor will point at

integer(kind=ftorch_int), intent(in) :: layout(1)

Control order of indices

integer(kind=c_int), intent(in) :: device_type

Device type the tensor will live on (torch_kCPU or torch_kCUDA)

integer(kind=c_int), intent(in), optional :: device_index

device index to use for torch_kCUDA case

logical, intent(in), optional :: requires_grad

Whether gradients need to be computed for the created tensor

public subroutine torch_tensor_from_array_int16_2d(tensor, data_in, layout, device_type, device_index, requires_grad)

Return a Torch tensor pointing to data_in array of rank 2 containing data of type int16

Arguments

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

Returned tensor

integer(kind=int16), intent(in), target :: data_in(:,:)

Input data that tensor will point at

integer(kind=ftorch_int), intent(in) :: layout(2)

Control order of indices

integer(kind=c_int), intent(in) :: device_type

Device type the tensor will live on (torch_kCPU or torch_kCUDA)

integer(kind=c_int), intent(in), optional :: device_index

device index to use for torch_kCUDA case

logical, intent(in), optional :: requires_grad

Whether gradients need to be computed for the created tensor

public subroutine torch_tensor_from_array_int16_3d(tensor, data_in, layout, device_type, device_index, requires_grad)

Return a Torch tensor pointing to data_in array of rank 3 containing data of type int16

Arguments

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

Returned tensor

integer(kind=int16), intent(in), target :: data_in(:,:,:)

Input data that tensor will point at

integer(kind=ftorch_int), intent(in) :: layout(3)

Control order of indices

integer(kind=c_int), intent(in) :: device_type

Device type the tensor will live on (torch_kCPU or torch_kCUDA)

integer(kind=c_int), intent(in), optional :: device_index

device index to use for torch_kCUDA case

logical, intent(in), optional :: requires_grad

Whether gradients need to be computed for the created tensor

public subroutine torch_tensor_from_array_int16_4d(tensor, data_in, layout, device_type, device_index, requires_grad)

Return a Torch tensor pointing to data_in array of rank 4 containing data of type int16

Arguments

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

Returned tensor

integer(kind=int16), intent(in), target :: data_in(:,:,:,:)

Input data that tensor will point at

integer(kind=ftorch_int), intent(in) :: layout(4)

Control order of indices

integer(kind=c_int), intent(in) :: device_type

Device type the tensor will live on (torch_kCPU or torch_kCUDA)

integer(kind=c_int), intent(in), optional :: device_index

device index to use for torch_kCUDA case

logical, intent(in), optional :: requires_grad

Whether gradients need to be computed for the created tensor

public subroutine torch_tensor_from_array_int16_5d(tensor, data_in, layout, device_type, device_index, requires_grad)

Return a Torch tensor pointing to data_in array of rank 5 containing data of type int16

Arguments

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

Returned tensor

integer(kind=int16), intent(in), target :: data_in(:,:,:,:,:)

Input data that tensor will point at

integer(kind=ftorch_int), intent(in) :: layout(5)

Control order of indices

integer(kind=c_int), intent(in) :: device_type

Device type the tensor will live on (torch_kCPU or torch_kCUDA)

integer(kind=c_int), intent(in), optional :: device_index

device index to use for torch_kCUDA case

logical, intent(in), optional :: requires_grad

Whether gradients need to be computed for the created tensor

public subroutine torch_tensor_from_array_int32_1d(tensor, data_in, layout, device_type, device_index, requires_grad)

Return a Torch tensor pointing to data_in array of rank 1 containing data of type int32

Arguments

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

Returned tensor

integer(kind=int32), intent(in), target :: data_in(:)

Input data that tensor will point at

integer(kind=ftorch_int), intent(in) :: layout(1)

Control order of indices

integer(kind=c_int), intent(in) :: device_type

Device type the tensor will live on (torch_kCPU or torch_kCUDA)

integer(kind=c_int), intent(in), optional :: device_index

device index to use for torch_kCUDA case

logical, intent(in), optional :: requires_grad

Whether gradients need to be computed for the created tensor

public subroutine torch_tensor_from_array_int32_2d(tensor, data_in, layout, device_type, device_index, requires_grad)

Return a Torch tensor pointing to data_in array of rank 2 containing data of type int32

Arguments

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

Returned tensor

integer(kind=int32), intent(in), target :: data_in(:,:)

Input data that tensor will point at

integer(kind=ftorch_int), intent(in) :: layout(2)

Control order of indices

integer(kind=c_int), intent(in) :: device_type

Device type the tensor will live on (torch_kCPU or torch_kCUDA)

integer(kind=c_int), intent(in), optional :: device_index

device index to use for torch_kCUDA case

logical, intent(in), optional :: requires_grad

Whether gradients need to be computed for the created tensor

public subroutine torch_tensor_from_array_int32_3d(tensor, data_in, layout, device_type, device_index, requires_grad)

Return a Torch tensor pointing to data_in array of rank 3 containing data of type int32

Arguments

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

Returned tensor

integer(kind=int32), intent(in), target :: data_in(:,:,:)

Input data that tensor will point at

integer(kind=ftorch_int), intent(in) :: layout(3)

Control order of indices

integer(kind=c_int), intent(in) :: device_type

Device type the tensor will live on (torch_kCPU or torch_kCUDA)

integer(kind=c_int), intent(in), optional :: device_index

device index to use for torch_kCUDA case

logical, intent(in), optional :: requires_grad

Whether gradients need to be computed for the created tensor

public subroutine torch_tensor_from_array_int32_4d(tensor, data_in, layout, device_type, device_index, requires_grad)

Return a Torch tensor pointing to data_in array of rank 4 containing data of type int32

Arguments

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

Returned tensor

integer(kind=int32), intent(in), target :: data_in(:,:,:,:)

Input data that tensor will point at

integer(kind=ftorch_int), intent(in) :: layout(4)

Control order of indices

integer(kind=c_int), intent(in) :: device_type

Device type the tensor will live on (torch_kCPU or torch_kCUDA)

integer(kind=c_int), intent(in), optional :: device_index

device index to use for torch_kCUDA case

logical, intent(in), optional :: requires_grad

Whether gradients need to be computed for the created tensor

public subroutine torch_tensor_from_array_int32_5d(tensor, data_in, layout, device_type, device_index, requires_grad)

Return a Torch tensor pointing to data_in array of rank 5 containing data of type int32

Arguments

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

Returned tensor

integer(kind=int32), intent(in), target :: data_in(:,:,:,:,:)

Input data that tensor will point at

integer(kind=ftorch_int), intent(in) :: layout(5)

Control order of indices

integer(kind=c_int), intent(in) :: device_type

Device type the tensor will live on (torch_kCPU or torch_kCUDA)

integer(kind=c_int), intent(in), optional :: device_index

device index to use for torch_kCUDA case

logical, intent(in), optional :: requires_grad

Whether gradients need to be computed for the created tensor

public subroutine torch_tensor_from_array_int64_1d(tensor, data_in, layout, device_type, device_index, requires_grad)

Return a Torch tensor pointing to data_in array of rank 1 containing data of type int64

Arguments

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

Returned tensor

integer(kind=int64), intent(in), target :: data_in(:)

Input data that tensor will point at

integer(kind=ftorch_int), intent(in) :: layout(1)

Control order of indices

integer(kind=c_int), intent(in) :: device_type

Device type the tensor will live on (torch_kCPU or torch_kCUDA)

integer(kind=c_int), intent(in), optional :: device_index

device index to use for torch_kCUDA case

logical, intent(in), optional :: requires_grad

Whether gradients need to be computed for the created tensor

public subroutine torch_tensor_from_array_int64_2d(tensor, data_in, layout, device_type, device_index, requires_grad)

Return a Torch tensor pointing to data_in array of rank 2 containing data of type int64

Arguments

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

Returned tensor

integer(kind=int64), intent(in), target :: data_in(:,:)

Input data that tensor will point at

integer(kind=ftorch_int), intent(in) :: layout(2)

Control order of indices

integer(kind=c_int), intent(in) :: device_type

Device type the tensor will live on (torch_kCPU or torch_kCUDA)

integer(kind=c_int), intent(in), optional :: device_index

device index to use for torch_kCUDA case

logical, intent(in), optional :: requires_grad

Whether gradients need to be computed for the created tensor

public subroutine torch_tensor_from_array_int64_3d(tensor, data_in, layout, device_type, device_index, requires_grad)

Return a Torch tensor pointing to data_in array of rank 3 containing data of type int64

Arguments

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

Returned tensor

integer(kind=int64), intent(in), target :: data_in(:,:,:)

Input data that tensor will point at

integer(kind=ftorch_int), intent(in) :: layout(3)

Control order of indices

integer(kind=c_int), intent(in) :: device_type

Device type the tensor will live on (torch_kCPU or torch_kCUDA)

integer(kind=c_int), intent(in), optional :: device_index

device index to use for torch_kCUDA case

logical, intent(in), optional :: requires_grad

Whether gradients need to be computed for the created tensor

public subroutine torch_tensor_from_array_int64_4d(tensor, data_in, layout, device_type, device_index, requires_grad)

Return a Torch tensor pointing to data_in array of rank 4 containing data of type int64

Arguments

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

Returned tensor

integer(kind=int64), intent(in), target :: data_in(:,:,:,:)

Input data that tensor will point at

integer(kind=ftorch_int), intent(in) :: layout(4)

Control order of indices

integer(kind=c_int), intent(in) :: device_type

Device type the tensor will live on (torch_kCPU or torch_kCUDA)

integer(kind=c_int), intent(in), optional :: device_index

device index to use for torch_kCUDA case

logical, intent(in), optional :: requires_grad

Whether gradients need to be computed for the created tensor

public subroutine torch_tensor_from_array_int64_5d(tensor, data_in, layout, device_type, device_index, requires_grad)

Return a Torch tensor pointing to data_in array of rank 5 containing data of type int64

Arguments

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

Returned tensor

integer(kind=int64), intent(in), target :: data_in(:,:,:,:,:)

Input data that tensor will point at

integer(kind=ftorch_int), intent(in) :: layout(5)

Control order of indices

integer(kind=c_int), intent(in) :: device_type

Device type the tensor will live on (torch_kCPU or torch_kCUDA)

integer(kind=c_int), intent(in), optional :: device_index

device index to use for torch_kCUDA case

logical, intent(in), optional :: requires_grad

Whether gradients need to be computed for the created tensor

public subroutine torch_tensor_from_array_int8_1d(tensor, data_in, layout, device_type, device_index, requires_grad)

Return a Torch tensor pointing to data_in array of rank 1 containing data of type int8

Arguments

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

Returned tensor

integer(kind=int8), intent(in), target :: data_in(:)

Input data that tensor will point at

integer(kind=ftorch_int), intent(in) :: layout(1)

Control order of indices

integer(kind=c_int), intent(in) :: device_type

Device type the tensor will live on (torch_kCPU or torch_kCUDA)

integer(kind=c_int), intent(in), optional :: device_index

device index to use for torch_kCUDA case

logical, intent(in), optional :: requires_grad

Whether gradients need to be computed for the created tensor

public subroutine torch_tensor_from_array_int8_2d(tensor, data_in, layout, device_type, device_index, requires_grad)

Return a Torch tensor pointing to data_in array of rank 2 containing data of type int8

Arguments

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

Returned tensor

integer(kind=int8), intent(in), target :: data_in(:,:)

Input data that tensor will point at

integer(kind=ftorch_int), intent(in) :: layout(2)

Control order of indices

integer(kind=c_int), intent(in) :: device_type

Device type the tensor will live on (torch_kCPU or torch_kCUDA)

integer(kind=c_int), intent(in), optional :: device_index

device index to use for torch_kCUDA case

logical, intent(in), optional :: requires_grad

Whether gradients need to be computed for the created tensor

public subroutine torch_tensor_from_array_int8_3d(tensor, data_in, layout, device_type, device_index, requires_grad)

Return a Torch tensor pointing to data_in array of rank 3 containing data of type int8

Arguments

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

Returned tensor

integer(kind=int8), intent(in), target :: data_in(:,:,:)

Input data that tensor will point at

integer(kind=ftorch_int), intent(in) :: layout(3)

Control order of indices

integer(kind=c_int), intent(in) :: device_type

Device type the tensor will live on (torch_kCPU or torch_kCUDA)

integer(kind=c_int), intent(in), optional :: device_index

device index to use for torch_kCUDA case

logical, intent(in), optional :: requires_grad

Whether gradients need to be computed for the created tensor

public subroutine torch_tensor_from_array_int8_4d(tensor, data_in, layout, device_type, device_index, requires_grad)

Return a Torch tensor pointing to data_in array of rank 4 containing data of type int8

Arguments

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

Returned tensor

integer(kind=int8), intent(in), target :: data_in(:,:,:,:)

Input data that tensor will point at

integer(kind=ftorch_int), intent(in) :: layout(4)

Control order of indices

integer(kind=c_int), intent(in) :: device_type

Device type the tensor will live on (torch_kCPU or torch_kCUDA)

integer(kind=c_int), intent(in), optional :: device_index

device index to use for torch_kCUDA case

logical, intent(in), optional :: requires_grad

Whether gradients need to be computed for the created tensor

public subroutine torch_tensor_from_array_int8_5d(tensor, data_in, layout, device_type, device_index, requires_grad)

Return a Torch tensor pointing to data_in array of rank 5 containing data of type int8

Arguments

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

Returned tensor

integer(kind=int8), intent(in), target :: data_in(:,:,:,:,:)

Input data that tensor will point at

integer(kind=ftorch_int), intent(in) :: layout(5)

Control order of indices

integer(kind=c_int), intent(in) :: device_type

Device type the tensor will live on (torch_kCPU or torch_kCUDA)

integer(kind=c_int), intent(in), optional :: device_index

device index to use for torch_kCUDA case

logical, intent(in), optional :: requires_grad

Whether gradients need to be computed for the created tensor

public subroutine torch_tensor_from_array_real32_1d(tensor, data_in, layout, device_type, device_index, requires_grad)

Return a Torch tensor pointing to data_in array of rank 1 containing data of type real32

Arguments

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

Returned tensor

real(kind=real32), intent(in), target :: data_in(:)

Input data that tensor will point at

integer(kind=ftorch_int), intent(in) :: layout(1)

Control order of indices

integer(kind=c_int), intent(in) :: device_type

Device type the tensor will live on (torch_kCPU or torch_kCUDA)

integer(kind=c_int), intent(in), optional :: device_index

device index to use for torch_kCUDA case

logical, intent(in), optional :: requires_grad

Whether gradients need to be computed for the created tensor

public subroutine torch_tensor_from_array_real32_2d(tensor, data_in, layout, device_type, device_index, requires_grad)

Return a Torch tensor pointing to data_in array of rank 2 containing data of type real32

Arguments

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

Returned tensor

real(kind=real32), intent(in), target :: data_in(:,:)

Input data that tensor will point at

integer(kind=ftorch_int), intent(in) :: layout(2)

Control order of indices

integer(kind=c_int), intent(in) :: device_type

Device type the tensor will live on (torch_kCPU or torch_kCUDA)

integer(kind=c_int), intent(in), optional :: device_index

device index to use for torch_kCUDA case

logical, intent(in), optional :: requires_grad

Whether gradients need to be computed for the created tensor

public subroutine torch_tensor_from_array_real32_3d(tensor, data_in, layout, device_type, device_index, requires_grad)

Return a Torch tensor pointing to data_in array of rank 3 containing data of type real32

Arguments

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

Returned tensor

real(kind=real32), intent(in), target :: data_in(:,:,:)

Input data that tensor will point at

integer(kind=ftorch_int), intent(in) :: layout(3)

Control order of indices

integer(kind=c_int), intent(in) :: device_type

Device type the tensor will live on (torch_kCPU or torch_kCUDA)

integer(kind=c_int), intent(in), optional :: device_index

device index to use for torch_kCUDA case

logical, intent(in), optional :: requires_grad

Whether gradients need to be computed for the created tensor

public subroutine torch_tensor_from_array_real32_4d(tensor, data_in, layout, device_type, device_index, requires_grad)

Return a Torch tensor pointing to data_in array of rank 4 containing data of type real32

Arguments

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

Returned tensor

real(kind=real32), intent(in), target :: data_in(:,:,:,:)

Input data that tensor will point at

integer(kind=ftorch_int), intent(in) :: layout(4)

Control order of indices

integer(kind=c_int), intent(in) :: device_type

Device type the tensor will live on (torch_kCPU or torch_kCUDA)

integer(kind=c_int), intent(in), optional :: device_index

device index to use for torch_kCUDA case

logical, intent(in), optional :: requires_grad

Whether gradients need to be computed for the created tensor

public subroutine torch_tensor_from_array_real32_5d(tensor, data_in, layout, device_type, device_index, requires_grad)

Return a Torch tensor pointing to data_in array of rank 5 containing data of type real32

Arguments

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

Returned tensor

real(kind=real32), intent(in), target :: data_in(:,:,:,:,:)

Input data that tensor will point at

integer(kind=ftorch_int), intent(in) :: layout(5)

Control order of indices

integer(kind=c_int), intent(in) :: device_type

Device type the tensor will live on (torch_kCPU or torch_kCUDA)

integer(kind=c_int), intent(in), optional :: device_index

device index to use for torch_kCUDA case

logical, intent(in), optional :: requires_grad

Whether gradients need to be computed for the created tensor

public subroutine torch_tensor_from_array_real64_1d(tensor, data_in, layout, device_type, device_index, requires_grad)

Return a Torch tensor pointing to data_in array of rank 1 containing data of type real64

Arguments

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

Returned tensor

real(kind=real64), intent(in), target :: data_in(:)

Input data that tensor will point at

integer(kind=ftorch_int), intent(in) :: layout(1)

Control order of indices

integer(kind=c_int), intent(in) :: device_type

Device type the tensor will live on (torch_kCPU or torch_kCUDA)

integer(kind=c_int), intent(in), optional :: device_index

device index to use for torch_kCUDA case

logical, intent(in), optional :: requires_grad

Whether gradients need to be computed for the created tensor

public subroutine torch_tensor_from_array_real64_2d(tensor, data_in, layout, device_type, device_index, requires_grad)

Return a Torch tensor pointing to data_in array of rank 2 containing data of type real64

Arguments

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

Returned tensor

real(kind=real64), intent(in), target :: data_in(:,:)

Input data that tensor will point at

integer(kind=ftorch_int), intent(in) :: layout(2)

Control order of indices

integer(kind=c_int), intent(in) :: device_type

Device type the tensor will live on (torch_kCPU or torch_kCUDA)

integer(kind=c_int), intent(in), optional :: device_index

device index to use for torch_kCUDA case

logical, intent(in), optional :: requires_grad

Whether gradients need to be computed for the created tensor

public subroutine torch_tensor_from_array_real64_3d(tensor, data_in, layout, device_type, device_index, requires_grad)

Return a Torch tensor pointing to data_in array of rank 3 containing data of type real64

Arguments

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

Returned tensor

real(kind=real64), intent(in), target :: data_in(:,:,:)

Input data that tensor will point at

integer(kind=ftorch_int), intent(in) :: layout(3)

Control order of indices

integer(kind=c_int), intent(in) :: device_type

Device type the tensor will live on (torch_kCPU or torch_kCUDA)

integer(kind=c_int), intent(in), optional :: device_index

device index to use for torch_kCUDA case

logical, intent(in), optional :: requires_grad

Whether gradients need to be computed for the created tensor

public subroutine torch_tensor_from_array_real64_4d(tensor, data_in, layout, device_type, device_index, requires_grad)

Return a Torch tensor pointing to data_in array of rank 4 containing data of type real64

Arguments

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

Returned tensor

real(kind=real64), intent(in), target :: data_in(:,:,:,:)

Input data that tensor will point at

integer(kind=ftorch_int), intent(in) :: layout(4)

Control order of indices

integer(kind=c_int), intent(in) :: device_type

Device type the tensor will live on (torch_kCPU or torch_kCUDA)

integer(kind=c_int), intent(in), optional :: device_index

device index to use for torch_kCUDA case

logical, intent(in), optional :: requires_grad

Whether gradients need to be computed for the created tensor

public subroutine torch_tensor_from_array_real64_5d(tensor, data_in, layout, device_type, device_index, requires_grad)

Return a Torch tensor pointing to data_in array of rank 5 containing data of type real64

Arguments

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

Returned tensor

real(kind=real64), intent(in), target :: data_in(:,:,:,:,:)

Input data that tensor will point at

integer(kind=ftorch_int), intent(in) :: layout(5)

Control order of indices

integer(kind=c_int), intent(in) :: device_type

Device type the tensor will live on (torch_kCPU or torch_kCUDA)

integer(kind=c_int), intent(in), optional :: device_index

device index to use for torch_kCUDA case

logical, intent(in), optional :: requires_grad

Whether gradients need to be computed for the created tensor

public subroutine torch_tensor_from_blob(tensor, data, ndims, tensor_shape, layout, dtype, device_type, device_index, requires_grad)

Exposes the given data as a tensor without taking ownership of the original data. This routine will take an (i, j, k) array and return an (k, j, i) tensor.

Arguments

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

Returned tensor

type(c_ptr), intent(in) :: data

Pointer to data

integer(kind=c_int), intent(in) :: ndims

Number of dimensions of the tensor

integer(kind=c_int64_t), intent(in) :: tensor_shape(*)

Shape of the tensor

integer(kind=c_int), intent(in) :: layout(*)

Layout for strides for accessing data

integer(kind=c_int), intent(in) :: dtype

Data type of the tensor

integer(kind=c_int), intent(in) :: device_type

Device type the tensor will live on (torch_kCPU or torch_kCUDA)

integer(kind=c_int), intent(in), optional :: device_index

device index to use for torch_kCUDA case

logical(kind=c_bool), intent(in), optional :: requires_grad

Whether gradients need to be computed for the created tensor

public subroutine torch_tensor_ones(tensor, ndims, tensor_shape, dtype, device_type, device_index, requires_grad)

Returns a tensor filled with the scalar value 1.

Arguments

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

Returned tensor

integer(kind=c_int), intent(in) :: ndims

Number of dimensions of the tensor

integer(kind=c_int64_t), intent(in) :: tensor_shape(*)

Shape of the tensor

integer(kind=c_int), intent(in) :: dtype

Data type of the tensor

integer(kind=c_int), intent(in) :: device_type

Device type the tensor will live on (torch_kCPU or torch_kCUDA)

integer(kind=c_int), intent(in), optional :: device_index

device index to use for torch_kCUDA case

logical(kind=c_bool), intent(in), optional :: requires_grad

Whether gradients need to be computed for the created tensor

public subroutine torch_tensor_print(tensor)

Prints the contents of a tensor.

Arguments

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

Input tensor

public subroutine torch_tensor_to_array_int16_1d(tensor, data_out, sizes)

Return the array data associated with a Torch tensor of rank 1 and data type int16

Arguments

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

Returned tensor

integer(kind=int16), intent(out), pointer :: data_out(:)

Pointer to tensor data

integer, intent(in), optional :: sizes(1)

Number of entries for each rank

public subroutine torch_tensor_to_array_int16_2d(tensor, data_out, sizes)

Return the array data associated with a Torch tensor of rank 2 and data type int16

Arguments

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

Returned tensor

integer(kind=int16), intent(out), pointer :: data_out(:,:)

Pointer to tensor data

integer, intent(in), optional :: sizes(2)

Number of entries for each rank

public subroutine torch_tensor_to_array_int16_3d(tensor, data_out, sizes)

Return the array data associated with a Torch tensor of rank 3 and data type int16

Arguments

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

Returned tensor

integer(kind=int16), intent(out), pointer :: data_out(:,:,:)

Pointer to tensor data

integer, intent(in), optional :: sizes(3)

Number of entries for each rank

public subroutine torch_tensor_to_array_int16_4d(tensor, data_out, sizes)

Return the array data associated with a Torch tensor of rank 4 and data type int16

Arguments

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

Returned tensor

integer(kind=int16), intent(out), pointer :: data_out(:,:,:,:)

Pointer to tensor data

integer, intent(in), optional :: sizes(4)

Number of entries for each rank

public subroutine torch_tensor_to_array_int16_5d(tensor, data_out, sizes)

Return the array data associated with a Torch tensor of rank 5 and data type int16

Arguments

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

Returned tensor

integer(kind=int16), intent(out), pointer :: data_out(:,:,:,:,:)

Pointer to tensor data

integer, intent(in), optional :: sizes(5)

Number of entries for each rank

public subroutine torch_tensor_to_array_int32_1d(tensor, data_out, sizes)

Return the array data associated with a Torch tensor of rank 1 and data type int32

Arguments

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

Returned tensor

integer(kind=int32), intent(out), pointer :: data_out(:)

Pointer to tensor data

integer, intent(in), optional :: sizes(1)

Number of entries for each rank

public subroutine torch_tensor_to_array_int32_2d(tensor, data_out, sizes)

Return the array data associated with a Torch tensor of rank 2 and data type int32

Arguments

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

Returned tensor

integer(kind=int32), intent(out), pointer :: data_out(:,:)

Pointer to tensor data

integer, intent(in), optional :: sizes(2)

Number of entries for each rank

public subroutine torch_tensor_to_array_int32_3d(tensor, data_out, sizes)

Return the array data associated with a Torch tensor of rank 3 and data type int32

Arguments

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

Returned tensor

integer(kind=int32), intent(out), pointer :: data_out(:,:,:)

Pointer to tensor data

integer, intent(in), optional :: sizes(3)

Number of entries for each rank

public subroutine torch_tensor_to_array_int32_4d(tensor, data_out, sizes)

Return the array data associated with a Torch tensor of rank 4 and data type int32

Arguments

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

Returned tensor

integer(kind=int32), intent(out), pointer :: data_out(:,:,:,:)

Pointer to tensor data

integer, intent(in), optional :: sizes(4)

Number of entries for each rank

public subroutine torch_tensor_to_array_int32_5d(tensor, data_out, sizes)

Return the array data associated with a Torch tensor of rank 5 and data type int32

Arguments

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

Returned tensor

integer(kind=int32), intent(out), pointer :: data_out(:,:,:,:,:)

Pointer to tensor data

integer, intent(in), optional :: sizes(5)

Number of entries for each rank

public subroutine torch_tensor_to_array_int64_1d(tensor, data_out, sizes)

Return the array data associated with a Torch tensor of rank 1 and data type int64

Arguments

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

Returned tensor

integer(kind=int64), intent(out), pointer :: data_out(:)

Pointer to tensor data

integer, intent(in), optional :: sizes(1)

Number of entries for each rank

public subroutine torch_tensor_to_array_int64_2d(tensor, data_out, sizes)

Return the array data associated with a Torch tensor of rank 2 and data type int64

Arguments

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

Returned tensor

integer(kind=int64), intent(out), pointer :: data_out(:,:)

Pointer to tensor data

integer, intent(in), optional :: sizes(2)

Number of entries for each rank

public subroutine torch_tensor_to_array_int64_3d(tensor, data_out, sizes)

Return the array data associated with a Torch tensor of rank 3 and data type int64

Arguments

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

Returned tensor

integer(kind=int64), intent(out), pointer :: data_out(:,:,:)

Pointer to tensor data

integer, intent(in), optional :: sizes(3)

Number of entries for each rank

public subroutine torch_tensor_to_array_int64_4d(tensor, data_out, sizes)

Return the array data associated with a Torch tensor of rank 4 and data type int64

Arguments

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

Returned tensor

integer(kind=int64), intent(out), pointer :: data_out(:,:,:,:)

Pointer to tensor data

integer, intent(in), optional :: sizes(4)

Number of entries for each rank

public subroutine torch_tensor_to_array_int64_5d(tensor, data_out, sizes)

Return the array data associated with a Torch tensor of rank 5 and data type int64

Arguments

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

Returned tensor

integer(kind=int64), intent(out), pointer :: data_out(:,:,:,:,:)

Pointer to tensor data

integer, intent(in), optional :: sizes(5)

Number of entries for each rank

public subroutine torch_tensor_to_array_int8_1d(tensor, data_out, sizes)

Return the array data associated with a Torch tensor of rank 1 and data type int8

Arguments

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

Returned tensor

integer(kind=int8), intent(out), pointer :: data_out(:)

Pointer to tensor data

integer, intent(in), optional :: sizes(1)

Number of entries for each rank

public subroutine torch_tensor_to_array_int8_2d(tensor, data_out, sizes)

Return the array data associated with a Torch tensor of rank 2 and data type int8

Arguments

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

Returned tensor

integer(kind=int8), intent(out), pointer :: data_out(:,:)

Pointer to tensor data

integer, intent(in), optional :: sizes(2)

Number of entries for each rank

public subroutine torch_tensor_to_array_int8_3d(tensor, data_out, sizes)

Return the array data associated with a Torch tensor of rank 3 and data type int8

Arguments

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

Returned tensor

integer(kind=int8), intent(out), pointer :: data_out(:,:,:)

Pointer to tensor data

integer, intent(in), optional :: sizes(3)

Number of entries for each rank

public subroutine torch_tensor_to_array_int8_4d(tensor, data_out, sizes)

Return the array data associated with a Torch tensor of rank 4 and data type int8

Arguments

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

Returned tensor

integer(kind=int8), intent(out), pointer :: data_out(:,:,:,:)

Pointer to tensor data

integer, intent(in), optional :: sizes(4)

Number of entries for each rank

public subroutine torch_tensor_to_array_int8_5d(tensor, data_out, sizes)

Return the array data associated with a Torch tensor of rank 5 and data type int8

Arguments

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

Returned tensor

integer(kind=int8), intent(out), pointer :: data_out(:,:,:,:,:)

Pointer to tensor data

integer, intent(in), optional :: sizes(5)

Number of entries for each rank

public subroutine torch_tensor_to_array_real32_1d(tensor, data_out, sizes)

Return the array data associated with a Torch tensor of rank 1 and data type real32

Arguments

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

Returned tensor

real(kind=real32), intent(out), pointer :: data_out(:)

Pointer to tensor data

integer, intent(in), optional :: sizes(1)

Number of entries for each rank

public subroutine torch_tensor_to_array_real32_2d(tensor, data_out, sizes)

Return the array data associated with a Torch tensor of rank 2 and data type real32

Arguments

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

Returned tensor

real(kind=real32), intent(out), pointer :: data_out(:,:)

Pointer to tensor data

integer, intent(in), optional :: sizes(2)

Number of entries for each rank

public subroutine torch_tensor_to_array_real32_3d(tensor, data_out, sizes)

Return the array data associated with a Torch tensor of rank 3 and data type real32

Arguments

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

Returned tensor

real(kind=real32), intent(out), pointer :: data_out(:,:,:)

Pointer to tensor data

integer, intent(in), optional :: sizes(3)

Number of entries for each rank

public subroutine torch_tensor_to_array_real32_4d(tensor, data_out, sizes)

Return the array data associated with a Torch tensor of rank 4 and data type real32

Arguments

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

Returned tensor

real(kind=real32), intent(out), pointer :: data_out(:,:,:,:)

Pointer to tensor data

integer, intent(in), optional :: sizes(4)

Number of entries for each rank

public subroutine torch_tensor_to_array_real32_5d(tensor, data_out, sizes)

Return the array data associated with a Torch tensor of rank 5 and data type real32

Arguments

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

Returned tensor

real(kind=real32), intent(out), pointer :: data_out(:,:,:,:,:)

Pointer to tensor data

integer, intent(in), optional :: sizes(5)

Number of entries for each rank

public subroutine torch_tensor_to_array_real64_1d(tensor, data_out, sizes)

Return the array data associated with a Torch tensor of rank 1 and data type real64

Arguments

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

Returned tensor

real(kind=real64), intent(out), pointer :: data_out(:)

Pointer to tensor data

integer, intent(in), optional :: sizes(1)

Number of entries for each rank

public subroutine torch_tensor_to_array_real64_2d(tensor, data_out, sizes)

Return the array data associated with a Torch tensor of rank 2 and data type real64

Arguments

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

Returned tensor

real(kind=real64), intent(out), pointer :: data_out(:,:)

Pointer to tensor data

integer, intent(in), optional :: sizes(2)

Number of entries for each rank

public subroutine torch_tensor_to_array_real64_3d(tensor, data_out, sizes)

Return the array data associated with a Torch tensor of rank 3 and data type real64

Arguments

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

Returned tensor

real(kind=real64), intent(out), pointer :: data_out(:,:,:)

Pointer to tensor data

integer, intent(in), optional :: sizes(3)

Number of entries for each rank

public subroutine torch_tensor_to_array_real64_4d(tensor, data_out, sizes)

Return the array data associated with a Torch tensor of rank 4 and data type real64

Arguments

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

Returned tensor

real(kind=real64), intent(out), pointer :: data_out(:,:,:,:)

Pointer to tensor data

integer, intent(in), optional :: sizes(4)

Number of entries for each rank

public subroutine torch_tensor_to_array_real64_5d(tensor, data_out, sizes)

Return the array data associated with a Torch tensor of rank 5 and data type real64

Arguments

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

Returned tensor

real(kind=real64), intent(out), pointer :: data_out(:,:,:,:,:)

Pointer to tensor data

integer, intent(in), optional :: sizes(5)

Number of entries for each rank

public subroutine torch_tensor_zeros(tensor, ndims, tensor_shape, dtype, device_type, device_index, requires_grad)

Returns a tensor filled with the scalar value 0.

Arguments

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

Returned tensor

integer(kind=c_int), intent(in) :: ndims

Number of dimensions of the tensor

integer(kind=c_int64_t), intent(in) :: tensor_shape(*)

Shape of the tensor

integer(kind=c_int), intent(in) :: dtype

Data type of the tensor

integer(kind=c_int), intent(in) :: device_type

Device type the tensor will live on (torch_kCPU or torch_kCUDA)

integer(kind=c_int), intent(in), optional :: device_index

device index to use for torch_kCUDA case

logical(kind=c_bool), intent(in), optional :: requires_grad

Whether gradients need to be computed for the created tensor