NNAPI NN_TRY macros use Statement Expressions (a GNU extension) to
propagate errors. However, a "return" statement in a Statement
Expression can lead to memory leaks when the Statement Expression is
being used to initialize a member of a struct. Specifically, when one
member of a struct is already initialized, and a Statement Expression
used to initialize a subsequent member early-returns, the previously
initialized members will not have their destructors called.
This CL moves any NN_TRY macro out of struct initialization to avoid any
potential memory leaks.
Bug: 230500484
Test: mma
Test: presubmit
Change-Id: I3493fd4764f8eacc86750e6414e62bc891abaccd
Merged-In: I3493fd4764f8eacc86750e6414e62bc891abaccd
These defines are redundant because they are already defined in
neuralnetworks_utils_defaults.
Bug: N/A
Test: mma
Change-Id: I1c5c44e9e61da19bc10dd8ed2e38099f7c4baccd
* Timed out runs do not show any warning messages.
* These test files cannot finish clang-tidy runs with
the following settings:
TIDY_TIMEOUT=90
WITH_TIDY=1
CLANG_ANALYZER_CHECKS=1
* When TIDY_TIMEOUT is set, in Android continuous builds,
tidy_timeout_srcs files will not be compiled by clang-tidy.
When developers build locally without TIDY_TIMEOUT,
tidy_timeout_srcs files will be compiled.
* Some of these test modules may be split into smaller ones,
or disable some time consuming checks, and then
enable clang-tidy to run within limited time.
Bug: 201099167
Test: make droid tidy-hardware-interfaces_subset
Change-Id: I1de28f1572fff368f67eab512fffec9f2e5c2a9b
The following AIDL types are added:
- TokenValuePair
- PrepareModelConfig
- ExecutionConfig
The following AIDL methods are added:
- IDevice::prepareModelWithConfig
- IPreparedModel::executeSynchronouslyWithConfig
- IPreparedModel::executeFencedWithConfig
- IBurst::executeSynchronouslyWithConfig
The compilation and execution hints are being stored as a list of
token-value pairs as part of the PrepareModelConfig / ExecutionConfig.
And the PrepareModelConfig / ExecutionConfig parcelables are created in
order to make future extensions to the execution related interfaces
easier.
It is the drivers responsibility to verify the hints, and it is allowed
for the driver to ignore them.
Bug: 203248587
Test: neuralnetworks_utils_hal_aidl_test
Change-Id: I98240fd75089fc85cdfcaa0be28aab8a6f0dfca5
Merged-In: I98240fd75089fc85cdfcaa0be28aab8a6f0dfca5
(cherry picked from commit 0e671f3edb)
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
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
This change deletes all existing OWNERS files under
hardware/interfaces/neuralnetworks and creates a new OWNERS file with
the current NNAPI team members.
This change also updates the NNAPI project path in
hardware/interfaces/neuralnetworks/README.
Bug: 179510251
Test: N/A
Change-Id: Iaca69505c8449ae7d93be0db99205f5f56556e86
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
This change:
* Renames ExecutionBurstController to Burst in 1.2/utils
* Renames ExecutionBurstUtils to BurstUtils in 1.2/utils
* Renames ExecutionBurstServer to Burst in common/adapter
Bug: N/A
Test: mma
Change-Id: Ibd460229887c8c9cd23ebc6ee61da37c7c820288
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)
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
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
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
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
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
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
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
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
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)
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)
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)
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
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)
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)
"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)
prepareModelFromCache* was tested for handling of errors happening
during the preparation launch but not during the actual preparation.
Bug: 163801800
Test: mma
Test: atest neuralnetworks_utils_hal_common_test
Test: atest neuralnetworks_utils_hal_1_[0-3]_test
Change-Id: I2c4b235fd4877238d7a18be8b0ea051434c1df6b
Merged-In: I2c4b235fd4877238d7a18be8b0ea051434c1df6b
(cherry picked from commit c6cf50ad42)
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)
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)
Prior to this CL, the NN utility code would always use the type of
IPreparedModel provided by IPreparedModeCallback::notify*. This means
that an IPreparedModel returned as a dynamic type of V1_X but static
type of V1_Y would be used by the utility code as V1_Y. This CL adds
dynamic casting, such that an IPreparedModel returned as a dynamic type
of V1_X but static type V1_Y will be dynamically cast to V1_X and used
as a V1_X::IPreparedModel.
This CL also adds the utility functions
V1_[0123]::convertFromNonCanonical to convert from a non-canonical type
to another non-canonical type by using canonical types as an
intermediate conversion "hop."
Bug: 178180472
Test: mma
Change-Id: I709b2a8944af2cc78b089aade55df1e2ab7b40cc
Merged-In: I709b2a8944af2cc78b089aade55df1e2ab7b40cc
(cherry picked from commit 49b5e4ebea)
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)
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)
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)
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)
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)
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)
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)
This change renames all `convert` functions to `unvalidatedConvert`.
This change also introduces new `convert` functions that act only on the
types that appear in the NN HIDL methods directly. These new `convert`
functions perform validation. Specifically, if either the source or
destination value is invalid, then the conversion fails.
Bug: 160667419
Test: mma
Test: NeuralNetworksTest_static
Change-Id: I492956ff60ad1466c67893993d28cdd6f3860708
Merged-In: I492956ff60ad1466c67893993d28cdd6f3860708
(cherry picked from commit 32acc06144)