Closed iamthebot closed 6 years ago
Confirmed that this started breaking in 0.16.0 w/ the corresponding xtensor-python release.
Any chance you could post what the slices are in the view? Will investigate today
I tried to replicate with this code (using xarray) but didn't manage to produce a segfault.
xt::xarray<float> x3 = xt::arange(0, 100);
x3.reshape({5, 5, 4});
xarray<unsigned char> x4 = x3;
xt::view(x3, 0) = xt::view(x4, 1);
xt::view(x3, 1) = xt::view(x4, 0);
xt::view(x3, 2) = xt::view(x4, 2);
xt::view(x3, 3) = xt::view(x4, 4);
auto v = xt::view(x4, 3);
xt::view(x3, 4, 0) = xt::view(v, 2);
std::cout << x3 << std::endl;
(using 0.16.0 and master)
This was my attempt to recreate in python but I still don't get a segfault (feeded it from python with arr = np.arange(3 * 10 * 10, dtype=np.int32).reshape(3, 10, 10); print(tz.vass(arr))
.
xt::pyarray<float>
test_view_assign(xt::pyarray<int>& arr)
{
xt::pyarray<float> res = xt::zeros<int>({3, 10, 10});
for (int i = 0; i < arr.shape()[0]; ++i)
{
std::cout << "I == " << i % 3 << std::endl;
auto v1 = xt::view(res, i % 3);
auto v2 = xt::view(arr, i);
v1 = v2;
}
return res;
}
PYBIND11_PLUGIN(tzwo)
{
xt::import_numpy();
py::module m("tzwo", "Test module for xtensor python bindings");
m.def("view_ass", test_view_assign);
return m.ptr();
}
@iamthebot do you still see this issue with the latest releases?
@wolfv yeah this is still broken in 0.16.2. Here is a minimal example:
xt::xarray<std::uint8_t> images;
xt::xarray<float> output;
images.resize({{100,512,512,3}});
output.resize({{100,512,512,3}});
for(int i=0; i<100; ++i)
{
auto img_view = xt::view(images, i);
//copy input to output as floats
auto out_view = xt::view(output, i);
std::printf("created views\n");
out_view = img_view; //this causes a segfault
std::printf("copied input to output\n");
}
edited to simplify failing example
Also, changing output
to be an xt::xtensor<float, 4>
prevents the segfault for some reason.
This is the result of attaching an
xt::view
from a pyarray to another view on anxt::pyarray
. This was working fine in previous releases but no longer working when I upgraded xtensor-python and xtensor.