architecture/network/onnx/import

ONNX import orchestration for rebuilding a NeatapticTS runtime network.

This file is the chapter-level tour guide for the import folder. The import path is intentionally staged so a reader can follow the same questions the runtime asks while restoring a model:

  1. What architecture should be rebuilt?
  2. Which runtime factories should own the scaffold?
  3. How do dense weights and activations map back onto nodes?
  4. Which recurrent and pooling hints need a second pass?

The neighboring files each own one of those stages. Keeping this overview on the flow file makes the generated folder README read like an import pipeline instead of an alphabetical pile of helper files.

Example:

const restored = runOnnxImportFlow(onnxModel);
const output = restored.activate([0.2, 0.8]);

architecture/network/onnx/import/network.onnx.import-flow.utils.ts

runExternalOnnxImportFlow

runExternalOnnxImportFlow(
  binaryModel: Uint8Array<ArrayBufferLike>,
): default

Execute the external binary ONNX import flow for the first supported dense lane.

High-level behavior:

  1. Decode and normalize one accepted binary ModelProto into an importer-owned dense chain.
  2. Fold that chain into the JSON-first model shape used by the existing import flow.
  3. Reuse the same reconstruction pipeline to build the runtime network.

Parameters:

Returns: Reconstructed network instance.

runOnnxImportFlow

runOnnxImportFlow(
  onnx: OnnxModel,
): default

Execute the complete ONNX import flow and reconstruct a runtime network.

High-level behavior:

  1. Extract architecture dimensions and build a perceptron scaffold.
  2. Restore dense parameters and activation functions.
  3. Reconstruct recurrent/pooling metadata and rebuild connection caches.

Parameters:

Returns: Reconstructed network instance.

architecture/network/onnx/import/network.onnx.runtime-load.types.ts

Import-owned types for ONNX runtime factory loading.

These payloads describe the small runtime bootstrap contract that the import flow uses to rebuild a perceptron scaffold and attach recurrent layer constructors without making the parser own a hard-coded constructor shape.

Example:

const runtimeFactories: OnnxRuntimeFactories = {
  perceptronFactory,
  layerModule,
};

OnnxPerceptronBuildContext

Build context for mapping ONNX layer sizes into a Neataptic MLP factory call.

OnnxPerceptronSizeValidationContext

Validation context for perceptron size-list checks during ONNX import, supplying sizes, minimum count, and message.

OnnxRuntimeFactories

Runtime factories consumed during ONNX import network reconstruction, grouping the perceptron and layer module.

OnnxRuntimeLayerFactory

OnnxRuntimeLayerFactory(
  size: number,
): default

Runtime layer-constructor signature used for recurrent layer reconstruction, accepting size and returning a Layer.

OnnxRuntimeLayerModule

Runtime layer module shape consumed by ONNX import orchestration, exposing LSTM and GRU factory constructors.

OnnxRuntimePerceptronFactory

OnnxRuntimePerceptronFactory(
  sizes: number[],
): default

Runtime perceptron factory signature used by ONNX import orchestration, producing a Network from size arguments.

architecture/network/onnx/import/network.onnx.runtime-load.utils.ts

buildPerceptronNetwork

buildPerceptronNetwork(
  buildContext: OnnxPerceptronBuildContext,
): default

Build a perceptron network from size-extraction context.

Parameters:

Returns: Reconstructed network instance.

createPerceptronBuildContext

createPerceptronBuildContext(
  sizes: number[],
): OnnxPerceptronBuildContext

Build perceptron-network construction context.

Parameters:

Returns: Build context.

createPerceptronFactory

createPerceptronFactory(): OnnxRuntimePerceptronFactory

Create an ONNX import network factory from modern static constructors.

Returns: Perceptron-compatible factory function.

createPerceptronSizeValidationContext

createPerceptronSizeValidationContext(
  sizes: number[],
): OnnxPerceptronSizeValidationContext

Build perceptron-size validation context.

Parameters:

Returns: Validation context.

createRuntimeLayerModule

createRuntimeLayerModule(): OnnxRuntimeLayerModule

Create the runtime layer-module wiring used by ONNX import orchestrators.

Returns: Runtime recurrent-layer module object.

foldRuntimeFactories

foldRuntimeFactories(
  perceptronFactory: OnnxRuntimePerceptronFactory,
  layerModule: OnnxRuntimeLayerModule,
): OnnxRuntimeFactories

Fold runtime perceptron and layer module into a transport payload.

Parameters:

Returns: Runtime factories payload.

foldRuntimeLayerModule

foldRuntimeLayerModule(
  lstmFactory: OnnxRuntimeLayerFactory,
  gruFactory: OnnxRuntimeLayerFactory,
): OnnxRuntimeLayerModule

Fold LSTM/GRU factories into a runtime layer module payload.

Parameters:

Returns: Runtime layer module.

loadRuntimeFactories

loadRuntimeFactories(): OnnxRuntimeFactories

Resolve runtime constructor factories used by the ONNX import orchestration.

Returns: Perceptron factory and layer module object.

resolveLayerFactory

resolveLayerFactory(
  layerKey: keyof OnnxRuntimeLayerModule,
): OnnxRuntimeLayerFactory

Resolve one runtime layer factory by module key.

Parameters:

Returns: Matching layer factory.

validatePerceptronSizes

validatePerceptronSizes(
  validationContext: OnnxPerceptronSizeValidationContext,
): void

Validate perceptron size-list constraints.

Parameters:

Returns: Nothing. Throws on invalid size-list.

architecture/network/onnx/import/network.onnx.import-weights.types.ts

Import-owned types for ONNX weight restoration and Conv reconstruction.

This chapter explains the state carried through the importer's heaviest restoration pass: hidden-size derivation, dense and per-neuron tensor assignment, and the optional Conv metadata replay that maps flattened ONNX initializers back onto runtime connections.

Keeping these types near the weight importer makes the generated import README read like a reconstruction guide instead of scattering the execution model across the root compatibility barrel.

Example:

const assignmentContext: OnnxImportWeightAssignmentContext = {
  onnx,
  hiddenLayerSizes,
  metadataProps,
  initializerMap,
  sortedLayerIndices,
  inputNodes,
  hiddenNodes,
  outputNodes,
};

OnnxImportAggregatedLayerAssignmentContext

Context for assigning aggregated dense tensors for one layer, supplying the initializer map and layer node pair.

OnnxImportAggregatedNeuronAssignmentContext

Context for assigning one aggregated dense target neuron row, carrying previous nodes, target, and tensor refs.

OnnxImportConvCoordinateAssignmentContext

Context for applying Conv weights and bias at one output coordinate.

OnnxImportConvKernelAssignmentContext

Context for assigning one concrete Conv kernel connection weight, carrying tensor context, coordinate, and channels.

OnnxImportConvLayerContext

Context object for reconstructing one Conv layer's imported connectivity weights.

OnnxImportConvLayerContextBuildParams

Build params for creating one Conv reconstruction layer context, supplying assignment context and Conv metadata.

OnnxImportConvMetadata

Parsed Conv metadata payload used for optional reconstruction pass, listing Conv layer indices and mapping specs.

OnnxImportConvNodeSlices

Layer node slices used while applying Conv reconstruction assignments, carrying target and previous layer nodes.

OnnxImportConvOutputCoordinate

Coordinate for one Conv output neuron traversal position, encoding output channel, row, and column indices.

OnnxImportConvSourceLayout

Source layout used when replaying Conv weights onto dense source nodes.

OnnxImportConvTensorContext

