onnx.utils¶
Extractor¶
- class onnx.utils.Extractor(model: ModelProto)[source]¶
extract_model¶
- onnx.utils.extract_model(input_path: str, output_path: str, input_names: List[str], output_names: List[str], check_model: bool = True) None [source]¶
Extracts sub-model from an ONNX model.
The sub-model is defined by the names of the input and output tensors exactly.
Note: For control-flow operators, e.g. If and Loop, the _boundary of sub-model_, which is defined by the input and output tensors, should not _cut through_ the subgraph that is connected to the _main graph_ as attributes of these operators.
- Parameters:
input_path (string) – The path to original ONNX model.
output_path (string) – The path to save the extracted ONNX model.
input_names (list of string) – The names of the input tensors that to be extracted.
output_names (list of string) – The names of the output tensors that to be extracted.
check_model (bool) – Whether to run model checker on the extracted model.