Skip to content
fn

reduce_output_shape

→Shape
int reduce_output_shape(const int & input_shape, const int & axes, bool keepdims)

Compute the output shape of a reduction over selected axes.

Reduced dimensions are removed by default; passing keepdims=true leaves them in place as size-1 axes (matching reference-framework semantics) so the result broadcasts cleanly against the input.

Parameters

input_shapeconst Shape&
Shape of the tensor being reduced.
axesconst std::vector<int>&
Pre-normalised axis list (see normalize_axes).
keepdimsbool
Whether to retain reduced axes as size 1.

Returns

Shape

Resulting shape after the reduction.