Resolved Conv initializer tensors and dimensions for one layer, including channels, kernel height, and width.

OnnxImportHiddenSizeDerivationContext

Context for deriving hidden layer sizes from initializer tensors and metadata.

OnnxImportInboundConnectionMap

Inbound connection lookup map keyed by source node for one target neuron.

OnnxImportLayerNodePair

Node slices for one sequential imported layer assignment pass, carrying current and previous layer node lists.

OnnxImportLayerNodePairBuildParams

Build params for one sequential layer node-pair slice operation, specifying layer index and sequential position.

OnnxImportLayerTensorNames

Weight tensor names for one imported layer index, identifying weight and bias initializer name strings.

OnnxImportLayerWeightBucket

Bucketed ONNX dense/per-neuron tensors for one exported layer index, holding the aggregated and per-neuron lists.

OnnxImportPerNeuronAssignmentContext

Context for assigning one per-neuron imported target node, carrying previous nodes and weight and bias tensors.

OnnxImportPerNeuronLayerAssignmentContext

Context for assigning per-neuron tensors for one layer, supplying the initializer map and sequential layer node pair.

OnnxImportWeightAssignmentBuildParams

Build params for creating shared ONNX import weight-assignment context, supplying network, model, and hidden sizes.

OnnxImportWeightAssignmentContext

Shared weight-assignment context built once per ONNX import, carrying model, layers, metadata, and initializer map.

architecture/network/onnx/import/network.onnx.import-weights.utils.ts

Assign weights and biases from ONNX initializers to a newly created network.

applyAggregatedLayerWeights

applyAggregatedLayerWeights(
  aggregatedContext: OnnxImportAggregatedLayerAssignmentContext,
): void

Apply aggregated dense tensor assignments for one layer.

Parameters:

Returns: Nothing.

applyAggregatedNeuronAssignment

applyAggregatedNeuronAssignment(
  neuronContext: OnnxImportAggregatedNeuronAssignmentContext,
): void

Apply aggregated dense row weights and bias for one target neuron.

Parameters:

Returns: Nothing.

applyConvCoordinateAssignment

applyConvCoordinateAssignment(
  coordinateContext: OnnxImportConvCoordinateAssignmentContext,
): void

Apply Conv bias and kernel weights for one output coordinate.

Parameters:

Returns: Nothing.

applyConvLayerReconstruction

applyConvLayerReconstruction(
  layerContext: OnnxImportConvLayerContext,
): void

Apply Conv reconstruction for one validated Conv layer context.

Parameters:

Returns: Nothing.

applyDenseWeightAssignments

applyDenseWeightAssignments(
  assignmentContext: OnnxImportWeightAssignmentContext,
): void

Apply dense/per-neuron assignments for all sorted layer indices.

Parameters:

Returns: Nothing.

applyOptionalConvReconstruction

applyOptionalConvReconstruction(
  assignmentContext: OnnxImportWeightAssignmentContext,
): void

Apply optional Conv2D reconstruction pass from metadata payloads.

Parameters:

Returns: Nothing.

applyPerNeuronAssignment

applyPerNeuronAssignment(
  perNeuronAssignmentContext: OnnxImportPerNeuronAssignmentContext,
): void

Apply one per-neuron weight vector and bias assignment.

Parameters:

Returns: Nothing.

applyPerNeuronLayerWeights

applyPerNeuronLayerWeights(
  perNeuronContext: OnnxImportPerNeuronLayerAssignmentContext,
): void

Apply per-neuron tensor assignments for one layer.

Parameters:

Returns: Nothing.

assignConvKernelWeight

assignConvKernelWeight(
  kernelAssignmentContext: OnnxImportConvKernelAssignmentContext,
): void

Assign one Conv kernel weight to the matching inbound neuron connection.

Parameters:

Returns: Nothing.

assignLayerWeights

assignLayerWeights(
  initializerMap: Record<string, OnnxTensor>,
  nodePair: OnnxImportLayerNodePair,
): void

Assign one layer's weights using aggregated or per-neuron tensors.

Parameters:

Returns: Nothing.

assignWeightsAndBiases

assignWeightsAndBiases(
  network: default,
  onnx: OnnxModel,
  hiddenLayerSizes: number[],
  metadataProps: OnnxMetadataProperty[] | undefined,
): void

Contract for assignWeightsAndBiases.

buildConvLayerContext

buildConvLayerContext(
  params: OnnxImportConvLayerContextBuildParams,
): OnnxImportConvLayerContext | null

Build one Conv layer reconstruction context.

Parameters:

Returns: Conv layer context when valid.

buildConvNeuronLinearIndex

buildConvNeuronLinearIndex(
  coordinate: OnnxImportConvOutputCoordinate,
  convSpec: Conv2DMapping,
): number

Build flattened linear index for one Conv output coordinate.

Parameters:

Returns: Linear neuron index.

buildConvNodeSlices

buildConvNodeSlices(
  layerContext: OnnxImportConvLayerContext,
): OnnxImportConvNodeSlices

Build Conv current/previous node slices for one layer context.

Parameters:

Returns: Node slice payload.

buildConvTensorContext

buildConvTensorContext(
  layerContext: OnnxImportConvLayerContext,
): OnnxImportConvTensorContext | null

Build validated Conv tensor context for one layer.

Parameters:

Returns: Conv tensor context when valid.

buildHiddenLayerSizesFromBuckets

buildHiddenLayerSizesFromBuckets(
  layerWeightBuckets: Record<string, OnnxImportLayerWeightBucket>,
  sortedLayerIndices: number[],
): number[]

Build hidden-layer sizes from weight buckets while excluding output layer.

Parameters:

Returns: Hidden-layer sizes.

buildInboundConnectionMap

buildInboundConnectionMap(
  neuronInternal: NodeInternals,
): OnnxImportInboundConnectionMap

Build inbound connection lookup map for one neuron.

Parameters:

Returns: Inbound connection map keyed by source node.

buildInitializerMap

buildInitializerMap(
  initializers: OnnxTensor[],
  metadataProps: OnnxMetadataProperty[],
): Record<string, OnnxTensor>

Build ONNX initializer map keyed by tensor name.

Parameters:

Returns: Tensor map by name.

buildInputCoordinate

buildInputCoordinate(
  kernelAssignmentContext: OnnxImportConvKernelAssignmentContext,
): { inputRow: number; inputColumn: number; } | null

Build input-space coordinate for one Conv kernel element.

Parameters:

Returns: Input coordinate when in bounds.

buildInputFeatureLinearIndex

buildInputFeatureLinearIndex(
  sourceLayout: OnnxImportConvSourceLayout,
  inChannelIndex: number,
  inputRow: number,
  inputColumn: number,
): number

Build linear feature index in input feature space.

Parameters:

Returns: Linear input feature index.

buildLayerNodePair

buildLayerNodePair(
  assignmentContext: OnnxImportWeightAssignmentContext,
  params: OnnxImportLayerNodePairBuildParams,
): OnnxImportLayerNodePair

Build current/previous node slices for one sequential import layer pass.

Parameters:

Returns: Layer node pair.

buildLayerTensorNames

buildLayerTensorNames(
  layerIndex: number,
): OnnxImportLayerTensorNames

Build dense weight/bias tensor names for one layer index.

Parameters:

Returns: Layer tensor names.

buildPerNeuronTensorNames

buildPerNeuronTensorNames(
  layerIndex: number,
  neuronIndex: number,
): OnnxImportLayerTensorNames

Build per-neuron tensor names for one layer and neuron index.

