Commit graph

47 commits

Author SHA1 Message Date
Michael Butler
60a7b86cf0 Rename Version::ANDROID_* to kVersionFeatureLevel* -- hal
Prior to this change, version constants (e.g., Version::ANDROID_S) were
public static constants to make the version constants look as if they
were enum values. However, this method prevented versions from being
constexpr, because the Version type was incomplete by that point in
time. This change moves these version constants outside of the Version
struct, and makes them constexpr. They have the new names:
* Version::ANDROID_OC_MR1 -> kVersionFeatureLevel1
* Version::ANDROID_P -> kVersionFeatureLevel2
* Version::ANDROID_Q -> kVersionFeatureLevel3
* Version::ANDROID_R -> kVersionFeatureLevel4
* Version::ANDROID_S -> kVersionFeatureLevel5
* Version::FEATURE_LEVEL_6 -> kVersionFeatureLevel6
* Version::EXPERIMENTAL -> kVersionFeatureLevelExperimental

Bug: 206975939
Test: mma
Change-Id: Ibf5f2fdb1459a69c51865aa5fdcd0cb0c3a88ade
2021-11-18 23:56:54 +00:00
Michael Butler
34f0a8f418 Make NNAPI Version more structured -- hal
Prior to this topic, NNAPI Versions were linear and represented by an
enumeration. However, this did not properly account for the
non-linearity of runtime-specific features such as a control flow
operations with operands of dynamic sizes. This topic alters Version to
be a struct containing a feature level enumeration as well as a boolean
which indicates whether there are runtime-specific features.

Bug: 206975939
Test: mma
Test: NeuralNetworksTests_static
Change-Id: I78c54ef597bf269b137f2835332bdedac49883d4
2021-11-18 23:56:15 +00:00
Michael Butler
c331067aac Move Aidl utility code to aidl/utils -- hal 2/2
This change is part of an effort to remove HAL types from
libneuralnetworks_common*. This change:
* Updates the header guard names for the new directory
* Removes the "Aidl" prefix from the files
* Adds temporary "Aidl" header files under include/ that redirect to
   their corresponding files in include/nnapi/hal/aidl/
* Changes references of libneuralnetworks_common_hidl to
   libneuralnetworks_common

Bug: 191442336
Test: mma
Change-Id: Icbcc04e0a49a9adf8d8826fd5735028ea26de0ca
2021-11-01 21:34:53 -07:00
Michael Butler
abc86918ae Revert^2 "Provide explicitly versioned NNAPI AIDL utils libs -- HAL."
Reason for revert: rollforward fix of this topic

This change is a revert of I3d3ac4745, which itself is a revert of
I74f1798e8.

This CL modifies the AIDL utils libraries to be explicitly
versioned. Currently, we only have two versions: v1 and "current".
Specifically, the following changes are made:
- Remove AIDL dependencies from neuralnetworks_utils_hal_common
- Create explicitly versioned libs of neuralnetworks_utils_hal_aidl*

This is needed because it is not allowed for a build target to
link against multiple versions of the same AIDL lirary.

The canonical driver will report ANDROID_S for AIDL v1, and FL6 for v2.

Reverted Changes:
I2aefa0023:Revert "Use explicitly versioned NNAPI HAL util li...
Ia7df07ab9:Revert "Add neuralnetworks_utils_hal_aidl_v2 to al...
Iadd823460:Revert "Provide explicitly version NNAPI AIDL util...
I3d3ac4745:Revert "Provide explicitly versioned NNAPI AIDL ut...

Bug: 202405342
Test: NNT_static
Test: CtsNNAPITestCases
Test: VtsHalNeuralnetworksTargetTest
Change-Id: Ib3b732aa406f6d37e8f941082807c9232720c909
Merged-In: Ib3b732aa406f6d37e8f941082807c9232720c909
(cherry picked from commit 478a78ea77)
2021-10-29 14:28:45 -07:00
Michael Butler
49d95e0457 Move NN HandleError from utils/common to 1.0/utils
This change is part of a larger chain of changes to remove HIDL and AIDL
libraries from neuralnetworks_utils_hal_common.

Bug: N/A
Test: mma
Change-Id: Iae9f692ffc72700294aae694c256e75c7e353fef
2021-10-26 21:18:33 +00:00
Michael Butler
e8645c3b8d Relocate NN ProtectCallback to 1.0/utils
This change is part of a larger chain of changes to remove HIDL and AIDL
libraries from neuralnetworks_utils_hal_common.

Bug: N/A
Test: mma
Change-Id: Ib43f1cb683a09ae5c9116a6dea4d269c9c2c78b4
2021-10-26 21:18:09 +00:00
Michael Butler
15965821e8 Move NN memory utils from utils/common to 1.0/utils
This change is part of a larger chain of changes to remove HIDL and AIDL
libraries from neuralnetworks_utils_hal_common.

Bug: N/A
Test: mma
Change-Id: I9d4f0c30932fad7ccb6231aa03e57f7227af4880
2021-10-26 21:17:53 +00:00
Michael Butler
301ef060e9 Remove hal::utils::countNumberOfConsumers
This CL removes hal::utils::countNumberOfConsumers and uses the existing
nn::countNumberOfConsumers.

This change is part of a larger chain of changes to remove HIDL and AIDL
libraries from neuralnetworks_utils_hal_common.

Bug: N/A
Test: mma
Change-Id: I7d06ea355eae7aa80b94b09a23d606bbb2322120
2021-10-26 21:17:10 +00:00
Michael Butler
68e98f40dc Merge "Allow implicit conversions for NN errors -- hal" 2021-10-18 22:45:51 +00:00
Ian Hua
068df81ab6 AIDL interface changes for NNAPI feature level 6.
- Add BATCH_MATMUL operation
- Support TENSOR_INT32 for RESHAPE operation.

Also update "current" version snapshot and use
android.hardware.neuralnetworks-V2-ndk since AIDL v1 has been frozen.

Bug: 193012662
Bug: 200281183
Test: mm
Change-Id: Iabe45c57e2306d61055f711eda03b80b9cbe906d
Merged-In: Iabe45c57e2306d61055f711eda03b80b9cbe906d
2021-10-18 11:38:55 +01:00
Michael Butler
ff9a5a527a Allow implicit conversions for NN errors -- hal
This change allows GeneralErrors to be created from a string and allows
ExecutionErrors to be created from a string or a GeneralError.
This makes error handling more terse, removing the need for helper
functions such as makeGeneralFailure or makeExecutionFailure.

Bug: N/A
Test: mma
Change-Id: I8c5e80a2eb4f399fad64aab763fe6fa08cf8d1db
2021-10-15 16:37:09 -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
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
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
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
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
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
76e491fa46 Implement full canonical Burst in NN util code
Bug: 180492058
Bug: 177267324
Test: mma
Test: presubmit
Change-Id: I5018f6cf2dbaf705f74f4f46318142c64433e19d
Merged-In: I5018f6cf2dbaf705f74f4f46318142c64433e19d
(cherry picked from commit acff4063b6)
2021-03-16 11:57:19 -07: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
Michael Butler
65de531533 Merge changes from topic "nnapi-numberOfConsumers"
* changes:
  Create NNAPI adapter interface
  Make NNAPI countNumberOfConsumers return GeneralResult -- hal
2021-02-23 20:01:01 +00:00
Bob Badour
b224b363de [LSC] Add LOCAL_LICENSE_KINDS to hardware/interfaces
Added SPDX-license-identifier-Apache-2.0 to:
  atrace/1.0/Android.bp
  atrace/1.0/default/Android.bp
  atrace/1.0/vts/functional/Android.bp
  audio/2.0/Android.bp
  audio/2.0/config/Android.bp
  audio/4.0/Android.bp
  audio/4.0/config/Android.bp
  audio/5.0/Android.bp
  audio/5.0/config/Android.bp
  audio/6.0/Android.bp
  audio/6.0/config/Android.bp
  audio/7.0/Android.bp
  audio/7.0/config/Android.bp
  audio/common/2.0/Android.bp
  audio/common/4.0/Android.bp
  audio/common/5.0/Android.bp
  audio/common/6.0/Android.bp
  audio/common/7.0/Android.bp
  audio/common/7.0/example/Android.bp
  audio/common/all-versions/default/Android.bp
  audio/common/all-versions/default/service/Android.bp
  audio/common/all-versions/test/utility/Android.bp
  audio/common/all-versions/util/Android.bp
  audio/core/all-versions/default/Android.bp
  audio/core/all-versions/default/util/Android.bp
  audio/core/all-versions/vts/functional/Android.bp
  audio/effect/2.0/Android.bp
  audio/effect/2.0/xml/Android.bp
  audio/effect/4.0/Android.bp
  audio/effect/4.0/xml/Android.bp
  audio/effect/5.0/Android.bp
  audio/effect/5.0/xml/Android.bp
  audio/effect/6.0/Android.bp
  audio/effect/6.0/xml/Android.bp
  audio/effect/7.0/Android.bp
  audio/effect/7.0/xml/Android.bp
  audio/effect/all-versions/default/Android.bp
  audio/effect/all-versions/default/util/Android.bp
  audio/effect/all-versions/vts/functional/Android.bp
  audio/policy/1.0/vts/functional/Android.bp
  audio/policy/1.0/xml/Android.bp
  audio/policy/1.0/xml/pfw_schemas/Android.bp
  authsecret/1.0/Android.bp
  authsecret/1.0/default/Android.bp
  authsecret/1.0/vts/functional/Android.bp
  authsecret/aidl/Android.bp
  authsecret/aidl/default/Android.bp
  authsecret/aidl/vts/Android.bp
  automotive/audiocontrol/1.0/Android.bp
  automotive/audiocontrol/1.0/default/Android.bp
  automotive/audiocontrol/1.0/vts/functional/Android.bp
  automotive/audiocontrol/2.0/Android.bp
  automotive/audiocontrol/2.0/default/Android.bp
  automotive/audiocontrol/2.0/vts/functional/Android.bp
  automotive/can/1.0/default/libnetdevice/Android.bp
  automotive/can/1.0/hidl-utils/Android.bp
  automotive/can/1.0/tools/Android.bp
  automotive/can/1.0/tools/configurator/Android.bp
  automotive/can/1.0/tools/configurator/proto/Android.bp
  automotive/can/1.0/tools/libcanhaltools/Android.bp
  automotive/can/1.0/vts/functional/Android.bp
  automotive/can/1.0/vts/utils/Android.bp
  automotive/evs/1.0/Android.bp
  automotive/evs/1.0/default/Android.bp
  automotive/evs/1.0/vts/functional/Android.bp
  automotive/evs/1.1/Android.bp
  automotive/evs/1.1/default/Android.bp
  automotive/evs/1.1/vts/functional/Android.bp
  automotive/evs/1.1/vts/fuzzing/Android.bp
  automotive/evs/common/utils/default/Android.bp
  automotive/evs/common/utils/default/test/fuzz/Android.bp
  automotive/occupant_awareness/aidl/Android.bp
  automotive/occupant_awareness/aidl/default/Android.bp
  automotive/occupant_awareness/aidl/mock/Android.bp
  automotive/occupant_awareness/aidl/vts/functional/Android.bp
  automotive/sv/1.0/Android.bp
  automotive/sv/1.0/default/Android.bp
  automotive/sv/1.0/vts/functional/Android.bp
  automotive/vehicle/2.0/Android.bp
  automotive/vehicle/2.0/default/Android.bp
  automotive/vehicle/2.0/default/impl/vhal_v2_0/proto/Android.bp
  automotive/vehicle/2.0/utils/Android.bp
  biometrics/face/1.0/Android.bp
  biometrics/face/1.0/default/Android.bp
  biometrics/face/1.0/vts/functional/Android.bp
  biometrics/fingerprint/2.1/Android.bp
  biometrics/fingerprint/2.1/default/Android.bp
  biometrics/fingerprint/2.1/vts/functional/Android.bp
  biometrics/fingerprint/2.2/Android.bp
  biometrics/fingerprint/2.2/vts/functional/Android.bp
  bluetooth/1.0/Android.bp
  bluetooth/1.0/default/Android.bp
  bluetooth/1.0/vts/functional/Android.bp
  bluetooth/1.1/Android.bp
  bluetooth/1.1/default/Android.bp
  bluetooth/1.1/vts/functional/Android.bp
  bluetooth/a2dp/1.0/Android.bp
  bluetooth/a2dp/1.0/default/Android.bp
  bluetooth/a2dp/1.0/vts/functional/Android.bp
  bluetooth/audio/2.0/Android.bp
  bluetooth/audio/2.0/default/Android.bp
  bluetooth/audio/2.0/vts/functional/Android.bp
  bluetooth/audio/2.1/Android.bp
  bluetooth/audio/2.1/default/Android.bp
  bluetooth/audio/2.1/vts/functional/Android.bp
  bluetooth/audio/utils/Android.bp
  boot/1.0/Android.bp
  boot/1.0/default/Android.bp
  boot/1.0/vts/functional/Android.bp
  boot/1.1/Android.bp
  boot/1.1/default/Android.bp
  boot/1.1/default/boot_control/Android.bp
  boot/1.1/vts/functional/Android.bp
  boot/1.2/Android.bp
  boot/1.2/default/Android.bp
  boot/1.2/vts/functional/Android.bp
  broadcastradio/1.0/Android.bp
  broadcastradio/1.0/default/Android.bp
  broadcastradio/1.0/vts/functional/Android.bp
  broadcastradio/1.1/Android.bp
  broadcastradio/1.1/default/Android.bp
  broadcastradio/1.1/vts/functional/Android.bp
  broadcastradio/2.0/Android.bp
  broadcastradio/2.0/default/Android.bp
  broadcastradio/2.0/vts/functional/Android.bp
  broadcastradio/common/tests/Android.bp
  broadcastradio/common/utils/Android.bp
  broadcastradio/common/utils1x/Android.bp
  broadcastradio/common/utils2x/Android.bp
  broadcastradio/common/vts/utils/Android.bp
  camera/common/1.0/Android.bp
  camera/common/1.0/default/Android.bp
  camera/device/1.0/Android.bp
  camera/device/1.0/default/Android.bp
  camera/device/3.2/Android.bp
  camera/device/3.2/default/Android.bp
  camera/device/3.3/Android.bp
  camera/device/3.3/default/Android.bp
  camera/device/3.4/Android.bp
  camera/device/3.4/default/Android.bp
  camera/device/3.5/Android.bp
  camera/device/3.5/default/Android.bp
  camera/device/3.6/Android.bp
  camera/device/3.6/default/Android.bp
  camera/metadata/3.2/Android.bp
  camera/metadata/3.3/Android.bp
  camera/metadata/3.4/Android.bp
  camera/metadata/3.5/Android.bp
  camera/provider/2.4/Android.bp
  camera/provider/2.4/default/Android.bp
  camera/provider/2.4/vts/functional/Android.bp
  camera/provider/2.5/Android.bp
  camera/provider/2.5/default/Android.bp
  camera/provider/2.6/Android.bp
  cas/1.0/Android.bp
  cas/1.0/default/Android.bp
  cas/1.0/vts/functional/Android.bp
  cas/1.1/Android.bp
  cas/1.1/default/Android.bp
  cas/1.1/vts/functional/Android.bp
  cas/1.2/Android.bp
  cas/1.2/default/Android.bp
  cas/1.2/vts/functional/Android.bp
  cas/native/1.0/Android.bp
  common/aidl/Android.bp
  common/fmq/aidl/Android.bp
  common/support/Android.bp
  compatibility_matrices/Android.bp
  compatibility_matrices/Android.mk
  compatibility_matrices/build/Android.bp
  compatibility_matrices/exclude/Android.bp
  configstore/1.0/Android.bp
  configstore/1.0/vts/functional/Android.bp
  configstore/1.1/Android.bp
  configstore/1.1/default/Android.mk
  configstore/utils/Android.bp
  confirmationui/1.0/Android.bp
  confirmationui/1.0/default/Android.bp
  confirmationui/1.0/vts/functional/Android.bp
  confirmationui/support/Android.bp
  contexthub/1.0/Android.bp
  contexthub/1.0/default/Android.bp
  contexthub/1.0/vts/functional/Android.bp
  contexthub/1.1/Android.bp
  contexthub/1.1/default/Android.bp
  contexthub/1.1/vts/functional/Android.bp
  contexthub/common/vts/Android.bp
  drm/1.0/Android.bp
  drm/1.0/default/Android.bp
  drm/1.0/vts/functional/Android.bp
  drm/1.1/Android.bp
  drm/1.1/vts/functional/Android.bp
  drm/1.2/Android.bp
  drm/1.2/vts/functional/Android.bp
  drm/1.3/Android.bp
  drm/1.3/vts/functional/Android.bp
  dumpstate/1.0/Android.bp
  dumpstate/1.0/default/Android.bp
  dumpstate/1.0/vts/functional/Android.bp
  dumpstate/1.1/Android.bp
  dumpstate/1.1/default/Android.bp
  dumpstate/1.1/vts/functional/Android.bp
  fastboot/1.0/Android.bp
  fastboot/1.0/default/Android.bp
  fastboot/1.1/Android.bp
  fastboot/1.1/default/Android.bp
  gatekeeper/1.0/Android.bp
  gatekeeper/1.0/default/Android.bp
  gatekeeper/1.0/software/Android.bp
  gatekeeper/1.0/software/tests/Android.bp
  gatekeeper/1.0/vts/functional/Android.bp
  gnss/1.0/Android.bp
  gnss/1.0/default/Android.bp
  gnss/1.0/vts/functional/Android.bp
  gnss/1.1/Android.bp
  gnss/1.1/default/Android.bp
  gnss/1.1/vts/functional/Android.bp
  gnss/2.0/Android.bp
  gnss/2.0/default/Android.bp
  gnss/2.0/vts/functional/Android.bp
  gnss/2.1/Android.bp
  gnss/2.1/default/Android.bp
  gnss/2.1/vts/functional/Android.bp
  gnss/common/utils/default/Android.bp
  gnss/common/utils/vts/Android.bp
  gnss/measurement_corrections/1.0/Android.bp
  gnss/measurement_corrections/1.1/Android.bp
  gnss/visibility_control/1.0/Android.bp
  graphics/allocator/2.0/Android.bp
  graphics/allocator/2.0/default/Android.bp
  graphics/allocator/2.0/utils/gralloc1-adapter/Android.bp
  graphics/allocator/2.0/utils/hal/Android.bp
  graphics/allocator/2.0/utils/passthrough/Android.bp
  graphics/allocator/3.0/Android.bp
  graphics/allocator/4.0/Android.bp
  graphics/bufferqueue/1.0/Android.bp
  graphics/bufferqueue/2.0/Android.bp
  graphics/common/1.0/Android.bp
  graphics/common/1.1/Android.bp
  graphics/common/1.2/Android.bp
  graphics/common/aidl/Android.bp
  graphics/composer/2.1/Android.bp
  graphics/composer/2.1/default/Android.bp
  graphics/composer/2.1/utils/command-buffer/Android.bp
  graphics/composer/2.1/utils/hal/Android.bp
  graphics/composer/2.1/utils/hwc2on1adapter/Android.bp
  graphics/composer/2.1/utils/hwc2onfbadapter/Android.bp
  graphics/composer/2.1/utils/passthrough/Android.bp
  graphics/composer/2.1/utils/resources/Android.bp
  graphics/composer/2.1/utils/vts/Android.bp
  graphics/composer/2.1/vts/functional/Android.bp
  graphics/composer/2.2/Android.bp
  graphics/composer/2.2/default/Android.mk
  graphics/composer/2.2/utils/command-buffer/Android.bp
  graphics/composer/2.2/utils/hal/Android.bp
  graphics/composer/2.2/utils/passthrough/Android.bp
  graphics/composer/2.2/utils/resources/Android.bp
  graphics/composer/2.2/utils/vts/Android.bp
  graphics/composer/2.2/vts/functional/Android.bp
  graphics/composer/2.3/Android.bp
  graphics/composer/2.3/default/Android.bp
  graphics/composer/2.3/utils/command-buffer/Android.bp
  graphics/composer/2.3/utils/hal/Android.bp
  graphics/composer/2.3/utils/passthrough/Android.bp
  graphics/composer/2.3/utils/vts/Android.bp
  graphics/composer/2.3/vts/functional/Android.bp
  graphics/composer/2.4/Android.bp
  graphics/composer/2.4/default/Android.bp
  graphics/composer/2.4/utils/command-buffer/Android.bp
  graphics/composer/2.4/utils/hal/Android.bp
  graphics/composer/2.4/utils/passthrough/Android.bp
  graphics/composer/2.4/utils/vts/Android.bp
  graphics/composer/2.4/vts/functional/Android.bp
  graphics/mapper/2.0/Android.bp
  graphics/mapper/2.0/default/Android.bp
  graphics/mapper/2.0/utils/hal/Android.bp
  graphics/mapper/2.0/utils/passthrough/Android.bp
  graphics/mapper/2.0/utils/vts/Android.bp
  graphics/mapper/2.0/vts/functional/Android.bp
  graphics/mapper/2.1/Android.bp
  graphics/mapper/2.1/default/Android.bp
  graphics/mapper/2.1/utils/hal/Android.bp
  graphics/mapper/2.1/utils/passthrough/Android.bp
  graphics/mapper/2.1/utils/vts/Android.bp
  graphics/mapper/2.1/vts/functional/Android.bp
  graphics/mapper/3.0/Android.bp
  graphics/mapper/3.0/utils/vts/Android.bp
  graphics/mapper/3.0/vts/functional/Android.bp
  graphics/mapper/4.0/Android.bp
  graphics/mapper/4.0/utils/vts/Android.bp
  graphics/mapper/4.0/vts/functional/Android.bp
  health/1.0/Android.bp
  health/1.0/default/Android.bp
  health/2.0/Android.bp
  health/2.0/default/Android.bp
  health/2.0/utils/libhealthhalutils/Android.bp
  health/2.0/utils/libhealthservice/Android.bp
  health/2.0/utils/libhealthstoragedefault/Android.bp
  health/2.0/vts/functional/Android.bp
  health/2.1/Android.bp
  health/2.1/default/Android.bp
  health/2.1/vts/functional/Android.bp
  health/storage/1.0/Android.bp
  health/storage/1.0/default/Android.bp
  health/storage/1.0/vts/functional/Android.bp
  health/storage/aidl/Android.bp
  health/storage/aidl/default/Android.bp
  health/storage/aidl/vts/functional/Android.bp
  health/storage/impl_common/Android.bp
  health/storage/test_common/Android.bp
  health/utils/libhealth2impl/Android.bp
  health/utils/libhealthloop/Android.bp
  identity/aidl/Android.bp
  identity/aidl/default/Android.bp
  identity/aidl/vts/Android.bp
  identity/support/Android.bp
  input/classifier/1.0/Android.bp
  input/classifier/1.0/default/Android.bp
  input/classifier/1.0/vts/functional/Android.bp
  input/common/1.0/Android.bp
  ir/1.0/Android.bp
  ir/1.0/default/Android.bp
  ir/1.0/vts/functional/Android.bp
  keymaster/3.0/Android.bp
  keymaster/3.0/default/Android.mk
  keymaster/3.0/vts/functional/Android.bp
  keymaster/4.0/Android.bp
  keymaster/4.0/default/Android.bp
  keymaster/4.0/support/Android.bp
  keymaster/4.0/vts/functional/Android.bp
  keymaster/4.0/vts/performance/Android.bp
  keymaster/4.1/Android.bp
  keymaster/4.1/default/Android.bp
  keymaster/4.1/support/Android.bp
  keymaster/4.1/vts/functional/Android.bp
  keymaster/aidl/Android.bp
  light/2.0/Android.bp
  light/2.0/default/Android.bp
  light/2.0/vts/functional/Android.bp
  light/aidl/Android.bp
  light/aidl/default/Android.bp
  light/aidl/vts/functional/Android.bp
  light/utils/Android.bp
  media/1.0/Android.bp
  media/1.0/xml/Android.mk
  media/Android.bp
  media/bufferpool/1.0/Android.bp
  media/bufferpool/2.0/Android.bp
  media/c2/1.0/Android.bp
  media/c2/1.1/Android.bp
  media/omx/1.0/Android.bp
  media/omx/1.0/vts/functional/audio/Android.bp
  media/omx/1.0/vts/functional/common/Android.bp
  media/omx/1.0/vts/functional/component/Android.bp
  media/omx/1.0/vts/functional/store/Android.bp
  media/omx/1.0/vts/functional/video/Android.bp
  memtrack/1.0/Android.bp
  memtrack/1.0/default/Android.bp
  memtrack/1.0/vts/functional/Android.bp
  memtrack/aidl/Android.bp
  memtrack/aidl/default/Android.bp
  memtrack/aidl/vts/Android.bp
  neuralnetworks/1.0/Android.bp
  neuralnetworks/1.0/utils/Android.bp
  neuralnetworks/1.0/vts/functional/Android.bp
  neuralnetworks/1.1/Android.bp
  neuralnetworks/1.1/utils/Android.bp
  neuralnetworks/1.1/vts/functional/Android.bp
  neuralnetworks/1.2/Android.bp
  neuralnetworks/1.2/utils/Android.bp
  neuralnetworks/1.2/vts/functional/Android.bp
  neuralnetworks/1.3/Android.bp
  neuralnetworks/1.3/utils/Android.bp
  neuralnetworks/1.3/vts/functional/Android.bp
  neuralnetworks/aidl/Android.bp
  neuralnetworks/aidl/utils/Android.bp
  neuralnetworks/aidl/vts/functional/Android.bp
  neuralnetworks/utils/common/Android.bp
  neuralnetworks/utils/service/Android.bp
  nfc/1.0/Android.bp
  nfc/1.0/default/Android.bp
  nfc/1.0/vts/functional/Android.bp
  nfc/1.1/Android.bp
  nfc/1.1/vts/functional/Android.bp
  nfc/1.2/Android.bp
  nfc/1.2/vts/functional/Android.bp
  oemlock/1.0/Android.bp
  oemlock/1.0/vts/functional/Android.bp
  oemlock/aidl/Android.bp
  oemlock/aidl/default/Android.bp
  oemlock/aidl/vts/Android.bp
  power/1.0/Android.bp
  power/1.0/default/Android.bp
  power/1.0/vts/functional/Android.bp
  power/1.1/Android.bp
  power/1.1/vts/functional/Android.bp
  power/1.2/Android.bp
  power/1.2/vts/functional/Android.bp
  power/1.3/Android.bp
  power/1.3/vts/functional/Android.bp
  power/aidl/Android.bp
  power/aidl/default/Android.bp
  power/aidl/vts/Android.bp
  power/stats/1.0/Android.bp
  power/stats/1.0/default/Android.bp
  power/stats/1.0/vts/functional/Android.bp
  power/stats/aidl/Android.bp
  power/stats/aidl/default/Android.bp
  power/stats/aidl/vts/Android.bp
  radio/1.0/Android.bp
  radio/1.0/vts/functional/Android.bp
  radio/1.1/Android.bp
  radio/1.1/vts/functional/Android.bp
  radio/1.2/Android.bp
  radio/1.2/default/Android.bp
  radio/1.2/vts/functional/Android.bp
  radio/1.3/Android.bp
  radio/1.3/vts/functional/Android.bp
  radio/1.4/Android.bp
  radio/1.4/vts/functional/Android.bp
  radio/1.5/Android.bp
  radio/1.5/vts/functional/Android.bp
  radio/1.6/Android.bp
  radio/1.6/vts/functional/Android.bp
  radio/config/1.0/Android.bp
  radio/config/1.0/default/Android.bp
  radio/config/1.0/vts/functional/Android.bp
  radio/config/1.1/Android.bp
  radio/config/1.1/vts/functional/Android.bp
  radio/config/1.2/Android.bp
  radio/config/1.2/vts/functional/Android.bp
  radio/config/1.3/Android.bp
  radio/config/1.3/vts/functional/Android.bp
  radio/deprecated/1.0/Android.bp
  rebootescrow/aidl/Android.bp
  rebootescrow/aidl/default/Android.bp
  rebootescrow/aidl/vts/functional/Android.bp
  renderscript/1.0/Android.bp
  renderscript/1.0/default/Android.bp
  renderscript/1.0/vts/functional/Android.bp
  secure_element/1.0/Android.bp
  secure_element/1.0/vts/functional/Android.bp
  secure_element/1.1/Android.bp
  secure_element/1.1/vts/functional/Android.bp
  secure_element/1.2/Android.bp
  secure_element/1.2/vts/functional/Android.bp
  security/keymint/aidl/Android.bp
  security/keymint/aidl/default/Android.bp
  security/keymint/aidl/vts/functional/Android.bp
  security/keymint/support/Android.bp
  security/secureclock/aidl/Android.bp
  security/secureclock/aidl/vts/functional/Android.bp
  security/sharedsecret/aidl/Android.bp
  security/sharedsecret/aidl/vts/functional/Android.bp
  sensors/1.0/Android.bp
  sensors/1.0/default/Android.bp
  sensors/1.0/vts/functional/Android.bp
  sensors/2.0/Android.bp
  sensors/2.0/default/Android.bp
  sensors/2.0/multihal/Android.bp
  sensors/2.0/vts/functional/Android.bp
  sensors/2.1/Android.bp
  sensors/2.1/default/Android.bp
  sensors/2.1/multihal/Android.bp
  sensors/2.1/vts/functional/Android.bp
  sensors/common/default/2.X/Android.bp
  sensors/common/default/2.X/multihal/Android.bp
  sensors/common/default/2.X/multihal/tests/Android.bp
  sensors/common/utils/Android.bp
  sensors/common/vts/2_X/Android.bp
  sensors/common/vts/utils/Android.bp
  soundtrigger/2.0/Android.bp
  soundtrigger/2.0/default/Android.bp
  soundtrigger/2.0/default/Android.mk
  soundtrigger/2.0/vts/functional/Android.bp
  soundtrigger/2.1/Android.bp
  soundtrigger/2.1/default/Android.mk
  soundtrigger/2.1/vts/functional/Android.bp
  soundtrigger/2.2/Android.bp
  soundtrigger/2.2/default/Android.bp
  soundtrigger/2.2/vts/functional/Android.bp
  soundtrigger/2.3/Android.bp
  soundtrigger/2.3/default/Android.bp
  soundtrigger/2.3/vts/functional/Android.bp
  tests/bar/1.0/Android.bp
  tests/bar/1.0/default/Android.bp
  tests/baz/1.0/Android.bp
  tests/baz/1.0/default/Android.bp
  tests/expression/1.0/Android.bp
  tests/extension/light/2.0/Android.bp
  tests/extension/light/2.0/default/Android.bp
  tests/extension/vibrator/aidl/Android.bp
  tests/extension/vibrator/aidl/client/Android.bp
  tests/extension/vibrator/aidl/default/Android.bp
  tests/foo/1.0/Android.bp
  tests/foo/1.0/default/Android.bp
  tests/foo/1.0/default/lib/Android.bp
  tests/hash/1.0/Android.bp
  tests/hash/1.0/default/Android.bp
  tests/inheritance/1.0/Android.bp
  tests/inheritance/1.0/default/Android.bp
  tests/lazy/1.0/Android.bp
  tests/lazy/1.1/Android.bp
  tests/libhwbinder/1.0/Android.bp
  tests/libhwbinder/1.0/default/Android.bp
  tests/libhwbinder/aidl/Android.bp
  tests/memory/1.0/Android.bp
  tests/memory/1.0/default/Android.bp
  tests/memory/2.0/Android.bp
  tests/msgq/1.0/Android.bp
  tests/msgq/1.0/default/Android.bp
  tests/multithread/1.0/Android.bp
  tests/multithread/1.0/default/Android.bp
  tests/safeunion/1.0/Android.bp
  tests/safeunion/1.0/default/Android.bp
  tests/safeunion/cpp/1.0/Android.bp
  tests/safeunion/cpp/1.0/default/Android.bp
  tests/trie/1.0/Android.bp
  tests/trie/1.0/default/Android.bp
  tetheroffload/config/1.0/Android.bp
  tetheroffload/config/1.0/vts/functional/Android.bp
  tetheroffload/control/1.0/Android.bp
  tetheroffload/control/1.0/vts/functional/Android.bp
  tetheroffload/control/1.1/Android.bp
  tetheroffload/control/1.1/vts/functional/Android.bp
  thermal/1.0/Android.bp
  thermal/1.0/default/Android.bp
  thermal/1.0/vts/functional/Android.bp
  thermal/1.1/Android.bp
  thermal/1.1/vts/functional/Android.bp
  thermal/2.0/Android.bp
  thermal/2.0/default/Android.bp
  thermal/2.0/vts/functional/Android.bp
  tv/cec/1.0/Android.bp
  tv/cec/1.0/default/Android.bp
  tv/input/1.0/Android.bp
  tv/input/1.0/default/Android.bp
  tv/input/1.0/vts/functional/Android.bp
  tv/tuner/1.0/Android.bp
  tv/tuner/1.0/default/Android.bp
  tv/tuner/1.0/vts/functional/Android.bp
  usb/1.0/Android.bp
  usb/1.0/default/Android.bp
  usb/1.0/vts/functional/Android.bp
  usb/1.1/Android.bp
  usb/1.1/vts/functional/Android.bp
  usb/1.2/Android.bp
  usb/1.2/vts/functional/Android.bp
  usb/gadget/1.0/Android.bp
  usb/gadget/1.1/Android.bp
  usb/gadget/1.1/default/Android.bp
  usb/gadget/1.1/default/lib/Android.bp
  vibrator/1.0/Android.bp
  vibrator/1.0/default/Android.bp
  vibrator/1.0/vts/functional/Android.bp
  vibrator/1.1/Android.bp
  vibrator/1.1/vts/functional/Android.bp
  vibrator/1.2/Android.bp
  vibrator/1.2/vts/functional/Android.bp
  vibrator/1.3/Android.bp
  vibrator/1.3/example/Android.bp
  vibrator/1.3/vts/functional/Android.bp
  vibrator/aidl/Android.bp
  vibrator/aidl/default/Android.bp
  vibrator/aidl/vts/Android.bp
  vr/1.0/Android.bp
  vr/1.0/default/Android.bp
  vr/1.0/vts/functional/Android.bp
  weaver/1.0/Android.bp
  weaver/1.0/vts/functional/Android.bp
  weaver/aidl/Android.bp
  weaver/aidl/default/Android.bp
  weaver/aidl/vts/Android.bp
  wifi/1.0/Android.bp
  wifi/1.0/vts/functional/Android.bp
  wifi/1.1/Android.bp
  wifi/1.1/vts/functional/Android.bp
  wifi/1.2/Android.bp
  wifi/1.2/vts/functional/Android.bp
  wifi/1.3/Android.bp
  wifi/1.3/vts/functional/Android.bp
  wifi/1.4/Android.bp
  wifi/1.4/default/Android.mk
  wifi/1.4/vts/functional/Android.bp
  wifi/hostapd/1.0/Android.bp
  wifi/hostapd/1.0/vts/functional/Android.bp
  wifi/hostapd/1.1/Android.bp
  wifi/hostapd/1.1/vts/functional/Android.bp
  wifi/hostapd/1.2/Android.bp
  wifi/hostapd/1.2/vts/functional/Android.bp
  wifi/offload/1.0/Android.bp
  wifi/offload/1.0/vts/functional/Android.bp
  wifi/supplicant/1.0/Android.bp
  wifi/supplicant/1.0/vts/functional/Android.bp
  wifi/supplicant/1.1/Android.bp
  wifi/supplicant/1.1/vts/functional/Android.bp
  wifi/supplicant/1.2/Android.bp
  wifi/supplicant/1.2/vts/functional/Android.bp
  wifi/supplicant/1.3/Android.bp
  wifi/supplicant/1.3/vts/functional/Android.bp

