6.1. TopsIDEAS onnx extract¶
描述¶
按照给定的输入输出tensor提取onnx模型的子图。
命令行¶
使用方法¶
usage: topsideas onnx extract [-h] --input_onnx INPUT_ONNX [--output_onnx OUTPUT_ONNX] [--inputs INPUT_META [INPUT_META ...]]
[--outputs OUTPUT_META [OUTPUT_META ...]] [--infer_shape_mode {onnx,symbolic,static,skip}]
参数¶
:::{table} topsideas onnx extract 参数列表
:widths: 8 32 20 45
short |
long |
default |
help |
---|---|---|---|
|
|
show this help message and exit |
|
|
|
Provide the original onnx file. |
|
|
|
Export the modified ONNX file. |
|
|
|
Input metadata for subgraph (names, shapes, and data types). Use ‘auto’ to make |
|
|
|
Output metadata for subgraph (names and data types). No dataformat provided to make |
|
|
|
The mode to do shape inference, choices are [‘onnx’, ‘symbolic’, ‘static’, ‘skip’]. |
:::
示例¶
topsideas onnx extract --input_onnx=demo.onnx --inputs 'MaxPool:0' --outputs 'concat:0' --output_onnx=demo_subgraph.onnx
:::{figure-md}
提取onnx子图示例 :::
API¶
使用方法¶
from topsideas.onnx import Extract
result = Extract.run(model, input_meta, output_meta)
参数¶
:::{table} topsideas.onnx.Extract 参数列表
:widths: 25 40 35
argument |
type |
default |
---|---|---|
model |
onnx.onnx_ml_pb2.ModelProto |
|
input_meta |
List[str] |
|
output_meta |
List[str] |
|
infer_shape_mode |
str |
onnx |
RETURN |
onnx.onnx_ml_pb2.ModelProto |
:::