mirror of
https://github.com/babalae/better-genshin-impact.git
synced 2026-04-16 21:09:22 +08:00
36 lines
1.1 KiB
C#
36 lines
1.1 KiB
C#
using BetterGenshinImpact.GameTask;
|
|
using BetterGenshinImpact.Model;
|
|
using Microsoft.ML.OnnxRuntime;
|
|
using System.ComponentModel;
|
|
|
|
namespace BetterGenshinImpact.Core.Recognition.ONNX;
|
|
|
|
public class BgiSessionOption : Singleton<BgiSessionOption>
|
|
{
|
|
public static string[] InferenceDeviceTypes { get; } = ["CPU", "GPU_DirectML"];
|
|
|
|
public SessionOptions Options { get; set; } = TaskContext.Instance().Config.InferenceDevice switch
|
|
{
|
|
"CPU" => new SessionOptions(),
|
|
"GPU_DirectML" => MakeSessionOptionWithDirectMlProvider(),
|
|
_ => throw new InvalidEnumArgumentException("无效的推理设备")
|
|
};
|
|
|
|
public static SessionOptions MakeSessionOptionWithDirectMlProvider()
|
|
{
|
|
var sessionOptions = new SessionOptions();
|
|
sessionOptions.AppendExecutionProvider_DML(0);
|
|
return sessionOptions;
|
|
}
|
|
|
|
// /// <summary>
|
|
// /// 重新加载每个推理器(测试没用,只能重启)
|
|
// /// </summary>
|
|
// public void RefreshInference()
|
|
// {
|
|
// // 自动秘境每次都会NEW不用管
|
|
// // Yap、自动钓鱼
|
|
// GameTaskManager.RefreshTriggerConfigs();
|
|
// }
|
|
}
|