Contents

class

SushiAI::NN::LayerAdapter

template <typename L>

Adapts a compile-time Module to the runtime ILayer interface.

Declared in
include/SushiAI/nn/ilayer.hpp
Inherits
SushiAI::NN::ILayer

Template parameters

L

Wrapped layer type satisfying the Module contract.

Public member functions

LayerAdapter(L layer, Shape output_shape)

Wraps a module instance with the per-sample shape it produces.

Parameters

output_shape

Must equal what layer traces, batch axis excluded.

LayerAdapter(L layer, int64_t output_features)

Wraps a module instance that produces a rank-1 feature vector.

Parameters

output_features

Must be positive; the shape becomes [output_features].

virtual Graph::ValueId forward(const Graph::GraphBuilder &builder, Graph::ValueId x) override

Traces the layer, declaring its parameters on first call.

Parameters

builder

Where the nodes go.

x

The input value.

Returns

The result's id.

virtual void walk_parameters(std::string_view prefix, const ParameterVisitor &visitor) override

Applies visitor to every declared parameter this layer owns.

Parameters

prefix

The name prefix this layer's parameters hang under.

visitor

Called once per declared parameter.

virtual Shape output_shape() const noexcept override

Returns the per-sample shape after this layer, batch axis excluded.

L & layer() noexcept

The wrapped layer, for a test that wants to inspect it.

const L & layer() const noexcept

The wrapped layer, read-only.