onnx_diagnostic.helpers.model_builder_helper

onnx_diagnostic.helpers.model_builder_helper.create_model_builder(config: Any, model: torch.nn.Module, cache_dir: str, precision: str = 'fp32', execution_provider: str = 'cpu', verbose: int = 0, **extra_options) Model[source][source]

Creates a model based on a configuration. The onnx model is returned by function save_model_builder().

Parameters:
  • config – configuration

  • cache_dir – cache directory

  • precision – precision

  • execution_provider – execution provider

  • verbose – verbosity

  • extra_options – extra options

Returns:

model

onnx_diagnostic.helpers.model_builder_helper.download_model_builder_to_cache(url: str = 'https://raw.githubusercontent.com/microsoft/onnxruntime-genai/refs/heads/main/src/python/py/models/builder.py')[source][source]

Downloads builder.py from the https://github.com/microsoft/onnxruntime-genai/blob/main/src/python/py/models/builder.py.

onnx_diagnostic.helpers.model_builder_helper.import_model_builder(module_name: str = 'builder') object[source][source]

Imports the downloaded model.by.

onnx_diagnostic.helpers.model_builder_helper.save_model_builder(self, out_dir: str | None = '', verbose: int = 0) ModelProto[source][source]

Saves a model created by function create_model_builder(). If out_dir is empty or not specified, the function still returns the generated model.