Skip to content

xreducer is not sharable despite being an xsharable_expression #2916

@EALePain

Description

@EALePain

xreducer is an xsharable_expression, but attempting to call xt::make_xshared results in a compiler error because xreducer does not have the full interface expected by xshared_expression.
A simple example:

#include <xtensor/containers/xtensor.hpp>
#include <xtensor/generators/xrandom.hpp>

int main()
{
    size_t n = 1000;
    size_t m = 9;
    size_t o = 12;

    xt::xtensor<double, 3> tensor = xt::random::rand({n, m, o}, -20., 20.);

    auto result = xt::make_xshared(xt::sum(tensor, {2}));
}

On Compiler Explorer: https://godbolt.org/z/xbn19Poes

Whether you argue you should or shouldn't share a reducer, the end result in my opinion should not be for it to fail during instantiation of xshared_expression<xreducer<...>>. Reducer should either be stripped of its xsharable_expression-ness, the xshared_expression should include requires statements that disable unavailable methods, or xreducer should have its interface updated to include those currently non-extant methods.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions