architecture/network/slab

Slab Packing / Structure‑of‑Arrays Backend (Educational Module)

Packs per‑connection data into parallel typed arrays (SoA) to accelerate forward passes and to illustrate memory/layout optimizations.

Why SoA?

Key Arrays (logical length = used): weights | from | to | flags | (optional) gain | (optional) plastic. Adjacency (CSR style): outStart (nodeCount+1), outOrder (per‑source permutation) enabling fast fan‑out.

On‑Demand & Omission:

Capacity Strategy: geometric growth (1.25x browser / 1.75x Node) amortizes realloc cost. Pooling (config gated) reuses typed arrays (see getSlabAllocationStats).

Rebuild Steps (sync): reindex nodes → grow/allocate if needed → single pass populate → optional slabs → version++. Async variant slices the population loop into microtasks to reduce long main‑thread blocks.

Example (inspection):

const slab = net.getConnectionSlab();
console.log('Edges', slab.used, 'Version', slab.version, 'Cap', slab.capacity);
console.log('First weight from->to', slab.weights[0], slab.from[0], slab.to[0]);

architecture/network/slab/network.slab.utils.types.ts

BuildAdjacencyContext

Shared immutable inputs used across the CSR adjacency build pipeline for outgoing-order construction.

ConnectionInternals

Internal Connection properties accessed during slab build, serialization, and typed-array buffer write operations.

ConnectionSlabView

Packed SoA view returned by getConnectionSlab exposing typed-array weight, index, and flag buffers.

FanOutCollectionContext

Context for fan-out collection: build inputs plus the output count buffer.

FastSlabNodeRuntime

Node shape required by fast slab activation kernels for typed-array forward pass inference.

NetworkActivationRuntime

Runtime activation contract consumed by slab-based forward-pass execution paths for network inference.

NetworkSlabProps

Internal Network properties used by slab orchestration for typed-array buffer management and dirty tracking.

NetworkTopoRuntime

Runtime topology contract used to lazily rebuild topological order when the activation cache is dirty.

OutgoingOrderBuildContext

Context for constructing the source-grouped outgoing connection order from precomputed CSR start indices.

PoolKeyMetrics

Per-pool-key allocation and reuse counters used for educational diagnostics and memory-pool observability.

PublishAdjacencyContext

Context for publishing fully built adjacency slabs to internal network state.

SLAB_DEFAULT_ASYNC_CHUNK_SIZE

Default async slab rebuild chunk size when no override is provided.

SLAB_GROWTH_FACTOR_BROWSER

Capacity growth factor for browser runtime slab allocations, tuned for tighter memory environments.

SLAB_GROWTH_FACTOR_NODE

Capacity growth factor for Node.js runtime slab allocations, scaled conservatively to allow large networks.

SLAB_ONE

Numeric one sentinel used for neutral gain defaults and index math.

SLAB_ZERO

Numeric zero sentinel used across slab orchestration and helper pipelines.

SlabBuildContext

Immutable inputs required to build or grow connection slab buffers.

SlabPopulateResult

Result of scanning and populating optional gain and plastic typed-array slab buffers.

SlabWriteArrays

Writable typed-array slab buffers targeted during connection serialization and buffer population.

StartIndicesBuildContext

Context for constructing CSR start offsets from precomputed fan-out counts.

TypedArray

Union of slab typed array element container types supported by activation buffer allocation.

TypedArrayConstructor

Constructor type for typed arrays used in activation slab allocation and dynamic buffer growth.

architecture/network/slab/network.slab.utils.ts

canUseFastSlab

canUseFastSlab(
  training: boolean,
): boolean

Report whether current network state can use slab fast activation without fallback. Mirrors _canUseFastSlab while exposing eligibility to callers and diagnostics.

Parameters:

Returns: True when slab fast path predicates hold.

ConnectionSlabView

Packed SoA view returned by getConnectionSlab exposing typed-array weight, index, and flag buffers.

