Modern Apps git

← Modern-Apps.git

library:ml: the Supertonic vocoder verified, with causal padding

Commit
54e7fc383129a340353c1608b0af53bc40a49514
Author
vayun-mathur <[email protected]>
When
2026-08-28 05:48 UTC (3 months ago)
Parents
2bff23f

Diff

library/ml/src/main/rust/src/nets/reference.rs
diff --git a/library/ml/src/main/rust/src/nets/reference.rs b/library/ml/src/main/rust/src/nets/reference.rsindex 2856759eaf..5632b211b9 100644--- a/library/ml/src/main/rust/src/nets/reference.rs+++ b/library/ml/src/main/rust/src/nets/reference.rs@@ -1042,7 +1042,7 @@ fn uniform(state: &mut u32) -> f32 { #[cfg(test)] mod tests {     use super::super::{-        mobilefacenet, ppocr_det, ppocr_rec, scrfd, selfie, u2netp, vits_dec, vits_enc, vits_flow, Act,+        mobilefacenet, ppocr_det, ppocr_rec, scrfd, selfie, supertonic_vocoder, u2netp, vits_dec, vits_enc, vits_flow, Act,         Builder,     };     use super::*;@@ -2394,6 +2394,28 @@ mod tests {          // A voice is a runtime download rather than a bundled asset, so the vocoder's         // `.maml` is given by path instead of being looked up in the tree.+        if graph == "supertonic_voc" {+            let path = std::env::var("PARITY_MAML").expect("PARITY_MAML");+            let bytes = std::fs::read(&path).unwrap_or_else(|e| panic!("{path}: {e}"));+            let weights =+                crate::weights::Weights::parse(&bytes, crate::weights::graph::SUPERTONIC_VOC)+                    .expect("the vocoder asset parses");+            let plan = supertonic_vocoder::build(&weights, width).expect("the vocoder builds");+            // The latent arrives `[144, L]` and the plan wants `[24, 6L]`, and that is NOT a flat+            // reinterpretation: the export reshapes to `[24, 6, L]`, transposes the last two axes+            // and flattens, so position `p` of channel `c` is `latent[c * 6 + p % 6][p / 6]`.+            // Assuming a plain reshape here produced audio that correlated with the reference at+            // 0.009 — structurally wrong rather than merely imprecise.+            let unpacked = supertonic_vocoder::unpack_latent(&input, width as usize)+                .expect("the latent unpacks");+            let channelled = run(&plan, weights.data(), &unpacked).expect("the vocoder runs");+            // And the plan emits `[512, 1, T]` while the waveform is time-major. Both marshalling+            // steps are the host's job in production; it is copying into an audio buffer anyway.+            let samples = supertonic_vocoder::interleave(&channelled);+            write(&dir.join("reference.f32"), &samples);+            println!("supertonic_voc at {width} frames: wrote {} values", samples.len());+            return;+        }         if graph == "vits_dp" {             let path = std::env::var("PARITY_MAML").expect("PARITY_MAML");             let bytes = std::fs::read(&path).unwrap_or_else(|e| panic!("{path}: {e}"));
library/ml/src/main/rust/src/nets/supertonic_vocoder.rs
diff --git a/library/ml/src/main/rust/src/nets/supertonic_vocoder.rs b/library/ml/src/main/rust/src/nets/supertonic_vocoder.rsindex 6bcbeec192..9e0f8de060 100644--- a/library/ml/src/main/rust/src/nets/supertonic_vocoder.rs+++ b/library/ml/src/main/rust/src/nets/supertonic_vocoder.rs@@ -10,14 +10,17 @@ //! # The two reinterpretations, both free //! //! **In.** The latent arrives as `[144, L]` and the first convolution wants 24 channels. 144 is-//! `24 * 6`, the `chunk_compress_factor`, and `[144, L]` to `[24, 6L]` is a plain reshape of the-//! same flat buffer — so the plan simply declares its input as `[24, 1, 6L]` and the caller-//! passes the same bytes. No copy, no shader.+//! `24 * 6`, the `chunk_compress_factor`, but the unpacking is an **interleave and not a plain+//! reshape**: the export reshapes to `[24, 6, L]`, transposes the last two axes and flattens+//! again, so position `p` of channel `c` comes from `latent[c * 6 + p % 6][p / 6]`. See+//! [`unpack_latent`]. Treating it as a flat reinterpretation produced audio that correlated with+//! the reference at 0.009 — structurally wrong rather than merely imprecise, and the sort of+//! mistake that sounds like noise rather than like a bug. //! //! **Out.** The last convolution emits `[512, 1, T]` and the waveform is-//! `sample[t * 512 + s] = out[s][t]`. That transpose happens on the host, which is copying into-//! an audio buffer regardless. Measured: 3072 output samples per input latent frame, at-//! `L = 54`, `55` and `108`.+//! `sample[t * 512 + s] = out[s][t]`. See [`interleave`]. That transpose happens on the host,+//! which is copying into an audio buffer regardless. Measured: 3072 output samples per input+//! latent frame, at `L = 54`, `55` and `108`. //! //! # Edge padding, and the three folds it permits //!@@ -103,6 +106,45 @@ impl Layers {     } } +/// Unpack a `[144, frames]` latent into the `[24, 6 * frames]` the plan reads.+///+/// **Not** a flat reinterpretation. The export reshapes `[144, L]` to `[24, 6, L]`, transposes+/// the last two axes and flattens, so position `p` of channel `c` comes from+/// `latent[c * 6 + p % 6][p / 6]`. Assuming a plain reshape correlated with the reference at+/// 0.009 rather than 0.99, so this is worth a fixture of its own.+pub fn unpack_latent(latent: &[f32], frames: usize) -> Result<Vec<f32>, String> {+    let packed = PACKED as usize;+    let compress = COMPRESS as usize;+    if latent.len() != packed * frames {+        return Err(format!(+            "{} latent values for {packed} channels over {frames} frames",+            latent.len()+        ));+    }+    let positions = frames * compress;+    let mut out = vec![0.0f32; LATENT as usize * positions];+    for channel in 0..LATENT as usize {+        for position in 0..positions {+            let source = (channel * compress + position % compress) * frames + position / compress;+            out[channel * positions + position] = latent[source];+        }+    }+    Ok(out)+}++/// Read the plan's `[512, 1, T]` output as a waveform: `sample[t * 512 + s] = out[s][t]`.+pub fn interleave(channelled: &[f32]) -> Vec<f32> {+    let channels = SAMPLES_PER_POSITION as usize;+    let positions = channelled.len() / channels.max(1);+    let mut out = vec![0.0f32; channelled.len()];+    for channel in 0..channels {+        for position in 0..positions {+            out[position * channels + channel] = channelled[channel * positions + position];+        }+    }+    out+}+ /// Build the vocoder for a latent of `frames` frames. /// /// The input is `[24, 1, 6 * frames]` — the caller's `[144, frames]` latent, reinterpreted. The@@ -171,7 +213,14 @@ pub fn build(weights: &dyn WeightSource, frames: u32) -> Result<Plan, String> {  /// A convolution along the sequence, padded so the length is unchanged. ///-/// The pad is `dilation * (kernel - 1) / 2` each side, which for the odd kernels here is exact.+/// The padding is **causal**: the whole `dilation * (kernel - 1)` goes on the left and none on+/// the right, which is what the export's `Pad` nodes carry — `[0, 0, 6, 0, 0, 0]` for a 7-tap at+/// dilation 1, growing to 12 and 24 at dilations 2 and 4. So each output position sees only+/// itself and its past, which is what lets a vocoder stream.+///+/// Implementing this symmetrically instead shifts the signal a little further at every one of+/// the eleven padded convolutions. The output stays the right length and the right magnitude and+/// correlates with the reference at 0.02, which sounds like noise rather than like a bug. struct Along {     /// Output channels.     out: u32,@@ -186,7 +235,7 @@ struct Along {  fn along(b: &mut Builder, l: &mut Layers, x: Id, shape: Along) -> Id {     let Along { out, kernel, dilation, group, act } = shape;-    let pad = dilation * (kernel - 1) / 2;+    let past = dilation * (kernel - 1);     b.conv(         x,         l.take(),@@ -194,7 +243,8 @@ fn along(b: &mut Builder, l: &mut Layers, x: Id, shape: Along) -> Id {         (1, kernel),         (1, 1),         (1, dilation),-        (0, pad, 0, pad),+        // (top, left, bottom, right): everything on the left.+        (0, past, 0, 0),         group,         act,     )@@ -220,6 +270,49 @@ mod tests {         (source, plan)     } +    #[test]+    fn unpacking_the_latent_interleaves_rather_than_reshaping() {+        // Two frames of the 144 packed channels, each value encoding its own (channel, frame) so+        // the mapping is readable. A plain reshape would give a different answer for every+        // position except those where `p % 6 == 0`, which is why it correlated at 0.009 rather+        // than failing outright.+        let frames = 2usize;+        let packed = PACKED as usize;+        let latent: Vec<f32> =+            (0..packed * frames).map(|i| (i / frames) as f32 * 100.0 + (i % frames) as f32).collect();+        let got = unpack_latent(&latent, frames).expect("unpacks");+        let positions = frames * COMPRESS as usize;+        assert_eq!(got.len(), LATENT as usize * positions);+        // Channel 0, position 0..12: source channel `p % 6`, source frame `p / 6`.+        let want: Vec<f32> = (0..positions)+            .map(|p| (p % 6) as f32 * 100.0 + (p / 6) as f32)+            .collect();+        assert_eq!(&got[0..positions], &want[..]);+        // Channel 3 starts at packed channel 18, so its first position is 1800.+        assert_eq!(got[3 * positions], 1800.0);+        // And a plain reshape would have put packed channel 3 frame 0 there instead.+        assert_ne!(got[3 * positions], 300.0);+    }++    #[test]+    fn unpacking_refuses_a_latent_of_the_wrong_length() {+        let error = unpack_latent(&[0.0; 10], 2).expect_err("wrong length");+        assert!(error.contains("10 latent values"), "{error}");+    }++    #[test]+    fn interleaving_reads_the_output_plane_as_a_waveform() {+        // Two positions of the 512 channels. Sample `t * 512 + s` is channel `s` at position `t`.+        let channels = SAMPLES_PER_POSITION as usize;+        let plane: Vec<f32> = (0..channels * 2).map(|i| i as f32).collect();+        let got = interleave(&plane);+        // Channel 0 position 0, then channel 1 position 0, ...+        assert_eq!(got[0], 0.0);+        assert_eq!(got[1], 2.0);+        assert_eq!(got[channels], 1.0);+        assert_eq!(got.len(), plane.len());+    }+     #[test]     fn the_pass_reads_every_tensor_in_the_file_exactly_once() {         let (source, _) = plan(FRAMES);
library/ml/src/main/rust/src/weights.rs
diff --git a/library/ml/src/main/rust/src/weights.rs b/library/ml/src/main/rust/src/weights.rsindex 02e3d3c05e..723b4c68a8 100644--- a/library/ml/src/main/rust/src/weights.rs+++ b/library/ml/src/main/rust/src/weights.rs@@ -73,6 +73,8 @@ pub mod graph {     ///     /// Read on the host rather than compiled into a plan: see [`crate::post::duration`].     pub const VITS_DP: u32 = 10;+    /// Supertonic 3's ConvNeXt vocoder. See [`crate::nets::supertonic_vocoder`].+    pub const SUPERTONIC_VOC: u32 = 11; }  /// One tensor's entry in the table: where it is and what shape it is.
scripts/ml/maml_convert.py
diff --git a/scripts/ml/maml_convert.py b/scripts/ml/maml_convert.pyindex 0a57254da3..1d193a690a 100644--- a/scripts/ml/maml_convert.py+++ b/scripts/ml/maml_convert.py@@ -111,6 +111,7 @@ GRAPHS = {     "vits_enc": 8,     "vits_flow": 9,     "vits_dp": 10,+    "supertonic_voc": 11, }  # SHA-256 over the ordered layer table (see `layer_table_digest`). Regenerate with@@ -126,6 +127,7 @@ EXPECTED_DIGEST = {     "vits_enc": "93ee24f70b490334d11b383f043e81284a3e781bc263597830c50f8df14db2c1",     "vits_flow": "38cecda81bcfd4eb98782395905ddbe4637aa7f55fecb2de996d09fc530e2e6d",     "vits_dp": "d02a6e28700823af95cbeeeb2b40d77e531f90086599deb3f840ce9a2a57a494",+    "supertonic_voc": "64e3a3437fa8f889fb679a5e08553ba7392c05a32cd844a0d2340698372a0071", }  # Graphs that are one **module** of a larger export, keyed by the node-name prefix that
scripts/ml/onnx_parity.py
diff --git a/scripts/ml/onnx_parity.py b/scripts/ml/onnx_parity.pyindex 8138159d38..97d4ca57b7 100644--- a/scripts/ml/onnx_parity.py+++ b/scripts/ml/onnx_parity.py@@ -58,6 +58,7 @@ PROBE = {     "vits_enc": "/enc_p/proj/Conv_output_0",     "vits_flow": None,     "vits_dp": None,+    "supertonic_voc": None, }  # Graphs that are one module of a larger export, and have to be cut out of it before they can@@ -85,6 +86,8 @@ SUBGRAPH = {     # state, the padding mask as ones, and the already-scaled noise. Cutting the noise out is     # what makes the comparison possible at all — left in, the export draws its own and two     # runs would not agree with each other, let alone with the runtime.+    # A whole file, not a module: no `first`, so nothing is extracted. 144 latent channels.+    "supertonic_voc": {"channels": 144},     "vits_dp": {         "first": "/dp/pre/Conv",         "channels": 192,@@ -160,7 +163,10 @@ def main():     work = tempfile.mkdtemp(prefix="maml_parity_")      cut = SUBGRAPH.get(args.graph)-    if cut is not None:+    # A cut without a `first` is a whole-graph model that merely needs a non-image input+    # shape - Supertonic ships its vocoder as its own file rather than as a module of a+    # larger one, so there is nothing to extract.+    if cut is not None and cut.get("first"):         model = extract(args.onnx, model, cut, work)     probe = PROBE[args.graph] or final_logits(model)     if probe not in {o.name for o in model.graph.output}:
scripts/ml/supertonic_fold.py
diff --git a/scripts/ml/supertonic_fold.py b/scripts/ml/supertonic_fold.pynew file mode 100644index 0000000000..74b55d2459--- /dev/null+++ b/scripts/ml/supertonic_fold.py@@ -0,0 +1,282 @@+#!/usr/bin/env python3+"""Supertonic 3's vocoder ONNX to `.maml`, folding its three per-channel affines away.++`nets::supertonic_vocoder` is a hardcoded forward pass of convolutions, layer norms, GELUs and+residual adds — and nothing else. The export has three per-channel affines that are not any of+those, and rather than adding an op for each, all three fold into a convolution:++    input   Mul by [24] then Add by [24]      -> folds into `embed`+    block   Mul by a [512] layer scale        -> folds into that block's `pwconv2`+    tail    BatchNormalization over [512]     -> folds into `head/layer1`++# Why the fold is legal here and not in ppocr_fold.py++`conv(a x + b)` is `conv_{aW}(x) + sum(W b)` at an interior position, and the constant term is a+per-output-channel bias. At a *border* it depends on what the padding supplies. With zero padding+the pad contributes `0` rather than `b`, the fold is wrong at the edge, and+`ppocr_fold.fold_affine_into_convs` refuses padded convolutions for exactly that reason — it was+a real bug in a shipped asset.++Every convolution in this vocoder is preceded by an ONNX `Pad` with **`mode=edge`**. A replicated+border supplies `a x_border + b`, which is what the fold assumes, so it holds everywhere. The+`pwconv2` case is unconditional anyway: a 1x1 has no border.++# Two smaller shape fixes++* `head/act` is a `PRelu` with a single shared slope. The runtime's `Act::PRelu` reads one slope+  per channel, so the scalar is widened to 2048 copies. 4 KB, and it keeps the shader branchless.+* `head/layer2` has no bias in the export. A zero one is synthesised, as `maml_convert` already+  does for `vits_dec`.++Usage:+    ./scripts/ml/supertonic_fold.py vocoder.onnx --graph supertonic_voc -o vocoder.maml+"""++import argparse+import hashlib+import os+import sys++import numpy as np+import onnx+from onnx import numpy_helper++sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))+import maml_convert  # noqa: E402  (needs the path above)++# The vocoder's stack width, and the widening inside each block.+CHANNELS = 512+INNER = CHANNELS * 4+++def constants(graph):+    """Every initializer and `Constant` node output, by name."""+    held = {i.name: numpy_helper.to_array(i) for i in graph.initializer}+    for node in graph.node:+        if node.op_type == "Constant":+            for attribute in node.attribute:+                if attribute.name == "value":+                    held[node.output[0]] = numpy_helper.to_array(attribute.t)+    return held+++def edge_padded(graph):+    """Whether every `Pad` in the graph replicates its border.++    Checked rather than assumed: the folds below are only valid for `edge`, and a future export+    that switched to `constant` would otherwise fold silently and wrongly.+    """+    modes = set()+    for node in graph.node:+        if node.op_type != "Pad":+            continue+        mode = "constant"+        for attribute in node.attribute:+            if attribute.name == "mode":+                mode = attribute.s.decode()+        modes.add(mode)+    return modes == {"edge"}+++def fold_into(weight, bias, scale, shift):+    """`conv(scale * x + shift)` as a convolution on `x`.++    `weight` is `[out, in, k]`, `scale` and `shift` are per **input** channel. The scale rides on+    the weight; the shift becomes a constant per output channel, which is where the `k` sum+    comes from.+    """+    scaled = weight * scale.reshape(1, -1, 1)+    added = (weight * shift.reshape(1, -1, 1)).sum(axis=(1, 2))+    return scaled, bias + added+++def fold_output(weight, bias, scale, shift):+    """`scale * conv(x) + shift` as a convolution, for a per-**output**-channel affine."""+    return weight * scale.reshape(-1, 1, 1), bias * scale + shift+++def batchnorm_affine(node, held, epsilon=1e-5):+    """A `BatchNormalization`'s inference-time per-channel scale and shift."""+    gamma, beta, mean, variance = (held[name] for name in node.input[1:5])+    for attribute in node.attribute:+        if attribute.name == "epsilon":+            epsilon = attribute.f+    scale = gamma / np.sqrt(variance + epsilon)+    return scale, beta - mean * scale+++def collect(graph):+    """The vocoder's layers and tensors, folded, in the order the Rust reads them."""+    held = constants(graph)+    if not edge_padded(graph):+        raise SystemExit(+            "this export does not pad every convolution with mode=edge, so the affine folds "+            "below are not valid; see the module docstring"+        )++    # The input affine, which precedes `embed`.+    input_scale = input_shift = None+    for node in graph.node:+        if node.op_type in ("Mul", "Add"):+            sized = [i for i in node.input if i in held and held[i].size == 24]+            if not sized:+                continue+            value = np.asarray(held[sized[0]], dtype=np.float64).reshape(-1)+            if node.op_type == "Mul" and input_scale is None:+                input_scale = value+            elif node.op_type == "Add" and input_shift is None:+                input_shift = value+    if input_scale is None or input_shift is None:+        raise SystemExit("no [24] input affine found ahead of embed")++    # And a scalar divisor at the very head - `normalizer.scale` in tts.json. Folded into the+    # per-channel scale rather than left for the runtime: dividing by it is multiplying the+    # affine''s slope, and the shift is applied after the division so it is untouched.+    divisor = None+    for node in graph.node:+        if node.op_type == "Div":+            scalars = [i for i in node.input if i in held and np.size(held[i]) == 1]+            if scalars:+                divisor = float(np.asarray(held[scalars[0]]).reshape(-1)[0])+                break+    if divisor is None or divisor == 0.0:+        raise SystemExit("no scalar Div found at the head of the graph")+    input_scale = input_scale / divisor++    # Each block's layer scale, and the tail's BatchNormalization.+    layer_scales = []+    for node in graph.node:+        if node.op_type == "Mul" and "convnext" in node.name:+            sized = [i for i in node.input if i in held and held[i].size == CHANNELS]+            if sized:+                layer_scales.append(np.asarray(held[sized[0]], dtype=np.float64).reshape(-1))+    norm = next((n for n in graph.node if n.op_type == "BatchNormalization"), None)+    if norm is None:+        raise SystemExit("no BatchNormalization found ahead of head/layer1")+    tail_scale, tail_shift = batchnorm_affine(norm, held)++    layers, tensors = [], []+    scales = iter(layer_scales)++    def add(op, name, weight, bias, key):+        first = len(tensors)+        tensors.append(np.ascontiguousarray(weight, dtype=np.float32))+        tensors.append(np.ascontiguousarray(bias, dtype=np.float32))+        layers.append(maml_convert.Layer(len(layers), op, name, key, first, 2))++    for node in graph.node:+        if node.op_type == "LayerNormalization":+            # Each block's norm sits between its depthwise and its `pwconv1`, so walking the+            # graph in order puts its pair in exactly the right place in the table.+            gamma = np.asarray(held[node.input[1]], dtype=np.float64)+            beta = np.asarray(held[node.input[2]], dtype=np.float64)+            add(+                "LayerNorm",+                node.name,+                gamma,+                beta,+                f"LayerNorm g={list(gamma.shape)} b={list(beta.shape)}",+            )+            continue+        if node.op_type != "Conv":+            continue+        weight = np.asarray(held[node.input[1]], dtype=np.float64)+        if len(node.input) > 2:+            bias = np.asarray(held[node.input[2]], dtype=np.float64)+        else:+            # `head/layer2` has none; the Rust reads a pair for every layer.+            bias = np.zeros(weight.shape[0], dtype=np.float64)+        note = ""++        if "embed" in node.name:+            weight, bias = fold_into(weight, bias, input_scale, input_shift)+            note = " folded=input_affine"+        elif "pwconv2" in node.name:+            weight, bias = fold_output(weight, bias, next(scales), 0.0)+            note = " folded=layer_scale"+        elif "head/layer1" in node.name:+            weight, bias = fold_into(weight, bias, tail_scale, tail_shift)+            note = " folded=final_norm"+        elif len(node.input) == 2:+            note = " b0=synthesised"++        lifted, _ = maml_convert.lift_to_2d(weight, node)+        group = 1+        for attribute in node.attribute:+            if attribute.name == "group":+                group = attribute.i+        key = (+            f"Conv w={list(lifted.shape)} b={list(bias.shape)} g={group}"+            f" pad=edge{note}"+        )+        add("Conv", node.name, lifted, bias, key)++        # The PReLU sits between the two head convolutions, and its slope is one tensor.+        if "head/layer1" in node.name:+            prelu = next(n for n in graph.node if n.op_type == "PRelu")+            slope = np.asarray(held[prelu.input[1]], dtype=np.float64).reshape(-1)+            if slope.size != 1:+                raise SystemExit(f"{prelu.name}: a {slope.size}-element slope, expected one")+            widened = np.full((INNER, 1, 1), float(slope[0]), dtype=np.float32)+            first = len(tensors)+            tensors.append(widened)+            layers.append(+                maml_convert.Layer(+                    len(layers),+                    "PRelu",+                    prelu.name,+                    f"PRelu s={list(widened.shape)} shared={float(slope[0]):.6f}",+                    first,+                    1,+                )+            )++    remaining = list(scales)+    if remaining:+        raise SystemExit(f"{len(remaining)} layer scales were never folded into a pwconv2")+    return layers, tensors+++def main():+    parser = argparse.ArgumentParser(description=__doc__.splitlines()[0])+    parser.add_argument("onnx")+    parser.add_argument("--graph", required=True, choices=sorted(maml_convert.GRAPHS))+    parser.add_argument("-o", "--out")+    parser.add_argument("--print-layers", action="store_true")+    parser.add_argument("--print-digest", action="store_true")+    args = parser.parse_args()++    raw = open(args.onnx, "rb").read()+    onnx_sha256 = hashlib.sha256(raw).digest()+    model = onnx.load(args.onnx)+    layers, tensors = collect(model.graph)++    if args.print_layers:+        for layer in layers:+            print(f"{layer.index:4d} t{layer.first_tensor:<4d} {layer.key()}  # {layer.name}")+    digest = maml_convert.layer_table_digest(layers)+    if args.print_digest:+        print(f'    "{args.graph}": "{digest}",')+    pinned = maml_convert.EXPECTED_DIGEST.get(args.graph, "")+    if digest != pinned and not args.print_digest:+        raise SystemExit(+            f"layer table digest {digest}\n           pinned  {pinned}\n"+            "The folded layer table changed, so the hardcoded forward pass no longer\n"+            "matches this export. Re-read it, update the Rust, then re-pin with\n"+            "--print-digest."+        )++    blob, count = maml_convert.build(+        layers, tensors, maml_convert.GRAPHS[args.graph], onnx_sha256+    )+    if args.out:+        with open(args.out, "wb") as f:+            f.write(blob)+    print(+        f"{args.graph}: {count} folded layers, {len(tensors)} tensors, "+        f"{len(blob)} bytes ({len(raw)} fp32 in)"+    )+++if __name__ == "__main__":+    main()