Added SPDX-license-identifier-Apache-2.0 SPDX-license-identifier-NCSA to:
  Android.bp
  automotive/can/1.0/Android.bp
  automotive/can/1.0/default/Android.bp

Added SPDX-license-identifier-NCSA to:
  automotive/can/1.0/default/libc++fs/Android.bp

Bug: 68860345
Bug: 151177513
Bug: 151953481

Test: m all

Exempt-From-Owner-Approval: janitorial work

Change-Id: I602b072f77ff41e9eb8d3c36b6b5315d63664006
Merged-in: I602b072f77ff41e9eb8d3c36b6b5315d63664006
2021-02-21 20:36:55 -08:00
Michael Butler
68b6926e3c Make NNAPI countNumberOfConsumers return GeneralResult -- hal
Previously, countNumberOfConsumers would trigger a CHECK if the input
was invalid. This CL makes countNumberOfConsumers gracefully fail on
errors, instead returning the error through the GeneralResult.

Bug: N/A
Test: mma
Change-Id: Iee54f87768e52fdf701c22d94083c053b881733d
Merged-In: Iee54f87768e52fdf701c22d94083c053b881733d
(cherry picked from commit c4d98007fd)
2021-02-19 17:34:32 -08:00
Michael Butler
ab2f482af3 Store AHWB in NN canonical memory type -- hal
Prior to this CL, the canonical memory type only held a SharedHandle,
which mirrors the behavior of native_handle_t/hidl_handle. This means
memory types including AHardwareBuffer were stored as this SharedHandle
type. With this CL, the canonical memory type is stored directly as
AHardwareBuffer to avoid using non-NDK AHardwareBuffer calls in the NN
runtime.