fastSlabActivate

fastSlabActivate(
  input: number[],
): number[]

High‑performance forward pass using packed slabs + CSR adjacency.

Fallback Conditions (auto‑detected):

Implementation Notes:

Parameters:

Returns: Output activations (detached plain array) of length network.output.

getConnectionSlab

getConnectionSlab(): ConnectionSlabView

Obtain (and lazily rebuild if dirty) the current packed SoA view of connections.

Gain Omission: If the internal gain slab is absent (all gains neutral) a synthetic neutral array is created and returned (NOT retained) to keep external educational tooling branch‑free while preserving omission memory savings internally.

Returns: Read‑only style view (do not mutate) containing typed arrays + metadata.

getSlabAllocationStats

getSlabAllocationStats(): { fresh: number; pooled: number; pool: Record<string, PoolKeyMetrics>; }

Allocation statistics snapshot for slab typed arrays.

Includes:

NOTE: Stats are cumulative (not auto‑reset); callers may diff successive snapshots.

Returns: Plain object copy (safe to serialize) of current allocator counters.

getSlabVersion

getSlabVersion(): number

Return the monotonic slab rebuild version used to detect stale packed views.

Returns: Non‑negative integer (0 if slab never built yet).

rebuildConnectionSlab

rebuildConnectionSlab(
  force: boolean,
): void

Build (or refresh) the packed connection slabs for the network synchronously.

ACTIONS

  1. Optionally reindex nodes if structural mutations invalidated indices.
  2. Grow (geometric) or reuse existing typed arrays to ensure capacity >= active connections.
  3. Populate the logical slice [0, connectionCount) with weight/from/to/flag data.
  4. Lazily allocate gain & plastic slabs only on first non‑neutral / plastic encounter; omit otherwise.
  5. Release previously allocated optional slabs when they revert to neutral / unused (omission optimization).
  6. Update internal bookkeeping: logical count, dirty flags, version counter.

PERFORMANCE

O(C) over active connections with amortized allocation cost due to geometric growth.

Parameters:

rebuildConnectionSlabAsync

rebuildConnectionSlabAsync(
  chunkSize: number,
): Promise<void>

Cooperative asynchronous slab rebuild (Browser only).

Strategy:

Metrics: Increments _slabAsyncBuilds for observability. Fallback: On Node (no window) defers to synchronous rebuild for simplicity.

Parameters:

Returns: Promise resolving once rebuild completes.

architecture/network/slab/network.slab.pool.utils.ts

Internal helpers for typed-array slab allocation, release, and pool stats.

_acquireTA

_acquireTA(
  kind: string,
  ctor: TypedArrayConstructor,
  length: number,
  bytesPerElement: number,
): TypedArray

Acquire a typed-array slab for the requested key, reusing pooled capacity when available and allocating only on pool miss.

Parameters:

Returns: Acquired typed array.

_getSlabAllocationStatsSnapshot

_getSlabAllocationStatsSnapshot(): { fresh: number; pooled: number; pool: Record<string, PoolKeyMetrics>; }

Produce a serializable view of slab allocation telemetry, including global fresh-versus-pooled counts and per-key pool depth.

Returns: Snapshot containing fresh, pooled, and per-key counters.

_releaseTA

_releaseTA(
  kind: string,
  bytesPerElement: number,
  arr: TypedArray,
): void

Return a typed array to its bounded per-key slab pool so later activation passes can reuse capacity without reallocating.

Parameters:

Returns: Nothing.

architecture/network/slab/network.slab.view.utils.ts

_createConnectionSlabView

_createConnectionSlabView(
  network: default,
): ConnectionSlabView

Creates a read-oriented packed slab view from current network internals.

Parameters:

Returns: Packed connection slab view.

_readSlabVersion

_readSlabVersion(
  network: default,
): number

Reads the current monotonic slab version counter from network internals.

Parameters:

Returns: Non-negative slab version counter.

