From 5dde02c7f6702fd54081bdd19c8e91305375a666 Mon Sep 17 00:00:00 2001 From: Ian Hua Date: Fri, 15 Oct 2021 11:06:31 +0100 Subject: Add FL6 spec tests to AIDL VTS. Also skip FL6 (AIDL_V2) tests for older AIDL drivers. Cherrypicked from I689fef0945428f6548977628e3c43628dd1e5bf7 Bug: 206089870 Test: VtsHalNeuralnetworksTargetTest Specifically, for old driver such as AIDL_V1 sample driver, it can pass HIDL tests and skip AIDL_V2 tests. For new driver such as AIDL_V2 sample driver, it can pass all tests. Change-Id: I689fef0945428f6548977628e3c43628dd1e5bf7 (cherry picked from commit 23d4e5e298fbc27c2f9728b3fef620120c4029ae) --- neuralnetworks/aidl/vts/functional/ValidateModel.cpp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'neuralnetworks/aidl/vts/functional/ValidateModel.cpp') diff --git a/neuralnetworks/aidl/vts/functional/ValidateModel.cpp b/neuralnetworks/aidl/vts/functional/ValidateModel.cpp index 698c054941..afb3b7150d 100644 --- a/neuralnetworks/aidl/vts/functional/ValidateModel.cpp +++ b/neuralnetworks/aidl/vts/functional/ValidateModel.cpp @@ -1122,6 +1122,7 @@ static bool removeOperationInputSkip(const Operation& op, size_t input) { // align_corners and half_pixel_centers parameters. // - L2_NORMALIZATION, LOCAL_RESPONSE_NORMALIZATION, SOFTMAX can have an optional axis // parameter. + // - PACK has at least 2 inputs, with the first element being INT32. switch (op.type) { case OperationType::CONCATENATION: { if (op.inputs.size() > 2 && input != op.inputs.size() - 1) { @@ -1178,6 +1179,11 @@ static bool removeOperationInputSkip(const Operation& op, size_t input) { return true; } } break; + case OperationType::PACK: { + if (op.inputs.size() > 2 && input != 0) { + return true; + } + } break; default: break; } -- cgit v1.2.3 From ce0048732ab5d1f5a40ab4c00a59465029304eb9 Mon Sep 17 00:00:00 2001 From: David Gross Date: Mon, 22 Aug 2022 17:16:26 -0700 Subject: 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 Merged-In: I3f81d71ca3c0ad4c639096b1dc034a8909bc8971 Change-Id: I3f81d71ca3c0ad4c639096b1dc034a8909bc8971 (cherry picked from commit 79324920f7fca8cea92f0c48c4aefc9c97105354) --- .../aidl/vts/functional/ValidateModel.cpp | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) (limited to 'neuralnetworks/aidl/vts/functional/ValidateModel.cpp') diff --git a/neuralnetworks/aidl/vts/functional/ValidateModel.cpp b/neuralnetworks/aidl/vts/functional/ValidateModel.cpp index 060434ed08..d7baf199a5 100644 --- a/neuralnetworks/aidl/vts/functional/ValidateModel.cpp +++ b/neuralnetworks/aidl/vts/functional/ValidateModel.cpp @@ -344,26 +344,24 @@ size_t sizeForBinder(const Model& model) { // currently 1Mb, which is shared by all transactions in progress // for the process." // -// Will our representation fit under this limit? There are two complications: +// Will our representation fit under this limit? There are three complications: // - Our representation size is just approximate (see sizeForBinder()). -// - This object may not be the only occupant of the Binder transaction buffer. +// - This object may not be the only occupant of the Binder transaction buffer +// (although our VTS test suite should not be putting multiple objects in the +// buffer at once). +// - IBinder.MAX_IPC_SIZE recommends limiting a transaction to 64 * 1024 bytes. // So we'll be very conservative: We want the representation size to be no -// larger than half the transaction buffer size. +// larger than half the recommended limit. // // If our representation grows large enough that it still fits within // the transaction buffer but combined with other transactions may // exceed the buffer size, then we may see intermittent HAL transport // errors. static bool exceedsBinderSizeLimit(size_t representationSize) { - // Instead of using this fixed buffer size, we might instead be able to use - // ProcessState::self()->getMmapSize(). However, this has a potential - // problem: The binder/mmap size of the current process does not necessarily - // indicate the binder/mmap size of the service (i.e., the other process). - // The only way it would be a good indication is if both the current process - // and the service use the default size. - static const size_t kHalfBufferSize = 1024 * 1024 / 2; - - return representationSize > kHalfBufferSize; + // There is no C++ API to retrieve the value of the Java variable IBinder.MAX_IPC_SIZE. + static const size_t kHalfMaxIPCSize = 64 * 1024 / 2; + + return representationSize > kHalfMaxIPCSize; } ///////////////////////// VALIDATE EXECUTION ORDER //////////////////////////// -- cgit v1.2.3