ExecutionProviderCatalog 類別
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
提供方法以發現、取得及註冊 AI 執行提供者(EPs),以配合 ONNX 執行時使用。
ExecutionProviderCatalog 處理套件管理與硬體選擇的複雜性,是您的應用程式透過 Windows 機器學習執行時存取硬體優化機器學習加速的入口。
public ref class ExecutionProviderCatalog sealed
/// [Windows.Foundation.Metadata.ContractVersion(Microsoft.Windows.AI.MachineLearning.MachineLearningContract, 65536)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
/// [Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
class ExecutionProviderCatalog final
[Windows.Foundation.Metadata.ContractVersion(typeof(Microsoft.Windows.AI.MachineLearning.MachineLearningContract), 65536)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
[Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
public sealed class ExecutionProviderCatalog
Public NotInheritable Class ExecutionProviderCatalog
- 繼承
- 屬性
範例
// Get the default catalog
var catalog = Microsoft.Windows.AI.MachineLearning.ExecutionProviderCatalog.GetDefault();
// Ensure and register all compatible execution providers
await catalog.EnsureAndRegisterCertifiedAsync();
// Use ONNX Runtime directly for inference (using Microsoft.ML.OnnxRuntime namespace)
// Get the default catalog
winrt::Microsoft::Windows::AI::MachineLearning::ExecutionProviderCatalog catalog =
winrt::Microsoft::Windows::AI::MachineLearning::ExecutionProviderCatalog::GetDefault();
// Ensure and register all compatible execution providers
catalog.EnsureAndRegisterCertifiedAsync().get();
// Use ONNX Runtime C API directly for inference
import winui3.microsoft.windows.ai.machinelearning as winml
# Get the default catalog
catalog = winml.ExecutionProviderCatalog.get_default()
# DO NOT call winml's register methods in Python. Those will not work for the onnxruntime Python environment.
# Instead, register execution providers following this pattern:
providers = catalog.find_all_providers()
for provider in providers:
provider.ensure_ready_async().get()
ort.register_execution_provider_library(provider.name, provider.library_path)
方法
| 名稱 | Description |
|---|---|
| EnsureAndRegisterCertifiedAsync() |
提供方法以發現、取得及註冊 AI 執行提供者(EPs),以配合 ONNX 執行時使用。 ExecutionProviderCatalog 處理套件管理與硬體選擇的複雜性,是您的應用程式透過 Windows 機器學習執行時存取硬體優化機器學習加速的入口。 |
| FindAllProviders() |
擷取所有與當前硬體相容的執行提供者集合。 |
| GetDefault() |
取得預設的 ExecutionProviderCatalog 實例,該實例提供系統上所有執行提供者的存取權限。 |
| RegisterCertifiedAsync() |
在不確保 ONNX 執行時已準備好的情況下,將所有相容的執行提供者註冊給 ONNX 執行環境。 此系統僅註冊機器上已有的提供者,避免 EnsureAndRegisterCertifiedAsync 可能要求的冗長下載時間。 |