_resolveConnectionGainView

_resolveConnectionGainView(
  internalNet: NetworkSlabProps,
  capacity: number,
): Float32Array<ArrayBufferLike> | Float64Array<ArrayBufferLike> | null

Resolves gain slab view, synthesizing neutral gain values when omitted.

Parameters:

Returns: Gain array view.

_resolveConnectionSlabCapacity

_resolveConnectionSlabCapacity(
  internalNet: NetworkSlabProps,
): number

Resolves effective slab capacity using explicit capacity first.

Parameters:

Returns: Effective capacity value.

architecture/network/slab/network.slab.setup.utils.ts

_prepareSlabBuildPreconditions

_prepareSlabBuildPreconditions(
  buildContext: SlabBuildContext,
): void

Applies all required prerequisite normalization steps before starting slab rebuild passes.

Parameters:

Returns: Nothing.

architecture/network/slab/network.slab.activate.utils.ts

_activateFastSlab

_activateFastSlab(
  network: default,
  input: number[],
): number[]

Executes fast slab activation once slab and adjacency prerequisites are prepared.

Parameters:

Returns: Output activation array.

architecture/network/slab/network.slab.shared.helpers.utils.ts

_reindexNodes

_reindexNodes(
  network: default,
): void

Assigns sequential node indices used by slab packing and fast-path traversal.

Parameters:

Returns: Nothing.

architecture/network/slab/network.slab.rebuild.helpers.utils.ts

Internal slab rebuild helper functions extracted from network.slab.utils.ts.

_allocateCoreSlabArrays

_allocateCoreSlabArrays(
  buildContext: SlabBuildContext,
): void

Allocates core slab arrays (weights/from/to/flags).

Parameters:

Returns: Nothing.

_allocateCoreSlabArraysAsync

_allocateCoreSlabArraysAsync(
  buildContext: SlabBuildContext,
): Promise<void>

Allocates async core slabs with optional timer yields between large allocations.

Parameters:

Returns: Promise resolved after async core slabs are ready.

_allocateGainSlabForAsync

_allocateGainSlabForAsync(
  buildContext: SlabBuildContext,
): Promise<void>

Allocates gain slab for async pass prefill strategy.

Parameters:

Returns: Promise resolved after the gain slab is ready.

_applyGainOmissionPolicy

_applyGainOmissionPolicy(
  buildContext: SlabBuildContext,
  populateResult: SlabPopulateResult,
): void

Applies gain omission rule by releasing a fully neutral gain slab so optional gain storage remains absent unless non-default values are present.

Parameters:

Returns: Nothing.

_applyPlasticPolicyAsync

_applyPlasticPolicyAsync(
  buildContext: SlabBuildContext,
  populateResult: SlabPopulateResult,
): void

Applies async plastic slab allocation and release policy so chunked rebuilds keep plastic-rate arrays aligned with observed plastic connection flags.

Parameters:

Returns: Nothing.

_applyPlasticPolicySync

_applyPlasticPolicySync(
  buildContext: SlabBuildContext,
  populateResult: SlabPopulateResult,
): void

Applies sync plastic slab allocation and release policy so plasticity-rate storage exists only when plastic connections appear in the packed set.

Parameters:

Returns: Nothing.

_createInitialSlabPopulateResult

_createInitialSlabPopulateResult(
  internalNet: NetworkSlabProps,
): SlabPopulateResult

Creates initial populate result from current optional slab state.

Parameters:

Returns: Initial populate result.

_createSlabBuildContext

_createSlabBuildContext(
  network: default,
  growthFactor: number,
): SlabBuildContext

Creates immutable slab build context for one rebuild pass so capacity, precision, and runtime pointers stay consistent across helper calls.

Parameters:

Returns: Build context.

_createSlabWriteArrays

_createSlabWriteArrays(
  buildContext: SlabBuildContext,
): SlabWriteArrays

Creates strongly typed write-array bundle for connection population.

