lstm_cell

std.nn.lstm_cell · Level L3

One step of a long short-term memory (LSTM) cell: from the hidden state h, the cell state c and an input x, the next h and c. The four gates (input, forget, output, candidate) each take their weights from W, U and b by index. The body that lstm scans.

gₖ = act(Wₖh + Uₖx + bₖ); c′ = f⊙c + i⊙g; h′ = o⊙tanh(c′)

Signature

lstm_cell(h: f64[k], c: f64[k], x: f64[m], W: f64[4, k, k], U: f64[4, k, m], b: f64[4, k]) → f64[k], f64[k]

Structure

The function as NOVA stores it: one box per input, operation and output, and arrows that carry values. A double border marks another library function this one runs — called once, or by Scan once per element; select it to open that function.

cf64[k]10hf64[k]Wf64[4, k, k]Uf64[4, k, m]xf64[m]bf64[4, k]32GatherW1GatherU1Gatherb1GatherW0GatherU0ReshapehcGatherb0ReshapexcGatherW3GatherU3Gatherb3GatherW2GatherU2Gatherb2MatMulWh1MatMulUx1MatMulWh0MatMulUx0MatMulWh3MatMulUx3MatMulWh2MatMulUx2Adds1Adds0Adds3Adds2Reshapef1Reshapef0Reshapef3Reshapef2Addz1Addz0Addz3Addz2Sigmoida1Sigmoida0Tanha3Sigmoida2MultiplyfcMultiplyigAddc2TanhtcMultiplyh2h2f64[k]c2f64[k]
  • input
  • operation
  • constant
  • call
  • output

Verification

  • Signature proven by NOVA’s shape solver, for every size.
  • Agrees with the reference i, f, o = σ(W[g] @ h + U[g] @ x + b[g]) for g = 0, 1, 2; g = tanh(W[3] @ h + U[3] @ x + b[3]); c2 = f*c + i*g; h2 = o*tanh(c2) to 80 digits (100-digit arithmetic), on all 40 test cases.
  • All 332 float64 results inside the running error bound; the closest uses 12% of it.
  • Interpreter and NumPy backend return bit-identical results.
  • At float32 too: the 40 test cases rounded to float32, and 40 of them inside the running error bound at u = 2⁻²⁴; the closest uses 22% of it.
Accuracy in detail
correctly rounded (the float64 nearest the exact value)
53%
bit-equal to the NumPy formula in float64
100%
largest error, in units in the last place
86

Large ulp counts appear where a result is tiny next to the numbers it is computed from (after cancellation, for example), so one unit in the last place is tiny too; the absolute error is still inside the bound. Results within their own error of zero are not counted.

Identity

Calls
—
Called by
sha256:6ea8ce6c3bd0e71400ad10c2143bbdab325e625b3dbc686314445b44f2a3a8d2

The semantic hash of the graph. It changes when the program changes, and never when only its documentation does.

Control handle

Symbol
Ω:std.nn.lstm_cell · Ω:lstm_cell
Pins
sha256:ec35b0381eabbe83ea31ec517f8d6ea1377d4d2729e3a2921ebfd7c7c3b46493this graph alone
Evidence
sha256:6b175eac05d739b4e9e47d0ccb293121ca383b8592e74e5d7f2eebc0d237cd8bthe hash of its verification record
Needs
no capability: a pure function

Through NOVA’s control layer, the symbol launches this function only while the program still matches what it pins: a change to this graph, or to any graph it reaches, needs a migration first.

ΣEML 2026

Efficient New Language — a high-density semantic overlay for humans and AI agents.

This site’s demos run on the real EML toolchain, in your browser.

© 2026 EveMissLab (一言諾科技有限公司) / Neo.K. All rights reserved.