Parameters:

Returns: Per-neuron tensor names.

buildWeightAssignmentContext

buildWeightAssignmentContext(
  params: OnnxImportWeightAssignmentBuildParams,
): OnnxImportWeightAssignmentContext

Build the shared assignment context for import weight restoration.

Parameters:

Returns: Shared assignment context.

collectConvKernelCoordinates

collectConvKernelCoordinates(
  inChannels: number,
  kernelHeight: number,
  kernelWidth: number,
): OnnxConvKernelCoordinate[]

Collect all kernel traversal coordinates for one Conv output position.

Parameters:

Returns: Kernel traversal coordinates.

collectConvOutputCoordinates

collectConvOutputCoordinates(
  convSpec: Conv2DMapping,
  outChannels: number,
): OnnxImportConvOutputCoordinate[]

Collect all output traversal coordinates for one Conv layer.

Parameters:

Returns: Output traversal coordinates.

collectLayerWeightBuckets

collectLayerWeightBuckets(
  initializers: OnnxTensor[],
): Record<string, OnnxImportLayerWeightBucket>

Collect ONNX weight tensor buckets grouped by export layer index.

Parameters:

Returns: Layer-weight buckets keyed by export layer index.

collectNodesByType

collectNodesByType(
  nodes: default[],
  nodeType: "hidden" | "input" | "output",
): default[]

Collect nodes by runtime node type discriminator.

Parameters:

Returns: Filtered nodes.

collectSortedLayerIndices

collectSortedLayerIndices(
  layerWeightBuckets: Record<string, OnnxImportLayerWeightBucket>,
): number[]

Collect sorted layer indices from weight buckets.

Parameters:

Returns: Ascending export layer indices.

collectSortedUniqueLayerIndices

collectSortedUniqueLayerIndices(
  initializerMap: Record<string, OnnxTensor>,
): number[]

Collect unique sorted layer indices from initializer weight tensors.

Parameters:

Returns: Unique sorted layer indices.

deriveHiddenLayerSizes

deriveHiddenLayerSizes(
  initializers: OnnxTensor[],
  metadataProps: OnnxMetadataProperty[] | undefined,
): number[]

Derive hidden-layer sizes from ONNX weight initializers in export order.

Parameters:

Returns: Hidden layer sizes in order.

hasAggregatedLayerWeights

hasAggregatedLayerWeights(
  aggregatedContext: OnnxImportAggregatedLayerAssignmentContext,
): boolean

Determine whether the layer has aggregated weight tensor data.

Parameters:

Returns: True when aggregated tensor exists.

hydrateSharedInitializerAliases

hydrateSharedInitializerAliases(
  initializerMap: Record<string, OnnxTensor>,
  metadataProps: OnnxMetadataProperty[],
): void

Hydrate alias tensor names back into the initializer map for metadata-backed shared initializers.

parseConvMetadata

parseConvMetadata(
  metadataProps: OnnxMetadataProperty[],
): OnnxImportConvMetadata | null

Parse Conv reconstruction metadata payload.

Parameters:

Returns: Parsed Conv metadata.

parseLayerIndexFromWeightTensor

parseLayerIndexFromWeightTensor(
  tensorName: string,
): number | null

Parse layer index from dense/per-neuron weight tensor name.

Parameters:

Returns: Parsed layer index or null.

parseMetadataLayerSizes

parseMetadataLayerSizes(
  metadataProps: OnnxMetadataProperty[],
): number[] | null

Parse explicit metadata-driven hidden layer sizes.

Parameters:

Returns: Parsed hidden layer sizes when available.

parseSharedInitializerAliases

parseSharedInitializerAliases(
  metadataProps: OnnxMetadataProperty[],
): { aliasTensorName: string; canonicalTensorName: string; }[]

Parse valid shared-initializer alias metadata records from ONNX metadata.

parseWeightTensorName

parseWeightTensorName(
  tensorName: string,
): { layerIndex: string; neuronIndex: number | null; } | null

Parse layer/neuron components from a weight tensor name.

Parameters:

Returns: Parsed layer+neuron components when matched.

readConvKernelWeight

readConvKernelWeight(
  kernelAssignmentContext: OnnxImportConvKernelAssignmentContext,
): number

Read one Conv kernel weight from flattened ONNX tensor payload.

Parameters:

Returns: Kernel weight.

resetInboundConnectionWeights

resetInboundConnectionWeights(
  neuronInternal: NodeInternals,
): void

Reset all inbound weights so Conv reconstruction can write only receptive edges.

Parameters:

Returns: Nothing.

resolveCurrentLayerNodes

resolveCurrentLayerNodes(
  assignmentContext: OnnxImportWeightAssignmentContext,
  params: { layerIndex: number; },
): default[]

Resolve current layer nodes for one sequential layer assignment pass.

Parameters:

Returns: Current layer nodes.

resolveLayerHiddenSize

resolveLayerHiddenSize(
  layerWeightBuckets: Record<string, OnnxImportLayerWeightBucket>,
  layerIndex: number,
): number

Resolve one hidden-layer size from its weight bucket.

Parameters:

Returns: Hidden-layer size.

resolvePreviousLayerNodes

resolvePreviousLayerNodes(
  assignmentContext: OnnxImportWeightAssignmentContext,
  params: { layerIndex: number; },
): default[]

Resolve previous layer nodes for one sequential layer assignment pass.

Parameters:

Returns: Previous layer nodes.

sumHiddenSizesToIndex

sumHiddenSizesToIndex(
  hiddenLayerSizes: number[],
  exclusiveEndIndex: number,
): number

Sum hidden-layer sizes from index 0 to exclusiveEndIndex.

Parameters:

Returns: Prefix sum.

architecture/network/onnx/import/network.onnx.import-activations.utils.ts

appendOperationToLayer

appendOperationToLayer(
  operationsByLayer: OnnxActivationLayerOperations,
  layerIndex: number,
  operation: OnnxActivationOperation,
): void

Append one operation to the lookup bucket for a layer.

Parameters:

Returns: Nothing.

applyHiddenLayerActivations

applyHiddenLayerActivations(
  context: OnnxActivationAssignmentContext,
): void

Apply imported activation operations to hidden layer nodes.

Parameters:

Returns: Nothing.

applyHiddenLayerTraversalActivation

applyHiddenLayerTraversalActivation(
  traversalContext: HiddenLayerActivationTraversalContext,
): void

Apply activation operations for one hidden-layer traversal context.

Parameters:

Returns: Nothing.

applyHiddenLayerTraversalContexts

applyHiddenLayerTraversalContexts(
  traversalContexts: HiddenLayerActivationTraversalContext[],
): void

Apply hidden-layer activation assignment for each traversal context.

Parameters:

Returns: Nothing.

applyHiddenNeuronActivation

applyHiddenNeuronActivation(
  traversalContext: HiddenLayerActivationTraversalContext,
  neuronIndex: number,
): void

Apply one hidden neuron activation if the target node exists.

Parameters:

Returns: Nothing.

applyOutputLayerActivation

applyOutputLayerActivation(
  context: OnnxActivationAssignmentContext,
): void

Apply imported activation to all output nodes.

Parameters:

Returns: Nothing.

asNodeInternals

asNodeInternals(
  node: unknown,
): NodeInternals

Cast one public node instance to runtime node internals.

Parameters:

Returns: Runtime node internals.

assignActivationFunctions

assignActivationFunctions(
  network: default,
  onnx: OnnxModel,
  hiddenLayerSizes: number[],
): void

