Skip to content

Fix vstack for mixed fixed-shape inputs#2897

Open
Alex-PLACET wants to merge 8 commits into
xtensor-stack:masterfrom
Alex-PLACET:add-vstack-functionality-for-fixed-shape-tensors-in-xbuilder
Open

Fix vstack for mixed fixed-shape inputs#2897
Alex-PLACET wants to merge 8 commits into
xtensor-stack:masterfrom
Alex-PLACET:add-vstack-functionality-for-fixed-shape-tensors-in-xbuilder

Conversation

@Alex-PLACET
Copy link
Copy Markdown
Contributor

@Alex-PLACET Alex-PLACET commented Apr 28, 2026

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

Fix xt::vstack so it works with xtensor_fixed inputs when stacking a mix of 1-D and 2-D fixed-shape expressions.

Before this change, vstack could try to build a runtime shape for fixed-shape inputs, which fails for cases like stacking xshape<1, 2> with xshape<2, 2>. The fixed-shape path now computes the stacked result shape at compile time instead.

@Alex-PLACET
Copy link
Copy Markdown
Contributor Author

Addressing #2372

@Alex-PLACET Alex-PLACET marked this pull request as ready for review April 28, 2026 14:51
@Alex-PLACET Alex-PLACET linked an issue May 5, 2026 that may be closed by this pull request
Comment thread include/xtensor/generators/xbuilder.hpp Outdated
template <class... CT>
using vstack_fixed_shape_t = concat_fixed_shape_t<
0,
typename vstack_fixed_shape<typename std::decay_t<CT>::shape_type>::type...>;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not following the standard naming pattern, where usually xxx_t = typename xxx::type. Renaming vstack_fixed_shape into vstack_fixed_shape_impl, and having something like:

template <class... CT>
struct vstack_fixed_shape
{
     using type = concat_fixed_shape_t<0, typename vstack_fixed_shape_impl<typename std::decay_t<CT>::shape_type>::type...>;
};

template <class... CT>
using vstack_fixed_shape_t = typename vstack_fixed_shape_t<CT...>::type

would be more consistent with the standard

@Alex-PLACET Alex-PLACET force-pushed the add-vstack-functionality-for-fixed-shape-tensors-in-xbuilder branch from 8f697f2 to 9dba62e Compare May 12, 2026 09:41
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.

vstack with fixed shapes doesn't compile

2 participants