platform_hardware_interfaces/neuralnetworks
David Gross 79324920f7 Make VtsHalNeuralnetworks* tests more binder-friendly.
Certain mutation testing -- mutateOperandLifeTimeTest and
mutateOperandInputOutputTest -- can introduce potentially very large
CONSTANT_COPY operands, which can in turn create potentially very
large Models which must be passed across binder.  To avoid overflowing
the binder buffer, we estimate the size of the mutated Model, and skip
the test if that size is too high.  The old logic recognizes that our
tests only have a single active binder transaction at a time, and
assumes that there are no other clients using the same service at the
same time, and so we should have the binder buffer to ourselves; to be
conservative, we reject any Model whose estimated size exceeds half
the binder buffer size.  Unfortunately, sometimes the binder buffer
still overflows, because it unexpectedly contains an allocation from
some other transaction: It appears that binder buffer memory
management is not serialized with respect to transactions from our
tests, and therefore depending on scheduler behavior, there may be a
sizeable allocation still in the buffer when we attempt to pass the
large Model.  To fix this problem we become even more conservative,
and instead of limiting the Model to half the binder buffer size, we
limit it to half IBinder.MAX_IPC_SIZE (the recommended transaction
size limit).  To confirm that this change does not exclude too many
tests, I checked how may times the size filter function
exceedsBinderSizeLimit is called, how many times it rejects a model
under the new logic (modelsExceedHalfMaxIPCSize), and how many times
it rejects a model under the old logic (modelsExceedHalfMaxIPCSize).

Test: VtsHalNeuralnetworksV1_0TargetTest --gtest_filter=TestGenerated/ValidationTest.Test/*-*dsp*
Test: # models =  3592, modelsExceedHalfMaxIPCSize = 212, modelsExceedHalfBufferSize = 18
Test: VtsHalNeuralnetworksV1_1TargetTest --gtest_filter=TestGenerated/ValidationTest.Test/*-*dsp*
Test: # models =  7228, modelsExceedHalfMaxIPCSize = 330, modelsExceedHalfBufferSize = 28
Test: VtsHalNeuralnetworksV1_2TargetTest --gtest_filter=TestGenerated/ValidationTest.Test/*-*dsp*
Test: # models = 52072, modelsExceedHalfMaxIPCSize = 506, modelsExceedHalfBufferSize = 28
Test: VtsHalNeuralnetworksV1_3TargetTest --gtest_filter=TestGenerated/ValidationTest.Test/*-*dsp*
Test: # models = 73342, modelsExceedHalfMaxIPCSize = 568, modelsExceedHalfBufferSize = 28
Test: VtsHalNeuralnetworksTargetTest

Bug: 227719657
Bug: 227719752
Bug: 231928847
Bug: 238777741
Bug: 242271308

Change-Id: I3f81d71ca3c0ad4c639096b1dc034a8909bc8971
2022-08-25 23:11:41 +00:00
..
1.0 Make VtsHalNeuralnetworks* tests more binder-friendly. 2022-08-25 23:11:41 +00:00
1.1 Make VtsHalNeuralnetworks* tests more binder-friendly. 2022-08-25 23:11:41 +00:00
1.2 Make VtsHalNeuralnetworks* tests more binder-friendly. 2022-08-25 23:11:41 +00:00
1.3 Make VtsHalNeuralnetworks* tests more binder-friendly. 2022-08-25 23:11:41 +00:00
aidl Make VtsHalNeuralnetworks* tests more binder-friendly. 2022-08-25 23:11:41 +00:00
utils Freeze neuralnetworks AIDL version as v3 for FL7 2022-01-19 14:26:19 -08:00
README Add README to NeuralNetworks HAL 2018-03-05 12:59:35 -08:00
TEST_MAPPING Add canonical types adapters for NNAPI AIDL interface 2021-03-16 11:57:04 -07:00

NeuralNetworks sample driver implementation is located at
frameworks/ml/nn/driver/sample.