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

xt::adapt of shape of xt::view bugs #2805

Open
eugene-sanscartier opened this issue Sep 25, 2024 · 2 comments
Open

xt::adapt of shape of xt::view bugs #2805

eugene-sanscartier opened this issue Sep 25, 2024 · 2 comments

Comments

@eugene-sanscartier
Copy link

With this code:

    xt::xarray<double> A = xt::ones<double>({ 6, 4, 6, 8 });

    auto aa = xt::view(A, 0, xt::all());
    xt::adapt(aa.shape());

    auto bb = xt::view(A, 0, xt::all(), xt::all(), xt::all());
    xt::adapt(bb.shape());

    auto cc = xt::view(A, 0, xt::all(), xt::all(), 0);
    xt::adapt(cc.shape());

    return 0;

xt::adapt(aa.shape()) and xt::adapt(bb.shape()) gives errors at compilation.

xt::adapt(aa.shape()):

[build] In file included from /home/eugene/Master/software/partn_c++/build/_deps/xtensor-src/include/xtensor/xarray.hpp:20,
[build]                  from /home/eugene/Master/software/partn_c++/build/_deps/xtensor-src/include/xtensor/xadapt.hpp:20,
[build]                  from /home/eugene/Master/software/partn_c++/src/test_main.cpp:2:
[build] /home/eugene/Master/software/partn_c++/build/_deps/xtensor-src/include/xtensor/xcontainer.hpp: In instantiation of ‘struct xt::detail::allocator_type_impl<xt::sequence_view<xt::svector<long unsigned int, 4, std::allocator<long unsigned int>, true>, 1, -1> >’:
[build] /home/eugene/Master/software/partn_c++/build/_deps/xtensor-src/include/xtensor/xcontainer.hpp:57:11:   required by substitution of ‘template<class T> using xt::allocator_type_t = typename xt::detail::allocator_type_impl::type [with T = xt::sequence_view<xt::svector<long unsigned int, 4, std::allocator<long unsigned int>, true>, 1, -1>]’
[build]    57 |     using allocator_type_t = typename detail::allocator_type_impl<T>::type;
[build]       |           ^~~~~~~~~~~~~~~~
[build] /home/eugene/Master/software/partn_c++/build/_deps/xtensor-src/include/xtensor/xcontainer.hpp:80:15:   required from ‘class xt::xcontainer<xt::xtensor_adaptor<const xt::sequence_view<xt::svector<long unsigned int, 4, std::allocator<long unsigned int>, true>, 1, -1>&, 1, xt::layout_type::row_major, xt::xtensor_expression_tag> >’
[build]    80 |         using allocator_type = allocator_type_t<std::decay_t<storage_type>>;
[build]       |               ^~~~~~~~~~~~~~
[build] /home/eugene/Master/software/partn_c++/build/_deps/xtensor-src/include/xtensor/xcontainer.hpp:260:11:   required from ‘class xt::xstrided_container<xt::xtensor_adaptor<const xt::sequence_view<xt::svector<long unsigned int, 4, std::allocator<long unsigned int>, true>, 1, -1>&, 1, xt::layout_type::row_major, xt::xtensor_expression_tag> >’
[build]   260 |     class xstrided_container : public xcontainer<D>
[build]       |           ^~~~~~~~~~~~~~~~~~
[build] /home/eugene/Master/software/partn_c++/build/_deps/xtensor-src/include/xtensor/xtensor.hpp:209:11:   required from ‘class xt::xtensor_adaptor<const xt::sequence_view<xt::svector<long unsigned int, 4, std::allocator<long unsigned int>, true>, 1, -1>&, 1, xt::layout_type::row_major, xt::xtensor_expression_tag>’
[build]   209 |     class xtensor_adaptor : public xstrided_container<xtensor_adaptor<EC, N, L, Tag>>,
[build]       |           ^~~~~~~~~~~~~~~
[build] /home/eugene/Master/software/partn_c++/src/test_main.cpp:20:14:   required from here
[build]    20 |     xt::adapt(aa.shape());
[build]       |     ~~~~~~~~~^~~~~~~~~~~~
[build] /home/eugene/Master/software/partn_c++/build/_deps/xtensor-src/include/xtensor/xcontainer.hpp:46:19: error: no type named ‘allocator_type’ in ‘class xt::sequence_view<xt::svector<long unsigned int, 4, std::allocator<long unsigned int>, true>, 1, -1>’
[build]    46 |             using type = typename T::allocator_type;
[build]       |                   ^~~~
[build] ninja: build stopped: subcommand failed.

Both gives similar errors.
I tried other method of aa and bb and also get compilation errors. I believe it is a bug or inconsistencies since xt::adapt(cc.shape()) doesn't yield to compilation errors.

Thanks,

@eugene-sanscartier
Copy link
Author

Also, if it is not a bug, could I ask why it is so?

@zhaojie317
Copy link

Perhaps you can resolve the error by adding the line using allocator_type = typename E::allocator_type; to xstorage.hpp.

image

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

No branches or pull requests

2 participants