| | | 1 | | using System.Collections.Immutable; |
| | | 2 | | |
| | | 3 | | namespace InferenceEngine.Core.Diagnostics; |
| | | 4 | | |
| | | 5 | | /// <summary>How the engine resolved the model it loaded.</summary> |
| | | 6 | | public enum ModelSource |
| | | 7 | | { |
| | | 8 | | /// <summary>Not reported (engine not loaded, or an older engine version).</summary> |
| | | 9 | | Unspecified = 0, |
| | | 10 | | |
| | | 11 | | /// <summary>The consumer supplied the location explicitly |
| | | 12 | | /// (<see cref="InferenceEngineOptions.ModelPath"/> or a custom <c>ModelProvider</c>).</summary> |
| | | 13 | | ExplicitPath, |
| | | 14 | | |
| | | 15 | | /// <summary>The engine's default registry/provider resolved it (downloading to the model |
| | | 16 | | /// cache on first use) — i.e. the consumer did not pin a location.</summary> |
| | | 17 | | RegistryManaged, |
| | | 18 | | } |
| | | 19 | | |
| | | 20 | | /// <summary>Immutable snapshot of a loaded inference engine's provider, platform, and diagnostic trail.</summary> |
| | | 21 | | public sealed record InferenceEngineInfo |
| | | 22 | | { |
| | 189 | 23 | | public InferenceProvider Provider { get; init; } = InferenceProvider.Unknown; |
| | 202 | 24 | | public HostPlatform Platform { get; init; } = HostPlatformDetector.Current(); |
| | 90 | 25 | | public int DeviceId { get; init; } |
| | 90 | 26 | | public bool GpuAccelerationRequested { get; init; } |
| | | 27 | | |
| | | 28 | | /// <summary>Model file name the engine loaded (e.g. "yolov8n-face.onnx"). Empty until loaded.</summary> |
| | 233 | 29 | | public string ModelName { get; init; } = string.Empty; |
| | | 30 | | |
| | | 31 | | /// <summary>Absolute path the model was actually loaded from (consumer-supplied asset path or |
| | | 32 | | /// the registry's cache location). Empty until loaded.</summary> |
| | 233 | 33 | | public string ModelPath { get; init; } = string.Empty; |
| | | 34 | | |
| | | 35 | | /// <summary>How <see cref="ModelPath"/> was determined.</summary> |
| | 121 | 36 | | public ModelSource ModelSource { get; init; } = ModelSource.Unspecified; |
| | | 37 | | |
| | | 38 | | /// <summary>True when a fall-back occurred (FallbackReason != None).</summary> |
| | 180 | 39 | | public bool IsFallback { get; init; } |
| | 135 | 40 | | public InferenceFallbackReason FallbackReason { get; init; } = InferenceFallbackReason.None; |
| | | 41 | | |
| | | 42 | | /// <summary>Per-provider key/value options actually applied.</summary> |
| | 93 | 43 | | public IReadOnlyDictionary<string, string> ProviderOptions { get; init; } |
| | 113 | 44 | | = ImmutableDictionary<string, string>.Empty; |
| | | 45 | | |
| | | 46 | | /// <summary>Not populated in v1; always <see cref="string.Empty"/>.</summary> |
| | 151 | 47 | | public string OnnxRuntimeVersion { get; init; } = string.Empty; |
| | | 48 | | |
| | 203 | 49 | | public DateTimeOffset SessionCreatedAt { get; init; } = DateTimeOffset.UtcNow; |
| | | 50 | | |
| | | 51 | | /// <summary>Ordered diagnostic trail of every check performed during provider selection.</summary> |
| | 296 | 52 | | public IReadOnlyList<ProviderDiagnosticCheck> Checks { get; init; } = Array.Empty<ProviderDiagnosticCheck>(); |
| | | 53 | | |
| | 186 | 54 | | public static InferenceEngineInfo Empty { get; } = new(); |
| | | 55 | | } |