-m yobx print … print an onnx model on standard output#
The command loads an onnx model and prints it on standard output in one of several formats.
Description#
See yobx.helpers.onnx_helper.pretty_onnx() and
yobx.xshape.BasicShapeBuilder.
usage: print [-h] {dot,onnx-compact,mermaid,pretty,printer,raw,shape} input
Prints the model on the standard output.
positional arguments:
{dot,onnx-compact,mermaid,pretty,printer,raw,shape}
Prints out a model on the standard output.
dot - converts the graph into dot
onnx-compact - translates the model into compact Python code
pretty - an improved rendering
printer - onnx.printer.to_text(...)
raw - just prints the model with print(...)
shape - prints every node with input and output shapes
input onnx model to load
options:
-h, --help show this help message and exit
To show a model.
Examples#
Print a model in the default pretty format:
python -m yobx print pretty model.onnx
Print every node with its inferred input/output shapes:
python -m yobx print shape model.onnx
Print the raw protobuf representation:
python -m yobx print raw model.onnx
Print the onnx-native text representation:
python -m yobx print printer model.onnx
Dump the dot graph source:
python -m yobx print dot model.onnx
Output on a Dummy Model#
The following block builds a small Add + Relu model on the fly and runs
the command to show what the output actually looks like.
--- pretty ---
opset: domain='' version=18
input: name='X' type=dtype('float32') shape=[2, 3]
input: name='Y' type=dtype('float32') shape=[2, 3]
Add(X, Y) -> added
Relu(added) -> Z
output: name='Z' type=dtype('float32') shape=[2, 3]
--- printer ---
<
ir_version: 10,
opset_import: ["" : 18]
>
add_relu (float[2,3] X, float[2,3] Y) => (float[2,3] Z) {
added = Add (X, Y)
Z = Relu (added)
}