show#

Renders an ONNX model as text, a diagram, or code that rebuilds the model. The result is printed unless --output is specified.

python -m onnx_light show model.onnx
python -m onnx_light show model.onnx --format svg --output model.svg
python -m onnx_light show model.onnx --format onnx-compact

Command-line reference#

    usage: onnx-light show [-h]
                           [--format {pretty,mermaid,svg,dot,onnx-compact,builder,cpp}]
                           [--output OUTPUT] [--shape-inference] [--no-shapes]
                           [--include-attributes] [--include-inplace]
                           [--include-release] [--include-node-tags]
                           [--no-initializers] [--direction DIRECTION]
                           [--layout LAYOUT] [--graphviz GRAPHVIZ_FORMAT]
                           model
    
    Loads an ONNX model and renders it as plain text (pretty), a Mermaid
    flowchart, an SVG image, Graphviz DOT source or code that rebuilds the model
    (onnx-compact/builder/cpp). The result is written to stdout by default.
    
    positional arguments:
      model                 Path to the input ONNX model file.
    
    options:
      -h, --help            show this help message and exit
      --format {pretty,mermaid,svg,dot,onnx-compact,builder,cpp}, -f {pretty,mermaid,svg,dot,onnx-compact,builder,cpp}
                            Output format: 'pretty' (default) for a compact text
                            listing, 'mermaid' for a Mermaid flowchart, 'svg' for
                            an SVG image, 'dot' for Graphviz DOT source, or 'onnx-
                            compact'/'builder'/'cpp' for code that rebuilds the
                            model (Python for onnx-compact/builder, C++ for cpp;
                            see onnx_light.tools.translate).
      --output OUTPUT, -o OUTPUT
                            Write the rendered output to OUTPUT instead of
                            printing to stdout.
      --shape-inference     Run onnx-light shape inference on the model before
                            rendering.
      --no-shapes           Suppress shape annotations in the rendered output
                            (applies to 'mermaid' and 'svg' formats).
      --include-attributes  Include node attributes in the rendered output.
      --include-inplace     Show in-place buffer-reuse annotations
                            (onnx_light.inplace_reuse metadata).
      --include-release     Show post-execution release hints
                            (onnx_light.release_after and
                            onnx_light.not_used_after metadata). Only used by the
                            'pretty' format.
      --include-node-tags   Show semantic shape/axes/weight/ambiguous node-tag
                            annotations (onnx_light.node_tag metadata). Only used
                            by the 'pretty' format.
      --no-initializers     Exclude initializer nodes from the rendered graph
                            (applies to 'mermaid', 'svg' and 'dot' formats).
      --direction DIRECTION
                            Flowchart direction for 'mermaid', 'svg' and 'dot'
                            formats. One of TB (default), LR, TD or BT (mermaid
                            only).
      --layout LAYOUT       Box positioning strategy for the 'svg' format. One of
                            layered (default) or umap (requires the 'umap-learn'
                            package).
      --graphviz GRAPHVIZ_FORMAT
                            Invoke the Graphviz 'dot' executable on the generated
                            DOT source and write the result in GRAPHVIZ_FORMAT
                            (e.g. 'png', 'svg', 'pdf'). Only used when --format
                            dot is given. Requires Graphviz to be installed and
                            'dot' to be on PATH.