@reicek/neataptic-ts 0.1.25 → 0.1.26
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/copilot-instructions.md +11 -0
- package/.github/skills/trace-analyzer-extension/SKILL.md +3 -3
- package/.github/skills/trace-analyzer-extension/assets/extension-checklist.md +1 -1
- package/.github/skills/trace-analyzer-extension/references/analyzer-extension-workflow.md +1 -1
- package/.github/skills/trace-audit-reporting/SKILL.md +3 -3
- package/.github/skills/trace-audit-reporting/references/trace-analysis-workflow.md +1 -1
- package/package.json +19 -13
- package/plans/Flappy_Bird_Folder_Documentation_Pass.md +4 -4
- package/plans/README.md +24 -0
- package/plans/Roadmap.md +62 -40
- package/plans/analyze-trace-solid-split.plans.md +66 -0
- package/plans/architecture-solid-split.plans.md +9 -15
- package/plans/asciiMaze-typescript-repair.plans.md +1 -1
- package/plans/generate-docs-solid-split.plans.md +87 -0
- package/plans/methods-docs.plans.md +25 -1
- package/plans/methods-solid-split.plans.md +14 -14
- package/plans/neat-docs.plans.md +9 -1
- package/plans/neat-test-surface-repair.plans.md +1 -1
- package/plans/render-docs-html-solid-split.plans.md +68 -0
- package/plans/src-no-explicit-any-cleanup.plans.md +1 -1
- package/plans/utils-docs.plans.md +6 -1
- package/scripts/analyze-trace/analyze-trace.analysis.ts +479 -0
- package/scripts/analyze-trace/analyze-trace.constants.ts +35 -0
- package/scripts/analyze-trace/analyze-trace.io.ts +69 -0
- package/scripts/analyze-trace/analyze-trace.report.ts +100 -0
- package/scripts/analyze-trace/analyze-trace.shared.ts +116 -0
- package/scripts/analyze-trace/analyze-trace.ts +45 -0
- package/scripts/analyze-trace/analyze-trace.types.ts +72 -0
- package/scripts/assets/theme.css +80 -23
- package/scripts/copy-examples.ts +239 -0
- package/scripts/export-onnx.ts +223 -0
- package/scripts/generate-bench-tables.ts +378 -37
- package/scripts/generate-docs/generate-docs.constants.ts +107 -0
- package/scripts/generate-docs/generate-docs.order.ts +355 -0
- package/scripts/generate-docs/generate-docs.state.ts +31 -0
- package/scripts/generate-docs/generate-docs.targets.ts +165 -0
- package/scripts/generate-docs/generate-docs.ts +63 -0
- package/scripts/generate-docs/generate-docs.types.ts +112 -0
- package/scripts/generate-docs/output/generate-docs.output.folder-index.utils.ts +167 -0
- package/scripts/generate-docs/output/generate-docs.output.ordering.utils.ts +353 -0
- package/scripts/generate-docs/output/generate-docs.output.readme.utils.ts +420 -0
- package/scripts/generate-docs/output/generate-docs.output.ts +123 -0
- package/scripts/generate-docs/output/generate-docs.output.warnings.utils.ts +219 -0
- package/scripts/generate-docs/symbols/generate-docs.symbols.collection.utils.ts +365 -0
- package/scripts/generate-docs/symbols/generate-docs.symbols.jsdoc.utils.ts +373 -0
- package/scripts/generate-docs/symbols/generate-docs.symbols.normalize.utils.ts +155 -0
- package/scripts/generate-docs/symbols/generate-docs.symbols.render.utils.ts +149 -0
- package/scripts/generate-docs/symbols/generate-docs.symbols.signature.utils.ts +289 -0
- package/scripts/generate-docs/symbols/generate-docs.symbols.ts +11 -0
- package/scripts/mermaid-cli.mjs +102 -22
- package/scripts/mermaid-cli.ts +736 -0
- package/scripts/render-docs-html/render-docs-html.assets.ts +54 -0
- package/scripts/render-docs-html/render-docs-html.mermaid.ts +245 -0
- package/scripts/{render-docs-html.sidebar.ts → render-docs-html/render-docs-html.navigation.ts} +141 -144
- package/scripts/render-docs-html/render-docs-html.pages.ts +333 -0
- package/scripts/render-docs-html/render-docs-html.shared.ts +333 -0
- package/scripts/render-docs-html/render-docs-html.types.ts +42 -0
- package/scripts/render-docs-html.ts +23 -587
- package/scripts/run-docs.ts +238 -0
- package/scripts/write-dist-docs-pkg.ts +40 -0
- package/src/README.md +75 -75
- package/src/architecture/connection/README.md +5 -5
- package/src/architecture/layer/README.md +508 -508
- package/src/architecture/network/README.md +1458 -1458
- package/src/architecture/network/activate/README.md +694 -694
- package/src/architecture/network/bootstrap/README.md +77 -77
- package/src/architecture/network/connect/README.md +74 -74
- package/src/architecture/network/deterministic/README.md +135 -135
- package/src/architecture/network/evolve/README.md +364 -364
- package/src/architecture/network/gating/README.md +130 -130
- package/src/architecture/network/genetic/README.md +399 -399
- package/src/architecture/network/mutate/README.md +897 -897
- package/src/architecture/network/onnx/README.md +720 -720
- package/src/architecture/network/onnx/export/README.md +728 -728
- package/src/architecture/network/onnx/export/layers/README.md +450 -450
- package/src/architecture/network/onnx/import/README.md +618 -618
- package/src/architecture/network/onnx/schema/README.md +32 -32
- package/src/architecture/network/prune/README.md +245 -245
- package/src/architecture/network/remove/README.md +135 -135
- package/src/architecture/network/runtime/README.md +106 -106
- package/src/architecture/network/serialize/README.md +542 -542
- package/src/architecture/network/slab/README.md +608 -608
- package/src/architecture/network/standalone/README.md +212 -212
- package/src/architecture/network/stats/README.md +84 -84
- package/src/architecture/network/topology/README.md +465 -465
- package/src/architecture/network/training/README.md +200 -200
- package/src/architecture/node/README.md +5 -5
- package/src/architecture/nodePool/README.md +14 -14
- package/src/methods/README.md +99 -99
- package/src/methods/activation/README.md +189 -189
- package/src/methods/cost/README.md +131 -131
- package/src/methods/rate/README.md +86 -86
- package/src/multithreading/README.md +77 -77
- package/src/multithreading/workers/browser/README.md +8 -8
- package/src/multithreading/workers/node/README.md +8 -8
- package/src/neat/README.md +148 -148
- package/src/neat/adaptive/README.md +120 -120
- package/src/neat/adaptive/acceptance/README.md +40 -40
- package/src/neat/adaptive/complexity/README.md +137 -137
- package/src/neat/adaptive/core/README.md +197 -197
- package/src/neat/adaptive/lineage/README.md +90 -90
- package/src/neat/adaptive/mutation/README.md +284 -284
- package/src/neat/compat/README.md +43 -43
- package/src/neat/compat/core/README.md +90 -90
- package/src/neat/diversity/README.md +35 -35
- package/src/neat/diversity/core/README.md +88 -88
- package/src/neat/evaluate/README.md +85 -85
- package/src/neat/evaluate/auto-distance/README.md +75 -75
- package/src/neat/evaluate/entropy-compat/README.md +37 -37
- package/src/neat/evaluate/entropy-sharing/README.md +43 -43
- package/src/neat/evaluate/fitness/README.md +23 -23
- package/src/neat/evaluate/novelty/README.md +120 -120
- package/src/neat/evaluate/objectives/README.md +17 -17
- package/src/neat/evaluate/shared/README.md +94 -94
- package/src/neat/evolve/README.md +96 -96
- package/src/neat/evolve/adaptive/README.md +60 -60
- package/src/neat/evolve/objectives/README.md +63 -63
- package/src/neat/evolve/offspring/README.md +56 -56
- package/src/neat/evolve/population/README.md +171 -171
- package/src/neat/evolve/runtime/README.md +79 -79
- package/src/neat/evolve/speciation/README.md +74 -74
- package/src/neat/evolve/warnings/README.md +10 -10
- package/src/neat/export/README.md +114 -114
- package/src/neat/helpers/README.md +50 -50
- package/src/neat/init/README.md +9 -9
- package/src/neat/lineage/core/README.md +101 -101
- package/src/neat/multiobjective/category/README.md +74 -74
- package/src/neat/multiobjective/crowding/README.md +272 -272
- package/src/neat/multiobjective/dominance/README.md +171 -171
- package/src/neat/multiobjective/fronts/README.md +68 -68
- package/src/neat/multiobjective/metrics/README.md +43 -43
- package/src/neat/multiobjective/objectives/README.md +31 -31
- package/src/neat/multiobjective/shared/README.md +27 -27
- package/src/neat/mutation/README.md +97 -97
- package/src/neat/mutation/add-conn/README.md +115 -115
- package/src/neat/mutation/add-node/README.md +126 -126
- package/src/neat/mutation/flow/README.md +149 -149
- package/src/neat/mutation/repair/README.md +185 -185
- package/src/neat/mutation/select/README.md +117 -117
- package/src/neat/mutation/shared/README.md +32 -32
- package/src/neat/objectives/README.md +25 -25
- package/src/neat/objectives/core/README.md +67 -67
- package/src/neat/pruning/README.md +40 -40
- package/src/neat/pruning/core/README.md +171 -171
- package/src/neat/pruning/facade/README.md +32 -32
- package/src/neat/rng/README.md +104 -104
- package/src/neat/rng/core/README.md +137 -137
- package/src/neat/rng/facade/README.md +50 -50
- package/src/neat/selection/README.md +111 -111
- package/src/neat/selection/core/README.md +227 -227
- package/src/neat/selection/facade/README.md +61 -61
- package/src/neat/shared/README.md +163 -163
- package/src/neat/speciation/README.md +31 -31
- package/src/neat/speciation/threshold/README.md +35 -35
- package/src/neat/species/README.md +25 -25
- package/src/neat/species/core/README.md +20 -20
- package/src/neat/species/core/shared/README.md +18 -18
- package/src/neat/species/history/context/README.md +22 -22
- package/src/neat/telemetry/accessors/README.md +58 -58
- package/src/neat/telemetry/exports/README.md +233 -233
- package/src/neat/telemetry/facade/README.md +252 -252
- package/src/neat/telemetry/facade/archive/README.md +57 -57
- package/src/neat/telemetry/facade/buffer/README.md +43 -43
- package/src/neat/telemetry/facade/lineage/README.md +12 -12
- package/src/neat/telemetry/facade/objectives/README.md +44 -44
- package/src/neat/telemetry/facade/runtime/README.md +26 -26
- package/src/neat/telemetry/facade/species/README.md +27 -27
- package/src/neat/telemetry/metrics/README.md +696 -696
- package/src/neat/telemetry/recorder/README.md +57 -57
- package/src/neat/telemetry/types/README.md +32 -32
- package/src/neat/topology-intent/README.md +75 -75
- package/src/utils/README.md +193 -193
- package/test/examples/asciiMaze/browser-entry/README.md +92 -92
- package/test/examples/asciiMaze/dashboardManager/README.md +109 -109
- package/test/examples/asciiMaze/dashboardManager/telemetry/README.md +28 -28
- package/test/examples/asciiMaze/evolutionEngine/README.md +1527 -1527
- package/test/examples/asciiMaze/mazeMovement/README.md +105 -105
- package/test/examples/asciiMaze/mazeMovement/finalization/README.md +16 -16
- package/test/examples/asciiMaze/mazeMovement/policy/README.md +57 -57
- package/test/examples/asciiMaze/mazeMovement/runtime/README.md +52 -52
- package/test/examples/asciiMaze/mazeMovement/shaping/README.md +46 -46
- package/test/examples/flappy_bird/browser-entry/README.md +508 -508
- package/test/examples/flappy_bird/browser-entry/host/README.md +101 -101
- package/test/examples/flappy_bird/browser-entry/host/resize/README.md +144 -144
- package/test/examples/flappy_bird/browser-entry/network-view/README.md +194 -194
- package/test/examples/flappy_bird/browser-entry/playback/README.md +278 -278
- package/test/examples/flappy_bird/browser-entry/playback/background/README.md +129 -129
- package/test/examples/flappy_bird/browser-entry/playback/background/ground-grid/README.md +502 -502
- package/test/examples/flappy_bird/browser-entry/playback/frame-render/README.md +139 -139
- package/test/examples/flappy_bird/browser-entry/playback/snapshot/README.md +10 -10
- package/test/examples/flappy_bird/browser-entry/playback/trail/README.md +43 -43
- package/test/examples/flappy_bird/browser-entry/playback/worker-channel/README.md +30 -30
- package/test/examples/flappy_bird/browser-entry/runtime/README.md +59 -59
- package/test/examples/flappy_bird/browser-entry/visualization/README.md +276 -276
- package/test/examples/flappy_bird/browser-entry/worker-channel/README.md +16 -16
- package/test/examples/flappy_bird/constants/README.md +1070 -1070
- package/test/examples/flappy_bird/environment/README.md +22 -22
- package/test/examples/flappy_bird/evaluation/README.md +32 -32
- package/test/examples/flappy_bird/evaluation/rollout/README.md +141 -141
- package/test/examples/flappy_bird/flappy-evolution-worker/README.md +425 -425
- package/test/examples/flappy_bird/simulation-shared/README.md +170 -170
- package/test/examples/flappy_bird/simulation-shared/observation/README.md +109 -109
- package/test/examples/flappy_bird/trainer/README.md +325 -325
- package/test/examples/flappy_bird/trainer/evaluation/README.md +74 -74
- package/scripts/analyze-trace.ts +0 -590
- package/scripts/copy-examples.mjs +0 -114
- package/scripts/export-onnx.mjs +0 -86
- package/scripts/generate-bench-tables.mjs +0 -182
- package/scripts/generate-docs.ts +0 -2900
- package/scripts/write-dist-docs-pkg.mjs +0 -16
|
@@ -64,89 +64,77 @@ const outputName = tryEmitConvLayer({
|
|
|
64
64
|
|
|
65
65
|
## architecture/network/onnx/export/layers/network.onnx.export-dense.utils.ts
|
|
66
66
|
|
|
67
|
-
###
|
|
67
|
+
### appendDenseBiasInitializer
|
|
68
68
|
|
|
69
69
|
```ts
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
70
|
+
appendDenseBiasInitializer(
|
|
71
|
+
layerContext: DenseLayerContext,
|
|
72
|
+
biasTensorName: string,
|
|
73
|
+
biasVector: number[],
|
|
74
|
+
): void
|
|
73
75
|
```
|
|
74
76
|
|
|
75
|
-
|
|
76
|
-
same activation.
|
|
77
|
-
|
|
78
|
-
This is the cheapest ONNX shape the exporter can produce for a standard MLP
|
|
79
|
-
layer: one Gemm node for the affine transform and one activation node for the
|
|
80
|
-
whole layer. The same helper also preserves the library's legacy node-ordering
|
|
81
|
-
compatibility mode when older snapshots need deterministic graph ordering.
|
|
77
|
+
Append dense bias initializer.
|
|
82
78
|
|
|
83
79
|
Parameters:
|
|
84
|
-
- `
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
Example:
|
|
80
|
+
- `layerContext` - Dense layer context.
|
|
81
|
+
- `biasTensorName` - Bias tensor name.
|
|
82
|
+
- `biasVector` - Bias vector values.
|
|
89
83
|
|
|
90
|
-
|
|
91
|
-
const outputName = emitDenseLayer({
|
|
92
|
-
model,
|
|
93
|
-
layerIndex: 2,
|
|
94
|
-
previousOutputName: 'Layer_1',
|
|
95
|
-
previousLayerNodes,
|
|
96
|
-
currentLayerNodes,
|
|
97
|
-
options: {},
|
|
98
|
-
legacyNodeOrdering: false,
|
|
99
|
-
});
|
|
100
|
-
```
|
|
84
|
+
Returns: Nothing.
|
|
101
85
|
|
|
102
|
-
###
|
|
86
|
+
### appendDenseNodes
|
|
103
87
|
|
|
104
88
|
```ts
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
89
|
+
appendDenseNodes(
|
|
90
|
+
model: OnnxModel,
|
|
91
|
+
orderedNodes: DenseOrderedNodePayload[],
|
|
92
|
+
): void
|
|
108
93
|
```
|
|
109
94
|
|
|
110
|
-
|
|
111
|
-
neurons use different activations.
|
|
112
|
-
|
|
113
|
-
Instead of pretending the layer is homogeneous, this path exports one tiny
|
|
114
|
-
Gemm-plus-activation subgraph per neuron and then concatenates the results.
|
|
115
|
-
The graph is larger, but it preserves mixed activation behavior that a single
|
|
116
|
-
layer-wide activation node cannot express.
|
|
95
|
+
Append ordered dense nodes to the model graph.
|
|
117
96
|
|
|
118
97
|
Parameters:
|
|
119
|
-
- `
|
|
98
|
+
- `model` - Target model.
|
|
99
|
+
- `orderedNodes` - Ordered dense nodes.
|
|
120
100
|
|
|
121
|
-
Returns:
|
|
101
|
+
Returns: Nothing.
|
|
122
102
|
|
|
123
|
-
|
|
103
|
+
### appendDenseWeightInitializer
|
|
124
104
|
|
|
125
105
|
```ts
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
currentLayerNodes,
|
|
132
|
-
options: { allowMixedActivations: true },
|
|
133
|
-
});
|
|
106
|
+
appendDenseWeightInitializer(
|
|
107
|
+
layerContext: DenseLayerContext,
|
|
108
|
+
weightTensorName: string,
|
|
109
|
+
weightMatrixValues: number[],
|
|
110
|
+
): void
|
|
134
111
|
```
|
|
135
112
|
|
|
136
|
-
|
|
113
|
+
Append dense weight initializer.
|
|
114
|
+
|
|
115
|
+
Parameters:
|
|
116
|
+
- `layerContext` - Dense layer context.
|
|
117
|
+
- `weightTensorName` - Weight tensor name.
|
|
118
|
+
- `weightMatrixValues` - Weight values.
|
|
119
|
+
|
|
120
|
+
Returns: Nothing.
|
|
121
|
+
|
|
122
|
+
### buildSingleNeuronWeightRow
|
|
137
123
|
|
|
138
124
|
```ts
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
125
|
+
buildSingleNeuronWeightRow(
|
|
126
|
+
targetNodeInternal: NodeInternals,
|
|
127
|
+
previousLayerNodes: default[],
|
|
128
|
+
): number[]
|
|
142
129
|
```
|
|
143
130
|
|
|
144
|
-
|
|
131
|
+
Build one neuron's incoming weight row against previous layer.
|
|
145
132
|
|
|
146
133
|
Parameters:
|
|
147
|
-
- `
|
|
134
|
+
- `targetNodeInternal` - Target node internals.
|
|
135
|
+
- `previousLayerNodes` - Previous layer nodes.
|
|
148
136
|
|
|
149
|
-
Returns:
|
|
137
|
+
Returns: Weight row values.
|
|
150
138
|
|
|
151
139
|
### collectDenseInitializerValues
|
|
152
140
|
|
|
@@ -163,6 +151,31 @@ Parameters:
|
|
|
163
151
|
|
|
164
152
|
Returns: Dense initializer values.
|
|
165
153
|
|
|
154
|
+
### createActivationNode
|
|
155
|
+
|
|
156
|
+
```ts
|
|
157
|
+
createActivationNode(
|
|
158
|
+
denseActivationContext: DenseActivationContext,
|
|
159
|
+
): DenseActivationNodePayload
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
Create dense activation node definition.
|
|
163
|
+
|
|
164
|
+
Parameters:
|
|
165
|
+
- `denseActivationContext` - Dense activation context.
|
|
166
|
+
|
|
167
|
+
Returns: ONNX activation node payload.
|
|
168
|
+
|
|
169
|
+
### createDefaultGemmAttributes
|
|
170
|
+
|
|
171
|
+
```ts
|
|
172
|
+
createDefaultGemmAttributes(): { name: string; type: string; f?: number | undefined; i?: number | undefined; }[]
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
Build default Gemm attributes for ONNX export.
|
|
176
|
+
|
|
177
|
+
Returns: Default Gemm attribute list.
|
|
178
|
+
|
|
166
179
|
### createDenseTensorNames
|
|
167
180
|
|
|
168
181
|
```ts
|
|
@@ -178,43 +191,50 @@ Parameters:
|
|
|
178
191
|
|
|
179
192
|
Returns: Dense tensor names.
|
|
180
193
|
|
|
181
|
-
###
|
|
194
|
+
### createGemmNode
|
|
182
195
|
|
|
183
196
|
```ts
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
weightMatrixValues: number[],
|
|
188
|
-
): void
|
|
197
|
+
createGemmNode(
|
|
198
|
+
denseActivationContext: DenseActivationContext,
|
|
199
|
+
): DenseGemmNodePayload
|
|
189
200
|
```
|
|
190
201
|
|
|
191
|
-
|
|
202
|
+
Create dense Gemm node definition.
|
|
192
203
|
|
|
193
204
|
Parameters:
|
|
194
|
-
- `
|
|
195
|
-
- `weightTensorName` - Weight tensor name.
|
|
196
|
-
- `weightMatrixValues` - Weight values.
|
|
205
|
+
- `denseActivationContext` - Dense activation context.
|
|
197
206
|
|
|
198
|
-
Returns:
|
|
207
|
+
Returns: ONNX Gemm node payload.
|
|
199
208
|
|
|
200
|
-
###
|
|
209
|
+
### createSharedActivationNodePayload
|
|
201
210
|
|
|
202
211
|
```ts
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
biasVector: number[],
|
|
207
|
-
): void
|
|
212
|
+
createSharedActivationNodePayload(
|
|
213
|
+
params: SharedActivationNodeBuildParams,
|
|
214
|
+
): DenseActivationNodePayload
|
|
208
215
|
```
|
|
209
216
|
|
|
210
|
-
|
|
217
|
+
Build a shared activation node payload.
|
|
211
218
|
|
|
212
219
|
Parameters:
|
|
213
|
-
- `
|
|
214
|
-
- `biasTensorName` - Bias tensor name.
|
|
215
|
-
- `biasVector` - Bias vector values.
|
|
220
|
+
- `params` - Shared activation build parameters.
|
|
216
221
|
|
|
217
|
-
Returns:
|
|
222
|
+
Returns: Activation node payload.
|
|
223
|
+
|
|
224
|
+
### createSharedGemmNodePayload
|
|
225
|
+
|
|
226
|
+
```ts
|
|
227
|
+
createSharedGemmNodePayload(
|
|
228
|
+
params: SharedGemmNodeBuildParams,
|
|
229
|
+
): DenseGemmNodePayload
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
Build a shared Gemm node payload.
|
|
233
|
+
|
|
234
|
+
Parameters:
|
|
235
|
+
- `params` - Shared Gemm build parameters.
|
|
236
|
+
|
|
237
|
+
Returns: Gemm node payload.
|
|
218
238
|
|
|
219
239
|
### emitDenseActivationSubgraph
|
|
220
240
|
|
|
@@ -233,71 +253,104 @@ Parameters:
|
|
|
233
253
|
|
|
234
254
|
Returns: Nothing.
|
|
235
255
|
|
|
236
|
-
###
|
|
256
|
+
### emitDenseInitializers
|
|
237
257
|
|
|
238
258
|
```ts
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
legacyNodeOrdering: boolean,
|
|
243
|
-
): DenseOrderedNodePayload[]
|
|
259
|
+
emitDenseInitializers(
|
|
260
|
+
layerContext: DenseLayerContext,
|
|
261
|
+
): DenseTensorNames
|
|
244
262
|
```
|
|
245
263
|
|
|
246
|
-
|
|
264
|
+
Emit dense initializers and return tensor names.
|
|
247
265
|
|
|
248
266
|
Parameters:
|
|
249
|
-
- `
|
|
250
|
-
- `activationNode` - Activation node.
|
|
251
|
-
- `legacyNodeOrdering` - Whether legacy ordering is required.
|
|
267
|
+
- `layerContext` - Dense layer context.
|
|
252
268
|
|
|
253
|
-
Returns:
|
|
269
|
+
Returns: Tensor names.
|
|
254
270
|
|
|
255
|
-
###
|
|
271
|
+
### emitDenseLayer
|
|
256
272
|
|
|
257
273
|
```ts
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
): void
|
|
274
|
+
emitDenseLayer(
|
|
275
|
+
params: DenseLayerParams,
|
|
276
|
+
): string
|
|
262
277
|
```
|
|
263
278
|
|
|
264
|
-
|
|
279
|
+
Emit the compact dense export path for a layer whose neurons all share the
|
|
280
|
+
same activation.
|
|
281
|
+
|
|
282
|
+
This is the cheapest ONNX shape the exporter can produce for a standard MLP
|
|
283
|
+
layer: one Gemm node for the affine transform and one activation node for the
|
|
284
|
+
whole layer. The same helper also preserves the library's legacy node-ordering
|
|
285
|
+
compatibility mode when older snapshots need deterministic graph ordering.
|
|
265
286
|
|
|
266
287
|
Parameters:
|
|
267
|
-
- `
|
|
268
|
-
- `orderedNodes` - Ordered dense nodes.
|
|
288
|
+
- `params` - Dense emission parameters.
|
|
269
289
|
|
|
270
|
-
Returns:
|
|
290
|
+
Returns: Output tensor name.
|
|
271
291
|
|
|
272
|
-
|
|
292
|
+
Example:
|
|
273
293
|
|
|
274
294
|
```ts
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
295
|
+
const outputName = emitDenseLayer({
|
|
296
|
+
model,
|
|
297
|
+
layerIndex: 2,
|
|
298
|
+
previousOutputName: 'Layer_1',
|
|
299
|
+
previousLayerNodes,
|
|
300
|
+
currentLayerNodes,
|
|
301
|
+
options: {},
|
|
302
|
+
legacyNodeOrdering: false,
|
|
303
|
+
});
|
|
278
304
|
```
|
|
279
305
|
|
|
280
|
-
|
|
306
|
+
### emitOptionalLayerOutput
|
|
307
|
+
|
|
308
|
+
```ts
|
|
309
|
+
emitOptionalLayerOutput(
|
|
310
|
+
params: OptionalLayerOutputParams,
|
|
311
|
+
): string
|
|
312
|
+
```
|
|
313
|
+
|
|
314
|
+
Emit optional pooling and flatten output fold.
|
|
281
315
|
|
|
282
316
|
Parameters:
|
|
283
|
-
- `
|
|
317
|
+
- `params` - Optional output parameters.
|
|
284
318
|
|
|
285
|
-
Returns:
|
|
319
|
+
Returns: Output tensor name.
|
|
286
320
|
|
|
287
|
-
###
|
|
321
|
+
### emitPerNeuronLayer
|
|
288
322
|
|
|
289
323
|
```ts
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
):
|
|
324
|
+
emitPerNeuronLayer(
|
|
325
|
+
params: PerNeuronLayerParams,
|
|
326
|
+
): string
|
|
293
327
|
```
|
|
294
328
|
|
|
295
|
-
|
|
329
|
+
Emit the fallback dense-family representation for a layer whose target
|
|
330
|
+
neurons use different activations.
|
|
331
|
+
|
|
332
|
+
Instead of pretending the layer is homogeneous, this path exports one tiny
|
|
333
|
+
Gemm-plus-activation subgraph per neuron and then concatenates the results.
|
|
334
|
+
The graph is larger, but it preserves mixed activation behavior that a single
|
|
335
|
+
layer-wide activation node cannot express.
|
|
296
336
|
|
|
297
337
|
Parameters:
|
|
298
|
-
- `
|
|
338
|
+
- `params` - Per-neuron emission parameters.
|
|
299
339
|
|
|
300
|
-
Returns:
|
|
340
|
+
Returns: Output tensor name.
|
|
341
|
+
|
|
342
|
+
Example:
|
|
343
|
+
|
|
344
|
+
```ts
|
|
345
|
+
const outputName = emitPerNeuronLayer({
|
|
346
|
+
model,
|
|
347
|
+
layerIndex: 2,
|
|
348
|
+
previousOutputName: 'Layer_1',
|
|
349
|
+
previousLayerNodes,
|
|
350
|
+
currentLayerNodes,
|
|
351
|
+
options: { allowMixedActivations: true },
|
|
352
|
+
});
|
|
353
|
+
```
|
|
301
354
|
|
|
302
355
|
### emitPerNeuronSubgraph
|
|
303
356
|
|
|
@@ -314,22 +367,24 @@ Parameters:
|
|
|
314
367
|
|
|
315
368
|
Returns: Per-neuron activation output name.
|
|
316
369
|
|
|
317
|
-
###
|
|
370
|
+
### resolveDenseNodeOrder
|
|
318
371
|
|
|
319
372
|
```ts
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
373
|
+
resolveDenseNodeOrder(
|
|
374
|
+
gemmNode: DenseGemmNodePayload,
|
|
375
|
+
activationNode: DenseActivationNodePayload,
|
|
376
|
+
legacyNodeOrdering: boolean,
|
|
377
|
+
): DenseOrderedNodePayload[]
|
|
324
378
|
```
|
|
325
379
|
|
|
326
|
-
|
|
380
|
+
Resolve dense node order for legacy and current exports.
|
|
327
381
|
|
|
328
382
|
Parameters:
|
|
329
|
-
- `
|
|
330
|
-
- `
|
|
383
|
+
- `gemmNode` - Gemm node.
|
|
384
|
+
- `activationNode` - Activation node.
|
|
385
|
+
- `legacyNodeOrdering` - Whether legacy ordering is required.
|
|
331
386
|
|
|
332
|
-
Returns:
|
|
387
|
+
Returns: Ordered node list.
|
|
333
388
|
|
|
334
389
|
### resolveSingleNeuronInboundWeight
|
|
335
390
|
|
|
@@ -348,130 +403,55 @@ Parameters:
|
|
|
348
403
|
|
|
349
404
|
Returns: Inbound weight or zero when missing.
|
|
350
405
|
|
|
351
|
-
### createSharedGemmNodePayload
|
|
352
|
-
|
|
353
|
-
```ts
|
|
354
|
-
createSharedGemmNodePayload(
|
|
355
|
-
params: SharedGemmNodeBuildParams,
|
|
356
|
-
): DenseGemmNodePayload
|
|
357
|
-
```
|
|
358
|
-
|
|
359
|
-
Build a shared Gemm node payload.
|
|
360
|
-
|
|
361
|
-
Parameters:
|
|
362
|
-
- `params` - Shared Gemm build parameters.
|
|
363
|
-
|
|
364
|
-
Returns: Gemm node payload.
|
|
365
|
-
|
|
366
|
-
### createSharedActivationNodePayload
|
|
367
|
-
|
|
368
|
-
```ts
|
|
369
|
-
createSharedActivationNodePayload(
|
|
370
|
-
params: SharedActivationNodeBuildParams,
|
|
371
|
-
): DenseActivationNodePayload
|
|
372
|
-
```
|
|
373
|
-
|
|
374
|
-
Build a shared activation node payload.
|
|
375
|
-
|
|
376
|
-
Parameters:
|
|
377
|
-
- `params` - Shared activation build parameters.
|
|
378
|
-
|
|
379
|
-
Returns: Activation node payload.
|
|
380
|
-
|
|
381
|
-
### createDefaultGemmAttributes
|
|
382
|
-
|
|
383
|
-
```ts
|
|
384
|
-
createDefaultGemmAttributes(): { name: string; type: string; f?: number | undefined; i?: number | undefined; }[]
|
|
385
|
-
```
|
|
386
|
-
|
|
387
|
-
Build default Gemm attributes for ONNX export.
|
|
388
|
-
|
|
389
|
-
Returns: Default Gemm attribute list.
|
|
390
|
-
|
|
391
|
-
### emitOptionalLayerOutput
|
|
392
|
-
|
|
393
|
-
```ts
|
|
394
|
-
emitOptionalLayerOutput(
|
|
395
|
-
params: OptionalLayerOutputParams,
|
|
396
|
-
): string
|
|
397
|
-
```
|
|
398
|
-
|
|
399
|
-
Emit optional pooling and flatten output fold.
|
|
400
|
-
|
|
401
|
-
Parameters:
|
|
402
|
-
- `params` - Optional output parameters.
|
|
403
|
-
|
|
404
|
-
Returns: Output tensor name.
|
|
405
|
-
|
|
406
406
|
## architecture/network/onnx/export/layers/network.onnx.export-recurrent.utils.ts
|
|
407
407
|
|
|
408
|
-
###
|
|
408
|
+
### buildDefaultGemmAttributes
|
|
409
409
|
|
|
410
410
|
```ts
|
|
411
|
-
|
|
412
|
-
params: RecurrentLayerEmissionParams,
|
|
413
|
-
): string
|
|
411
|
+
buildDefaultGemmAttributes(): { name: string; type: string; f?: number | undefined; i?: number | undefined; }[]
|
|
414
412
|
```
|
|
415
413
|
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
This boundary models recurrence with two parallel Gemm branches:
|
|
419
|
-
one for the feed-forward input and one for the previous hidden state. The
|
|
420
|
-
recurrent branch uses a diagonal matrix derived from self-connections only,
|
|
421
|
-
which keeps the exported shape simple and matches the importer's current
|
|
422
|
-
reconstruction contract.
|
|
423
|
-
|
|
424
|
-
Hidden-state inputs are named `hidden_prev` for the first recurrent layer and
|
|
425
|
-
`hidden_prev_l{n}` for later recurrent layers. Mixed activations are not
|
|
426
|
-
supported on this path because the single activation node is applied after
|
|
427
|
-
the input and recurrent branches are summed.
|
|
428
|
-
|
|
429
|
-
Parameters:
|
|
430
|
-
- `params` - Recurrent emission parameters.
|
|
431
|
-
|
|
432
|
-
Returns: Output tensor name.
|
|
433
|
-
|
|
434
|
-
Example:
|
|
414
|
+
Build the shared attribute list for ONNX Gemm node payloads.
|
|
435
415
|
|
|
436
|
-
|
|
437
|
-
const outputName = emitRecurrentLayer({
|
|
438
|
-
model,
|
|
439
|
-
layerIndex: 1,
|
|
440
|
-
previousOutputName: 'input',
|
|
441
|
-
previousLayerNodes,
|
|
442
|
-
currentLayerNodes,
|
|
443
|
-
});
|
|
444
|
-
```
|
|
416
|
+
Returns: Gemm attribute payload list.
|
|
445
417
|
|
|
446
|
-
###
|
|
418
|
+
### buildInputBranchGemmEmissionContext
|
|
447
419
|
|
|
448
420
|
```ts
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
421
|
+
buildInputBranchGemmEmissionContext(
|
|
422
|
+
context: RecurrentLayerEmissionContext,
|
|
423
|
+
initializerNames: RecurrentInitializerNames,
|
|
424
|
+
graphNames: RecurrentGraphNames,
|
|
425
|
+
): RecurrentGemmEmissionContext
|
|
452
426
|
```
|
|
453
427
|
|
|
454
|
-
Build
|
|
428
|
+
Build Gemm emission context for the feed-forward branch.
|
|
455
429
|
|
|
456
430
|
Parameters:
|
|
457
|
-
- `
|
|
431
|
+
- `context` - Recurrent layer execution context.
|
|
432
|
+
- `initializerNames` - Recurrent initializer names.
|
|
433
|
+
- `graphNames` - Recurrent graph names.
|
|
458
434
|
|
|
459
|
-
Returns:
|
|
435
|
+
Returns: Gemm emission context.
|
|
460
436
|
|
|
461
|
-
###
|
|
437
|
+
### buildRecurrentBranchGemmEmissionContext
|
|
462
438
|
|
|
463
439
|
```ts
|
|
464
|
-
|
|
440
|
+
buildRecurrentBranchGemmEmissionContext(
|
|
465
441
|
context: RecurrentLayerEmissionContext,
|
|
466
|
-
|
|
442
|
+
initializerNames: RecurrentInitializerNames,
|
|
443
|
+
graphNames: RecurrentGraphNames,
|
|
444
|
+
): RecurrentGemmEmissionContext
|
|
467
445
|
```
|
|
468
446
|
|
|
469
|
-
Build
|
|
447
|
+
Build Gemm emission context for the recurrent hidden-state branch.
|
|
470
448
|
|
|
471
449
|
Parameters:
|
|
472
450
|
- `context` - Recurrent layer execution context.
|
|
451
|
+
- `initializerNames` - Recurrent initializer names.
|
|
452
|
+
- `graphNames` - Recurrent graph names.
|
|
473
453
|
|
|
474
|
-
Returns:
|
|
454
|
+
Returns: Gemm emission context.
|
|
475
455
|
|
|
476
456
|
### buildRecurrentGraphNames
|
|
477
457
|
|
|
@@ -488,88 +468,82 @@ Parameters:
|
|
|
488
468
|
|
|
489
469
|
Returns: Graph-name group for branch and activation nodes.
|
|
490
470
|
|
|
491
|
-
###
|
|
471
|
+
### buildRecurrentInitializerNames
|
|
492
472
|
|
|
493
473
|
```ts
|
|
494
|
-
|
|
474
|
+
buildRecurrentInitializerNames(
|
|
495
475
|
context: RecurrentLayerEmissionContext,
|
|
496
|
-
):
|
|
476
|
+
): RecurrentInitializerNames
|
|
497
477
|
```
|
|
498
478
|
|
|
499
|
-
|
|
479
|
+
Build deterministic tensor names for recurrent initializer emission.
|
|
500
480
|
|
|
501
481
|
Parameters:
|
|
502
482
|
- `context` - Recurrent layer execution context.
|
|
503
483
|
|
|
504
|
-
Returns:
|
|
484
|
+
Returns: Tensor-name group for initializer emission.
|
|
505
485
|
|
|
506
|
-
###
|
|
486
|
+
### buildRecurrentLayerEmissionContext
|
|
507
487
|
|
|
508
488
|
```ts
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
):
|
|
489
|
+
buildRecurrentLayerEmissionContext(
|
|
490
|
+
params: RecurrentLayerEmissionParams,
|
|
491
|
+
): RecurrentLayerEmissionContext
|
|
512
492
|
```
|
|
513
493
|
|
|
514
|
-
|
|
494
|
+
Build derived recurrent-layer context from input params.
|
|
515
495
|
|
|
516
496
|
Parameters:
|
|
517
|
-
- `
|
|
497
|
+
- `params` - User-provided recurrent layer params.
|
|
518
498
|
|
|
519
|
-
Returns:
|
|
499
|
+
Returns: Derived context with cached dimensions and layer slot.
|
|
520
500
|
|
|
521
|
-
###
|
|
501
|
+
### collectRecurrentInitializerValues
|
|
522
502
|
|
|
523
503
|
```ts
|
|
524
|
-
|
|
504
|
+
collectRecurrentInitializerValues(
|
|
525
505
|
context: RecurrentLayerEmissionContext,
|
|
526
|
-
|
|
527
|
-
graphNames: RecurrentGraphNames,
|
|
528
|
-
): RecurrentGemmEmissionContext
|
|
506
|
+
): RecurrentInitializerValues
|
|
529
507
|
```
|
|
530
508
|
|
|
531
|
-
|
|
509
|
+
Collect recurrent initializer vectors for one layer.
|
|
532
510
|
|
|
533
511
|
Parameters:
|
|
534
512
|
- `context` - Recurrent layer execution context.
|
|
535
|
-
- `initializerNames` - Recurrent initializer names.
|
|
536
|
-
- `graphNames` - Recurrent graph names.
|
|
537
513
|
|
|
538
|
-
Returns:
|
|
514
|
+
Returns: Dense and recurrent initializer vectors.
|
|
539
515
|
|
|
540
|
-
###
|
|
516
|
+
### emitRecurrentActivationNode
|
|
541
517
|
|
|
542
518
|
```ts
|
|
543
|
-
|
|
544
|
-
context:
|
|
545
|
-
|
|
546
|
-
graphNames: RecurrentGraphNames,
|
|
547
|
-
): RecurrentGemmEmissionContext
|
|
519
|
+
emitRecurrentActivationNode(
|
|
520
|
+
context: RecurrentActivationEmissionContext,
|
|
521
|
+
): void
|
|
548
522
|
```
|
|
549
523
|
|
|
550
|
-
|
|
524
|
+
Emit activation node for recurrent branch sum output.
|
|
551
525
|
|
|
552
526
|
Parameters:
|
|
553
|
-
- `context` -
|
|
554
|
-
- `initializerNames` - Recurrent initializer names.
|
|
555
|
-
- `graphNames` - Recurrent graph names.
|
|
527
|
+
- `context` - Activation emission context.
|
|
556
528
|
|
|
557
|
-
Returns:
|
|
529
|
+
Returns: Nothing.
|
|
558
530
|
|
|
559
|
-
###
|
|
531
|
+
### emitRecurrentAddNode
|
|
560
532
|
|
|
561
533
|
```ts
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
534
|
+
emitRecurrentAddNode(
|
|
535
|
+
model: OnnxModel,
|
|
536
|
+
graphNames: RecurrentGraphNames,
|
|
537
|
+
): void
|
|
565
538
|
```
|
|
566
539
|
|
|
567
|
-
|
|
540
|
+
Emit Add node that fuses feed-forward and recurrent branch outputs.
|
|
568
541
|
|
|
569
542
|
Parameters:
|
|
570
|
-
- `
|
|
543
|
+
- `model` - Target ONNX model.
|
|
544
|
+
- `graphNames` - Deterministic graph names for this layer.
|
|
571
545
|
|
|
572
|
-
Returns:
|
|
546
|
+
Returns: Nothing.
|
|
573
547
|
|
|
574
548
|
### emitRecurrentGemmNode
|
|
575
549
|
|
|
@@ -586,53 +560,59 @@ Parameters:
|
|
|
586
560
|
|
|
587
561
|
Returns: Nothing.
|
|
588
562
|
|
|
589
|
-
###
|
|
563
|
+
### emitRecurrentInitializers
|
|
590
564
|
|
|
591
565
|
```ts
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
graphNames: RecurrentGraphNames,
|
|
566
|
+
emitRecurrentInitializers(
|
|
567
|
+
context: RecurrentInitializerEmissionContext,
|
|
595
568
|
): void
|
|
596
569
|
```
|
|
597
570
|
|
|
598
|
-
Emit
|
|
571
|
+
Emit dense and recurrent initializer tensors.
|
|
599
572
|
|
|
600
573
|
Parameters:
|
|
601
|
-
- `
|
|
602
|
-
- `graphNames` - Deterministic graph names for this layer.
|
|
574
|
+
- `context` - Initializer emission context.
|
|
603
575
|
|
|
604
576
|
Returns: Nothing.
|
|
605
577
|
|
|
606
|
-
###
|
|
578
|
+
### emitRecurrentLayer
|
|
607
579
|
|
|
608
580
|
```ts
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
):
|
|
581
|
+
emitRecurrentLayer(
|
|
582
|
+
params: RecurrentLayerEmissionParams,
|
|
583
|
+
): string
|
|
612
584
|
```
|
|
613
585
|
|
|
614
|
-
Emit
|
|
586
|
+
Emit the constrained recurrent single-step export path for one hidden layer.
|
|
587
|
+
|
|
588
|
+
This boundary models recurrence with two parallel Gemm branches:
|
|
589
|
+
one for the feed-forward input and one for the previous hidden state. The
|
|
590
|
+
recurrent branch uses a diagonal matrix derived from self-connections only,
|
|
591
|
+
which keeps the exported shape simple and matches the importer's current
|
|
592
|
+
reconstruction contract.
|
|
593
|
+
|
|
594
|
+
Hidden-state inputs are named `hidden_prev` for the first recurrent layer and
|
|
595
|
+
`hidden_prev_l{n}` for later recurrent layers. Mixed activations are not
|
|
596
|
+
supported on this path because the single activation node is applied after
|
|
597
|
+
the input and recurrent branches are summed.
|
|
615
598
|
|
|
616
599
|
Parameters:
|
|
617
|
-
- `
|
|
600
|
+
- `params` - Recurrent emission parameters.
|
|
618
601
|
|
|
619
|
-
Returns:
|
|
602
|
+
Returns: Output tensor name.
|
|
620
603
|
|
|
621
|
-
|
|
604
|
+
Example:
|
|
622
605
|
|
|
623
606
|
```ts
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
607
|
+
const outputName = emitRecurrentLayer({
|
|
608
|
+
model,
|
|
609
|
+
layerIndex: 1,
|
|
610
|
+
previousOutputName: 'input',
|
|
611
|
+
previousLayerNodes,
|
|
612
|
+
currentLayerNodes,
|
|
613
|
+
});
|
|
627
614
|
```
|
|
628
615
|
|
|
629
|
-
Resolve ONNX activation type from first node in recurrent layer.
|
|
630
|
-
|
|
631
|
-
Parameters:
|
|
632
|
-
- `currentLayerNodes` - Current recurrent layer nodes.
|
|
633
|
-
|
|
634
|
-
Returns: ONNX activation op type.
|
|
635
|
-
|
|
636
616
|
### readNodeInternals
|
|
637
617
|
|
|
638
618
|
```ts
|
|
@@ -648,15 +628,35 @@ Parameters:
|
|
|
648
628
|
|
|
649
629
|
Returns: Node internals used by ONNX emission helpers.
|
|
650
630
|
|
|
651
|
-
###
|
|
631
|
+
### resolvePreviousHiddenInputName
|
|
652
632
|
|
|
653
633
|
```ts
|
|
654
|
-
|
|
634
|
+
resolvePreviousHiddenInputName(
|
|
635
|
+
layerIndex: number,
|
|
636
|
+
): string
|
|
655
637
|
```
|
|
656
638
|
|
|
657
|
-
|
|
639
|
+
Resolve recurrent branch hidden-state input for one layer.
|
|
658
640
|
|
|
659
|
-
|
|
641
|
+
Parameters:
|
|
642
|
+
- `layerIndex` - Current recurrent layer index.
|
|
643
|
+
|
|
644
|
+
Returns: Hidden-state tensor input name.
|
|
645
|
+
|
|
646
|
+
### resolveRecurrentActivationType
|
|
647
|
+
|
|
648
|
+
```ts
|
|
649
|
+
resolveRecurrentActivationType(
|
|
650
|
+
currentLayerNodes: default[],
|
|
651
|
+
): string
|
|
652
|
+
```
|
|
653
|
+
|
|
654
|
+
Resolve ONNX activation type from first node in recurrent layer.
|
|
655
|
+
|
|
656
|
+
Parameters:
|
|
657
|
+
- `currentLayerNodes` - Current recurrent layer nodes.
|
|
658
|
+
|
|
659
|
+
Returns: ONNX activation op type.
|
|
660
660
|
|
|
661
661
|
## architecture/network/onnx/export/layers/network.onnx.export-layer-graph.utils.ts
|
|
662
662
|
|
|
@@ -706,6 +706,74 @@ const outputName = emitLayerGraph({
|
|
|
706
706
|
|
|
707
707
|
## architecture/network/onnx/export/layers/network.onnx.export-layer-common.utils.ts
|
|
708
708
|
|
|
709
|
+
### appendIndexedMetadata
|
|
710
|
+
|
|
711
|
+
```ts
|
|
712
|
+
appendIndexedMetadata(
|
|
713
|
+
model: OnnxModel,
|
|
714
|
+
key: string,
|
|
715
|
+
layerIndex: number,
|
|
716
|
+
): void
|
|
717
|
+
```
|
|
718
|
+
|
|
719
|
+
Append an integer index to JSON-array metadata key.
|
|
720
|
+
|
|
721
|
+
Parameters:
|
|
722
|
+
- `model` - Target model.
|
|
723
|
+
- `key` - Metadata key.
|
|
724
|
+
- `layerIndex` - Layer index to append.
|
|
725
|
+
|
|
726
|
+
Returns: Nothing.
|
|
727
|
+
|
|
728
|
+
### appendMetadataSpec
|
|
729
|
+
|
|
730
|
+
```ts
|
|
731
|
+
appendMetadataSpec(
|
|
732
|
+
model: OnnxModel,
|
|
733
|
+
key: string,
|
|
734
|
+
spec: Conv2DMapping | Pool2DMapping,
|
|
735
|
+
): void
|
|
736
|
+
```
|
|
737
|
+
|
|
738
|
+
Append a JSON object to JSON-array metadata key.
|
|
739
|
+
|
|
740
|
+
Parameters:
|
|
741
|
+
- `model` - Target model.
|
|
742
|
+
- `key` - Metadata key.
|
|
743
|
+
- `spec` - Metadata object.
|
|
744
|
+
|
|
745
|
+
Returns: Nothing.
|
|
746
|
+
|
|
747
|
+
### appendPoolingMetadata
|
|
748
|
+
|
|
749
|
+
```ts
|
|
750
|
+
appendPoolingMetadata(
|
|
751
|
+
context: PoolingEmissionContext,
|
|
752
|
+
): void
|
|
753
|
+
```
|
|
754
|
+
|
|
755
|
+
Append pooling metadata for one emitted pooling layer.
|
|
756
|
+
|
|
757
|
+
Parameters:
|
|
758
|
+
- `context` - Pooling emission context.
|
|
759
|
+
|
|
760
|
+
Returns: Nothing.
|
|
761
|
+
|
|
762
|
+
### asNodeInternals
|
|
763
|
+
|
|
764
|
+
```ts
|
|
765
|
+
asNodeInternals(
|
|
766
|
+
node: default,
|
|
767
|
+
): NodeInternals
|
|
768
|
+
```
|
|
769
|
+
|
|
770
|
+
Normalize a public node instance into ONNX export internals.
|
|
771
|
+
|
|
772
|
+
Parameters:
|
|
773
|
+
- `node` - Source node.
|
|
774
|
+
|
|
775
|
+
Returns: Internal runtime-facing node representation.
|
|
776
|
+
|
|
709
777
|
### buildDenseWeightsAndBiases
|
|
710
778
|
|
|
711
779
|
```ts
|
|
@@ -753,58 +821,39 @@ Parameters:
|
|
|
753
821
|
|
|
754
822
|
Returns: Flattened row-major recurrent matrix.
|
|
755
823
|
|
|
756
|
-
###
|
|
757
|
-
|
|
758
|
-
```ts
|
|
759
|
-
emitOptionalPoolingAndFlatten(
|
|
760
|
-
params: OptionalPoolingAndFlattenParams,
|
|
761
|
-
): string
|
|
762
|
-
```
|
|
763
|
-
|
|
764
|
-
Emit optional pooling and flatten nodes after a layer output.
|
|
765
|
-
|
|
766
|
-
Parameters:
|
|
767
|
-
- `params` - Pooling parameters.
|
|
768
|
-
|
|
769
|
-
Returns: Final output tensor name after optional pooling/flatten.
|
|
770
|
-
|
|
771
|
-
### appendIndexedMetadata
|
|
824
|
+
### buildIndexedMetadataProperty
|
|
772
825
|
|
|
773
826
|
```ts
|
|
774
|
-
|
|
775
|
-
model: OnnxModel,
|
|
827
|
+
buildIndexedMetadataProperty(
|
|
776
828
|
key: string,
|
|
777
829
|
layerIndex: number,
|
|
778
|
-
):
|
|
830
|
+
): OnnxMetadataProperty
|
|
779
831
|
```
|
|
780
832
|
|
|
781
|
-
|
|
833
|
+
Build a new index-array metadata property.
|
|
782
834
|
|
|
783
835
|
Parameters:
|
|
784
|
-
- `model` - Target model.
|
|
785
836
|
- `key` - Metadata key.
|
|
786
|
-
- `layerIndex` - Layer index
|
|
837
|
+
- `layerIndex` - Layer index.
|
|
787
838
|
|
|
788
|
-
Returns:
|
|
839
|
+
Returns: Metadata property.
|
|
789
840
|
|
|
790
|
-
###
|
|
841
|
+
### buildSpecMetadataProperty
|
|
791
842
|
|
|
792
843
|
```ts
|
|
793
|
-
|
|
794
|
-
model: OnnxModel,
|
|
844
|
+
buildSpecMetadataProperty(
|
|
795
845
|
key: string,
|
|
796
846
|
spec: Conv2DMapping | Pool2DMapping,
|
|
797
|
-
):
|
|
847
|
+
): OnnxMetadataProperty
|
|
798
848
|
```
|
|
799
849
|
|
|
800
|
-
|
|
850
|
+
Build a new spec-array metadata property.
|
|
801
851
|
|
|
802
852
|
Parameters:
|
|
803
|
-
- `model` - Target model.
|
|
804
853
|
- `key` - Metadata key.
|
|
805
|
-
- `spec` -
|
|
854
|
+
- `spec` - Mapping spec.
|
|
806
855
|
|
|
807
|
-
Returns:
|
|
856
|
+
Returns: Metadata property.
|
|
808
857
|
|
|
809
858
|
### collectDenseRows
|
|
810
859
|
|
|
@@ -821,21 +870,6 @@ Parameters:
|
|
|
821
870
|
|
|
822
871
|
Returns: Dense rows containing per-target weights and bias.
|
|
823
872
|
|
|
824
|
-
### foldDenseRowsToInitializers
|
|
825
|
-
|
|
826
|
-
```ts
|
|
827
|
-
foldDenseRowsToInitializers(
|
|
828
|
-
denseRows: DenseWeightRow[],
|
|
829
|
-
): DenseWeightBuildResult
|
|
830
|
-
```
|
|
831
|
-
|
|
832
|
-
Fold dense rows into flattened ONNX initializer arrays.
|
|
833
|
-
|
|
834
|
-
Parameters:
|
|
835
|
-
- `denseRows` - Dense rows.
|
|
836
|
-
|
|
837
|
-
Returns: Flattened dense initializer result.
|
|
838
|
-
|
|
839
873
|
### collectDenseRowWeights
|
|
840
874
|
|
|
841
875
|
```ts
|
|
@@ -851,37 +885,35 @@ Parameters:
|
|
|
851
885
|
|
|
852
886
|
Returns: Row weights in source-node order.
|
|
853
887
|
|
|
854
|
-
###
|
|
888
|
+
### collectPoolingAttributes
|
|
855
889
|
|
|
856
890
|
```ts
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
): number
|
|
891
|
+
collectPoolingAttributes(
|
|
892
|
+
poolSpec: Pool2DMapping,
|
|
893
|
+
): PoolingAttributes
|
|
861
894
|
```
|
|
862
895
|
|
|
863
|
-
|
|
896
|
+
Collect ONNX pooling attributes from one pooling spec.
|
|
864
897
|
|
|
865
898
|
Parameters:
|
|
866
|
-
- `
|
|
867
|
-
- `sourceNode` - Source node.
|
|
899
|
+
- `poolSpec` - Pooling spec.
|
|
868
900
|
|
|
869
|
-
Returns:
|
|
901
|
+
Returns: Pooling attributes for ONNX node payload.
|
|
870
902
|
|
|
871
|
-
###
|
|
903
|
+
### collectRecurrentRow
|
|
872
904
|
|
|
873
905
|
```ts
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
):
|
|
906
|
+
collectRecurrentRow(
|
|
907
|
+
context: RecurrentRowCollectionContext,
|
|
908
|
+
): number[]
|
|
877
909
|
```
|
|
878
910
|
|
|
879
|
-
|
|
911
|
+
Collect one recurrent matrix row.
|
|
880
912
|
|
|
881
913
|
Parameters:
|
|
882
|
-
- `
|
|
914
|
+
- `context` - Row collection context.
|
|
883
915
|
|
|
884
|
-
Returns:
|
|
916
|
+
Returns: Recurrent row values.
|
|
885
917
|
|
|
886
918
|
### collectRecurrentRows
|
|
887
919
|
|
|
@@ -898,52 +930,35 @@ Parameters:
|
|
|
898
930
|
|
|
899
931
|
Returns: Recurrent row collection.
|
|
900
932
|
|
|
901
|
-
###
|
|
902
|
-
|
|
903
|
-
```ts
|
|
904
|
-
collectRecurrentRow(
|
|
905
|
-
context: RecurrentRowCollectionContext,
|
|
906
|
-
): number[]
|
|
907
|
-
```
|
|
908
|
-
|
|
909
|
-
Collect one recurrent matrix row.
|
|
910
|
-
|
|
911
|
-
Parameters:
|
|
912
|
-
- `context` - Row collection context.
|
|
913
|
-
|
|
914
|
-
Returns: Recurrent row values.
|
|
915
|
-
|
|
916
|
-
### resolveDiagonalRecurrentWeight
|
|
933
|
+
### emitOptionalFlattenAfterPooling
|
|
917
934
|
|
|
918
935
|
```ts
|
|
919
|
-
|
|
920
|
-
context:
|
|
921
|
-
|
|
922
|
-
): number
|
|
936
|
+
emitOptionalFlattenAfterPooling(
|
|
937
|
+
context: FlattenAfterPoolingContext,
|
|
938
|
+
): string
|
|
923
939
|
```
|
|
924
940
|
|
|
925
|
-
|
|
941
|
+
Conditionally emit flatten node after pooling.
|
|
926
942
|
|
|
927
943
|
Parameters:
|
|
928
|
-
- `context` -
|
|
929
|
-
- `columnIndex` - Column index in row.
|
|
944
|
+
- `context` - Flatten emission context.
|
|
930
945
|
|
|
931
|
-
Returns:
|
|
946
|
+
Returns: Output tensor name after optional flatten.
|
|
932
947
|
|
|
933
|
-
###
|
|
948
|
+
### emitOptionalPoolingAndFlatten
|
|
934
949
|
|
|
935
950
|
```ts
|
|
936
|
-
|
|
951
|
+
emitOptionalPoolingAndFlatten(
|
|
937
952
|
params: OptionalPoolingAndFlattenParams,
|
|
938
|
-
):
|
|
953
|
+
): string
|
|
939
954
|
```
|
|
940
955
|
|
|
941
|
-
|
|
956
|
+
Emit optional pooling and flatten nodes after a layer output.
|
|
942
957
|
|
|
943
958
|
Parameters:
|
|
944
|
-
- `params` -
|
|
959
|
+
- `params` - Pooling parameters.
|
|
945
960
|
|
|
946
|
-
Returns:
|
|
961
|
+
Returns: Final output tensor name after optional pooling/flatten.
|
|
947
962
|
|
|
948
963
|
### emitPoolingNode
|
|
949
964
|
|
|
@@ -960,51 +975,6 @@ Parameters:
|
|
|
960
975
|
|
|
961
976
|
Returns: Pooling output tensor name.
|
|
962
977
|
|
|
963
|
-
### collectPoolingAttributes
|
|
964
|
-
|
|
965
|
-
```ts
|
|
966
|
-
collectPoolingAttributes(
|
|
967
|
-
poolSpec: Pool2DMapping,
|
|
968
|
-
): PoolingAttributes
|
|
969
|
-
```
|
|
970
|
-
|
|
971
|
-
Collect ONNX pooling attributes from one pooling spec.
|
|
972
|
-
|
|
973
|
-
Parameters:
|
|
974
|
-
- `poolSpec` - Pooling spec.
|
|
975
|
-
|
|
976
|
-
Returns: Pooling attributes for ONNX node payload.
|
|
977
|
-
|
|
978
|
-
### emitOptionalFlattenAfterPooling
|
|
979
|
-
|
|
980
|
-
```ts
|
|
981
|
-
emitOptionalFlattenAfterPooling(
|
|
982
|
-
context: FlattenAfterPoolingContext,
|
|
983
|
-
): string
|
|
984
|
-
```
|
|
985
|
-
|
|
986
|
-
Conditionally emit flatten node after pooling.
|
|
987
|
-
|
|
988
|
-
Parameters:
|
|
989
|
-
- `context` - Flatten emission context.
|
|
990
|
-
|
|
991
|
-
Returns: Output tensor name after optional flatten.
|
|
992
|
-
|
|
993
|
-
### appendPoolingMetadata
|
|
994
|
-
|
|
995
|
-
```ts
|
|
996
|
-
appendPoolingMetadata(
|
|
997
|
-
context: PoolingEmissionContext,
|
|
998
|
-
): void
|
|
999
|
-
```
|
|
1000
|
-
|
|
1001
|
-
Append pooling metadata for one emitted pooling layer.
|
|
1002
|
-
|
|
1003
|
-
Parameters:
|
|
1004
|
-
- `context` - Pooling emission context.
|
|
1005
|
-
|
|
1006
|
-
Returns: Nothing.
|
|
1007
|
-
|
|
1008
978
|
### ensureMetadataRegistry
|
|
1009
979
|
|
|
1010
980
|
```ts
|
|
@@ -1037,39 +1007,69 @@ Parameters:
|
|
|
1037
1007
|
|
|
1038
1008
|
Returns: Matching metadata property if present.
|
|
1039
1009
|
|
|
1040
|
-
###
|
|
1010
|
+
### foldDenseRowsToInitializers
|
|
1041
1011
|
|
|
1042
1012
|
```ts
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
): OnnxMetadataProperty
|
|
1013
|
+
foldDenseRowsToInitializers(
|
|
1014
|
+
denseRows: DenseWeightRow[],
|
|
1015
|
+
): DenseWeightBuildResult
|
|
1047
1016
|
```
|
|
1048
1017
|
|
|
1049
|
-
|
|
1018
|
+
Fold dense rows into flattened ONNX initializer arrays.
|
|
1050
1019
|
|
|
1051
1020
|
Parameters:
|
|
1052
|
-
- `
|
|
1053
|
-
- `layerIndex` - Layer index.
|
|
1021
|
+
- `denseRows` - Dense rows.
|
|
1054
1022
|
|
|
1055
|
-
Returns:
|
|
1023
|
+
Returns: Flattened dense initializer result.
|
|
1056
1024
|
|
|
1057
|
-
###
|
|
1025
|
+
### parseMetadataArray
|
|
1058
1026
|
|
|
1059
1027
|
```ts
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
): OnnxMetadataProperty
|
|
1028
|
+
parseMetadataArray(
|
|
1029
|
+
metadataValue: string,
|
|
1030
|
+
): ItemType[] | undefined
|
|
1064
1031
|
```
|
|
1065
1032
|
|
|
1066
|
-
|
|
1033
|
+
Parse a metadata JSON array value safely.
|
|
1067
1034
|
|
|
1068
1035
|
Parameters:
|
|
1069
|
-
- `
|
|
1070
|
-
- `spec` - Mapping spec.
|
|
1036
|
+
- `metadataValue` - Metadata JSON string.
|
|
1071
1037
|
|
|
1072
|
-
Returns:
|
|
1038
|
+
Returns: Parsed array when valid, otherwise undefined.
|
|
1039
|
+
|
|
1040
|
+
### resolveDiagonalRecurrentWeight
|
|
1041
|
+
|
|
1042
|
+
```ts
|
|
1043
|
+
resolveDiagonalRecurrentWeight(
|
|
1044
|
+
context: RecurrentRowCollectionContext,
|
|
1045
|
+
columnIndex: number,
|
|
1046
|
+
): number
|
|
1047
|
+
```
|
|
1048
|
+
|
|
1049
|
+
Resolve recurrent weight value for one matrix coordinate.
|
|
1050
|
+
|
|
1051
|
+
Parameters:
|
|
1052
|
+
- `context` - Row collection context.
|
|
1053
|
+
- `columnIndex` - Column index in row.
|
|
1054
|
+
|
|
1055
|
+
Returns: Recurrent weight for diagonal entries, otherwise zero.
|
|
1056
|
+
|
|
1057
|
+
### resolveInboundWeight
|
|
1058
|
+
|
|
1059
|
+
```ts
|
|
1060
|
+
resolveInboundWeight(
|
|
1061
|
+
targetNodeInternal: NodeInternals,
|
|
1062
|
+
sourceNode: default,
|
|
1063
|
+
): number
|
|
1064
|
+
```
|
|
1065
|
+
|
|
1066
|
+
Resolve source-to-target inbound connection weight.
|
|
1067
|
+
|
|
1068
|
+
Parameters:
|
|
1069
|
+
- `targetNodeInternal` - Target node internals.
|
|
1070
|
+
- `sourceNode` - Source node.
|
|
1071
|
+
|
|
1072
|
+
Returns: Inbound weight or zero for disconnected edges.
|
|
1073
1073
|
|
|
1074
1074
|
### serializeIndexedMetadataValue
|
|
1075
1075
|
|
|
@@ -1105,17 +1105,17 @@ Parameters:
|
|
|
1105
1105
|
|
|
1106
1106
|
Returns: Serialized JSON value.
|
|
1107
1107
|
|
|
1108
|
-
###
|
|
1108
|
+
### toPoolingEmissionContext
|
|
1109
1109
|
|
|
1110
1110
|
```ts
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
):
|
|
1111
|
+
toPoolingEmissionContext(
|
|
1112
|
+
params: OptionalPoolingAndFlattenParams,
|
|
1113
|
+
): PoolingEmissionContext
|
|
1114
1114
|
```
|
|
1115
1115
|
|
|
1116
|
-
|
|
1116
|
+
Resolve pooling emission context from optional pooling parameters.
|
|
1117
1117
|
|
|
1118
1118
|
Parameters:
|
|
1119
|
-
- `
|
|
1119
|
+
- `params` - Optional pooling and flatten parameters.
|
|
1120
1120
|
|
|
1121
|
-
Returns:
|
|
1121
|
+
Returns: Pooling emission context.
|