class
SushiAI::NN::LayerStack
Holds a runtime sequential list of polymorphic layers.
- Declared in
include/SushiAI/nn/layer_stack.hpp
Public member functions
LayerStack()=defaultLayerStack(LayerStack &&) noexcept=defaultLayerStack & operator=(LayerStack &&) noexcept=defaultLayerStack(const LayerStack &)=deleteLayerStack & operator=(const LayerStack &)=deletevoid push(std::unique_ptr< ILayer > layer)Appends layer to the end of the stack.
Parameters
layerThe layer; ownership is taken.
Exceptions
ErrorIf
layeris null - a null entry would trace as a silent identity rather than failing.
Graph::ValueId forward(const Graph::GraphBuilder &builder, Graph::ValueId x)Traces every layer in order.
Parameters
builderWhere the nodes go.
xThe input value.
Returns
The last layer's result.
Exceptions
ErrorIf the stack is empty, which would otherwise make the model the identity function.
void walk_parameters(std::string_view prefix, const ParameterVisitor &visitor)Applies visitor to every declared parameter with index prefix.
Parameters
prefixParameter name prefix for hierarchy traversal.
visitorCallback invoked once per declared parameter.
std::size_t size() const noexceptHow many layers the stack holds.
bool empty() const noexceptWhether the stack holds no layers at all.
int64_t output_features() constHow many features a sample carries after the last layer.
Returns
The last layer's output width.
Exceptions
ErrorIf the stack is empty.
Shape output_shape() constReturns the last layer's per-sample output shape, batch axis excluded.
Precondition
The stack holds at least one layer.
ILayer & layer(std::size_t index) constThe layer at index, for a test that wants to inspect it.
Parameters
indexWhich layer, in [0, size()).
Returns
The layer; owned by the stack.
Exceptions
ErrorIf
indexis out of range.
Static public member functions
static constexpr auto fields()No parameters of its own; the layers own them all.

