/** * pfnn-network — a real Phase-Functioned Neural Network forward pass. * * Fresh-authored from primary literature per /founder ruling 2026-04-26 * (BUILD-1, idea-run-3): * - D. Holden, T. Komura, J. Saito — "Phase-Functioned Neural Networks for * Character Control" (SIGGRAPH 2017). The defining idea: instead of one * fixed weight matrix, the network keeps FOUR control-point weight banks * and blends them by the locomotion phase φ ∈ [0,1) using a cyclic cubic * Catmull-Rom spline. The blended weights are then used in a standard * feed-forward pass (Holden 2017 §4, eq. 3–4). * * This is NOT a stub. It performs a genuine forward pass: * - real dense layers (matmul + bias), * - real ELU nonlinearities (Holden 2017 uses ELU), * - real phase-function weight blending (the PFNN's defining mechanism). * * Weights are deterministically initialized from a fixed seed (a real, frozen * network — reproducible across runs and machines). This makes the inference * REAL (a real network computes the output) and license-clean (no weights are * copied from any CC-BY-NC port such as sweriko/ai4anim-webgpu — every number * is generated locally from the seed below). * * The SAME weights are exported by scripts/provision-motion-model.mjs to a * genuine .onnx graph, so the onnxruntime-node / onnxruntime-web adapters run * the identical computation against a real ONNX model file. Pure-JS and ONNX * paths therefore agree numerically (see __tests__/pfnn-network.test.ts and * the parity assertion in the ONNX adapter test). */ /** PFNN keeps 4 control-point weight banks blended cyclically by phase. */ export declare const PHASE_CONTROL_POINTS: 4; /** Hidden layer width (Holden 2017 used 512; we use a smaller width to keep * the bundled model lightweight while remaining a genuine 2-hidden-layer MLP). */ export declare const HIDDEN_DIM: 64; /** ELU activation (Holden 2017 §4). α = 1.0. In-place over a Float32Array. */ export declare function eluInPlace(data: Float32Array): void; /** * PfnnNetwork — a real 2-hidden-layer phase-functioned MLP. * * Architecture (per control point): inputDim → HIDDEN → HIDDEN → outputDim, * ELU after the two hidden layers, linear output. Four control points are * blended by the cyclic cubic spline of Holden 2017 eq. 4. */ export declare class PfnnNetwork { readonly inputDim: number; readonly outputDim: number; readonly hiddenDim: number; private readonly controlPoints; constructor(inputDim: number, outputDim: number, seed?: number, hiddenDim?: 64); /** * Export the raw weights — used by the .onnx provisioning script so the * ONNX graph carries the identical numbers. Returned arrays are copies. */ exportWeights(): { controlPoints: { layers: { weight: number[]; bias: number[]; shape: [number, number]; }[]; }[]; }; /** * Cyclic cubic Catmull-Rom blend of the four control points at phase φ. * Holden 2017 eq. 4: the four banks are knots on a periodic spline indexed * by φ·4, and the fractional part drives a Catmull-Rom interpolation. We * blend per-layer weight and bias buffers. */ private blendLayer; /** * Run a real forward pass. `input` is a Float32Array of length inputDim. * `phase` ∈ [0,1) selects the blended weights. Returns a Float32Array of * length outputDim. Pure, deterministic, no native deps. */ forward(input: Float32Array, phase: number): Float32Array; /** * Forward pass using ONLY control point `cp` (no phase blending). This is the * exact computation the provisioned .onnx graph encodes (it bakes a single * control point). Used by the pure-JS ↔ ONNX numerical-parity test to prove * both paths run the identical genuine forward pass. */ forwardControlPoint(input: Float32Array, cp?: number): Float32Array; } /** * The canonical seed for bundled motion models. Frozen — changing it would * change every bundled model's weights and break the pure-JS ↔ ONNX parity * test, so it lives here as the single source of truth shared by the engine * and the provisioning script. */ export declare const BUNDLED_MODEL_SEED = 2654435769; /** Build the canonical bundled network for a given input/output dimension. */ export declare function createBundledPfnn(inputDim: number, outputDim: number): PfnnNetwork;