lstm_op
→std::vector<TensorImplPtr>int lstm_op(const int & input, const int & h0, const int & c0, const int & weights, const backend::IBackend::LstmOpts & opts)Run a single-layer LSTM forward pass and return {output, hn, cn}.
Thin public entry point that delegates to LstmBackward::forward
and is bound into Python as lucid._C.engine.nn.lstm_forward. The
Python LSTM module in lucid.nn.modules.rnn calls this once per
layer per direction and composes multi-layer, bidirectional and
inter-layer dropout behaviour itself.
Math
Per-time-step gating (Hochreiter & Schmidhuber 1997):
References
Hochreiter & Schmidhuber, "Long Short-Term Memory" (Neural Computation 1997).
See Also
lucid.nn.LSTM — Python multi-layer / bidirectional /
projection wrapper that composes single-layer engine calls.
lucid.nn.LSTMCell — single-time-step variant.
Parameters
inputTensorImplPtr(T, B, input_size).h0TensorImplPtr(1, B, H_rec) (zero-filled by the caller if no explicit initial state is supplied).c0TensorImplPtr(1, B, hidden_size).weightsstd::vector<TensorImplPtr>{W_ih, W_hh, b_ih, b_hh} (plus optional W_hr when projection is enabled). Gate matrices are stacked in [i, f, g, o] order along the leading axis.Returns
std::vector<TensorImplPtr>{output, hn, cn} — output sequence (T, B, H_out), final hidden state (1, B, H_out), final cell state (1, B, hidden_size).
Notes
Only output participates in autograd; hn and cn are
returned as detached tensors so the Python wrapper can feed them as
initial states to a stacked next-layer call without leaking gradient
edges between layers.