Parameters:

Returns: Write-array bundle.

_ensureGainArrayExistsForIndex

_ensureGainArrayExistsForIndex(
  buildContext: SlabBuildContext,
  populateResult: SlabPopulateResult,
  connectionIndex: number,
): void

Ensures gain slab exists before writing non-neutral value.

Parameters:

Returns: Nothing.

_ensureSlabCapacityAsync

_ensureSlabCapacityAsync(
  buildContext: SlabBuildContext,
): Promise<void>

Ensures async rebuild has enough slab capacity so cooperative chunked population can proceed without mid-pass reallocations or pointer invalidation hazards.

Parameters:

Returns: Promise resolved after any required cooperative allocations finish.

_ensureSlabCapacitySync

_ensureSlabCapacitySync(
  buildContext: SlabBuildContext,
): void

Ensures sync rebuild has enough slab capacity so packed arrays can hold every active connection before synchronous field population begins.

Parameters:

Returns: Nothing.

_expandSlabCapacity

_expandSlabCapacity(
  currentCapacity: number,
  requiredCapacity: number,
  growthFactor: number,
): number

Computes next capacity satisfying required size using geometric growth.

Parameters:

Returns: Expanded capacity.

_fillPlasticityRates

_fillPlasticityRates(
  network: default,
  plasticArray: Float32Array<ArrayBufferLike> | Float64Array<ArrayBufferLike>,
  connectionCount: number,
): void

Fills plastic slab values from connection plasticity rates.

Parameters:

Returns: Nothing.

_finalizeAsyncSlabRebuild

_finalizeAsyncSlabRebuild(
  buildContext: SlabBuildContext,
): void

Finalizes async rebuild bookkeeping fields so runtime counters and slab-version invalidation match the completed cooperative population pass in production telemetry.

Parameters:

Returns: Nothing.

_finalizeSharedSlabState

_finalizeSharedSlabState(
  internalNet: NetworkSlabProps,
  connectionCount: number,
): void

Finalizes shared rebuild bookkeeping fields.

Parameters:

Returns: Nothing.

_finalizeSyncSlabRebuild

_finalizeSyncSlabRebuild(
  buildContext: SlabBuildContext,
): void

Finalizes sync rebuild bookkeeping fields so connection counts, dirty flags, and slab versions remain coherent for downstream runtime caches and adapters.

Parameters:

Returns: Nothing.

_populateAsyncChunkRange

_populateAsyncChunkRange(
  buildContext: SlabBuildContext,
  writeArrays: SlabWriteArrays,
  populateResult: SlabPopulateResult,
  startIndex: number,
  endIndex: number,
): void

Populates one inclusive-exclusive chunk range for async rebuild.

Parameters:

Returns: Nothing.

_populateSlabConnectionsAsync

_populateSlabConnectionsAsync(
  buildContext: SlabBuildContext,
  chunkSize: number,
): Promise<SlabPopulateResult>

Populates core slab arrays in cooperative async chunks so large graphs remain responsive while preserving deterministic packed ordering semantics for replayability.

Parameters:

Returns: Population result flags and optional slabs.

_populateSlabConnectionsSync

_populateSlabConnectionsSync(
  buildContext: SlabBuildContext,
): SlabPopulateResult

Populates core slab arrays in a synchronous single pass so all connection fields are packed deterministically for the active network snapshot.

Parameters:

Returns: Population result flags and optional slabs.

_releaseExistingSlabArrays

_releaseExistingSlabArrays(
  buildContext: SlabBuildContext,
): void

Releases all currently allocated slab arrays back to pool.

Parameters:

Returns: Nothing.

_resetOptionalSlabArraysAfterSyncAllocate

_resetOptionalSlabArraysAfterSyncAllocate(
  internalNet: NetworkSlabProps,
): void

Resets optional slabs after sync allocation to keep omission semantics.

Parameters:

Returns: Nothing.

_resolveAsyncChunkSize

