自 2025 年 3 月 27 日起,我们建议您使用 android-latest-release
而非 aosp-main
构建 AOSP 并为其做出贡献。如需了解详情,请参阅 AOSP 的变更。
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 兼容性测试套件 (CTS) 和供应商测试套件 (VTS) 进行测试。
本页面上的内容和代码示例受内容许可部分所述许可的限制。Java 和 OpenJDK 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-04-04。
[[["易于理解","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"]],["最后更新时间 (UTC):2025-04-04。"],[],[],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."]]