Skip to content

vstack with fixed shapes doesn't compile #2372

Closed

Description

@tailsu

The following code:

#include "xtensor/xfixed.hpp"

template <std::size_t Dim>
using PointList = xt::xtensor_fixed<float, xt::xshape<Dim, 2>>;

int main() {

  PointList<1> a;
  PointList<2> b;

  PointList<3> c = xt::vstack(xt::xtuple(a, b));
}

fails to compile on clang 12 with the following error:

xtensor/include/xtensor/xbuilder.hpp:850:17: error: no matching constructor for initialization of 'xt::fixed_shape<2, 2>'
                S({sizeof...(CT), shape[0]}) :
                ^ ~~~~~~~~~~~~~~~~~~~~~~~~~
xtensor/include/xtensor/xbuilder.hpp:876:34: note: in instantiation of function template specialization 'xt::detail::vstack_shape<xt::fixed_shape<2, 2>, const xt::xfixed_container<float, xt::fixed_shape<1, 2>, xt::layout_type::row_major, true, xt::xtensor_expression_tag> &, const xt::xfixed_container<float, xt::fixed_shape<2, 2>, xt::layout_type::row_major, true, xt::xtensor_expression_tag> &>' requested here
        auto new_shape = detail::vstack_shape(t, xtl::forward_sequence<shape_type, source_shape_type>(std::get<0>(t).shape()));
                                 ^
main.cpp:12:24: note: in instantiation of function template specialization 'xt::vstack<const xt::xfixed_container<float, xt::fixed_shape<1, 2>, xt::layout_type::row_major, true, xt::xtensor_expression_tag> &, const xt::xfixed_container<float, xt::fixed_shape<2, 2>, xt::layout_type::row_major, true, xt::xtensor_expression_tag> &>' requested here
  PointList<3> c = xt::vstack(xt::xtuple(a, b));

vstack is supposed to support fixed tensors as well, right?

Tested on today's master.

Activity

  1. tailsu commented on May 7, 2021

    @tailsu
    Author

    xt::hstack works correctly in the same scenario

  2. linked a pull request that will close this issueFix vstack for mixed fixed-shape inputs #2897on May 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions