col_to_row_major_2d Subroutine

public subroutine col_to_row_major_2d(data_in, data_out, m, n)

Convert flat column-major [m,n] to flat row-major [m,n] Fortran stores arrays column-major; ONNX rawData expects row-major.

Arguments

Type IntentOptional Attributes Name
real(kind=real32), intent(in) :: data_in(m*n)
real(kind=real32), intent(out) :: data_out(m*n)
integer, intent(in) :: m
integer, intent(in) :: n

Source Code

  subroutine col_to_row_major_2d(data_in, data_out, m, n)
    !! Convert flat column-major [m,n] to flat row-major [m,n]
    !! Fortran stores arrays column-major; ONNX rawData expects row-major.
    implicit none
    integer, intent(in) :: m, n
    real(real32), intent(in) :: data_in(m * n)
    real(real32), intent(out) :: data_out(m * n)
    integer :: i, j
    do i = 1, m
       do j = 1, n
          data_out((i-1)*n + j) = data_in((j-1)*m + i)
       end do
    end do
  end subroutine col_to_row_major_2d