oa::RnnCell

/ Rnn — vanilla Elman recurrent module. h_new = tanh( W_ih x + b_ih + W_hh h + b_hh ) Mirrors the Gru / GruCell API 1:1 (zeroState / step / forward, stacked layers) so the two recurrent modules are interchangeable in a model. Like the GRU it fuses its pointwise tail (Add + Tanh) into one RnnCellPointwise kernel. The two Linear projections stay separate dispatches; since oa::FnMatrix::Linear is pure dispatch, each needs a manual grad-node attach — see AttachLinearGrad in Rnn.cpp.

Inheritance

public Module

Public Methods

oa::Matrix oa::RnnCell::forward(const oa::Matrix & inInput)
oa::I32 oa::RnnCell::hiddenSize()
oa::Matrix oa::RnnCell::inputProjection(const oa::Matrix & inInput)
oa::I32 oa::RnnCell::inputSize()
oa::Matrix oa::RnnCell::step(const oa::Matrix & inInput, const oa::Matrix & inHidden)
oa::Matrix oa::RnnCell::stepWithGi(const oa::Matrix & inGi, const oa::Matrix & inHidden, oa::U32 inTimeOffset = 0, oa::U32 inBatchStride = 1)
oa::Matrix oa::RnnCell::zeroState(oa::I32 inBatch)

Constructor & Destructor Documentation

oa::RnnCell::RnnCell( oa::I32 inInputSize, oa::I32 inHiddenSize, bool inBias = true )
No public source comment is attached to this declaration.

Parameters

inInputSize
oa::I32

inHiddenSize
oa::I32

inBias
bool

Default: true

Public Method Documentation

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

Parameters

inInput
const oa::Matrix &

Returns

oa::Matrix

The declared return value.

oa::I32 oa::RnnCell::hiddenSize()
No public source comment is attached to this declaration.

Returns

oa::I32

The declared return value.

oa::Matrix oa::RnnCell::inputProjection( const oa::Matrix & inInput )
split projections so Rnn can hoist the (recurrence-free) input projection out of the timestep loop into one batched GEMM. inputProjection: gi = Linear(x, W_ih, b_ih) for any row count → [*, H]. stepWithGi: consumes a precomputed gi [B*T, H] at row offset timeOffset and runs only the recurrent gh = Linear(h, W_hh) + fused tanh pointwise (no per-step Slice).

Parameters

inInput
const oa::Matrix &

Returns

oa::Matrix

The declared return value.

oa::I32 oa::RnnCell::inputSize()
No public source comment is attached to this declaration.

Returns

oa::I32

The declared return value.

oa::Matrix oa::RnnCell::step( const oa::Matrix & inInput, const oa::Matrix & inHidden )
No public source comment is attached to this declaration.

Parameters

inInput
const oa::Matrix &

inHidden
const oa::Matrix &

Returns

oa::Matrix

The declared return value.

oa::Matrix oa::RnnCell::stepWithGi( const oa::Matrix & inGi, const oa::Matrix & inHidden, oa::U32 inTimeOffset = 0, oa::U32 inBatchStride = 1 )
No public source comment is attached to this declaration.

Parameters

inGi
const oa::Matrix &

inHidden
const oa::Matrix &

inTimeOffset
oa::U32

Default: 0

inBatchStride
oa::U32

Default: 1

Returns

oa::Matrix

The declared return value.

oa::Matrix oa::RnnCell::zeroState( oa::I32 inBatch )
No public source comment is attached to this declaration.

Parameters

inBatch
oa::I32

Returns

oa::Matrix

The declared return value.