xtensor-blas icon indicating copy to clipboard operation
xtensor-blas copied to clipboard

non-contiguous array

Open yashaach opened this issue 5 years ago • 0 comments

This is the simplest example that I can construct that still produce this error.

xt::pytensor<double, 2> dot_test(xt::pytensor<double, 3> & ar0,
                                 xt::pytensor<double, 2> & ar1,
                                 xt::pytensor<long, 1> & idx) {
  auto shape0 = ar0.shape();
  auto shape1 = ar1.shape();
  xt::pytensor<double, 2> out({shape0[0], shape0[1]});
  out.fill(NAN);
  for (unsigned j=0; j<len(idx); ++j)
    xt::view(out, j) =
      xt::linalg::dot(xt::view(ar0, j),
                      xt::view(ar1, idx(j)));
  return out;
}

If we give a non-contiguous numpy array as the first argument, it fails.

m1 = np.random.randn(30).reshape(2,3,5) m2 = np.random.randn(4).reshape(2,2) xt_tools.dot_test(m1[:,:,2:4], m2, np.arange(2))

Traceback (most recent call last): File "", line 1, in RuntimeError: No valid layout chosen.

**As the issue I raised a year ago, replacing the dot product line with the following somehow solves the problem. But this is probably not a good permanent fix. xt::linalg::dot(xt::eval(xt::view(ar0, j)), xt::eval(xt::view(ar1, idx(j))));

yashaach avatar Mar 01 '19 19:03 yashaach