Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 21 additions & 5 deletions Samples/WindowsML/Shared/cs/PerformanceConfigurator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,32 @@ namespace WindowsML.Shared
{
public static class PerformanceConfigurator
{
/// <summary>
/// Returns EP-specific session options for the given execution provider name.
///
/// The string literals below come from two sources that may use different names
/// for the same provider:
/// 1. ORT runtime — OrtEpDevice.EpName returned by ExecutionProviderCatalog.FindAllProviders()
/// 2. Model catalog JSON — the "executionProviders[].name" field in files like
/// Resources/SqueezeNetModelCatalog.json
///
/// When a provider appears under different names in these two sources, both forms
/// must be listed here so the lookup succeeds regardless of which name is passed in.
/// If a new EP is added to the ORT runtime or the catalog introduces an alias,
/// a corresponding entry should be added below.
Comment on lines +14 to +23
Copy link

Copilot AI Apr 14, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The XML doc comment misidentifies where the ORT EP name comes from. ExecutionProviderCatalog.FindAllProviders() returns ExecutionProvider objects whose name is provider.Name (WinRT catalog), whereas the ORT runtime EP name used by SessionOptions/OrtEpDevice comes from ORT enumeration (e.g., OrtEnv.GetEpDevices()OrtEpDevice.EpName). As written, the comment suggests OrtEpDevice.EpName is returned by FindAllProviders(), which is misleading—please update the doc to clearly distinguish WinRT catalog provider names vs ORT runtime EP names and point to the correct APIs for each source.

Suggested change
/// The string literals below come from two sources that may use different names
/// for the same provider:
/// 1. ORT runtime — OrtEpDevice.EpName returned by ExecutionProviderCatalog.FindAllProviders()
/// 2. Model catalog JSON — the "executionProviders[].name" field in files like
/// Resources/SqueezeNetModelCatalog.json
///
/// When a provider appears under different names in these two sources, both forms
/// must be listed here so the lookup succeeds regardless of which name is passed in.
/// If a new EP is added to the ORT runtime or the catalog introduces an alias,
/// a corresponding entry should be added below.
/// The string literals below may come from different sources that use different names
/// for the same provider:
/// 1. WinRT execution provider catalog names — returned by
/// ExecutionProviderCatalog.FindAllProviders() as ExecutionProvider.Name
/// 2. ORT runtime EP names — returned by ORT enumeration APIs such as
/// OrtEnv.GetEpDevices() as OrtEpDevice.EpName; these are the names used by
/// SessionOptions and OrtEpDevice
/// 3. Model catalog JSON — the "executionProviders[].name" field in files like
/// Resources/SqueezeNetModelCatalog.json
///
/// When a provider appears under different names in these sources, each relevant form
/// must be listed here so the lookup succeeds regardless of which name is passed in.
/// If a new EP is added to the ORT runtime, WinRT catalog, or model catalog introduces
/// an alias, a corresponding entry should be added below.

Copilot uses AI. Check for mistakes.
/// </summary>
public static Dictionary<string, string> GetEpOptions(string epName, PerformanceMode mode)
{
string normalized = (epName ?? string.Empty).Trim().ToUpperInvariant();
return normalized switch
{
"OPENVINOEXECUTIONPROVIDER" => GetOpenVinoOptions(mode),
"QNNEXECUTIONPROVIDER" => GetQnnOptions(mode),
"VITISAIEXECUTIONPROVIDER" => GetVitisAiOptions(mode),
"MIGRAPHXEXECUTIONPROVIDER" => GetMiGraphxOptions(mode),
"TENSORRTRTXEXECUTIONPROVIDER" => GetTensorRtRtxOptions(mode),
"OPENVINOEXECUTIONPROVIDER" => GetOpenVinoOptions(mode), // ORT runtime name
"QNNEXECUTIONPROVIDER" => GetQnnOptions(mode), // ORT runtime name
"VITISAIEXECUTIONPROVIDER" => GetVitisAiOptions(mode), // ORT runtime name
"MIGRAPHXEXECUTIONPROVIDER" => GetMiGraphxOptions(mode), // ORT runtime name
"TENSORRTRTXEXECUTIONPROVIDER" // ORT runtime name
or "NVTENSORRTRTXEXECUTIONPROVIDER" // catalog JSON name (SqueezeNetModelCatalog.json)
=> GetTensorRtRtxOptions(mode),
_ => new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase)
};
}
Expand Down
Loading