Assign runtime node activation functions from ONNX activation graph operations.

Parameters:

Returns: Nothing.

asSupportedActivationOperation

asSupportedActivationOperation(
  operationName: string,
): OnnxActivationOperation | null

Convert an ONNX op type to a supported activation operation.

Parameters:

Returns: Supported activation operation or null when unsupported.

buildActivationAssignmentContext

buildActivationAssignmentContext(
  sourceNetwork: default,
  sourceOnnx: OnnxModel,
  sourceHiddenLayerSizes: number[],
): OnnxActivationAssignmentContext

Build immutable assignment context for hidden/output activation import.

Parameters:

Returns: Prepared assignment context.

buildHiddenLayerTraversalContexts

buildHiddenLayerTraversalContexts(
  context: OnnxActivationAssignmentContext,
): HiddenLayerActivationTraversalContext[]

Build traversal contexts for each hidden layer.

Parameters:

Returns: Ordered hidden-layer traversal contexts.

buildHiddenNeuronIndices

buildHiddenNeuronIndices(
  hiddenLayerSize: number,
): number[]

Build contiguous hidden-neuron index list for one layer.

Parameters:

Returns: Ordered neuron indices.

collectNodeInternalsByType

collectNodeInternalsByType(
  sourceNetwork: default,
  targetType: string,
): NodeInternals[]

Collect node internals by runtime node type.

Parameters:

Returns: Runtime node internals matching the requested type.

collectOperationsByLayer

collectOperationsByLayer(
  sourceOnnx: OnnxModel,
): OnnxActivationLayerOperations

Collect ONNX activation operations grouped by export-layer index.

Parameters:

Returns: Layer-indexed activation operation lookup.

parseActivationNode

parseActivationNode(
  nodeName: string,
): OnnxActivationParseResult | null

Parse one ONNX activation node name.

Parameters:

Returns: Parsed layer/neuron metadata or null when not a supported activation node.

resolveActivationFunction

resolveActivationFunction(
  context: OnnxActivationOperationResolutionContext,
): ((x: number, derivate?: boolean | undefined) => number) & { name?: string | undefined; }

Resolve runtime activation function from operation context.

Parameters:

Returns: Runtime activation function.

resolveHiddenNode

resolveHiddenNode(
  traversalContext: HiddenLayerActivationTraversalContext,
  neuronIndex: number,
): NodeInternals | undefined

Resolve one hidden node by traversal/offset metadata.

Parameters:

Returns: Hidden node internals when present.

resolveLayerOperations

resolveLayerOperations(
  traversalContext: HiddenLayerActivationTraversalContext,
): OnnxActivationOperation[]

Resolve operations list for one hidden layer.

Parameters:

Returns: Ordered operations for target export layer.

resolveOperationByPriority

resolveOperationByPriority(
  context: OnnxActivationOperationResolutionContext,
): OnnxActivationOperation

Resolve activation operation by neuron-first then layer-default fallback.

Parameters:

Returns: Supported activation operation.

resolveOutputOperations

resolveOutputOperations(
  context: OutputLayerActivationContext,
): OnnxActivationOperation[]

Resolve output-layer operations from shared lookup.

Parameters:

Returns: Ordered output-layer operations.

architecture/network/onnx/import/network.onnx.import-orchestrators.types.ts

Import-owned type surface for ONNX architecture reconstruction orchestration.

These payloads stay close to the orchestration helpers that parse terminal dimensions, restore recurrent self-connections, and attach pooling metadata. Keeping them here makes the import chapter explain its own execution state without forcing the root ONNX compatibility barrel to remain the ownership home for importer-only details.

NetworkWithOnnxImportAdvancedGraph

Network instance augmented with optional imported advanced-graph metadata via the _onnxAdvancedGraph field.

NetworkWithOnnxImportPooling

Network instance augmented with optional imported ONNX pooling metadata via the _onnxPooling field.

OnnxImportAdvancedGraphCrossLayerConnection

Audit-only cross-layer feed-forward edge carried through Phase 5 import fallback.

OnnxImportAdvancedGraphMetadata

Parsed advanced-graph metadata attached to imported network instances, grouping merges, residual adds, and blocks.

OnnxImportArchitectureContext

Shared architecture extraction context with resolved graph dimensions, initializers, and metadata properties.

OnnxImportArchitectureResult

Parsed architecture dimensions extracted from ONNX import graph payloads, with input, output, and hidden sizes.

OnnxImportAttentionBlock

Explicit fixed-width self-attention block carried through Phase 5 import fallback.

OnnxImportConcatMerge

Explicit concat merge carried through Phase 5 import hardening, identifying layer indices and merge tensor names.

OnnxImportDimensionRecord

Loose ONNX shape-dimension record used by legacy import payload access.

OnnxImportFlattenConsistencyAudit

Metadata-only audit record comparing a flattened pooled width to the next dense width.

OnnxImportHiddenLayerSpan

Hidden-layer span payload with one-based layer numbering and global offset.

OnnxImportLayerConnectionContext

Execution context for assigning one hidden-layer recurrent diagonal tensor, carrying model, nodes, and span.

OnnxImportPoolingMetadata

Parsed pooling metadata payload attached to imported network instances, listing pool specs and virtual shapes.

OnnxImportPoolingVirtualShape

Virtual spatial shape derived from Conv and Pool metadata during import.

OnnxImportRecurrentRestorationContext

Context for recurrent self-connection restoration from ONNX metadata and tensors.

OnnxImportResidualAdd

Explicit one-hop residual-add merge carried through Phase 5 import hardening.

OnnxImportSelfConnectionUpsertContext

Context for upserting one hidden node self-connection from recurrent weight.

OnnxImportSharedInitializerAlias

Audit-only shared initializer alias carried through Phase 5 import fallback.

architecture/network/onnx/import/network.onnx.import-orchestrators.utils.ts

Restore recurrent self-connections from recurrent metadata and R tensors. Restoration uses metadata-gated span resolution and diagonal tensor extraction so imported recurrent units recover their self-feedback semantics without guessing hidden-node layout.

applyLayerSelfConnections

applyLayerSelfConnections(
  layerConnectionContext: OnnxImportLayerConnectionContext,
): void

Apply one hidden layer diagonal recurrent self-weights.

Parameters:

Returns: Nothing.

attachOnnxAdvancedGraphMetadata

attachOnnxAdvancedGraphMetadata(
  network: default,
  metadata: OnnxMetadataProperty[],
  onnx: OnnxModel | undefined,
): void

Attach optional advanced-graph audit metadata from ONNX model metadata.

Phase 5 starts with honest fallback: import keeps rebuilding the layered baseline, but it can still preserve the exact cross-layer feed-forward edges the exporter detected so later residual, concat, and attention passes have a deterministic seam to reuse.

Parameters:

Returns: Nothing.

attachOnnxPoolingMetadata

attachOnnxPoolingMetadata(
  network: default,
  metadata: OnnxMetadataProperty[],
): void

Attach optional pooling metadata from ONNX model to network instance. The importer keeps pooling metadata as additive diagnostics state so later runtime or visualization tooling can reason about spatial stages without modifying core graph wiring.

Parameters:

Returns: Nothing.

attachParsedPoolingMetadata

attachParsedPoolingMetadata(
  network: default,
  poolingMetadata: OnnxImportPoolingMetadata,
): void

Attach parsed pooling metadata to imported network instance.

Parameters:

Returns: Nothing.

buildArchitectureContext

buildArchitectureContext(
  onnx: OnnxModel,
): OnnxImportArchitectureContext

