fillshape#
Fills an ONNX model with shape-inference information and optional memory and
shape-tag metadata. Without --output or --show, the input file is
overwritten.
python -m onnx_light fillshape model.onnx --output model_shapes.onnx
python -m onnx_light fillshape model.onnx --show
Command-line reference#
usage: onnx-light fillshape [-h] [--output OUTPUT] [--keep] [--inplace-info]
[--release-info] [--peak-memory] [--shape-tag]
[--show] [--token NAME=LOW:HIGH]
[--verbose [LEVEL]]
model
Runs onnx_shapes shape inference on a model and writes the inferred shapes
back into graph.value_info and graph.output.
positional arguments:
model Path to the input ONNX model file.
options:
-h, --help show this help message and exit
--output OUTPUT, -o OUTPUT
Path to write the result to. When omitted the input
file is overwritten in place.
--keep Seed the inference context from shapes already present
in the model. Existing non-conflicting shapes are kept
as anchors.
--inplace-info Also compute in-place buffer-reuse opportunities and
record them in each node's metadata_props under the
key ``onnx_light.inplace_reuse``.
--release-info Also compute last-use release hints and record them in
each node's metadata_props under the keys
``onnx_light.release_after`` and
``onnx_light.not_used_after``.
--peak-memory Also compute symbolic worst-case scratch memory for
each node under ``onnx_light.peak_memory_max`` and,
when justified, an average under
``onnx_light.peak_memory_average``. Unknown maxima
remain unresolved symbols. Positive concrete maxima
also refresh the legacy ``onnx_light.peak_memory``
allocation hint.
--shape-tag After shape inference, infer semantic
shape/axes/weight/ambiguous tags for every value and
node in the graph and record them in metadata_props
(per-value key ``onnx_light.value_tag`` and per-node
key ``onnx_light.node_tag``).
--show Print inferred shapes to stdout; do not save the
model.
--token NAME=LOW:HIGH
Bind a symbolic dimension token to an inclusive
integer range before running shape inference. May be
given multiple times (e.g. --token batch=1:8 --token
seq=1:128). The lower bound is used for shape
propagation. Symbolic dims not covered by --token
remain symbolic.
--verbose [LEVEL] Print shape-inference progress; default level is 1
when the option is present. Level 2 also prints per-
event details.