_resolveAsyncChunkSize(
  totalConnections: number,
  requestedChunkSize: number,
): number

Resolves effective async chunk size using adaptive heuristics so very large rebuilds honor browser frame budgets without starving throughput under load.

Parameters:

Returns: Effective chunk size.

_shouldSkipSlabRebuild

_shouldSkipSlabRebuild(
  internalNet: NetworkSlabProps,
  force: boolean,
): boolean

Determines whether slab rebuild can be skipped so callers avoid unnecessary typed-array churn when no topology mutation invalidated packed connection buffers.

Parameters:

Returns: True when rebuild can be skipped.

_updatePlasticPresence

_updatePlasticPresence(
  populateResult: SlabPopulateResult,
  connection: ConnectionInternals,
): void

Updates plastic-presence flag from connection bitfield.

Parameters:

Returns: Nothing.

_weightArrayCtor

_weightArrayCtor(
  useFloat32Weights: boolean | undefined,
): Float32ArrayConstructor | Float64ArrayConstructor

Resolves typed-array constructor for weight slabs.

Parameters:

Returns: Matching typed-array constructor.

_weightByteWidth

_weightByteWidth(
  useFloat32Weights: boolean | undefined,
): number

Resolves byte width for weight slab arrays.

Parameters:

Returns: Byte width for weight elements.

_writeConnectionCoreFields

_writeConnectionCoreFields(
  writeArrays: SlabWriteArrays,
  connection: ConnectionInternals,
  connectionIndex: number,
): void

Writes core fields for one connection into slab arrays.

Parameters:

Returns: Nothing.

_writeConnectionGainField

_writeConnectionGainField(
  buildContext: SlabBuildContext,
  populateResult: SlabPopulateResult,
  connection: ConnectionInternals,
  connectionIndex: number,
): void

Writes gain field for one connection and updates gain flags.

Parameters:

Returns: Nothing.

_yieldAsyncChunkMacrotask

_yieldAsyncChunkMacrotask(): Promise<void>

Yields one macrotask turn between browser async slab chunks.

Returns: Promise resolved on the next timer turn.

architecture/network/slab/network.slab.adjacency.helpers.utils.ts

Internal slab adjacency helpers extracted from network.slab.utils.ts.

_buildAdjacency

_buildAdjacency(
  network: default,
): void

Build or refresh CSR-style adjacency (outStart + outOrder) for fast fan-out traversal.

Parameters:

Returns: Nothing.

asNetworkSlabProps

asNetworkSlabProps(
  network: default,
): NetworkSlabProps

Cast network instance into internal slab-backed shape.

Parameters:

Returns: Internal slab-backed network representation.

buildOutgoingOrder

buildOutgoingOrder(
  outgoingOrderBuildContext: OutgoingOrderBuildContext,
): Uint32Array<ArrayBufferLike>

Build source-grouped outgoing order using CSR start offsets.

Parameters:

Returns: Ordered outgoing connection indices.

buildOutgoingStartIndices

buildOutgoingStartIndices(
  startIndicesBuildContext: StartIndicesBuildContext,
): Uint32Array<ArrayBufferLike>

Build CSR start offsets from fan-out counts.

Parameters:

Returns: Outgoing start indices slab.

collectFanOutCounts

collectFanOutCounts(
  buildContext: BuildAdjacencyContext,
): Uint32Array<ArrayBufferLike>

Collect fan-out counts for each source node.

Parameters:

Returns: Fan-out counts per node.

createBuildAdjacencyContext

createBuildAdjacencyContext(
  network: default,
): BuildAdjacencyContext | null

Build adjacency context when required slabs are available.

Parameters:

Returns: Build context or null when adjacency cannot be built yet.

createFanOutCollectionContext

createFanOutCollectionContext(
  buildContext: BuildAdjacencyContext,
): FanOutCollectionContext

Build fan-out collection context.

Parameters:

