xtl icon indicating copy to clipboard operation
xtl copied to clipboard

How to get integral value from xt::sum()?

Open pauljurczak opened this issue 1 year ago • 0 comments

How do I get integral value (int or unsigned int) from xt::sum() to return from function f2()?

I tried:

int f2(const xt::xtensor_fixed<uint8_t, xt::xshape<H, W>> &img) {
  return xt::sum(xt::argmax(img, 1))();
}

which causes Segmentation fault (core dumped).

This version doesn't compile no viable conversion from returned value of type 'reducer_type':

int f2(const xt::xtensor_fixed<uint8_t, xt::xshape<H, W>> &img) {
  return xt::sum<int>(xt::argmax(img, 1));
}

How to convert reducer_type to int?

pauljurczak avatar Dec 21 '23 08:12 pauljurczak