Bug: 179906132
Test: mma
Test: NeuralNetworksTest_static
Test: presubmit
Change-Id: I394071c193d15ac0c90ac47e5a2a9a79c635db6c
Merged-In: I394071c193d15ac0c90ac47e5a2a9a79c635db6c
(cherry picked from commit bbe43d950e)
2021-02-17 10:15:39 -08:00
Michael Butler
fadeb8a920 Change NNAPI Memory to ref-counted SharedMemory -- hal
Bug: 179906132
Test: mma
Test: NeuralNetworksTest_static
Test: presubmit
Change-Id: I6435db906a2efe4938da18149a1fcd6d24730a95
Merged-In: I6435db906a2efe4938da18149a1fcd6d24730a95
(cherry picked from commit 79a16ebb6f)
2021-02-17 10:15:09 -08:00
Lev Proleev
6b6dfcd439 Add utils for AIDL types conversions
Add conversions between canonical types and NNAPI AIDL interface types
that are needed for AIDL sample driver implementation.

Bug: 172922059
Test: VtsNeuralnetworksTargetTest
Change-Id: I02803302e02457e52c752114b47b94239eff20e9
Merged-In: I02803302e02457e52c752114b47b94239eff20e9
(cherry picked from commit 532136b9d4)
2021-02-09 15:28:23 +00:00
Michael Butler
95331510ad Implement partial canonical Burst in NN util code
This CL adds a simple implementation of IBurst that dispatches calls to
an IPreparedModel object and changes
IPreparedModel::configureExecutionBurst to return this new object
(instead of returning an error).

