oa::Module

oa::Module — base class for all neural network modules.

Public Types

Public Methods

oa::Vector<ModuleBuffer *> oa::Module::allBufferPtrs(bool inPersistentOnly = false)
oa::Vector<NamedParameter> oa::Module::allNamedParameterPtrs()
oa::Vector<Parameter *> oa::Module::allParameterPtrs()
oa::Vector<Parameter> oa::Module::allParameters()
const oa::Vector<ModuleBuffer> & oa::Module::buffers()
oa::Vector<ModuleBuffer> & oa::Module::buffers()
const oa::Vector<NamedChild> & oa::Module::children()
oa::Vector<NamedChild> & oa::Module::children()
void oa::Module::eval()
Matrix oa::Module::forward(const Matrix & inInput)
oa::Device oa::Module::getDevice()
const oa::String & oa::Module::getName()
oa::Bool oa::Module::isTraining()
oa::Status oa::Module::load(Engine & inEngine, const oa::String & inPath)
oa::Status oa::Module::load(Engine & inEngine, const oa::String & inPath, Optimizer & inOptimizer)
oa::Status oa::Module::loadFrom(Engine & inEngine, const ModelFile & inFile)
oa::I64 oa::Module::numParameters()
Matrix oa::Module::operator()(const Matrix & inInput)
const oa::Vector<Parameter> & oa::Module::parameters()
oa::Vector<Parameter> & oa::Module::parameters()
void oa::Module::registerBuffer(oa::StringView inName, Matrix inData, bool inPersistent = true)
void oa::Module::registerModule(oa::StringView inName, oa::SharedPtr<Module> inModule)
void oa::Module::registerParameter(oa::StringView inName, Matrix inData, bool inRequiresGrad = true)
oa::Status oa::Module::save(Engine & inEngine, const oa::String & inPath)
oa::Status oa::Module::save(Engine & inEngine, const oa::String & inPath, const Optimizer & inOptimizer)
oa::Status oa::Module::saveTo(Engine & inEngine, ModelFile & outFile)
void oa::Module::setName(oa::StringView inName)
void oa::Module::train(oa::Bool inTraining = true)

Constructor & Destructor Documentation

void oa::Module::~Module()
No public source comment is attached to this declaration.

Public Method Documentation

oa::Vector<ModuleBuffer *> oa::Module::allBufferPtrs( bool inPersistentOnly = false )
No public source comment is attached to this declaration.

Parameters

inPersistentOnly
bool

Default: false

Returns

oa::Vector<ModuleBuffer *>

The declared return value.

oa::Vector<NamedParameter> oa::Module::allNamedParameterPtrs()
No public source comment is attached to this declaration.

Returns

oa::Vector<NamedParameter>

The declared return value.

oa::Vector<Parameter *> oa::Module::allParameterPtrs()
No public source comment is attached to this declaration.

Returns

oa::Vector<Parameter *>

The declared return value.

oa::Vector<Parameter> oa::Module::allParameters()
Recursive parameter collection (use these for nested modules)

Returns

oa::Vector<Parameter>

The declared return value.

const oa::Vector<ModuleBuffer> & oa::Module::buffers()
No public source comment is attached to this declaration.

Returns

const oa::Vector<ModuleBuffer> &

The declared return value.

oa::Vector<ModuleBuffer> & oa::Module::buffers()
persistent/non-trainable state. buffers never receive gradients and never participate in optimizer parameter traversal or numParameters().

Returns

oa::Vector<ModuleBuffer> &

The declared return value.

const oa::Vector<NamedChild> & oa::Module::children()
No public source comment is attached to this declaration.

Returns

const oa::Vector<NamedChild> &

The declared return value.

oa::Vector<NamedChild> & oa::Module::children()
No public source comment is attached to this declaration.

Returns

oa::Vector<NamedChild> &

The declared return value.

void oa::Module::eval()
No public source comment is attached to this declaration.

Returns

void

The declared return value.

Matrix oa::Module::forward( const Matrix & inInput )
forward — the only virtual method layers override.

Parameters

inInput
const Matrix &

Returns

Matrix

The declared return value.

oa::Device oa::Module::getDevice()
No public source comment is attached to this declaration.

Returns

