partition#

Extracts local functions while preserving inline weights and leaving large external weight payloads unloaded. Chooses repeated-layer detection or transfer-aware partitioning, saves a rewritten ONNX model and prints a function summary.

python -m onnx_light partition layer model.onnx --output model.layers.onnx
python -m onnx_light partition mincut model.onnx --output model.partition.onnx

See partition for algorithm descriptions, weight preservation and output placement.

Both methods print their selection policy and two totals per call: inputs and outputs, each with symbolic logical bytes and transfer bytes. Constants contribute logical bytes but no transfer bytes, except for overridable initializers. The report omits individual tensors, also with --verbose. Unavailable volumes are explicit unknowns. These post-internalization formulas are descriptive, not compared by the selectors.

Command-line reference#

    usage: onnx-light partition [-h] METHOD ...
    
    positional arguments:
      METHOD
        layer     Applies only RepeatedLayer to extract repeated computations.
        mincut    Applies only PartitionGroup using bounded transfer-aware
                  interval partitioning.
    
    options:
      -h, --help  show this help message and exit

Repeated layers#

partition layer retains the former layers arguments: model, --output/-o, --tiny-tensor-threshold and --verbose/-v.

    usage: onnx-light partition layer [-h] --output OUTPUT
                                      [--tiny-tensor-threshold BYTES]
                                      [--verbose [VERBOSE]]
                                      model
    
    Applies only RepeatedLayer to extract repeated computations. Preserves inline
    weights and external weight references, and loads tiny external tensors for
    shape inference. Saves a rewritten ONNX model and prints a function summary.
    
    positional arguments:
      model                 Path to the input binary ONNX model.
    
    options:
      -h, --help            show this help message and exit
      --output OUTPUT, -o OUTPUT
                            Output ONNX file, overwritten if it exists. External
                            weight paths are preserved.
      --tiny-tensor-threshold BYTES
                            Inline external tensors strictly smaller than BYTES
                            (default: 128).
      --verbose [VERBOSE], -v [VERBOSE]
                            Print loading and extraction progress.

Transfer-aware groups#

partition mincut accepts the same arguments plus an optional --max-boundary-bytes cap (no cap by default), --min-group-nodes (default 2) and --max-group-nodes (default 128). The minimum must be at least two and must not exceed the maximum. Symbolic boundaries are supported by default: the algorithm minimizes unknown transfers first, then known bytes. An explicit byte cap requires fully known boundary sizes. Each partition is also limited to floor(model_weights / 20) distinct constant inputs before internalization. This 5% budget counts weights, not their byte volumes. Over-budget operators remain outside extracted functions.

    usage: onnx-light partition mincut [-h] --output OUTPUT
                                       [--tiny-tensor-threshold BYTES]
                                       [--verbose [VERBOSE]]
                                       [--max-boundary-bytes BYTES]
                                       [--min-group-nodes N] [--max-group-nodes N]
                                       [--max-constant-inputs N]
                                       model
    
    Applies only PartitionGroup using bounded transfer-aware interval
    partitioning. Preserves inline weights and external weight references, and
    loads tiny external tensors for shape inference. Saves a rewritten ONNX model
    and prints a function summary.
    
    positional arguments:
      model                 Path to the input binary ONNX model.
    
    options:
      -h, --help            show this help message and exit
      --output OUTPUT, -o OUTPUT
                            Output ONNX file, overwritten if it exists. External
                            weight paths are preserved.
      --tiny-tensor-threshold BYTES
                            Inline external tensors strictly smaller than BYTES
                            (default: 128).
      --verbose [VERBOSE], -v [VERBOSE]
                            Print loading and extraction progress.
      --max-boundary-bytes BYTES
                            Optional transfer-byte cap for fully known boundaries
                            (default: no cap).
      --min-group-nodes N   Minimum nodes per group, at least 2 (default: 2).
      --max-group-nodes N   Maximum nodes per group, at least --min-group-nodes
                            (default: 128).
      --max-constant-inputs N
                            Maximum distinct constant inputs per group before
                            internalization (default: 5% of model weights, rounded
                            down).