NNAPI 迁移指南
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
Neural Networks API (NNAPI) 已废弃。该 API 在 Android 8.1 中引入,旨在为设备端机器学习提供硬件加速推理统一接口,并在 Android 15 中废弃。
NNAPI 发布后,设备端机器学习 (ODML) 领域迅速发展。Transformer 和扩散模型等突破性成果以及该领域的创新速度之快,意味着开发者需要经常更新的工具和基础架构。
为了满足这些需求,Google 开发了 Play 服务中的 TensorFlow Lite,为自定义设备端机器学习模型提供了可更新的 TensorFlow 运行时,以及 AICore,该工具可直接在 Android 设备上提供 Gemini Nano 等 GenAI 基础模型。为了更明确地说明在 Android 上实现正式版 ML 的推荐路径,我们废弃了 NNAPI (Neural Networks API)。
如需从 NNAPI 迁移,请参阅 Google Play 服务中的 TensorFlow Lite 的说明,并根据需要参阅 TFLite GPU 代理以实现硬件加速。
本页面上的内容和代码示例受内容许可部分所述许可的限制。Java 和 OpenJDK 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-04-07。
[null,null,["最后更新时间 (UTC):2025-04-07。"],[],[],null,["# NNAPI Migration Guide\n\nThe Neural Networks API (NNAPI) is deprecated. It was\n[introduced in Android 8.1](/about/versions/oreo/android-8.1#nnapi) to provide a unified interface for hardware\naccelerated inference for on-device machine learning,\nand deprecated in Android 15.\n\nAfter NNAPI's release, the field of on-device machine learning (ODML)\nadvanced rapidly. Breakthroughs such as transformer and diffusion models,\nalong with the high rate of innovation in the field meant that\ndevelopers needed tools and infrastructure that update frequently.\n\nTo meet those needs, Google developed\n[TensorFlow Lite in Play Services](https://www.tensorflow.org/lite/android/play_services),\nproviding an updatable TensorFlow runtime for custom on-device ML models,\nand [AICore](/ml/aicore), which provide GenAI foundation models like\nGemini Nano directly on Android devices. To provide greater clarity on\nthe recommended paths for production ML on Android, NNAPI (Neural Networks API)\nwas deprecated.\n\nTo migrate from NNAPI, see the instructions for\n[TensorFlow Lite in Google Play Services](https://www.tensorflow.org/lite/android/play_services)\nand optionally [TFLite GPU delegate](https://www.tensorflow.org/lite/android/delegates/gpu) for hardware acceleration."]]