This CL additionally defines an InvalidBurst class that returns errors
whenever it is used and a ResilientBurst class to recover an IBurst
object when it has died.

Bug: 177267324
Test: mma
Change-Id: I4c7e7ff4e6559aeb5e62c4fa02f2e751fef9d87d
Merged-In: I4c7e7ff4e6559aeb5e62c4fa02f2e751fef9d87d
(cherry picked from commit 44f324fb0d)
2021-01-19 16:21:17 +00:00
Michael Butler
2a8b679bba Introduce canonical IBurst object in NNAPI -- hal
A sibling change to this change introduces a canonical IBurst object and
a new method IPreparedModel::configureExecutionBurst. This CL performs
minimal changes to the NN hal utility code to make the code still
compile.

Bug: 177267324
Test: mma
Change-Id: I076067289dde7def5622a6cb25233619f80efa41
Merged-In: I076067289dde7def5622a6cb25233619f80efa41
(cherry picked from commit b6a7ed5d5f)
2021-01-19 16:21:07 +00:00
Michael Butler
9adab0cf49 Add isUpdatable to NNAPI canonical IDevice -- hal
Bug: 177284207
Test: mma
Change-Id: I580d5325be91f566ee1c591736a87a94d0a74315
Merged-In: I580d5325be91f566ee1c591736a87a94d0a74315
(cherry picked from commit 080fbf755c)
2021-01-19 16:21:01 +00:00
Michael Butler
6e492a62e1 Create unit tests for NN interface utility code
This CL introduces unit tests to validate the V1_X::utils::Device,
*PreparedModel, and *Buffer adapter classes. It does so by mocking the
underlying HIDL interface in order to simulate a driver returning bad
data, HIDL transport failures, and service crashes.