Build architecture extraction context from ONNX graph state.

Parameters:

Returns: Normalized architecture extraction context.

buildHiddenLayerSpans

buildHiddenLayerSpans(
  hiddenLayerSizes: number[],
): OnnxImportHiddenLayerSpan[]

Build hidden-layer spans with one-based layer numbering and global offsets.

Parameters:

Returns: Hidden-layer span payload list.

buildImportedLayers

buildImportedLayers(
  network: default,
  hiddenLayerSizes: number[],
): default[][]

Build the imported layer ordering from runtime nodes and hidden-layer widths.

buildVirtualPoolingShape

buildVirtualPoolingShape(
  poolingSpec: Pool2DMapping,
  convSpec: Conv2DMapping,
  flattenLayerSet: Set<number>,
): OnnxImportPoolingVirtualShape | null

Build one virtual pooled shape from the pre-pool Conv output shape.

Parameters:

Returns: Virtual pooled shape when the metadata is usable.

calculateSpatialOutputSize

calculateSpatialOutputSize(
  inputSize: number,
  kernelSize: number,
  strideSize: number,
  leadingPadding: number,
  trailingPadding: number,
): number

Calculate one pooled spatial output size from kernel, stride, and padding metadata.

Parameters:

Returns: Derived output size, or zero when the metadata is unusable.

collectAvailableConvSpecs

collectAvailableConvSpecs(
  metadata: OnnxMetadataProperty[],
): Conv2DMapping[]

Collect explicit and inferred Conv specs that can anchor pooling shape simulation.

Parameters:

Returns: Layer-indexed Conv specs, preferring explicit specs over inferred ones.

collectDiagonalRecurrentWeights

collectDiagonalRecurrentWeights(
  recurrentTensorWeights: number[],
  hiddenLayerSize: number,
): number[]

Collect diagonal recurrent weights from flattened layer tensor data.

Parameters:

Returns: Diagonal recurrent self-weights.

collectFlattenConsistencyAudit

collectFlattenConsistencyAudit(
  virtualShapes: OnnxImportPoolingVirtualShape[],
  hiddenLayerSizes: number[],
  outputCount: number,
): OnnxImportFlattenConsistencyAudit[]

Collect flatten-consistency audit records for virtual pooled shapes with flatten metadata.

Parameters:

Returns: Metadata-only flatten-consistency audit records.

collectFusedRecurrentGateWeights

collectFusedRecurrentGateWeights(
  recurrentTensorWeights: number[],
  unitSize: number,
): number[]

Collect diagonal recurrent weights from the recurrent gate block inside a fused tensor.

Parameters:

Returns: Diagonal recurrent self-weights for the recurrent gate slice.

collectNodesByType

collectNodesByType(
  nodes: default[],
  nodeType: "hidden" | "input" | "output",
): default[]

Collect nodes matching one runtime node-type discriminator.

Parameters:

Returns: Filtered node list.

collectPerceptronBoundaryNodes

collectPerceptronBoundaryNodes(
  nodes: default[],
): default[]

Collect input and output boundary nodes for perceptron imports.

Parameters:

Returns: Input/output-only node list.

collectRecurrentLayerSpans

collectRecurrentLayerSpans(
  restorationContext: OnnxImportRecurrentRestorationContext,
): OnnxImportHiddenLayerSpan[]

Resolve recurrent-target hidden-layer spans from metadata + hidden sizes.

Parameters:

Returns: Hidden-layer spans requiring recurrent restoration.

collectVirtualPoolingShapes

collectVirtualPoolingShapes(
  poolingSpecs: Pool2DMapping[],
  convSpecs: Conv2DMapping[],
  flattenLayers: number[],
): OnnxImportPoolingVirtualShape[]

Derive virtual pooled shapes from Conv and Pool metadata without changing weights.

Parameters:

Returns: Derived virtual pooled shapes for future consistency checks.

extractOnnxArchitecture

extractOnnxArchitecture(
  onnx: OnnxModel,
): OnnxImportArchitectureResult

Extract input/output counts and hidden layer sizes from ONNX model. This architecture probe normalizes graph terminal dimensions and initializer-derived hidden spans into one deterministic result contract used by all downstream reconstruction passes.

Parameters:

Returns: Parsed architecture dimensions.

findFusedRecurrentInitializer

findFusedRecurrentInitializer(
  layerConnectionContext: OnnxImportLayerConnectionContext,
): OnnxTensor | undefined

Resolve a fused recurrent tensor for one hidden-layer span when generic Rk is absent.

Parameters:

Returns: Matching fused recurrent tensor when present.

findMetadataProperty

findMetadataProperty(
  metadata: OnnxMetadataProperty[],
  metadataKey: string,
): OnnxMetadataProperty | undefined

Find one ONNX metadata property by key.

Parameters:

Returns: Matching metadata property when present.

findRecurrentInitializer

findRecurrentInitializer(
  layerConnectionContext: OnnxImportLayerConnectionContext,
): OnnxTensor | undefined

Resolve recurrent initializer tensor for one hidden-layer span.

Parameters:

Returns: Recurrent initializer tensor when available.

inferRecurrentLayerIndicesFromInitializers

inferRecurrentLayerIndicesFromInitializers(
  hiddenLayerSizes: number[],
  onnx: OnnxModel,
): number[]

Infer recurrent layer indices from plain recurrent tensors when metadata is absent.

Parameters:

Returns: One-based recurrent layer indices inferred from Rk tensors.

isAdvancedGraphCrossLayerConnection

isAdvancedGraphCrossLayerConnection(
  value: unknown,
): boolean

Validate one parsed cross-layer audit record.

Parameters:

Returns: Whether the value matches the expected metadata shape.

isAttentionBlock

isAttentionBlock(
  value: unknown,
): boolean

Validate one parsed fixed-width self-attention audit record.

isResidualAdd

isResidualAdd(
  value: unknown,
): boolean

Validate one parsed residual-add record.

isSharedInitializerAlias

isSharedInitializerAlias(
  value: unknown,
): boolean

Validate one parsed shared-initializer alias audit record.

isSingleLayerPerceptronImport

isSingleLayerPerceptronImport(
  hiddenLayerSizes: number[],
): boolean

Determine whether import shape corresponds to a single-layer perceptron.

Parameters:

Returns: True when no hidden layers exist.

normalizeRecurrentLayerIndices

normalizeRecurrentLayerIndices(
  parsedMetadataValue: string | number | boolean | number[] | Record<string, number> | null,
): number[]

Normalize recurrent layer indices parsed from metadata JSON.

Parameters:

Returns: Recurrent layer indices.

parseAdvancedGraphCrossLayerConnections

parseAdvancedGraphCrossLayerConnections(
  metadata: OnnxMetadataProperty[],
): OnnxImportAdvancedGraphCrossLayerConnection[] | null

Parse valid cross-layer feed-forward audit metadata.

parseAdvancedGraphMetadata

parseAdvancedGraphMetadata(
  metadata: OnnxMetadataProperty[],
  onnx: OnnxModel | undefined,
): OnnxImportAdvancedGraphMetadata | null

Parse advanced-graph cross-layer metadata from ONNX metadata.

Parameters:

Returns: Parsed advanced-graph metadata, or null when absent or invalid.

parseAttentionBlockMetadata

parseAttentionBlockMetadata(
  metadata: OnnxMetadataProperty[],
  onnx: OnnxModel | undefined,
): OnnxImportAttentionBlock[] | null

