xtensor-stack / xtensor

C++ tensors with broadcasting and lazy computing
BSD 3-Clause "New" or "Revised" License
3.36k stars 398 forks source link

xt::tile An uncaught exception occurred: std::bad_alloc #2690

Open marktohark opened 1 year ago

marktohark commented 1 year ago

version is 0.24.6

xt::xarray<int> t{{1, 2}, {3, 4}};
std::vector<int> rep = {2, 3};
auto tb = xt::tile(t, rep);
for(auto b : tb.shape())
    std::cout << b << " ";
std::cout << std::endl;

it will get an error "An uncaught exception occurred: std::bad_alloc"

tdegeus commented 1 year ago

Thanks for reporting. Just to make sure, tb.shape(0) and tb.shape(1) give what?

marktohark commented 1 year ago

exception is happend in xt::tile. so cannot get tb.shape

i use debug tool to trace, there is some clue. when t.dim >= 4, xt::tile is work well. i remember that "compute_size" get alloc size wrong. dim is 2, but compute_size will get 4.