onnx.shape_inference¶
infer_shapes¶
-
onnx.shape_inference.infer_shapes(
model: Union[ModelProto, bytes],
check_type: bool = False,
strict_mode: bool = False,
data_prop: bool = False
) ModelProto [source]¶ Apply shape inference to the provided ModelProto.
Inferred shapes are added to the value_info field of the graph.
If the inferred values conflict with values already provided in the graph, that means that the provided values are invalid (or there is a bug in shape inference), and the result is unspecified.
- Parameters:
model (Union[ModelProto, bytes], bool, bool, bool) –
check_type (bool) – Checks the type-equality for input and output
strict_mode (bool) – Stricter shape inference, it will throw errors if any; Otherwise, simply stop if any error
data_prop (bool) – Enables data propagation for limited operators to perform shape computation
- Returns:
(ModelProto) model with inferred shape information
infer_shapes_path¶
-
onnx.shape_inference.infer_shapes_path(
model_path: str,
output_path: str = '',
check_type: bool = False,
strict_mode: bool = False,
data_prop: bool = False
) None [source]¶ Take model path for shape_inference same as infer_shape; it support >2GB models Directly output the inferred model to the output_path; Default is the original model path