Parse valid fixed-width self-attention audit metadata.

parseOptionalConvSpecs

parseOptionalConvSpecs(
  metadata: OnnxMetadataProperty[],
  metadataKey: string,
): Conv2DMapping[]

Parse one optional Conv spec metadata field.

Parameters:

Returns: Parsed Conv specs or an empty list when absent/invalid.

parseOptionalLayerIndicesMetadata

parseOptionalLayerIndicesMetadata(
  metadata: OnnxMetadataProperty[],
  metadataKey: string,
): number[]

Parse one optional layer-index metadata field.

Parameters:

Returns: Parsed layer indices or an empty list when absent/invalid.

parsePoolingMetadata

parsePoolingMetadata(
  network: default,
  metadata: OnnxMetadataProperty[],
): OnnxImportPoolingMetadata | null

Parse pooling metadata payload from ONNX metadata.

Parameters:

Returns: Parsed pooling metadata payload.

parseRecurrentLayerIndices

parseRecurrentLayerIndices(
  rawMetadataValue: string,
): number[]

Parse recurrent layer indices metadata.

Parameters:

Returns: Normalized recurrent layer indices.

parseResidualAddMetadata

parseResidualAddMetadata(
  metadata: OnnxMetadataProperty[],
): OnnxImportResidualAdd[] | null

Parse valid one-hop residual-add metadata.

parseSharedInitializerAliases

parseSharedInitializerAliases(
  metadata: OnnxMetadataProperty[],
): OnnxImportSharedInitializerAlias[] | null

Parse valid shared-initializer alias audit metadata.

pruneSingleLayerHiddenPlaceholders

pruneSingleLayerHiddenPlaceholders(
  network: default,
  hiddenLayerSizes: number[],
): void

Remove placeholder hidden nodes that arise from single-layer perceptron imports.

Parameters:

Returns: Nothing.

readLastDimensionValue

readLastDimensionValue(
  dimensions: { dim_value?: number | undefined; }[],
): number

Read the terminal ONNX shape dimension value from one shape array.

Parameters:

Returns: Terminal dim_value payload.

reconstructFusedRecurrentLayers

reconstructFusedRecurrentLayers(
  network: default,
  onnx: OnnxModel,
  hiddenLayerSizes: number[],
  layerFactory: OnnxLayerFactory,
  metadata: OnnxMetadataProperty[],
): void

Contract for reconstructFusedRecurrentLayers.

resolveConsumerLayerWidth

resolveConsumerLayerWidth(
  consumerLayerIndex: number,
  hiddenLayerSizes: number[],
  outputCount: number,
): number | undefined

Resolve the width of the next dense consumer after one flattened pooling site.

Parameters:

Returns: Consumer width when a dense consumer exists.

resolveRecurrentLayerIndices

resolveRecurrentLayerIndices(
  hiddenLayerSizes: number[],
  metadata: OnnxMetadataProperty[],
  onnx: OnnxModel,
): number[]

Resolve recurrent layer indices from ONNX metadata.

Parameters:

Returns: Parsed recurrent layer indices.

resolveResidualWeight

resolveResidualWeight(
  residualWeights: number[],
  sourceLayerWidth: number,
  sourceLayerIndex: number,
  targetLayerIndex: number,
): number

Resolve one residual branch weight from a row-major target-by-source matrix.

restoreRecurrentSelfConnections

restoreRecurrentSelfConnections(
  network: default,
  onnx: OnnxModel,
  hiddenLayerSizes: number[],
  metadata: OnnxMetadataProperty[],
): void

Contract for restoreRecurrentSelfConnections.

restoreResidualAddConnections

restoreResidualAddConnections(
  network: default,
  onnx: OnnxModel,
  hiddenLayerSizes: number[],
  metadata: OnnxMetadataProperty[],
): void

Restore supported one-hop residual-add skip connections from ONNX metadata.

The import side stays conservative: it only rehydrates skip edges when the exporter recorded both the residual merge intent and the exact cross-layer edge list, and when the residual branch tensor is still present.

Parameters:

Returns: Nothing.

restoreSingleResidualAddConnections

restoreSingleResidualAddConnections(
  network: default,
  onnx: OnnxModel,
  importedLayers: default[][],
  crossLayerConnections: OnnxImportAdvancedGraphCrossLayerConnection[],
  residualAdd: OnnxImportResidualAdd,
): void

Restore one residual-add branch using the recorded edge list and residual weight tensor.

sliceLayerHiddenNodes

sliceLayerHiddenNodes(
  layerConnectionContext: OnnxImportLayerConnectionContext,
): default[]

Slice hidden nodes for one hidden-layer span.

Parameters:

Returns: Hidden nodes belonging to the span.

upsertFeedForwardConnection

upsertFeedForwardConnection(
  sourceNode: default,
  targetNode: default,
  weight: number,
): void

Upsert one feed-forward connection between two runtime nodes.

upsertSelfConnection

upsertSelfConnection(
  selfConnectionContext: OnnxImportSelfConnectionUpsertContext,
): void

Upsert one node self-connection for recurrent import restoration.

Parameters:

Returns: Nothing.

architecture/network/onnx/import/network.onnx.import-fused-recurrent.types.ts

OnnxFusedGateApplicationContext

Gate-weight application context for one reconstructed fused layer, carrying spec, unit size, and weight arrays.

OnnxFusedGateRowAssignmentContext

Context for assigning one gate-neuron row from flattened ONNX tensors.

OnnxFusedLayerNeighborhood

Hidden-layer neighborhood slices around a reconstructed fused layer, including old, previous, and next node lists.

OnnxFusedLayerReconstructionContext

Execution context for one fused recurrent layer reconstruction, carrying spec, export index, and hidden layer index.

OnnxFusedLayerRuntime

Runtime interface of a reconstructed fused recurrent layer instance.

The importer only relies on a narrow runtime contract: access to the reconstructed nodes, an input wiring hook, and an optional output group that can be reconnected to the next restored layer.

OnnxFusedRecurrentKind

Supported fused recurrent operator families recognized during ONNX import, currently limited to LSTM and GRU.

OnnxFusedRecurrentSpec

Fused recurrent family specification used during import reconstruction.

This tells the importer how to interpret one emitted ONNX recurrent family: how many gates to expect, what order those gates were serialized in, and which gate owns the self-recurrent diagonal replay.

OnnxFusedTensorPayload

Fused recurrent tensor payload read from ONNX initializers.

The importer resolves the three recurrent tensor families up front so the reconstruction pass can focus on wiring and row assignment instead of repeatedly re-looking up initializers.

OnnxIncomingWeightAssignmentContext

Context for assigning dense incoming weights for one gate-neuron row.

architecture/network/onnx/import/network.onnx.import-fused-recurrent.utils.ts

Reconstruct emitted fused LSTM/GRU layers from ONNX metadata and initializers.

applyGateWeights

applyGateWeights(
  context: OnnxFusedGateApplicationContext,
): void

Apply imported gate parameters to a reconstructed fused layer.

Parameters:

Returns: Nothing.

assignGateRow

assignGateRow(
  context: OnnxFusedGateRowAssignmentContext,
): void

Assign one gate-neuron row parameters.

Parameters:

Returns: Nothing.

assignIncomingWeightAtColumn

assignIncomingWeightAtColumn(
  context: OnnxIncomingWeightAssignmentContext,
  columnIndex: number,
): void

Assign one incoming connection weight by source-column index.

Parameters:

Returns: Nothing.

assignIncomingWeights

