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.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(torch_tensor), | intent(out) | :: | tensor |
Returned tensor |
||
| real(kind=real64), | intent(in), | pointer, contiguous | :: | data_in(:,:,:,:) |
Input data that tensor will point at |
|
| integer(kind=int32), | intent(in) | :: | layout(4) |
Control order of indices |
||
| integer(kind=c_int), | intent(in) | :: | device_type |
Device type the tensor will live on ( |
||
| 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 |
subroutine torch_tensor_from_array_real64_4d_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 : real64 ! output tensor type(torch_tensor), intent(out) :: tensor !! Returned tensor ! inputs real(kind=real64), 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(4) !! 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 = 4 !! Number of dimension of input data integer(c_int), parameter :: dtype = torch_kFloat64 !! Data type integer(int64) :: tensor_shape(4) !! Shape of the input tensor integer(int64) :: tensor_strides(4) !! 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_real64_4d_legacy