oa::Device

The declared return value.

const oa::String & oa::Module::getName()
No public source comment is attached to this declaration.

Returns

const oa::String &

The declared return value.

oa::Bool oa::Module::isTraining()
No public source comment is attached to this declaration.

Returns

oa::Bool

The declared return value.

oa::Status oa::Module::load( Engine & inEngine, const oa::String & inPath )
No public source comment is attached to this declaration.

Parameters

inEngine
Engine &

inPath
const oa::String &

Returns

oa::Status

The declared return value.

oa::Status oa::Module::load( Engine & inEngine, const oa::String & inPath, Optimizer & inOptimizer )
No public source comment is attached to this declaration.

Parameters

inEngine
Engine &

inPath
const oa::String &

inOptimizer
Optimizer &

Returns

oa::Status

The declared return value.

oa::Status oa::Module::loadFrom( Engine & inEngine, const ModelFile & inFile )
validate the complete module tree before mutating live state.

Parameters

inEngine
Engine &

inFile
const ModelFile &

Returns

oa::Status

The declared return value.

oa::I64 oa::Module::numParameters()
No public source comment is attached to this declaration.

Returns

oa::I64

The declared return value.

Matrix oa::Module::operator()( const Matrix & inInput )
No public source comment is attached to this declaration.

Parameters

inInput
const Matrix &

Returns

Matrix

The declared return value.

const oa::Vector<Parameter> & oa::Module::parameters()
No public source comment is attached to this declaration.

Returns

const oa::Vector<Parameter> &

The declared return value.

oa::Vector<Parameter> & oa::Module::parameters()
Parameter management WARNING: parameters() returns ONLY direct parameters (non-recursive), unlike PyTorch's .parameters(). For nested modules use allParameterPtrs() instead. FOOTGUN: module->parameters()[0] on a nested module is OOB. Always check .size() first or use allParameterPtrs().

Returns

oa::Vector<Parameter> &

The declared return value.

void oa::Module::registerBuffer( oa::StringView inName, Matrix inData, bool inPersistent = true )
No public source comment is attached to this declaration.

Parameters

inName
oa::StringView

inData
Matrix

inPersistent
bool

Default: true

Returns

void

The declared return value.

void oa::Module::registerModule( oa::StringView inName, oa::SharedPtr<Module> inModule )
No public source comment is attached to this declaration.

Parameters

inName
oa::StringView

inModule
oa::SharedPtr<Module>

Returns

void

The declared return value.

void oa::Module::registerParameter( oa::StringView inName, Matrix inData, bool inRequiresGrad = true )
No public source comment is attached to this declaration.

Parameters

inName
oa::StringView

inData
Matrix

inRequiresGrad
bool

Default: true

Returns

void

The declared return value.

oa::Status oa::Module::save( Engine & inEngine, const oa::String & inPath )
Persistence — non-virtual generic tree walks. Builds dotted parameter paths from registerModule/registerParameter names (e.g. "fc1.weight"). arch-specific loaders (SafeTensors, sharded LLM weights) live as separate helper fns that write into an already-constructed module. Optimizer overloads bundle state into the same .oam file so resume training is one call per side.

Parameters

inEngine
Engine &

inPath
const oa::String &

Returns

oa::Status

The declared return value.

oa::Status oa::Module::save( Engine & inEngine, const oa::String & inPath, const Optimizer & inOptimizer )
No public source comment is attached to this declaration.

Parameters

inEngine
Engine &

inPath
const oa::String &

inOptimizer
const Optimizer &

Returns

oa::Status

The declared return value.

oa::Status oa::Module::saveTo( Engine & inEngine, ModelFile & outFile )
Lower-level: dump self/restore self into a caller-owned ModelFile (no file I/O).

Parameters

inEngine
Engine &

outFile
ModelFile &

Returns

oa::Status

The declared return value.

void oa::Module::setName( oa::StringView inName )
Info

Parameters

inName
oa::StringView

Returns

void

The declared return value.

void oa::Module::train( oa::Bool inTraining = true )
training mode — propagates to every registered child. eval() is equivalent to train(false). Newly registered children inherit the parent's current mode.

Parameters

inTraining
oa::Bool

Default: true

Returns

void

The declared return value.