Note that the purpose of these new tests is to validate the adapter
classes themselves, not the HIDL interfaces they use. For example,
because nn::IPreparedModel does not currently define a method for
configuring a burst execution, V1_[23]::utils::PreparedModel similarly
does not use hardware::neuralnetworks::V1_[23]::IPreparedModel's
configureExecutionBurst method.

This CL also introduces unit tests to validate the utils::Resilient*
adapter classes, and mocks DEAD_OBJECT failures to ensure that the
underyling object can be recovered appropriately.

Bug: 163801800
Test: mma
Test: atest neuralnetworks_utils_hal_common_test
Test: atest neuralnetworks_utils_hal_1_[0-3]_test
Change-Id: I2c79865bf666d3f4bf53061ff5090746403583e9
Merged-In: I2c79865bf666d3f4bf53061ff5090746403583e9
(cherry picked from commit afc4d7cfe7)
2021-01-08 12:07:43 -08:00
Michael Butler
418c749746 Add recovery code to NN ResilientPreparedModel and *Buffer
Prior to this CL, ResilientPreparedModel and ResilientBuffer were
passthrough interfaces that just forwarded calls to the underlying
interface object. This CL implements the full recovery mechanism for
these two classes. However, because we do not want to enable this
functionality in the NN runtime yet, ResilientDevice hides the paths
that create ResilientPreparedModel and ResilientBuffer behind an #if
until we want to enable those paths.

Bug: N/A
Test: mma
Change-Id: Idfe8093c63c7ba2f16c995eec872d150696e7a08
Merged-In: Idfe8093c63c7ba2f16c995eec872d150696e7a08
(cherry picked from commit 667dc2dcac)
2021-01-08 12:07:20 -08:00
Michael Butler
bf59946c61 Remove 'blocking' param from NN ResilientPreparedModel and *Buffer
This change removes the 'blocking' parameter for the
ResilientPreparedModel::Factory and ResilientBuffer::Factory. The
'blocking' parameter is only useful for ResilientDevice::Factory, which
behind the scenes chooses between the HIDL calls IDevice::getService and
IDevice::tryGetService. The equivalent calls for IPreparedModel and
IBuffer are not used, as both are created from the IDevice object.

This change also modifies the ResilientDevice's device recovery
behavior. Prior to this change, ResilientDevice's recovery mechanism had
the following behavior:
* attempt to call a function
* if the function did not return a DEAD_OBJECT error, return
* if the function returned a DEAD_OBJECT error, attempt to recover the
  device
* whether or not the recovery succeeded, call the function again

This CL changes the behavior so that if device recovery fails,
ResilientDevice will not call the function the second time.

Bug: N/A
Test: mma
Change-Id: Icf37d05c884c740178324fcd046ea56914ef7d44
Merged-In: Icf37d05c884c740178324fcd046ea56914ef7d44
(cherry picked from commit 11761e37a8)
2020-12-21 21:09:56 -08:00
Michael Butler
7fd03c265e Cleanup NN callback error handling
This CL introduces a new templated class CallbackValue to handle HIDL
"return value" callbacks in a terser and more readable way.

This CL also introduces a new macro HANDLE_HAL_STATUS to return from the
current function when an error is present with the ability to append a
more descriptive error message.

Finally, this CL changes the behavior of synchronous executions. Prior
to this CL, IPreparedModel fell back to an asynchronous execution if the
synchronous execution was allowed and failed. This change instead
returns a failure if synchronous execution is allowed and fails.

