Kể từ ngày 27 tháng 3 năm 2025, bạn nên sử dụng android-latest-release
thay vì aosp-main
để xây dựng và đóng góp cho AOSP. Để biết thêm thông tin, hãy xem phần Thay đổi đối với AOSP.
Môi trường thời gian chạy NNAPI
Sử dụng bộ sưu tập để sắp xếp ngăn nắp các trang
Lưu và phân loại nội dung dựa trên lựa chọn ưu tiên của bạn.
Mô-đun Thời gian chạy NNAPI là một thư viện dùng chung nằm giữa ứng dụng và trình điều khiển phụ trợ. Android Neural Networks API (NNAPI) là một API ngôn ngữ C của Android được thiết kế để chạy các phép tính toán chuyên sâu dành cho máy học trên thiết bị di động và cho phép các phép suy luận tăng tốc phần cứng trên thiết bị Android. Mô-đun này có thể cập nhật, nghĩa là mô-đun này có thể nhận được bản cập nhật về chức năng bên ngoài chu kỳ phát hành Android thông thường.
Sau đây là những lợi ích của việc mô-đun hoá Thời gian chạy NNAPI.
Người dùng cuối có được tính nhất quán và khả năng tương thích được cải thiện.
Nhà phát triển nền tảng có thể vá lỗi trong môi trường thời gian chạy NNAPI, cải thiện khả năng tương tác của môi trường thời gian chạy NNAPI với trình điều khiển và triển khai các tính năng mới giúp cải thiện chức năng, độ ổn định, hiệu suất và tình trạng của NNAPI.
Nhà phát triển ứng dụng có thể cải thiện khả năng tương thích và hiệu suất của ứng dụng nhờ các nhân CPU được cập nhật.
Ranh giới mô-đun
Đối với Android 12 trở lên, bản sửa đổi HAL NNAPI sử dụng AIDL thay vì HIDL.
Đối với Android 11 trở xuống, ranh giới mô-đun Thời gian chạy NNAPI là platform/frameworks/ml/nn:libneuralnetworks.so
.
Mô-đun Thời gian chạy NNAPI (com.android.neuralnetworks
) ở định dạng APEX và có sẵn cho các thiết bị chạy Android 11 trở lên.
Phần phụ thuộc mô-đun
Mô-đun Thời gian chạy NNAPI này phụ thuộc vào NNAPI HAL và AHardwareBuffer.
Thử nghiệm
Để xác minh chức năng của mô-đun Thời gian chạy NNAPI, hãy sử dụng các bài kiểm thử Bộ kiểm tra tính tương thích với Android (CTS) và Bộ kiểm thử nhà cung cấp (VTS).
Nội dung và mã mẫu trên trang này phải tuân thủ các giấy phép như mô tả trong phần Giấy phép nội dung. Java và OpenJDK là nhãn hiệu hoặc nhãn hiệu đã đăng ký của Oracle và/hoặc đơn vị liên kết của Oracle.
Cập nhật lần gần đây nhất: 2025-07-27 UTC.
[[["Dễ hiểu","easyToUnderstand","thumb-up"],["Giúp tôi giải quyết được vấn đề","solvedMyProblem","thumb-up"],["Khác","otherUp","thumb-up"]],[["Thiếu thông tin tôi cần","missingTheInformationINeed","thumb-down"],["Quá phức tạp/quá nhiều bước","tooComplicatedTooManySteps","thumb-down"],["Đã lỗi thời","outOfDate","thumb-down"],["Vấn đề về bản dịch","translationIssue","thumb-down"],["Vấn đề về mẫu/mã","samplesCodeIssue","thumb-down"],["Khác","otherDown","thumb-down"]],["Cập nhật lần gần đây nhất: 2025-07-27 UTC."],[],[],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."]]