assignIncomingWeights(
  context: OnnxIncomingWeightAssignmentContext,
): void

Assign dense incoming weights for one gate neuron.

Parameters:

Returns: Nothing.

assignRecurrentDiagonalWeight

assignRecurrentDiagonalWeight(
  context: OnnxFusedGateRowAssignmentContext,
): void

Assign one recurrent diagonal self-weight.

Parameters:

Returns: Nothing.

assignRecurrentIncomingWeightAtColumn

assignRecurrentIncomingWeightAtColumn(
  context: OnnxFusedGateRowAssignmentContext,
  columnIndex: number,
): void

Assign one recurrent incoming weight from the native GRU previous-output carrier into the current gate neuron.

Parameters:

Returns: Nothing.

assignRecurrentWeights

assignRecurrentWeights(
  context: OnnxFusedGateRowAssignmentContext,
): void

Assign recurrent weights for one fused gate row.

Parameters:

Returns: Nothing.

buildContiguousGateGroups

buildContiguousGateGroups(
  fusedNodes: default[],
  gateOrder: string[],
  unitSize: number,
): Record<string, default[]>

Build contiguous gate groups from one fused node list.

Parameters:

Returns: Gate-name to neuron-list map.

createFusedLayerRuntime

createFusedLayerRuntime(
  layerFactory: OnnxLayerFactory,
  spec: OnnxFusedRecurrentSpec,
  unitSize: number,
): OnnxFusedLayerRuntime

Create one fused recurrent runtime layer instance.

Parameters:

Returns: Runtime fused layer.

createFusedRecurrentSpecs

createFusedRecurrentSpecs(): OnnxFusedRecurrentSpec[]

Build fused recurrent family specifications.

Returns: Family specifications.

createHiddenLayerRange

createHiddenLayerRange(
  hiddenLayerSizes: number[],
  hiddenLayerIndex: number,
): { start: number; end: number; }

Create hidden-range boundaries for one hidden-layer index.

Parameters:

Returns: Start and end boundaries.

createImmutableSplicedArray

createImmutableSplicedArray(
  source: TItem[],
  start: number,
  deleteCount: number,
  insertItems: TItem[],
): TItem[]

Create an immutable spliced copy, with a compatibility fallback when ES2023 toSpliced is typed as optional in ambient declarations.

Parameters:

Returns: New array containing the splice result.

createPreviousLayerSourceGroup

createPreviousLayerSourceGroup(
  previousLayerNodes: default[],
): PreviousLayerSourceGroup

Create a source group compatible with both runtime Layer input wiring and the existing mock fused-layer tests.

Parameters:

Returns: Group-like source wrapper.

deriveLayerNeighborhood

deriveLayerNeighborhood(
  network: default,
  hiddenLayerSizes: number[],
  hiddenLayerIndex: number,
): OnnxFusedLayerNeighborhood

Derive hidden-layer neighborhood slices for replacement traversal.

Parameters:

Returns: Layer neighborhood.

deriveNextLayerNodes

deriveNextLayerNodes(
  network: default,
  hiddenLayerSizes: number[],
  hiddenLayerIndex: number,
  hiddenNodes: default[],
): default[]

Derive next-layer nodes for a hidden layer.

Parameters:

Returns: Next-layer nodes.

derivePreviousLayerNodes

derivePreviousLayerNodes(
  network: default,
  hiddenLayerSizes: number[],
  hiddenLayerIndex: number,
  hiddenNodes: default[],
): default[]

Derive previous-layer nodes for a hidden layer.

Parameters:

Returns: Previous-layer nodes.

deriveUnitSize

deriveUnitSize(
  rows: number,
  gateCount: number,
): number | null

Derive hidden unit size from recurrent row count and gate count.

Parameters:

Returns: Unit size when compatible.

detachOldLayerConnections

detachOldLayerConnections(
  network: default,
  neighborhood: OnnxFusedLayerNeighborhood,
): void

Detach all connections touching replaced hidden-layer nodes.

Parameters:

Returns: Nothing.

filterNodesByType

filterNodesByType(
  network: default,
  nodeType: string,
): default[]

Filter network nodes by semantic type.

Parameters:

Returns: Filtered node collection.

findInitializerTensor

findInitializerTensor(
  onnx: OnnxModel,
  kind: OnnxFusedRecurrentKind,
  suffix: string,
  hiddenLayerIndex: number,
): OnnxTensor | undefined

Find one initializer tensor by fused family naming convention.

Parameters:

Returns: Initializer tensor when found.

isValidHiddenLayerIndex

isValidHiddenLayerIndex(
  hiddenLayerSizes: number[],
  hiddenLayerIndex: number,
): boolean

Validate hidden-layer index boundaries.

Parameters:

Returns: True when index is valid.

parseEmittedLayerIndices

parseEmittedLayerIndices(
  metadata: OnnxMetadataProperty[],
  spec: OnnxFusedRecurrentSpec,
): number[]

Parse exported layer indices from metadata for one fused family.

Parameters:

Returns: Export-layer indices.

parseMetadataJsonArray

parseMetadataJsonArray(
  metadataValue: string,
): number[]

Parse metadata JSON payload as an array of indices.

Parameters:

Returns: Parsed index array.

reconstructAllFusedFamilies

reconstructAllFusedFamilies(
  scope: FusedRecurrentImportScope,
  specs: OnnxFusedRecurrentSpec[],
): void

Reconstruct all fused recurrent families declared by metadata.

Parameters:

Returns: Nothing.

reconstructFusedRecurrentLayers

reconstructFusedRecurrentLayers(
  network: default,
  onnx: OnnxModel,
  hiddenLayerSizes: number[],
  layerFactory: OnnxLayerFactory,
  metadata: OnnxMetadataProperty[],
): void

Contract for reconstructFusedRecurrentLayers.

reconstructOneFusedFamily

reconstructOneFusedFamily(
  scope: FusedRecurrentImportScope,
  spec: OnnxFusedRecurrentSpec,
): void

Reconstruct one fused family across all emitted layer indices.

Parameters:

Returns: Nothing.

reconstructOneFusedLayer

reconstructOneFusedLayer(
  scope: FusedRecurrentImportScope,
  context: OnnxFusedLayerReconstructionContext,
): void

Reconstruct one fused layer from metadata and ONNX initializers.

Parameters:

Returns: Nothing.

replaceHiddenNodes

replaceHiddenNodes(
  network: default,
  neighborhood: OnnxFusedLayerNeighborhood,
  replacementNodes: default[],
): void

Replace hidden node segment with reconstructed fused layer nodes.

Parameters:

Returns: Nothing.

resolveFusedTensors

resolveFusedTensors(
  onnx: OnnxModel,
  context: OnnxFusedLayerReconstructionContext,
): OnnxFusedTensorPayload | null

Resolve ONNX fused tensors for one hidden layer.

Parameters:

Returns: Tensor payload when fully available.

resolveGateGroups

resolveGateGroups(
  fusedNodes: default[],
  spec: OnnxFusedRecurrentSpec,
  unitSize: number,
): { gateGroups: Record<string, default[]>; recurrentSourceNodes: default[]; }

Resolve gate groups and recurrent source nodes from one fused runtime layout.

Parameters:

Returns: Gate groups plus recurrent-source nodes.

resolveGruGateGroups

resolveGruGateGroups(
  fusedNodes: default[],
  unitSize: number,
): { gateGroups: Record<string, default[]>; recurrentSourceNodes: default[]; }

Resolve GRU gate groups for either the native six-group layout or the compact three-gate mock layout used by owner-local tests.

