54 lines
3.4 KiB
Diff
54 lines
3.4 KiB
Diff
--- a/app/src/main/java/com/kazeia/stt/WhisperHybridEngine.kt
|
|
+++ b/app/src/main/java/com/kazeia/stt/WhisperHybridEngine.kt
|
|
@@ -98,8 +98,15 @@ class WhisperHybridEngine(
|
|
val htpPath = "$nativeLibDir/libQnnHtp.so"
|
|
nlog("Loading HfWhisper encoder (QNN NPU)...")
|
|
val t0 = System.currentTimeMillis()
|
|
val encOpts = OrtSession.SessionOptions()
|
|
- encOpts.addQnn(mapOf("backend_path" to htpPath))
|
|
+ encOpts.addQnn(mapOf(
|
|
+ "backend_path" to htpPath,
|
|
+ "htp_performance_mode" to "burst", // NPU freq max (vs default = balanced)
|
|
+ "htp_arch" to "79", // SM8750 = SD8 Elite V79
|
|
+ "enable_htp_fp16_precision" to "1", // NPU fp16 natif
|
|
+ ))
|
|
+ encOpts.setOptimizationLevel(
|
|
+ OrtSession.SessionOptions.OptLevel.ALL_OPT)
|
|
hfEncoderSession = ortEnv!!.createSession(hfEncPath, encOpts)
|
|
val encMs = System.currentTimeMillis() - t0
|
|
nlog("HfEncoder NPU loaded: ${encMs}ms")
|
|
|
|
nlog("Loading HfWhisper decoder (QNN NPU)...")
|
|
val t1 = System.currentTimeMillis()
|
|
val decOpts = OrtSession.SessionOptions()
|
|
- decOpts.addQnn(mapOf("backend_path" to htpPath))
|
|
+ decOpts.addQnn(mapOf(
|
|
+ "backend_path" to htpPath,
|
|
+ "htp_performance_mode" to "burst",
|
|
+ "htp_arch" to "79",
|
|
+ "enable_htp_fp16_precision" to "1",
|
|
+ ))
|
|
+ decOpts.setOptimizationLevel(
|
|
+ OrtSession.SessionOptions.OptLevel.ALL_OPT)
|
|
hfDecoderSession = ortEnv!!.createSession(hfDecPath, decOpts)
|
|
val decMs = System.currentTimeMillis() - t1
|
|
nlog("HfDecoder NPU loaded: ${decMs}ms")
|
|
@@ -130,9 +137,15 @@ class WhisperHybridEngine(
|
|
if (!useHfModels) {
|
|
val encNpuPath = "$path/encoder_npu/model.onnx"
|
|
if (File(encNpuPath).exists()) {
|
|
try {
|
|
val encOpts = OrtSession.SessionOptions()
|
|
- encOpts.addQnn(mapOf("backend_path" to "$nativeLibDir/libQnnHtp.so"))
|
|
+ encOpts.addQnn(mapOf(
|
|
+ "backend_path" to "$nativeLibDir/libQnnHtp.so",
|
|
+ "htp_performance_mode" to "burst",
|
|
+ "htp_arch" to "79",
|
|
+ "enable_htp_fp16_precision" to "1",
|
|
+ ))
|
|
+ encOpts.setOptimizationLevel(
|
|
+ OrtSession.SessionOptions.OptLevel.ALL_OPT)
|
|
nlog("Loading encoder (QNN NPU)...")
|
|
val t0 = System.currentTimeMillis()
|
|
encoderSession = ortEnv!!.createSession(encNpuPath, encOpts)
|