Add XNN Pack toggle switch for ONNX inference acceleration (#155)

* Initial plan

* Add XNN Pack switch for ONNX inference acceleration

Co-authored-by: xkeyC <39891083+xkeyC@users.noreply.github.com>

* Refactor Rust ONNX session creation to reduce code duplication

Co-authored-by: xkeyC <39891083+xkeyC@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: xkeyC <39891083+xkeyC@users.noreply.github.com>
This commit is contained in:
Copilot
2025-11-28 21:23:31 +08:00
committed by GitHub
parent db024f19bd
commit db89100402
26 changed files with 197 additions and 74 deletions

View File

@@ -26,6 +26,7 @@ abstract class SettingsUIState with _$SettingsUIState {
String? customGamePath,
@Default(0) int locationCacheSize,
@Default(false) bool isUseInternalDNS,
@Default(true) bool isEnableOnnxXnnPack,
}) = _SettingsUIState;
}
@@ -44,6 +45,7 @@ class SettingsUIModel extends _$SettingsUIModel {
await _loadLocationCacheSize();
await _loadToolSiteMirrorState();
await _loadUseInternalDNS();
await _loadOnnxXnnPackState();
}
Future<void> setGameLaunchECore(BuildContext context) async {
@@ -227,4 +229,17 @@ class SettingsUIModel extends _$SettingsUIModel {
userBox.get("isUseInternalDNS", defaultValue: false);
state = state.copyWith(isUseInternalDNS: isUseInternalDNS);
}
void onChangeOnnxXnnPack(bool? b) {
final userBox = Hive.box("app_conf");
userBox.put("isEnableOnnxXnnPack", b ?? true);
_initState();
}
Future _loadOnnxXnnPackState() async {
final userBox = await Hive.openBox("app_conf");
final isEnableOnnxXnnPack =
userBox.get("isEnableOnnxXnnPack", defaultValue: true);
state = state.copyWith(isEnableOnnxXnnPack: isEnableOnnxXnnPack);
}
}