torch_tensor_from_array_int16_2d_legacy Subroutine Deprecated

public subroutine torch_tensor_from_array_int16_2d_legacy(tensor, data_in, layout, device_type, device_index, requires_grad) Deprecated

Uses

  • proc~~torch_tensor_from_array_int16_2d_legacy~~UsesGraph proc~torch_tensor_from_array_int16_2d_legacy torch_tensor_from_array_int16_2d_legacy iso_c_binding iso_c_binding proc~torch_tensor_from_array_int16_2d_legacy->iso_c_binding iso_fortran_env iso_fortran_env proc~torch_tensor_from_array_int16_2d_legacy->iso_fortran_env

This is the old layout-required signature for torch_tensor_from_array. Use torch_tensor_from_array instead. This will be removed in a future release.

Arguments

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

Returned tensor

integer(kind=int16), intent(in), pointer, contiguous :: data_in(:,:)

Input data that tensor will point at

integer(kind=int32), 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 a GPU device type)

integer, intent(in), optional :: device_index

Device index for GPU devices

logical, intent(in), optional :: requires_grad

Whether gradients need to be computed for the created tensor


Calls

proc~~torch_tensor_from_array_int16_2d_legacy~~CallsGraph proc~torch_tensor_from_array_int16_2d_legacy torch_tensor_from_array_int16_2d_legacy proc~torch_tensor_from_blob torch_tensor_from_blob proc~torch_tensor_from_array_int16_2d_legacy->proc~torch_tensor_from_blob interface~torch_from_blob_c torch_from_blob_c proc~torch_tensor_from_blob->interface~torch_from_blob_c

Called by

proc~~torch_tensor_from_array_int16_2d_legacy~~CalledByGraph proc~torch_tensor_from_array_int16_2d_legacy torch_tensor_from_array_int16_2d_legacy interface~torch_tensor_from_array_legacy torch_tensor_from_array_legacy interface~torch_tensor_from_array_legacy->proc~torch_tensor_from_array_int16_2d_legacy

Source Code

  subroutine torch_tensor_from_array_int16_2d_legacy(tensor, data_in, layout, &
                                                    device_type, device_index, requires_grad)
    use, intrinsic :: iso_c_binding, only : c_int, c_loc
    use, intrinsic :: iso_fortran_env, only : int16

    ! output tensor
    type(torch_tensor), intent(out) :: tensor  !! Returned tensor

    ! inputs
    integer(kind=int16), intent(in), pointer, contiguous :: data_in(:,:)
        !! Input data that tensor will point at
    integer(c_int), intent(in)    :: device_type
        !! Device type the tensor will live on (`torch_kCPU` or a GPU device type)
    integer(int32), intent(in) :: layout(2)  !! Control order of indices
    integer, optional, intent(in) :: device_index   !! Device index for GPU devices
    logical, optional, intent(in) :: requires_grad
        !! Whether gradients need to be computed for the created tensor

    ! local data
    integer(int32), parameter     :: ndims = 2
        !! Number of dimension of input data
    integer(c_int), parameter     :: dtype = torch_kInt16
        !! Data type
    integer(int64)                :: tensor_shape(2)
        !! Shape of the input tensor
    integer(int64)                :: tensor_strides(2)
        !! Strides for accessing data appropriately
    integer :: i

    write(*,*) "Warning: torch_tensor_from_array_legacy is deprecated and will be "
    write(*,*) "removed in a future version of FTorch. Please use torch_tensor_from_array, "
    write(*,*) "passing permute_dims as an optional argument after device_type, where possible."

    tensor_shape = shape(data_in)

    tensor_strides(:) = 0
    do i = 1, ndims
      if (i == 1) then
        tensor_strides(layout(i)) = 1_int64
      else
        tensor_strides(layout(i)) = tensor_strides(layout(i - 1)) * tensor_shape(layout(i - 1))
      end if
    end do

    call torch_tensor_from_blob(tensor, c_loc(data_in), ndims, tensor_shape, &
                                tensor_strides, dtype, device_type, device_index, &
                                requires_grad)

  end subroutine torch_tensor_from_array_int16_2d_legacy