Returns: Fan-out collection context.

createFanOutCountsBuffer

createFanOutCountsBuffer(
  nodeCount: number,
): Uint32Array<ArrayBufferLike>

Allocate fan-out counts buffer.

Parameters:

Returns: Zero-initialized fan-out counts.

createInsertionCursor

createInsertionCursor(
  outgoingStartIndices: Uint32Array<ArrayBufferLike>,
): Uint32Array<ArrayBufferLike>

Create insertion cursor copy from outgoing start indices.

Parameters:

Returns: Mutable insertion cursor.

createOutgoingOrderBuffer

createOutgoingOrderBuffer(
  connectionCount: number,
): Uint32Array<ArrayBufferLike>

Allocate outgoing order buffer.

Parameters:

Returns: Outgoing order buffer.

createOutgoingStartIndicesBuffer

createOutgoingStartIndicesBuffer(
  nodeCount: number,
): Uint32Array<ArrayBufferLike>

Allocate outgoing start indices buffer with terminal slot.

Parameters:

Returns: Outgoing start indices buffer.

hasRequiredConnectionSlabs

hasRequiredConnectionSlabs(
  internalNet: NetworkSlabProps,
): boolean

Check whether required connection slabs exist.

Parameters:

Returns: True when adjacency build prerequisites are present.

incrementFanOutCountAtSource

incrementFanOutCountAtSource(
  context: { fanOutCounts: Uint32Array<ArrayBufferLike>; connectionFromSlab: Uint32Array<ArrayBufferLike>; connectionIndex: number; },
): void

Increment fan-out count for one connection source index.

Parameters:

Returns: Nothing.

insertConnectionIntoOutgoingOrder

insertConnectionIntoOutgoingOrder(
  context: { connectionIndex: number; connectionFromSlab: Uint32Array<ArrayBufferLike>; outgoingOrder: Uint32Array<ArrayBufferLike>; insertionCursor: Uint32Array<ArrayBufferLike>; },
): void

Insert one connection index into the proper source-grouped slot.

Parameters:

Returns: Nothing.

iterateConnectionIndices

iterateConnectionIndices(
  connectionCount: number,
  visitor: (connectionIndex: number) => void,
): void

Iterate all connection indices.

Parameters:

Returns: Nothing.

iterateNodeIndices

iterateNodeIndices(
  nodeCount: number,
  visitor: (nodeIndex: number) => void,
): void

Iterate all node indices.

Parameters:

Returns: Nothing.

populateFanOutCounts

populateFanOutCounts(
  fanOutCollectionContext: FanOutCollectionContext,
): void

Populate fan-out counts from the connection source slab.

Parameters:

Returns: Nothing.

populateOutgoingOrder

populateOutgoingOrder(
  context: { connectionCount: number; connectionFromSlab: Uint32Array<ArrayBufferLike>; outgoingOrder: Uint32Array<ArrayBufferLike>; insertionCursor: Uint32Array<ArrayBufferLike>; },
): void

Populate outgoing order by source-grouped insertion.

Parameters:

Returns: Nothing.

populateOutgoingStartIndices

populateOutgoingStartIndices(
  context: { fanOutCounts: Uint32Array<ArrayBufferLike>; outgoingStartIndices: Uint32Array<ArrayBufferLike>; },
): number

Populate outgoing start indices and return terminal offset.

Parameters:

Returns: Terminal running offset after the last node.

publishAdjacency

publishAdjacency(
  publishAdjacencyContext: PublishAdjacencyContext,
): void

Publish adjacency slabs and clear dirty flag.

Parameters:

Returns: Nothing.

setTerminalOutgoingStartOffset

setTerminalOutgoingStartOffset(
  context: { nodeCount: number; outgoingStartIndices: Uint32Array<ArrayBufferLike>; terminalRunningOffset: number; },
): void

Set terminal outgoing start offset at the tail slot.

Parameters:

Returns: Nothing.

