xtensor-blas
xtensor-blas copied to clipboard
non-contiguous array
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
**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))));