nn_reshape_output_shape: Resolve a reshape layer's target shape against its input

View source: R/nn_layers.R

nn_reshape_output_shapeR Documentation

Resolve a reshape layer's target shape against its input

Description

Fills in a '-1' axis and checks that the element count is preserved. Shared by the sequential and functional shape passes so the two cannot disagree.

Usage

nn_reshape_output_shape(shape, input_shape)

Arguments

shape

Target per-sample shape, possibly containing one '-1'.

input_shape

Per-sample input shape.

Details

This check is not cosmetic: 'ggml_reshape_*()' enforces the element count with a 'GGML_ASSERT', which aborts the process rather than raising an R error, so a bad shape would take the whole session down.

Value

The resolved per-sample shape, with no '-1' left.


ggmlR documentation built on Oct. 23, 2026, 1:07 a.m.