provider_selection#

Metadata-driven execution-provider selection.

Which ONNX Runtime execution provider is fastest — and even which is usable — depends on both the host (Apple CoreML vs NVIDIA CUDA/TensorRT vs CPU) and on properties of the checkpoint itself (precision, whether its graph has static shapes). This module keeps that knowledge in one replaceable component rather than scattered platform if-ladders:

  • HostCapabilities carries the host facts as injectable data, with a single impure HostCapabilities.detect() classmethod.

  • ProviderPolicy is the port; DefaultProviderPolicy is the adapter that maps (checkpoint, host) to an ordered provider chain. Users with exotic hardware implement their own policy.

Importing this module requires ONNX Runtime (the [cpu] or [gpu] extra) and raises MissingExtraError if it is missing.

Classes#

DefaultProviderPolicy(**data)

Default policy mapping (checkpoint precision/shape, host) to a provider chain.

HostCapabilities(**data)

Execution-relevant facts about the host, captured as injectable data.

ProviderPolicy(*args, **kwargs)

Port mapping a checkpoint and host to an ordered execution-provider chain.