Skip to content

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

@pauljurczak

Description

@pauljurczak

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions