Commit graph

60 commits

Author SHA1 Message Date
Ian Hua
60b2f9730e Fix aidl_format errors for NNAPI AIDL.
Test: mm
Change-Id: I21576c79396c03cb741b576eee157560579f13a8
2021-09-15 15:45:55 +01:00
Ian Hua
d910bd6aaa Fix HAL and AIDL files to be consistent with API generation tool.
Bug: 161426966
Test: generate_api.sh
Change-Id: I4f4cc108ccdf2f37a1a7fa154ba8e8a186295276
2021-09-08 17:41:10 +01:00
Steven Moreland
067901ea81 Merge changes from topic "b188871598-security"
* changes:
  neuralnetworks: use versions for imports
  .graphics.common: use versions for imports
  keymint: use versions for imports
2021-08-31 16:47:14 +00:00
Steven Moreland
15a92dad5d neuralnetworks: use versions for imports
This makes sure that when developers add a new version of an interface,
or when interfaces are being frozen, the runtime/buildtime situation of
clients depending on those interfaces remains the same. This is required
for AIDL to continue working at scale.

Bug: 188871598
Test: build
Change-Id: Ib4c6e8f5bf34cc333675201dca4eab08dd88628d
2021-08-30 18:02:43 -07:00
Treehugger Robot
50a0c3ae3f Merge "Fix use-after-free crash in VtsHalNeuralnetworksTargetTest." 2021-08-27 18:48:44 +00:00
Michael Butler
ac45a5d77e Quickly exit VtsHalNeuralnetworks*TargetTest on failure
This change adds the AndroidTest.xml flag --gtest_break_on_failure to
cause the gtest to terminate after an error has been reached. This early
termination is important in the case where an NN HAL service crashes
mid-test, and all remaining tests would otherwise continue to run.

Bug: 197035200
Test: m vts -j
Test: vts-tradefed
Change-Id: I0b9a14345475e432b93f92c23010a8b39712443a
2021-08-24 23:44:57 -07:00
Michael Butler
9c3c8642fb Quick-fail NNAPI VTS test case if driver is dead
This CL adds a check during SetUp that an NNAPI driver service is still
alive by pinging the driver service. If it is not alive, the test will
fail during SetUp. Without this quick-fail, the test case would continue
as if the driver were still active, which would result in multiple
EXPECT_* and ASSERT_* statements failing instead of a single, clear
failure message.

Bug: 197035200
Test: mma
Test: presubmit: VtsHalNeuralnetworks*TargetTest
Change-Id: Ib1b75ed20f764055699590581d5ad4e5aff4baae
2021-08-23 18:27:49 -07:00
Xusong Wang
d2ecde5c54 Fix use-after-free crash in VtsHalNeuralnetworksTargetTest.
Prior to this CL, the AHardwareBuffer in TestBlobAHWB is released in the
destructor, but later used (unlock) during the destruction of the
mMapping member. This CL fixed this issue by managing the lifetime of
AHardwareBuffer with SharedMemory.

Bug: 197199690
Test: VtsHalNeuralnetworksTargetTest
Change-Id: I00748aaaa1a3a3d9b3b62bedb77a655ddb6e210f
2021-08-23 11:41:46 -07:00
Treehugger Robot
2cac932fef Merge "Revert^2 "Making NN hardware interface libs "host supported""" 2021-08-12 16:01:47 +00:00
Ray Hernandez
338d6f8b86 Revert^2 "Making NN hardware interface libs "host supported""
This is a revert of I6f657743, which is a revert of I1d7c66516.

Changing static libraries in hardware/interfaces/neuralnetworks to be
"host supported", meaning that the libraries within this directory
will be available on the host/linux build to make integration and
debugging more efficient.

Host Supported Libs:
* neuralnetworks_utils_hal_1_0
* neuralnetworks_utils_hal_1_1
* neuralnetworks_utils_hal_1_2
* neuralnetworks_utils_hal_1_3
* neuralnetworks_utils_hal_aidl
* neuralnetworks_utils_hal_common

Host Supported Tests:
* neuralnetworks_utils_hal_1_0_test
* neuralnetworks_utils_hal_1_1_test
* neuralnetworks_utils_hal_1_2_test
* neuralnetworks_utils_hal_1_3_test
* neuralnetworks_utils_hal_aidl_test
* neuralnetworks_utils_hal_common_test

Bug: 146324523
Test: neuralnetworks_utils_hal_*_test
Change-Id: I6c3cc00cd1ceefe4ae4ca5e40a8f3062d3251ff1
2021-08-11 21:54:44 +00:00
Michael Butler
e0b2d17cbf Merge "Revert "Making NN hardware interface libs "host supported""" 2021-08-05 00:00:07 +00:00
Ray Hernandez
ea89e30439 Revert "Making NN hardware interface libs "host supported""
Revert "Making NNAPI libraries and tests host supported"

Revert submission 1769046-neuralnetworks_host_build

Reason for revert: New Build Breakage
Reverted Changes:
Ib54d5c274:Making NNAPI libraries and tests host supported
I1d7c66516:Making NN hardware interface libs "host supported"...

Change-Id: I6f65774325889c50b9f8bbab13b557705419b6cf
2021-08-04 23:46:41 +00:00
Treehugger Robot
7519960237 Merge "Making NN hardware interface libs "host supported"" 2021-08-04 22:27:11 +00:00
rayhdez
a6d6002431 Making NN hardware interface libs "host supported"
Changing static libraries in hardware/interfaces/neuralnetworks to be
"host supported", meaning that the libraries within this directory
will be available on the host/linux build to make integration and
debugging more efficient.

Host Supported Libs:
* neuralnetworks_utils_hal_1_0
* neuralnetworks_utils_hal_1_1
* neuralnetworks_utils_hal_1_2
* neuralnetworks_utils_hal_1_3
* neuralnetworks_utils_hal_aidl
* neuralnetworks_utils_hal_common

Host Supported Tests:
* neuralnetworks_utils_hal_1_0_test
* neuralnetworks_utils_hal_1_1_test
* neuralnetworks_utils_hal_1_2_test
* neuralnetworks_utils_hal_1_3_test
* neuralnetworks_utils_hal_aidl_test
* neuralnetworks_utils_hal_common_test

Bug: 146324523
Test: neuralnetworks_utils_hal_*_test
Change-Id: I1d7c665169d2ce0c978b1e510e71f1371402a950
2021-07-27 22:14:05 +00:00
Jiyong Park
27f77fefd7 Remove ndk_platform backend. Use the ndk backend.
The ndk_platform backend will soon be deprecated because the ndk backend
can serve the same purpose. This is to eliminate the confusion about
having two variants (ndk and ndk_platform) for the same 'ndk' backend.

Bug: 161456198
Test: m
Change-Id: Ibe8beeaf0d1b33968fb782f1f70c17ae9e9bf871
2021-07-27 14:44:47 +09:00
Lev Proleev
a31aff1ace Fix ordering of cache files requirements from device
Data and model numbers were switched in the AIDL implementation of
canonical Device.

Bug: 190757709
Test: neuralnetworks_utils_hal_aidl_test
Change-Id: I0d95b2d436994ffc877a4e02eb31f449b983e61e
Merged-In: I0d95b2d436994ffc877a4e02eb31f449b983e61e
(cherry picked from commit 3fd4ec4706)
2021-06-28 16:11:43 +01:00
Michael Butler
e52a77efaa Simplify NNAPI SharedHandle -- hal
Prior to this CL, the NNAPI represented SharedHandle as a collection of
file descriptors and a vector of ints to act as metadata. This struct
mirrored Android's native_handle_t. However, the NNAPI only uses
SharedHandle to hold a single file descriptor to hold a single cache
file.

A sibling CL simplifies the SharedHandle by changing it to be a single
ref-counted file descriptor. This CL makes changes to the HAL utility
code in response to the SharedHandle change.

Bug: N/A
Test: mma
Test: NeuralNetworksTest_static
Change-Id: Ib390ad76bcdadffd85f8c2c502189aaa7da483e4
2021-06-08 20:14:52 -07:00
Xusong Wang
378a93819b Test readonly request input in AIDL VTS.
This CL modifies the AIDL generated tests to use readonly memory pool
for request inputs.

Bug: 188104713
Test: VtsHalNeuralnetworksTargetTest
Change-Id: I9e62f1cdeb501bf29bcb9c56317a452c9105b272
Merged-In: I9e62f1cdeb501bf29bcb9c56317a452c9105b272
(cherry picked from commit dfc013adaa)
2021-06-07 11:25:54 -07:00
Xusong Wang
5e0459576c Fix a bug in reusable burst execution.
The reusable burst execution incorrectly holds a reference to memory
identifier tokens.

Bug: 188568523
Test: NNT_static and inspect logcat
Change-Id: Ic8fb8be12bf579a316e7df8480ab3ccdc5c0e635
Merged-In: Ic8fb8be12bf579a316e7df8480ab3ccdc5c0e635
(cherry picked from commit 2082b871ab)
2021-06-07 11:25:33 -07:00
Slava Shklyaev
2980a7c9fc Modify VTS to allow testing shim caching
Bug: 185777967
Bug: 182877255
Test: VtsHalNeuralnetworksTargetTest
Change-Id: Ibaba149715cfd5e655ce4916b75a29473170f013
2021-06-01 12:41:41 +01:00
Xusong Wang
e3d0dad8d5 Use proper alignment and padding for pointer arguments -- HAL.
This CL modifies the shared memory allocation for pointer arguments to
use proper alignment and padding. We use default alignment (64) and
min padding (1) for HIDL drivers, and default alignment (64) and default
padding (64) for sAIDL drivers.

Bug: 184164929
Test: NNT_static
Change-Id: I22591640fa047d5f75d437edac1a7645d3b05526
Merged-In: I22591640fa047d5f75d437edac1a7645d3b05526
(cherry picked from commit 8bfa243972)
2021-05-11 09:17:34 -07:00
Xusong Wang
b2e8085ce2 Introduce reusable burst to canonical interface -- HAL.
This CL modifies the canonical interface for reusable burst executions:
- Add new method IBurst::createExecution

The reusable burst execution will not fallback to another execution path
if sending request packet fails. The behavior of single-time burst
execution remains unchanged.

Additionally, this CL enables pointer -> shared memory conversion in
1.2/1.3 burst implementation.

Bug: 184073769
Test: NNT_static
Test: neuralnetworks_utils_hal_1_0_test
Test: neuralnetworks_utils_hal_1_1_test
Test: neuralnetworks_utils_hal_1_2_test
Test: neuralnetworks_utils_hal_1_3_test
Test: neuralnetworks_utils_hal_common_test
Change-Id: Iaac81668d247c2cb76d70e6abbd10f00b397b19f
Merged-In: Iaac81668d247c2cb76d70e6abbd10f00b397b19f
(cherry picked from commit ead6d37ae9)
2021-05-10 15:22:08 -07:00
Xusong Wang
5f6bedb43a Introduce reusable execution to canonical interface -- HAL.
This CL modifies the canonical interface for reusable executions:
- Add new interface: IExecution with compute and computeFenced methods
- Add new method IPreparedModel::createExecution

In NNAPI runtime, the new interface IExecution is used to
memoize request-specific execution resources (e.g. converted HAL
request). The expected usage is that, IPreparedModel::createExecution
will be invoked in the first computation of a reusable NDK ANNExecution
object, and IExecution::compute* will be invoked repeatedly.

The IPreparedModel::execute* methods are preserved to avoid redundant
object creation and memoization overhead for a single-time
(non-reusable) execution.

For a vendor implementing the canonical interfaces, only the
IPreparedModel::execute* methods will be called because there is
currently no reusable execution at HAL interface. A DefaultExecution
implementation is provided to reduce the work needed on the vendor side.

Bug: 184073769
Test: NNT_static
Test: neuralnetworks_utils_hal_1_0_test
Test: neuralnetworks_utils_hal_1_1_test
Test: neuralnetworks_utils_hal_1_2_test
Test: neuralnetworks_utils_hal_1_3_test
Test: neuralnetworks_utils_hal_common_test
Test: neuralnetworks_utils_hal_aidl_test
Change-Id: I91790bb5ccf5ae648687fe603f88ffda2c9fd2b2
Merged-In: I91790bb5ccf5ae648687fe603f88ffda2c9fd2b2
(cherry picked from commit 727a7b2104)
2021-05-10 15:21:36 -07:00
Jooyung Han
3a966323ef aidl: Set explicit default values for enum-type fields
Fixes: 179853674
Test: mma in hardware/interfaces/neuralnetworks
Change-Id: I9fdc7089eaf1202299da098220875ef8398667fe
2021-04-27 13:58:46 +09:00
Andy Dyer-Smith
889c46c11a Fix typo in PAD_V2 comments
Bug: 158315823
Test: m

Change-Id: Ic7ba213f2e0ff523349e4b80926a302399db8d88
2021-04-23 16:25:12 +00:00
Michael Butler
3e9720b83f Remove NN canonical IDevice::isUpdatable -- hal
This CL alters the AIDL utility "getDevices" to return whether or not a
service is updatable. This CL additional removes IDevice::isUpdatable
because it is now redundant with the changes to "getDevices".

Bug: 170696350
Test: mma
Test: NeuralNetworksTest_static
Change-Id: I86228763937c0dd2ee5b1d9d547c367cd7504ed4
2021-04-21 13:27:59 -07:00
Treehugger Robot
0292dbbec8 Merge "Add units to hal times and durations names" 2021-04-21 11:35:45 +00:00
Lev Proleev
8df7d6eaf9 Add units to hal times and durations names
The change adds "Ns" suffix to timeOnDevice, timeInDriver,
loopTimeoutDuration, deadline and duration.

Fix: 183118329
Test: mm
Change-Id: I4afe34f27fc8717ac28c8fa09edda9918641c39a
Merged-In: Id1f9ee4b8e41873c97690bb19a5e84572dd9ccf1
2021-04-20 18:16:11 +00:00
Michael Butler
a546efe5ef Merge "Enable NN VTS and utility code to use lazy services" 2021-04-14 16:22:53 +00:00
Lev Proleev
e6273df6b8 Merge "Add explanations for FusedActivationFunc values" 2021-04-14 14:38:46 +00:00
Michael Butler
d3a6efc22e Enable NN VTS and utility code to use lazy services
This CL enables VtsHalNeuralnetworksTargetTest to use lazy services by
changing from AServiceManager_getService (which will return nullptr for
the service if the service is not able to be loaded within a short
amount of time) to AServiceManager_waitForService (which will wait for a
longer time, allowing lazy services to start up).

Similarly, the utility code is changed from using
AServiceManager_getService to AServiceManager_waitForService where
possible.

This CL also introduces an "InvalidDevice" utility class to the
nnapi/hal/aidl utility code. InvalidDevices are minimal devices that
support no functionality but are still able to pass VTS tests.

Bug: 170696939
Test: mma
Test: VtsHalNeuralnetworksTargetTest
Change-Id: I4f806b104ef6af863ec55c2c3f2a2dd1f72b9633
2021-04-13 16:14:13 -07:00
Lev Proleev
60aa6c2b03 Add explanations for FusedActivationFunc values
Fix: 183117976
Test: m
Change-Id: I55f4b7e3287e5bfdde6c2a2f94cee757c020c2d0
2021-04-12 16:00:15 +01:00
Michael Butler
f03ebd93b9 Update NN utility code and VTS tests with new Memory type
This CL fixes the compiler errors that arose of changing the Memory
representation of the NN AIDL HAL, and updates the conversion and
utility code to work with the new Memory type.

This change also makes libaidlcommonsupport available to apex modules at
min sdk level 29.

Bug: 183118727
Test: mma
Test: VtsHalNeuralnetworksTargetTest
Change-Id: Ief565473b4d82e0bb43785fc3b8275b16bd26cf6
Merged-In: Ief565473b4d82e0bb43785fc3b8275b16bd26cf6
(cherry picked from commit b0fcb3927d)
2021-04-07 12:54:45 -07:00
Michael Butler
dd53d04d8c Improve the structure of NNAPI AIDL Memory
Prior to this change, the NN AIDL HAL created a Memory struct analogous
to hidl_memory, consisting of a name, size, and native handle. However,
this Memory struct is not very structured, and requires both the client
and server to agree on how the data should be interpreted.

This CL tightens the structure of the Memory representation by
introducing Ashmem and MappableFile structs to android.hardware.common
in order to hold specific file descriptors representing memory regions.
Further, this CL redefines android.hardwre.neuralnetworks's Memory
object as a union of the Ashmem, MappableFile, and (existing)
HardwareBuffer memory types.

This change also adds "com.android.neuralnetworks" to the graphics
AIDL HAL's apex_available build rule.

Bug: 183118727
Test: mma
Change-Id: I32322df676b83597c9e95f13662c322a6a80accc
Merged-In: I32322df676b83597c9e95f13662c322a6a80accc
(cherry picked from commit 1158c80ff6)
2021-04-07 12:54:18 -07:00
Michael Butler
382d513dff Change NNAPI time from steady_clock to boot_clock -- hal
Previously, the NNAPI used std::chrono::steady_clock to represent and
measure timings. However, steady_clock does not count while the system
is suspended. Instead, boot_clock is monotonic like steady_clock but
does include the time when the system is suspended.

This change also indicates that services may convert from
std::chrono::steady_clock::time_point to
android::base::boot_clock::time_point in the HIDL 1.3 NN HAL.

Bug: 183118340
Test: mma
Test: VtsHalNeuralnetworksV1_3TargetTest
Test: VtsHalNeuralnetworksTargetTest
Test: presubmit
Change-Id: I5a7d039a31d9ce98602a301387ec99635f279f42
Merged-In: I5a7d039a31d9ce98602a301387ec99635f279f42
(cherry picked from commit b8cf54cf5a)
2021-04-06 15:00:49 -07:00
Michael Butler
7a9d6092cd Create NN AIDL Burst adapter
Bug: 180492058
Bug: 177267324
Test: mma
Test: NeuralNetworksTest_static
Change-Id: I2947faeb3820faa963e4df1eaf7aefec57b66c79
Merged-In: I2947faeb3820faa963e4df1eaf7aefec57b66c79
(cherry picked from commit 504f44926c)
2021-04-02 22:03:12 -07:00
Michael Butler
8414a6ebf9 Add additional parameters for NN Burst -- HAL
Adds deadline and loopTimeoutDuration to nn::IBurst::execute.

This CL additionally adds a test case for
IPreparedModel::configureExecutionBurst and adds the suffix "_H" to
the header guards that were missing "_H".

Bug: 180492058
Bug: 177267324
Test: mma
Test: NeuralNetworksTest_static
Change-Id: Ic9ba2fb9b4dee4e40d99ae91bb9555a58d0508d2
Merged-In: Ic9ba2fb9b4dee4e40d99ae91bb9555a58d0508d2
(cherry picked from commit bbbdb0d5f1)
2021-04-02 22:02:38 -07:00
Michael Butler
388bcebc8f Add missing validation for NN canonical types
Bug: 177669661
Test: mma
Test: NeuralNetworksTest_static
Change-Id: Ic05c177f61a906a69bf82ff9c4d5bb8b0556d5ca
Merged-In: Ic05c177f61a906a69bf82ff9c4d5bb8b0556d5ca
(cherry picked from commit 08ee3f9287)
2021-04-02 22:02:02 -07:00
Xusong Wang
3633d07092 Rename BufferRole.frequency -> probability -- HAL.
"Frenquency" often refers to the number of occurrences over a period of
time, while "probability" refers to the number of occurrences of one
event over the number of occurrences of all events. "Probability" is a
better name for this field.

Fixes: 183117895
Test: VtsHalNeuralnetworksTargetTest
Test: NNT_static
Change-Id: Ic86f73b8be2aed567ae4ca17bdb3a57c658fb349
Merged-In: Ic86f73b8be2aed567ae4ca17bdb3a57c658fb349
(cherry picked from commit 46bf892f46)
2021-04-02 10:26:29 -07:00
Michael Butler
7fc7e3756d Add Burst tests to NN AIDL HAL VTS
Bug: 180492058
Bug: 177267324
Test: mma
Test: VtsHalNeuralnetworksTargetTest
Change-Id: I1744005cbf750b70b42367b81a2fa6b8f24c1904
Merged-In: I1744005cbf750b70b42367b81a2fa6b8f24c1904
(cherry picked from commit 8b7e813868)
2021-03-20 14:20:58 +00:00
Michael Butler
88e6e9e66f Add IBurst to NN AIDL HAL -- hal
Burst executions are a sequence of executions of the same prepared model
that occur in rapid succession, such as frames of a camera capture or
successive audio samples. A burst object is used to control a set of
burst executions, and to preserve resources between executions, enabling
executions to have lower overhead.

This CL has the following changes:
1) Adds an IBurst interface to the NN AIDL HAL
2) Adds IPreparedModel::configureExecutionBurst to create an IBurst
   object
3) Extends VTS's InvalidPreparedModel to implement
   configureExecutionBurst.

Bug: 180492058
Bug: 177267324
Test: mma
Test: VTS+presubmit
Change-Id: I90cb18dcc392f07f342604a7fb2edae041848251
Merged-In: I90cb18dcc392f07f342604a7fb2edae041848251
(cherry picked from commit 5dc72d5485)
2021-03-20 14:20:30 +00:00
Michael Butler
37dcda8704 Format NN AIDL HAL
There were some comment changes made to tha auto-generated AIDL files.

Bug: N/A
Test: mma
Change-Id: I1a360115b82b0c222666c5d9189a220e74390654
Merged-In: I1a360115b82b0c222666c5d9189a220e74390654
(cherry picked from commit 402497e049)
2021-03-20 14:20:07 +00:00
Xusong Wang
dfefe265de Merge "Test padded request memories in VTS generated tests." 2021-03-19 17:22:50 +00:00
Slava Shklyaev
3fd9089a0a Merge "NNAPI: Add AIDL drivers registration" 2021-03-19 10:37:23 +00:00
Xusong Wang
16858a6a88 Test padded request memories in VTS generated tests.
This CL modifies the VTS generated tests to specify input and output
padding.

Bug: 179691454
Test: VtsHalNeuralnetworksTargetTest
Change-Id: Iec83199d6f046203acefdbd165887943447984a9
Merged-In: Iec83199d6f046203acefdbd165887943447984a9
(cherry picked from commit a0b82f3235)
2021-03-18 10:11:14 -07:00
Xusong Wang
62445b7d5b Document the default alignment and padding value.
This CL documents the default value of the preferred alignment and
padding for request memories.

Bug: 179799921
Test: m
Change-Id: I89c16c3e20939a0ad68d9e3b0061c4a16dc00d8b
Merged-In: I89c16c3e20939a0ad68d9e3b0061c4a16dc00d8b
(cherry picked from commit e6dcc9a38d)
2021-03-17 13:20:31 -07:00
Xusong Wang
5e4453f690 Merge "Passing padding information to the driver -- hal." 2021-03-17 20:19:18 +00:00
Lev Proleev
2d7195fd32 NNAPI: Add AIDL drivers registration
Bug: 179015258
Test: adb shell setprop debug.nn.partition 2 && \
Test: NeuralNetworksTest_static
Change-Id: I2c8c9a49ff917b243348043df1158a8d98f131ce
Merged-In: I2c8c9a49ff917b243348043df1158a8d98f131ce
(cherry picked from commit 5f732ff683)
2021-03-17 13:32:43 +00:00
Xusong Wang
5e36ca05e7 Passing padding information to the driver -- hal.
This CL changes the sAIDL interface to enable passing padding
information of the shared memory pool to the driver.

The sAIDL interface defines the padding field explicitly in DataLocation
to make it easy to convert to/from the canonical request.

Bug: 179691454
Test: NNT_static
Test: VtsHalNeuralnetworksTargetTest
Change-Id: Ie13b421531ee4df48822086b027d94a622a3518c
Merged-In: Ie13b421531ee4df48822086b027d94a622a3518c
(cherry picked from commit 6365ea1dbb)
2021-03-17 11:39:20 +00:00
Lev Proleev
900c28a250 Add canonical types adapters for NNAPI AIDL interface
Also:
* Add missing AIDL<->CT conversions
* Add AIDL-specific info to neuralnetworks/utils/README.md
* Add mock classes and tests AIDL adapters

Bug: 179015258
Test: neuralnetworks_utils_hal_test
Change-Id: Ifa98fadd46dca5dbf9b3ceb4da811aa8da45b6e4
Merged-In: Ifa98fadd46dca5dbf9b3ceb4da811aa8da45b6e4
(cherry picked from commit 3b93b0b56a)
2021-03-16 11:57:04 -07:00