architecture/network/slab/network.slab.fast-path.helpers.utils.ts

Internal fast-slab activation helpers extracted from slab utilities so the hot-path orchestration remains testable, readable, and isolated from broader runtime wiring concerns.

_activateThroughLegacyPath

_activateThroughLegacyPath(
  network: default,
  input: number[],
): number[]

Executes legacy network activation fallback.

Parameters:

Returns: Legacy activation output.

_canUseFastSlab

_canUseFastSlab(
  training: boolean,
): boolean

Evaluate whether the high-performance slab forward pass is currently safe to use under runtime, topology, gating, dropout, and stochastic-regularization constraints.

Parameters:

Returns: True if fast path can be safely used.

_collectFastSlabOutput

_collectFastSlabOutput(
  network: default,
  activationBuffer: Float32Array<ArrayBufferLike> | Float64Array<ArrayBufferLike>,
  nodeCount: number,
): number[]

Collect output activations from the slab working buffer into a detached plain array so callers receive stable values independent of pooled buffer reuse.

Parameters:

Returns: Output activation array.

_createFastActivationBuffer

_createFastActivationBuffer(
  useFloat32Activation: boolean,
  nodeCount: number,
): Float32Array<ArrayBufferLike> | Float64Array<ArrayBufferLike>

Creates typed fast activation/state buffer.

Parameters:

Returns: New typed buffer.

_ensureFastSlabBuffers

_ensureFastSlabBuffers(
  internalNet: NetworkSlabProps,
  nodeCount: number,
): void

Ensure reusable fast activation and state buffers are allocated with the correct length and numeric precision for the upcoming slab propagation pass.

Parameters:

Returns: Nothing.

_hasFastSlabPrerequisites

_hasFastSlabPrerequisites(
  internalNet: NetworkSlabProps,
): boolean

Checks whether core slab prerequisites are available.

Parameters:

Returns: True when all required slabs/adjacency arrays exist.

_hasFastSlabRegularizationBlockers

_hasFastSlabRegularizationBlockers(
  network: default,
  internalNet: NetworkSlabProps,
): boolean

Check runtime regularization features that invalidate slab fast-path execution.

Parameters:

Returns: True when a blocker is present.

_hasFastSlabStructuralEligibility

_hasFastSlabStructuralEligibility(
  network: default,
  internalNet: NetworkSlabProps,
): boolean

Check topology and structure constraints that must hold before the slab fast path can execute.

Parameters:

Returns: True when structure-level fast-path constraints hold.

_maybeActivateNonInputNode

_maybeActivateNonInputNode(
  network: default,
  node: FastSlabNodeRuntime,
  nodeIndex: number,
  stateBuffer: Float32Array<ArrayBufferLike> | Float64Array<ArrayBufferLike>,
  activationBuffer: Float32Array<ArrayBufferLike> | Float64Array<ArrayBufferLike>,
): void

Activates one non-input node when required.

Parameters:

Returns: Nothing.

_needsFastBufferReplacement

_needsFastBufferReplacement(
  buffer: Float32Array<ArrayBufferLike> | Float64Array<ArrayBufferLike> | undefined,
  nodeCount: number,
  useFloat32Activation: boolean,
): boolean

Checks whether a fast buffer requires replacement.

Parameters:

Returns: True when replacement is needed.

_prepareFastSlabRuntime

_prepareFastSlabRuntime(
  network: default,
  internalNet: NetworkSlabProps,
  reindexNodes: (network: default) => void,
): void

Prepare topology ordering and node indexing prerequisites before a fast slab pass so activation loops can run on up-to-date structural metadata.

Parameters:

Returns: Nothing.

_propagateFastSlabActivations

_propagateFastSlabActivations(
  network: default,
  internalNet: NetworkSlabProps,
  topoOrder: FastSlabNodeRuntime[],
  activationBuffer: Float32Array<ArrayBufferLike> | Float64Array<ArrayBufferLike>,
  stateBuffer: Float32Array<ArrayBufferLike> | Float64Array<ArrayBufferLike>,
): void

