自 2025 年 3 月 27 日起,我們建議您使用 android-latest-release
而非 aosp-main
建構及貢獻 AOSP。詳情請參閱「Android 開放原始碼計畫變更」。
NNAPI 執行階段
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
NNAPI 執行階段模組是位於應用程式和後端驅動程式之間的共用程式庫。Android Neural Networks API (NNAPI) 是一個 Android C API,專為在行動裝置上執行計算密集型作業,以便進行機器學習,並在 Android 裝置上啟用硬體加速推論作業。這個模組可更新,也就是說,它可以在正常的 Android 發布週期之外接收功能更新。
將 NNAPI 執行階段模組化的好處包括:
模組邊界
在 Android 12 以上版本中,NNAPI HAL 修訂版本會使用 AIDL,而非 HIDL。
在 Android 11 以下版本中,NNAPI 執行階段模組邊界為 platform/frameworks/ml/nn:libneuralnetworks.so
。
NNAPI 執行階段模組 (com.android.neuralnetworks
) 採用 APEX 格式,適用於搭載 Android 11 以上版本的裝置。
模組依附元件
這個 NNAPI 執行階段模組會依附 NNAPI HAL 和 AHardwareBuffer。
測試
如要驗證 NNAPI 執行階段模組的功能,請使用 Android Compatibility Test Suite (CTS) 和供應商測試套件 (VTS) 測試。
這個頁面中的內容和程式碼範例均受《內容授權》中的授權所規範。Java 與 OpenJDK 是 Oracle 和/或其關係企業的商標或註冊商標。
上次更新時間:2025-07-27 (世界標準時間)。
[[["容易理解","easyToUnderstand","thumb-up"],["確實解決了我的問題","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["缺少我需要的資訊","missingTheInformationINeed","thumb-down"],["過於複雜/步驟過多","tooComplicatedTooManySteps","thumb-down"],["過時","outOfDate","thumb-down"],["翻譯問題","translationIssue","thumb-down"],["示例/程式碼問題","samplesCodeIssue","thumb-down"],["其他","otherDown","thumb-down"]],["上次更新時間:2025-07-27 (世界標準時間)。"],[],[],null,["# NNAPI Runtime\n\n| **Deprecated:** Starting in Android 15, the\n| [NNAPI (NDK API)](https://developer.android.com/ndk/guides/neuralnetworks) is deprecated. The Neural Networks HAL interface\n| continues to be supported.\n|\n| For more information, see the\n| [NNAPI Migration Guide](https://developer.android.com/ndk/guides/neuralnetworks/migration-guide).\n\nThe NNAPI Runtime module is a shared library that sits between an app and\nbackend drivers. The [Android Neural Networks API\n(NNAPI)](https://developer.android.com/ndk/guides/neuralnetworks/)\nis an Android C API designed for running computationally intensive operations\nfor machine learning on mobile devices and enables hardware-accelerated\ninference operations on Android devices. This module is updatable, meaning it\ncan receive updates to functionality outside of the normal Android release\ncycle.\n\nThe benefits of modularizing the NNAPI Runtime include the following.\n\n- End users get improved consistency and compatibility.\n\n- Platform developers can patch bugs in the NNAPI runtime, improve NNAPI runtime\n interaction with drivers, and deploy new features that improve NNAPI\n capabilities, stability, performance, and health.\n\n- App developers get improved app compatibility and performance with updated CPU\n kernels.\n\nModule boundary\n---------------\n\nFor Android 12 and higher, the NNAPI HAL revision\nuses AIDL instead of HIDL.\n\nFor Android 11 and lower, the NNAPI Runtime module\nboundary is `platform/frameworks/ml/nn:libneuralnetworks.so`.\n\nModule format\n-------------\n\nThe NNAPI Runtime module (`com.android.neuralnetworks`) is in\n[APEX](/docs/core/ota/apex) format and is available for devices\nrunning Android 11 or higher.\n\nModule dependencies\n-------------------\n\nThis NNAPI Runtime module depends on the [NNAPI\nHAL](/docs/core/interaction/neural-networks#nnhal) and\n[AHardwareBuffer](/docs/core/interaction/neural-networks/memory-pools#ahardwarebuffer).\n\nTesting\n-------\n\nTo verify the functionality of the NNAPI Runtime module, use the Android\nCompatibility Test Suite (CTS) and Vendor Test Suite (VTS) tests."]]