Parameters:

Returns: Gate-name to neuron-list map plus recurrent-source nodes.

sumHiddenLayerSizes

sumHiddenLayerSizes(
  hiddenLayerSizes: number[],
  startIndex: number,
  endIndex: number,
): number

Sum hidden-layer sizes over a half-open range.

Parameters:

Returns: Summed size.

toHiddenLayerIndex

toHiddenLayerIndex(
  exportLayerIndex: number,
): number

Convert export-layer index to hidden-layer index.

Parameters:

Returns: Hidden-layer index.

wireFusedLayer

wireFusedLayer(
  fusedLayerRuntime: OnnxFusedLayerRuntime,
  previousLayerNodes: default[],
  nextLayerNodes: default[],
): void

Wire fused layer between previous and next layer slices.

Parameters:

Returns: Nothing.

architecture/network/onnx/import/network.onnx.import-external.types.ts

DecodedExternalOnnxAttribute

Decoded ONNX attribute payload preserving scalar, integer, and byte-string forms emitted by the protobuf decoder. Attribute decoding uses this shape before operation-specific coercion into importer contracts.

DecodedExternalOnnxDimension

Decoded ONNX dimension payload used by external import parsing to preserve symbolic and numeric shape information from protobuf conversion. Import normalization relies on this shape to reconstruct rank and axis semantics before tensor compatibility checks run.

DecodedExternalOnnxGraph

Decoded ONNX graph payload containing decoded graph interfaces, initializer tables, and ordered node records for external import orchestration. Graph traversal, initializer indexing, and topology validation all begin from this representation.

DecodedExternalOnnxModel

Decoded ONNX model payload containing optional graph content and operator-set imports used to validate supported external import lanes. External import entrypoints decode into this shape before compatibility and topology checks proceed.

DecodedExternalOnnxNode

Decoded ONNX node payload describing operator identity, wiring, and decoded attribute list for importer normalization passes. Node-level validation and operator support checks consume this schema directly.

DecodedExternalOnnxOpsetImport

Decoded ONNX operator-set import payload carrying the domain string and version number used by external import compatibility checks.

DecodedExternalOnnxTensor

Decoded ONNX tensor payload containing name, data type, shape dimensions, and raw or float initializer storage fields. Initializer extraction and shape-matching code paths depend on this decoded tensor contract.

DecodedExternalOnnxTensorType

Decoded ONNX tensor-type payload describing element type and optional shape dimensions after external binary decode. This type bridges raw protobuf decode output and importer-owned tensor validation routines.

DecodedExternalOnnxValueInfo

Decoded ONNX value-info payload carrying named tensor metadata for graph inputs, outputs, and intermediate value descriptors. It allows importer passes to align tensor names, element types, and shapes across graph boundaries.

OnnxDecodedBytes

Union type for raw byte fields emitted by onnx-proto object conversion; accepts string, Uint8Array, or number-array representations.

OnnxDecodedLongLike

Union type for ONNX 64-bit integer fields decoded by onnx-proto; includes numeric, string, and toString-capable object forms to handle platform-specific long encoding.

OnnxExternalDenseChain

Canonical importer-owned dense chain derived from an accepted external binary graph, collecting opset version, IO widths, and an ordered layer list.

OnnxExternalDenseLayer

Canonical single-layer payload for the external dense import lane, carrying input and output widths, weight values, biases, and the resolved activation operator.

OnnxExternalImportError

Error raised when an external ONNX binary falls outside the first supported import lane.

OnnxExternalImportErrorCategory

Named rejection category set for the external import lane; each string label identifies a distinct failure class so callers can route errors without string matching.

architecture/network/onnx/import/network.onnx.import-concat.utils.ts

attachOnnxConcatMergeMetadata

attachOnnxConcatMergeMetadata(
  network: default,
  metadata: OnnxMetadataProperty[],
  onnx: OnnxModel | undefined,
): void

Attach validated concat-merge audit metadata to an imported network instance.

Parameters:

Returns: Nothing.

buildImportedLayers

buildImportedLayers(
  network: default,
  hiddenLayerSizes: number[],
): default[][]

Build the imported layer ordering from runtime nodes and hidden-layer widths.

collectNodesByType

collectNodesByType(
  nodes: default[],
  nodeType: "hidden" | "input" | "output",
): default[]

Collect nodes matching one runtime node-type discriminator.

findInitializer

findInitializer(
  onnx: OnnxModel,
  tensorName: string,
): OnnxTensor | undefined

Resolve one initializer by tensor name.

findMetadataProperty

findMetadataProperty(
  metadata: OnnxMetadataProperty[],
  metadataKey: string,
): OnnxMetadataProperty | undefined

Find one ONNX metadata property by key.

findNodeByName

findNodeByName(
  onnx: OnnxModel,
  nodeName: string,
): OnnxNode | undefined

Resolve one node by its deterministic export name.

isConcatMerge

isConcatMerge(
  value: unknown,
): boolean

Validate one parsed concat-merge record.

matchesExportedConcatMergeSubset

matchesExportedConcatMergeSubset(
  onnx: OnnxModel,
  concatMerge: OnnxImportConcatMerge,
): boolean

Validate the same-family explicit concat subset emitted by this exporter.

parseConcatMergeMetadata

parseConcatMergeMetadata(
  metadata: OnnxMetadataProperty[],
  onnx: OnnxModel,
): OnnxImportConcatMerge[] | null

Parse valid explicit concat-merge metadata.

resolveConcatMergeWeight

resolveConcatMergeWeight(
  mergedWeights: number[],
  mergedSourceWidth: number,
  previousLayerWidth: number,
  targetLayerIndex: number,
  sourceLayerIndex: number,
): number

Resolve one concat branch weight from the widened row-major target-by-merged-source matrix.

restoreConcatMergeConnections

restoreConcatMergeConnections(
  network: default,
  onnx: OnnxModel,
  hiddenLayerSizes: number[],
  metadata: OnnxMetadataProperty[],
): void

Restore supported concat-merge skip connections from ONNX metadata.

The import side stays narrow and deterministic: it only rebuilds skipped source-layer fan-in for the explicit concat subset emitted by the exporter, using the widened dense weight tensor tail while the ordinary adjacent-layer slice remains assigned by the baseline dense import path.

Parameters:

Returns: Nothing.

restoreSingleConcatMergeConnections

restoreSingleConcatMergeConnections(
  onnx: OnnxModel,
  importedLayers: default[][],
  concatMerge: OnnxImportConcatMerge,
): void

Restore one concat-merge branch using the widened dense weight tensor tail.

upsertFeedForwardConnection

upsertFeedForwardConnection(
  sourceNode: default,
  targetNode: default,
  weight: number,
): void

Upsert one feed-forward connection between two runtime nodes.

architecture/network/onnx/import/network.onnx.import-external.utils.ts

normalizeExternalBinaryOnnxModel

normalizeExternalBinaryOnnxModel(
  binaryModel: Uint8Array<ArrayBufferLike>,
): OnnxModel

Normalize the first supported external binary ONNX subset into an importer-owned model.

Parameters:

Returns: Canonical JSON-first model that the existing import flow can reconstruct.

normalizeExternalDenseChain

normalizeExternalDenseChain(
  binaryModel: Uint8Array<ArrayBufferLike>,
): OnnxExternalDenseChain

Normalize the first supported external binary ONNX subset into a canonical dense chain.

Parameters:

Returns: Canonical dense-chain payload for importer reconstruction.

Generated from source JSDoc • GitHub