Propagate activations through topological order using packed slab arrays so weighted fan-out executes with contiguous memory access patterns and deterministic node-to-node accumulation behavior.

Parameters:

Returns: Nothing.

_propagateNodeOutgoingEdges

_propagateNodeOutgoingEdges(
  internalNet: NetworkSlabProps,
  nodeIndex: number,
  activationBuffer: Float32Array<ArrayBufferLike> | Float64Array<ArrayBufferLike>,
  stateBuffer: Float32Array<ArrayBufferLike> | Float64Array<ArrayBufferLike>,
  weightArray: Float32Array<ArrayBufferLike> | Float64Array<ArrayBufferLike>,
  toIndexArray: Uint32Array<ArrayBufferLike>,
  outgoingOrder: Uint32Array<ArrayBufferLike>,
  outgoingStartIndices: Uint32Array<ArrayBufferLike>,
): void

Propagates one node activation over all outgoing slab edges.

Parameters:

Returns: Nothing.

_recomputeTopologyOrder

_recomputeTopologyOrder(
  network: default,
): void

Recomputes topological order on demand.

Parameters:

Returns: Nothing.

_resolveFastTopoOrder

_resolveFastTopoOrder(
  network: default,
  internalNet: NetworkSlabProps,
): FastSlabNodeRuntime[]

Resolve the node iteration order used by fast slab propagation, preferring cached topological order and falling back to node storage order when needed.

Parameters:

Returns: Topological node order.

_resolveWeightedConnectionValue

_resolveWeightedConnectionValue(
  internalNet: NetworkSlabProps,
  weightArray: Float32Array<ArrayBufferLike> | Float64Array<ArrayBufferLike>,
  connectionIndex: number,
): number

Resolves effective connection weight including optional gain.

Parameters:

Returns: Effective weighted value.

_seedFastInputLayer

_seedFastInputLayer(
  network: default,
  input: number[],
  activationBuffer: Float32Array<ArrayBufferLike> | Float64Array<ArrayBufferLike>,
): void

Seed input-layer activation values into the working buffer and mirror those values onto runtime node fields before hidden-layer propagation begins.

Parameters:

Returns: Nothing.

_tryFastSlabFallbackForGating

_tryFastSlabFallbackForGating(
  network: default,
  input: number[],
): number[] | null

Attempt an immediate fallback to legacy activation when gating structures are present because gated connections violate the slab fast-path assumptions.

Parameters:

Returns: Legacy output or null when fast path may continue.

_tryFastSlabFallbackForMissingPrerequisites

_tryFastSlabFallbackForMissingPrerequisites(
  network: default,
  internalNet: NetworkSlabProps,
  input: number[],
): number[] | null

Attempt an immediate fallback to legacy activation when required slab arrays or adjacency prerequisites are missing from runtime state so incomplete slab snapshots never execute unsafe fast-path logic.

Parameters:

Returns: Legacy output or null when fast path may continue.

_writeInputNodeRuntime

_writeInputNodeRuntime(
  node: default,
  inputValue: number,
): void

Writes runtime activation/state for one input node.

Parameters:

Returns: Nothing.

resolveFastSlabActivationPrecision

resolveFastSlabActivationPrecision(
  network: default,
): ActivationPrecision | undefined

Read the resolved runtime activation precision for slab output pooling.

Parameters:

Returns: Active per-network activation precision when present.

resolveFastSlabBufferPrecision

resolveFastSlabBufferPrecision(
  internalNet: NetworkSlabProps & { _precisionConfig?: PrecisionConfig | undefined; _activationPrecision?: ActivationPrecision | undefined; },
): ActivationPrecision | undefined

Read the resolved runtime activation precision for fast slab working buffers.

Parameters:

Returns: Active per-network activation precision when present.

Generated from source JSDoc • GitHub