Docs / nablatensor-core / com.nablatensor.engine

final class

FlatTape

A recorded tape copied into flat parallel arrays, once, at compile time.

Every host engine walks the same tape millions of times. Calling op(int) and friends per node per scenario costs a bounds check and a field load that no amount of JIT will hoist out of the scenario loop, so each engine used to flatten the tape into its own set of arrays in its own constructor. This is that copy, written once.

Fields are final arrays rather than accessors deliberately: the sweeps read them in their innermost loop, and a plain array read is what C2 turns into a single load.

Public only so the engine modules can use it; not part of the supported API.

Constructors

FlatTape(AadTape tape)

Fields

final AadOp[] op

Opcode per node.

final int[] argA

First argument per node: a node index, or an input index for INPUT.

final int[] argB

Second argument per node: a node index, or a stream index for the draws.

final double[] constant

Literal value for CONST nodes, zero elsewhere.

final boolean[] active

Whether a node is on a path from some input to some output.

final int[] inputNode

Node index of each differentiable input, in input order.

final int[] outputNode

Node index of each recorded output, in recording order.

final int randStreams

Number of independent random streams the tape draws from.

Methods

int size()
static int[] scaled(int[] nodes, int stride)

nodes multiplied by stride, for a sweep that stores stride scenarios side by side per node and therefore indexes rows rather than nodes.