react-native-sherpa-onnx exposes execution provider and acceleration support: QNN (Qualcomm NPU), NNAPI (Android GPU/DSP/NPU), XNNPACK (CPU-optimized), and Core ML (iOS).
Execution Provider Overview
| Execution Provider | Supported | Provider ID | Notes |
|---|---|---|---|
| CPU | ✅ | cpu | Default fallback; always available |
| Core ML | ✅ | coreml | iOS only. Apple Neural Engine when available |
| XNNPACK | ✅ | xnnpack | CPU-optimized; Android/iOS when built in |
| NNAPI | ✅ | nnapi | Android only. Uses GPU/DSP/NPU via Android Neural Networks API |
| QNN | ✅ | qnn | Android only (Qualcomm NPU). Requires adding QNN runtime libs yourself |
| CUDA | ❌ | — | NVIDIA GPUs; targets desktop/server. Not applicable for mobile React Native |
| TRT (TensorRT) | ❌ | — | NVIDIA TensorRT; desktop/server. Not relevant for mobile |
| DirectML | ❌ | — | Windows GPU acceleration. Not supported |
| SpacemiT | ❌ | — | Not part of the current build |
Unsupported providers (CUDA, TRT, DirectML, SpacemiT): Implementation is not planned. If you need support for one of these, please open an issue.
Quick Start: Adding QNN Runtime Libs
To enable QNN on Android (so thatgetQnnSupport().canInit is true and you can use provider: 'qnn' for STT):
Download the Qualcomm AI Runtime
Download and accept the license:Qualcomm AI Runtime Community
Copy the QNN runtime libraries
Copy the required libraries (e.g.
libQnnHtp.so, libQnnHtpV*Stub.so, libQnnSystem.so) into your app’s native libs per ABI.See Run executables on your phone for the exact needed libraries.The path android/src/main/jniLibs/arm64-v8a should contain:The sherpa-onnx and ONNX Runtime libs used by this SDK are already built with QNN; you only add the Qualcomm runtime libs. Do not remove Qualcomm’s copyright or proprietary notices.
Unified AccelerationSupport API
All acceleration support getters return the same shape:Field Meanings by Backend
| Backend | providerCompiled | hasAccelerator | canInit |
|---|---|---|---|
| QNN (Android) | ORT providers contains QNN | native HTP init (QnnBackend_create) | QNN session test |
| NNAPI (Android) | ORT providers contains NNAPI | GPU or ACCELERATOR device present | NNAPI session test |
| XNNPACK | ORT providers contains XNNPACK | true when compiled (CPU-optimized) | XNNPACK session test |
| Core ML (iOS) | true (Core ML on iOS 11+) | Apple Neural Engine available | Not implemented (returns false) |
API Reference
getQnnSupport()
Returns QNN support in unified format.modelBase64?(string): Optional base64-encoded ONNX model for testing. If omitted, uses embedded test model.
Promise<AccelerationSupport>
getAvailableProviders()
Returns the list of ONNX Runtime execution providers available in the current build.Promise<string[]> — Provider names (e.g. ['CPU', 'QNN', 'NNAPI'])
getNnapiSupport()
Returns NNAPI (Android) support in unified format.modelBase64?(string): Optional base64-encoded ONNX model for testing.
Promise<AccelerationSupport>
Why can hasAccelerator be No and canInit be Yes?
Why can hasAccelerator be No and canInit be Yes?
The two values answer different questions:
- hasAccelerator comes from the Android NDK Neural Networks API: it checks whether the system reports at least one NNAPI device of type accelerator (GPU/DSP/NPU).
- canInit comes from creating an ONNX Runtime session with the NNAPI execution provider. NNAPI can still run on CPU if no accelerator is available.
provider: 'nnapi'.getXnnpackSupport()
Returns XNNPACK support in unified format.modelBase64?(string): Optional base64-encoded ONNX model for testing.
Promise<AccelerationSupport>
getCoreMlSupport()
Returns Core ML (iOS) support in unified format.modelBase64?(string): Optional base64-encoded ONNX model for testing.
Promise<AccelerationSupport>
On iOS,
providerCompiled is always true; hasAccelerator reflects Apple Neural Engine (iOS 15+). canInit is not implemented and returns false.Support Matrix
QNN Support
| Situation | providerCompiled | hasAccelerator | canInit |
|---|---|---|---|
| Android, QNN libs added, device supports HTP | ✅ | ✅ | ✅ |
| Android, QNN libs not added | ✅ | ❌ | ❌ |
| Android, build without QNN | ❌ | ❌ | ❌ |
| Android, QNN libs present but device/backend init fails | ✅ | ❌ | ❌ |
| iOS | ❌ | ❌ | ❌ |
NNAPI Support
| Situation | providerCompiled | hasAccelerator | canInit |
|---|---|---|---|
| Android, NNAPI in build, device reports accelerator, session OK | ✅ | ✅ | ✅ |
| Android, NNAPI in build, no accelerator reported, session OK | ✅ | ❌ | ✅ |
| Android, NNAPI in build, session fails | ✅ | * | ❌ |
| Android, build without NNAPI | ❌ | ❌ | ❌ |
| iOS | ❌ | ❌ | ❌ |
XNNPACK Support
| Situation | providerCompiled | hasAccelerator | canInit |
|---|---|---|---|
| Build has XNNPACK, session created | ✅ | ✅ | ✅ |
| Build has XNNPACK, no model passed | ✅ | ✅ | ❌ |
| Build without XNNPACK | ❌ | ❌ | ❌ |
Core ML Support
| Situation | providerCompiled | hasAccelerator | canInit |
|---|---|---|---|
| iOS 11+, device with ANE (A12+), iOS 15+ | ✅ | ✅ | ❌ |
| iOS 11+, device without ANE or simulator | ✅ | ❌ | ❌ |
| Android | ❌ | ❌ | ❌ |
License and Compliance (QNN SDK)
The Qualcomm AI Stack License allows you to distribute the QNN runtime libraries only in object code and only as part of your application — not on a standalone basis.How We Stay Compliant
-
This SDK: We do not ship QNN
.sofiles in the repository or npm package. The SDK uses sherpa-onnx/ORT built with QNN but relies on the app to provide the QNN runtime libs. - You (app developer): Download the Qualcomm AI Runtime Community, accept the license, and copy the required runtime libraries into your app.
- Notices: Do not remove Qualcomm’s copyright or proprietary notices. If your app ships with QNN libraries, include the applicable Qualcomm license/notice in your app’s legal/credits or documentation.
See Also
STT API
Use execution providers with Speech-to-Text
TTS API
Use execution providers with Text-to-Speech
Model Setup
Learn how to set up and manage models
Supported Models
View all supported model types