According to the official LiteRT-LM Kotlin API documentation (https://github.com/google-ai-edge/LiteRT-LM/blob/main/docs/api/kotlin/getting_started.md#2-initialize-the-engine), to use the NPU backend on Android, developers must:
-
Bundle NPU libraries: Manually compile/download the required NPU libraries and place them in the app's src/main/jniLibs directory (or another appropriate location).
-
Configure the Engine: Specify the path to these libraries when initializing the Engine. The documentation provides the following code snippet:
val engineConfig = EngineConfig(
modelPath = modelPath,
backend = Backend.NPU(nativeLibraryDir = context.applicationInfo.nativeLibraryDir)
)
Here, context.applicationInfo.nativeLibraryDir should point to the directory containing the bundled NPU native libraries.
Problem:
In flutter_gemmain, is it only necessary to place the NPU library for the SoC in the src/main/jniLibs directory, and is it unnecessary to set Backend.NPU(nativeLibraryDir = context.applicationInfo.nativeLibraryDir)?
According to the official LiteRT-LM Kotlin API documentation (https://github.com/google-ai-edge/LiteRT-LM/blob/main/docs/api/kotlin/getting_started.md#2-initialize-the-engine), to use the NPU backend on Android, developers must:
Bundle NPU libraries: Manually compile/download the required NPU libraries and place them in the app's src/main/jniLibs directory (or another appropriate location).
Configure the Engine: Specify the path to these libraries when initializing the Engine. The documentation provides the following code snippet:
val engineConfig = EngineConfig(
modelPath = modelPath,
backend = Backend.NPU(nativeLibraryDir = context.applicationInfo.nativeLibraryDir)
)
Here, context.applicationInfo.nativeLibraryDir should point to the directory containing the bundled NPU native libraries.
Problem:
In flutter_gemmain, is it only necessary to place the NPU library for the SoC in the src/main/jniLibs directory, and is it unnecessary to set Backend.NPU(nativeLibraryDir = context.applicationInfo.nativeLibraryDir)?