Skip to content

Commit

Permalink
feat: set integer size for FTorch FT_INT
Browse files Browse the repository at this point in the history
Integer size for FTorch can now be controlled using parameter `FT_INT`.

Currently, the default is set to `int32` but this could be changed if
required.

This fixes an issue on windows with the latest version of ifx/ifort
which builds with a different integer type leading to the following
error:

```
error #6284: There is no matching specific function for this generic function reference.   [TORCH_TENSOR_FROM_ARRAY]
   in_tensors(1) = torch_tensor_from_array(in_data, tensor_layout, torch_kCPU)
-------------------^
```
  • Loading branch information
TomMelt committed Nov 16, 2024
1 parent 516ea00 commit 476d626
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 58 deletions.
2 changes: 1 addition & 1 deletion examples/1_SimpleNet/simplenet_infer_fortran.f90
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ program inference
real(wp), dimension(5), target :: in_data
real(wp), dimension(5), target :: out_data
real(wp), dimension(5), target :: expected
integer :: tensor_layout(1) = [1]
integer(FT_INT) :: tensor_layout(1) = [1]

! Set up Torch data structures
! The net, a vector of input tensors (in this case we only have one), and the output tensor
Expand Down
4 changes: 2 additions & 2 deletions examples/2_ResNet18/resnet_infer_fortran.f90
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ subroutine main()

integer, parameter :: in_dims = 4
integer :: in_shape(in_dims) = [1, 3, 224, 224]
integer :: in_layout(in_dims) = [1, 2, 3, 4]
integer(FT_INT) :: in_layout(in_dims) = [1, 2, 3, 4]
integer, parameter :: out_dims = 2
integer :: out_shape(out_dims) = [1, 1000]
integer :: out_layout(out_dims) = [1, 2]
integer(FT_INT) :: out_layout(out_dims) = [1, 2]

! Path to input data
character(len=100) :: data_dir
Expand Down
2 changes: 1 addition & 1 deletion examples/4_MultiIO/multiionet_infer_fortran.f90
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ program inference
real(wp), dimension(4), target :: out_data1
real(wp), dimension(4), target :: out_data2
real(wp), dimension(4) :: expected
integer :: tensor_layout(1) = [1]
integer(FT_INT) :: tensor_layout(1) = [1]

! Set up Torch data structures
! The net, a vector of input tensors (in this case we only have one), and the output tensor
Expand Down
Loading

0 comments on commit 476d626

Please sign in to comment.