Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error converting array slice to matrix view in Fortran layout #41

Open
jasonkaye opened this issue Mar 6, 2023 · 0 comments
Open

Error converting array slice to matrix view in Fortran layout #41

jasonkaye opened this issue Mar 6, 2023 · 0 comments
Labels
bug Something isn't working

Comments

@jasonkaye
Copy link
Collaborator

I often want to take a matrix view of an array A, reshaped to rank 2, for example to contract over one of the indices of A with another matrix using a BLAS gemm. Furthermore, sometimes I want to do this with a slice of the array A, taking care so that reshaping is only done in contiguous memory. I am getting an error when I try to do this with Fortran layout arrays. Here is a minimal working example:

#include "nda/nda.hpp"
using namespace nda;

int main() {

  int m = 3;
  int n = 3;
  int p = 3;

  // This code compiles
  auto a = nda::array<double,3>(m,n,p);
  auto a_reshaped = nda::reshaped_view(a(range(2),range(n),range(p)), std::array<int, 2>({2*n,p}));
  auto a_matrix = matrix_const_view<double>(a_reshaped);

  // This code does not compile
  auto af = nda::array<double,3,F_layout>(m,n,p);
  auto af_reshaped = nda::reshaped_view(a(range(m),range(n),range(2)), std::array<int, 2>({m,n*2}));
  auto af_matrix = matrix_const_view<double,F_layout>(a_reshaped);

}

Note that the code compiles when I use C layout, but not when I use Fortran layout. The error is triggered at the matrix_const_view step, not at the reshaped_view step.

I am using the DEV_CUDA_LINALG branch of nda, hash #189c585fc78651859db279e98df53b1e4ee11a04, on a Linux machine.

@jasonkaye jasonkaye added the bug Something isn't working label Mar 6, 2023
@jasonkaye jasonkaye changed the title Error converting array slice to matrix view Error converting array slice to matrix view in Fortran layout Mar 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant