diff options
author | Michael Butler <butlermichael@google.com> | 2021-03-25 15:27:38 -0700 |
---|---|---|
committer | Michael Butler <butlermichael@google.com> | 2021-04-07 12:54:45 -0700 |
commit | f03ebd93b9a547538b43014a9be6cbb983676c91 (patch) | |
tree | 0a09f3fa3bbf2ff8dbe67a43c749761fab53b7e1 /neuralnetworks/aidl/vts/functional/ValidateModel.cpp | |
parent | dd53d04d8c19515223f86129ca043614e196840e (diff) |
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 b0fcb3927d848e9721f05a458b5d6d4d2cb8079d)
Diffstat (limited to 'neuralnetworks/aidl/vts/functional/ValidateModel.cpp')
-rw-r--r-- | neuralnetworks/aidl/vts/functional/ValidateModel.cpp | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/neuralnetworks/aidl/vts/functional/ValidateModel.cpp b/neuralnetworks/aidl/vts/functional/ValidateModel.cpp index 94d3daf6bb..698c054941 100644 --- a/neuralnetworks/aidl/vts/functional/ValidateModel.cpp +++ b/neuralnetworks/aidl/vts/functional/ValidateModel.cpp @@ -259,12 +259,16 @@ template <> size_t sizeForBinder(const Memory& memory) { // This is just a guess. - size_t size = 0; - const NativeHandle& handle = memory.handle; - size += sizeof(decltype(handle.fds)::value_type) * handle.fds.size(); - size += sizeof(decltype(handle.ints)::value_type) * handle.ints.size(); - size += sizeForBinder(memory.name); - size += sizeof(memory); + size_t size = sizeof(Memory); + + // Only hardwareBuffer type memory has dynamic memory that needs to be accounted for (in the + // form of a NativeHandle type). The other other types of memory (MappableFile, Ashmem) use a + // single file descriptor (with metadata) instead. + if (memory.getTag() == Memory::Tag::hardwareBuffer) { + const NativeHandle& handle = memory.get<Memory::Tag::hardwareBuffer>().handle; + size += sizeof(decltype(handle.fds)::value_type) * handle.fds.size(); + size += sizeof(decltype(handle.ints)::value_type) * handle.ints.size(); + } return size; } |