Mulai 27 Maret 2025, sebaiknya gunakan android-latest-release, bukan aosp-main, untuk mem-build dan berkontribusi pada AOSP. Untuk mengetahui informasi selengkapnya, lihat Perubahan pada AOSP.
Tetap teratur dengan koleksi
Simpan dan kategorikan konten berdasarkan preferensi Anda.
Di Android 10, Neural Networks API (NNAPI)
memperkenalkan fungsi yang memungkinkan
library dan aplikasi
framework machine learning mendapatkan informasi tentang perangkat yang tersedia dan
menentukan perangkat tempat model akan dieksekusi. Menyediakan informasi tentang
perangkat yang tersedia memungkinkan aplikasi mendapatkan versi driver tepat
yang ditemukan di perangkat untuk menghindari ketidakcocokan umum. Dengan memberi aplikasi
kemampuan untuk menentukan perangkat mana yang akan mengeksekusi berbagai bagian model,
aplikasi dapat dioptimalkan untuk produk tempat aplikasi di-deploy.
Dukungan untuk penemuan dan penetapan perangkat diperlukan untuk penerapan NN HAL 1.2.
Implementasi
Untuk mendukung fitur penemuan dan penetapan perangkat di NNAPI, terapkan
getType
dan
getVersionString
di IDevice.hal untuk memungkinkan framework mendapatkan jenis perangkat dan versi
driver.
Untuk setiap perangkat, tentukan jenisnya sebagai salah satu kategori berikut seperti
yang ditentukan di
DeviceType
di
types.hal.
OTHER: Perangkat yang tidak termasuk dalam kategori
lainnya, termasuk antarmuka heterogen, yang merupakan antarmuka IDevice
tunggal yang mengelola beberapa perangkat, mungkin dari jenis yang berbeda. Driver
dengan antarmuka heterogen juga harus mengekspos
antarmuka IDevice terpisah yang sesuai dengan setiap perangkat untuk
memungkinkan aplikasi memilih dari perangkat tersebut.
CPU: CPU single core atau multicore.
GPU: GPU yang dapat menjalankan model NNAPI dan mempercepat API grafis seperti
OpenGL ES dan Vulkan.
ACCELERATOR: Neural processing unit (NPU) khusus.
Terapkan
getVersionString
di IDevice.hal untuk mendapatkan string versi implementasi perangkat.
Metode ini harus menampilkan string yang dapat dibaca manusia. Format
string bersifat khusus vendor. String versi harus berbeda untuk setiap versi driver
baru.
Nama antarmuka IDevice harus mengikuti format
{VENDOR}-{DEVICE_NAME}.
Konten dan contoh kode di halaman ini tunduk kepada lisensi yang dijelaskan dalam Lisensi Konten. Java dan OpenJDK adalah merek dagang atau merek dagang terdaftar dari Oracle dan/atau afiliasinya.
Terakhir diperbarui pada 2025-07-27 UTC.
[[["Mudah dipahami","easyToUnderstand","thumb-up"],["Memecahkan masalah saya","solvedMyProblem","thumb-up"],["Lainnya","otherUp","thumb-up"]],[["Informasi yang saya butuhkan tidak ada","missingTheInformationINeed","thumb-down"],["Terlalu rumit/langkahnya terlalu banyak","tooComplicatedTooManySteps","thumb-down"],["Sudah usang","outOfDate","thumb-down"],["Masalah terjemahan","translationIssue","thumb-down"],["Masalah kode / contoh","samplesCodeIssue","thumb-down"],["Lainnya","otherDown","thumb-down"]],["Terakhir diperbarui pada 2025-07-27 UTC."],[],[],null,["# Device discovery and assignment\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\nIn Android 10, the\n[Neural Networks API (NNAPI)](/docs/core/interaction/neural-networks)\nintroduces functions that allow\nmachine learning framework\nlibraries and apps to get information about the devices available and\nspecify which devices to execute a model on. Providing information about the\navailable devices allows apps to get the exact version of the drivers\nfound on the device to avoid known incompatibilities. By giving apps the\nability to specify which devices are to execute different sections of a model,\napps can be optimized for the product on which they are deployed.\n\nSupport for device discovery and assignment is required for NN HAL 1.2\nimplementations.\n\nImplementation\n--------------\n\nTo support the device discovery and assignment features in NNAPI, implement\n[`getType`](https://android.googlesource.com/platform/hardware/interfaces/+/refs/heads/android16-release/neuralnetworks/1.2/IDevice.hal#76)\nand\n[`getVersionString`](https://android.googlesource.com/platform/hardware/interfaces/+/refs/heads/android16-release/neuralnetworks/1.2/IDevice.hal#56)\nin `IDevice.hal` to allow the framework to get the device type and driver\nversion.\n\nFor each device, specify the type as one of the following categories as\nspecified in\n[`DeviceType`](https://android.googlesource.com/platform/hardware/interfaces/+/refs/heads/android16-release/neuralnetworks/1.2/types.hal#4737)\nin\n[`types.hal`](https://android.googlesource.com/platform/hardware/interfaces/+/refs/heads/android16-release/neuralnetworks/1.2/types.hal).\n\n- **`OTHER`:** A device that doesn't fall into any of the other categories, including a heterogeneous interface, which is a single `IDevice` interface that manages multiple devices, possibly of different types. A driver with a heterogeneous interface should also expose separate `IDevice` interfaces that correspond to individual devices to allow an application to choose from those devices.\n- **`CPU`:** A single core or multicore CPU.\n- **`GPU`:** A GPU that can run NNAPI models and accelerate graphics APIs such as OpenGL ES and Vulkan.\n- **`ACCELERATOR`:** A dedicated neural processing unit (NPU).\n\nImplement\n[`getVersionString`](https://android.googlesource.com/platform/hardware/interfaces/+/refs/heads/android16-release/neuralnetworks/1.2/IDevice.hal#56)\nin `IDevice.hal` for getting the version string of the device implementation.\nThis method must return a string that is human readable. The format of the\nstring is vendor specific. The version string must be different for each new\nversion of a driver.\n\nThe name of the `IDevice` interface must follow the `{VENDOR}-{DEVICE_NAME}`\nformat."]]