experimental_experiment.convert.convert_helper

experimental_experiment.convert.convert_helper.inline_model_proto(model_proto: ModelProto) ModelProto[source]

Inlines a model.

Parameters:

model_proto – ModelProto

Returns:

inlined model

experimental_experiment.convert.convert_helper.optimize_model_proto_oxs(model_proto: ModelProto, verbose: int = 0, onnx_shape_inference: bool = False, inplace: bool = True, stats: Dict[str, Any] | None = None) ModelProto[source]

Optimizes a model proto to optimize onnxruntime.

Parameters:
  • model_proto – ModelProto

  • verbose – verbosity

  • onnx_shape_inference – enable shape inference

  • inplace – the function modifies the proto inplace as well

  • stats – if not empty, stores information

Returns:

optimized model

You should run that before calling this function

onnx_model = exported.to_model_proto(
    opset_version=self._resolved_onnx_exporter_options.onnx_registry.opset_version
)

from experimental_experiment.convert.convert_helper import optimize_model_proto_oxs
onnx_model = optimize_model_proto_oxs(onnx_model)
experimental_experiment.convert.convert_helper.ort_optimize(onnx_model: str | ModelProto, output: str, providers: str | List[str] = 'cpu', disable_aot: bool = False)[source]

Optimizes the model with onnxruntime.

Parameters:
  • onnx_model – ModelProto or file path

  • output – path for the output

  • providers – providers, cpu, cuda or a list of providers

  • disable_aot – disable AOT