Bug: 173084343
Test: mma
Change-Id: I62714a932e71dfc77401bbcb9eaaaf3d94fb9707
Merged-In: I62714a932e71dfc77401bbcb9eaaaf3d94fb9707
(cherry picked from commit 98ed9baf5d)
2020-12-21 21:09:37 -08:00
Michael Butler
aad934baa7 Add HIDL lifetime and protecting callback info to NN README
This CL copies information from
packages/modules/NeuralNetworks/runtime/VersionedInterfaces.cpp and
modifies the description to be more appropriate for the NN HAL utility
code.

Specific sections added to the README:
* "HIDL Interface Lifetimes across Processes"
* "Protecting Asynchronous Calls across HIDL"

Bug: 170289677
Test: mma
Change-Id: Id381895535d708b627f4746687b4d12e16560639
Merged-In: Id381895535d708b627f4746687b4d12e16560639
(cherry picked from commit 7a655bb3d4)
2020-12-21 21:09:14 -08:00
Michael Butler
4024d8f4d8 Change NN canonical timings to nanoseconds -- hal
A sibling CL to this CL changes the definition of nn::TimePoint to the
same type as std::chrono::steady_clock::time_point but has changed the
underlying duration representation to use uint64_t. That sibling CL also
renames nn::OptionalTimeoutDuration to nn::OptionalDuration, and changes
the definition to the same type as std::nanoseconds except the
underlying duration representation now uses uint64_t.

This CL makes changes to the NN HAL utility code in response to the
changes in the sibling CL.

Bug: 174297663
Test: mma
Test: NeuralNetworksTest_static
Change-Id: If44d9aefadb2c78b632ff289b5ff5a49f766525c
Merged-In: If44d9aefadb2c78b632ff289b5ff5a49f766525c
(cherry picked from commit ca11420785)
2020-12-21 21:08:43 -08:00
Michael Butler
cca3e20e23 Cleanup how transport errors are handled in NN utils
Prior to this change, whenever the NN utility code encountered a HIDL
transport error, the error message would display the file and line
number of the "handleTransportError" function itself. This change
introduces a new macro "HANDLE_TRANSPORT_FAILURE" that handles the
transport error in a similar way but now the error message displays
the file and line number of where the macro is called.

Bug: N/A
Test: mma
Change-Id: I35b34f8f5be52b7fcff0fbb58a37ab2b8c7dd8bb
Merged-In: I35b34f8f5be52b7fcff0fbb58a37ab2b8c7dd8bb
(cherry picked from commit 61f508e018)
2020-12-07 22:38:16 -08:00
Michael Butler
376005883c Invalidate NN interface objects on cache mismatch
Currently, if an IDevice object is a DEAD_OBJECT, the runtime attempts
to re-retrieve the handle to the rebooted IDevice service. If an update
occurs after the IDevice was originally created, the rebooted IDevice
object may have different metadata and behavior. This is problematic
because the original metadata is cached in the runtime. Further, an
application might have made decisions based on that metadata and
behavior. (Note that a driver service that is functionally the same but
has a different underlying implementation such as having more optimized
code will have different `getVersionString` metadata.) Instead, this CL
invalidates the IDevice object on cache mismatch, and always returns an
error if it is used.

Bug: 173081926
Test: mma
Change-Id: I805987361c627c32d45e1b7c7aed230376fc66ad
Merged-In: I805987361c627c32d45e1b7c7aed230376fc66ad
(cherry picked from commit 5a74c0fb0f)
2020-11-24 10:42:45 -08:00
Slava Shklyaev
49817a0e0f Replace nn::NativeHandle with nn::SharedHandle
Bug: 160669116
Test: mma
Change-Id: I73b2b93aab6cbf37d3c145e15ee9ae45228954f1
Merged-In: I73b2b93aab6cbf37d3c145e15ee9ae45228954f1
(cherry picked from commit d4290b8bf8)
2020-11-20 13:55:05 +00:00
Michael Butler
4b276a767b Implement NNAPI canonical interfaces
This CL implements the canonical IDevice, IPreparedModel, and IBuffer
interfaces for the 1.0, 1.1, 1.2, and 1.3 NN HIDL HAL interfaces.
Further, it introduces "Resilient" adapter interfaces to automatically
retrieve a handle to a recovered interface object after it has died and
rebooted.

This CL also updates the conversion code from returning nn::Result to
nn::GeneralResult, which includes a ErrorStatus code in the case of an
error.

Finally, this CL introduces a new static library
neuralnetworks_utils_hal_service which consists of a single function
::android::nn::hal::getDevices which can be used by the NNAPI runtime to
retrieve the HIDL services without knowing the underlying HIDL types.

Bug: 160668438
Test: mma
Test: NeuralNetworksTest_static
Change-Id: Iec6ae739df196b4034ffb35ea76781fd541ffec3
Merged-In: Iec6ae739df196b4034ffb35ea76781fd541ffec3
(cherry picked from commit 3670c385c4)
2020-11-16 14:29:55 -08:00
Michael Butler
b98aa6d6bf Create conversions to/from NNAPI canonical types
This CL creates the following primary sets of functions:
* V1_X::utils::convert(<canonical_type>) -- Converts a canonical type
  to the corresponding HAL version type.
* nn::convert(<V1_X_HAL_type>) -- Converts a HAL version type to the
  corresponding canonical type.
* neuralnetworks::utils::hasNoPointerData -- Indicates if the object
  contains no pointer-based data that could be relocated to shared
  memory.
* neuralnetworks::utils::flushDataFromPointerToShared -- Relocate
  pointer-based data to shared memory.
* neuralnetworks::utils::unflushDataFromSharedToPointer -- Undoes
  `flushDataFromPointerToShared` on a Request object. More
  specifically, `unflushDataFromSharedToPointer` copies the output
  shared memory data from the transformed Request object back to the
  output pointer-based memory in the original Request object.

It also introduces some other minor utility code, including
makeQuantized8PerformanceConsistentWithP, countNumberOfConsumers,
validate, valid, and validatedConvertToCanonical.

Bug: 160667419
Test: mma
Change-Id: I0732e658c1f4ed40cd122f1ca8581fb40b056757
Merged-In: I0732e658c1f4ed40cd122f1ca8581fb40b056757
(cherry picked from commit a685c3dbf4)
2020-10-05 12:47:57 -07:00