Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Copy constructor gets expression's chunk_shape if it is chunked #2092

Merged
merged 7 commits into from Jul 16, 2020

Conversation

davidbrochart
Copy link
Member

Checklist

  • The title and commit message(s) are descriptive.
  • Small commits made to fix your PR have been squashed to avoid history pollution.
  • Tests have been added for new features or bug fixes.
  • API of new functions and classes are documented.

Description

If an expression is assigned to a chunked array without specifying a chunk shape, the chunk shape is taken from the expression if the expression is chunked, otherwise the chunk shape is the expression's shape, which basically means no chunk (or one chunk).
TODO: propagate chunk shape in expressions.

@davidbrochart
Copy link
Member Author

It seems to work fine with gcc but not with clang.

@JohanMabille
Copy link
Member

JohanMabille commented Jul 15, 2020

Maybe you can rely on void_t to detect expressions that provide the chunk_shape method? Something like:

template <class E, class = void>
struct get_chunk_shape
{
    static const auto& run(const xexpression<E>& e)
    {
        return e.derived_cast().shape();
    }
};

template <class E>
struct get_chunk_shape<E, void_t<decltype(std::declval<E>().chunk_shape())>>
{
    static const auto& run(const xexpression<E>& e)
    {
        return e.derived_cast().chunk_shape();
    }
};

And then

        template <class E>
        xchunked_array(const xexpression<E>& e)
        {
            xchunked_array<chunk_type> arr(e, get_chunk_shape<E>::run(e));
            *this = arr;
        }

@JohanMabille JohanMabille force-pushed the xchunked_array branch 2 times, most recently from ba4bf07 to e12149e Compare July 16, 2020 14:33
@JohanMabille JohanMabille merged commit ef8ff77 into xtensor-stack:master Jul 16, 2020
@davidbrochart davidbrochart deleted the xchunked_array branch July 16, 2020 14:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants