Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 491b0a89 authored by Xusong Wang's avatar Xusong Wang
Browse files

Modify 1.2 VTS tests to consume test struct directly.

Comparing with v1.1, the converter for 1.2 HIDL model has additional support
for extraParam, dynamic output shape, and zero-sized output.

Modify CompilationCachingTests to use the new test struct.

Bug: 123092187
Bug: 138718240
Test: All VTS
Change-Id: I54ac97f62898e47a338b51cc6d895a0309ab001f
parent 6aad0402
Loading
Loading
Loading
Loading
+12 −3
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@
#include <android/hidl/memory/1.0/IMemory.h>
#include <hidlmemory/mapping.h>

#include <algorithm>
#include <vector>

namespace android {
@@ -63,11 +64,19 @@ Request createRequest(const TestModel& testModel) {
    size_t outputSize = 0;
    for (uint32_t i = 0; i < testModel.outputIndexes.size(); i++) {
        const auto& op = testModel.operands[testModel.outputIndexes[i]];
        size_t dataSize = op.data.size();

        // In the case of zero-sized output, we should at least provide a one-byte buffer.
        // This is because zero-sized tensors are only supported internally to the driver, or
        // reported in output shapes. It is illegal for the client to pre-specify a zero-sized
        // tensor as model output. Otherwise, we will have two semantic conflicts:
        // - "Zero dimension" conflicts with "unspecified dimension".
        // - "Omitted operand buffer" conflicts with "zero-sized operand buffer".
        size_t bufferSize = std::max<size_t>(op.data.size(), 1);

        DataLocation loc = {.poolIndex = kOutputPoolIndex,
                            .offset = static_cast<uint32_t>(outputSize),
                            .length = static_cast<uint32_t>(dataSize)};
        outputSize += op.data.alignedSize();
                            .length = static_cast<uint32_t>(bufferSize)};
        outputSize += op.data.size() == 0 ? TestBuffer::kAlignment : op.data.alignedSize();
        outputs[i] = {.hasNoValue = false, .location = loc, .dimensions = {}};
    }

+2 −3
Original line number Diff line number Diff line
@@ -37,13 +37,12 @@ cc_defaults {
        "android.hidl.memory@1.0",
        "libgmock",
        "libhidlmemory",
        "libneuralnetworks_generated_test_harness",
        "libneuralnetworks_utils",
        "VtsHalNeuralNetworksV1_0_utils",
    ],
    header_libs: [
        "libneuralnetworks_headers",
        "libneuralnetworks_generated_test_harness_headers",
        "libneuralnetworks_generated_tests",
    ],
    test_suites: ["general-tests"],
}
@@ -75,8 +74,8 @@ cc_test {
    srcs: [
        "BasicTests.cpp",
        ":VtsHalNeuralNetworksV1_2_all_generated_V1_2_tests",
        ":VtsHalNeuralNetworksV1_2_mobilenets",
        "CompilationCachingTests.cpp",
        ":VtsHalNeuralNetworksV1_2_mobilenets", // CompilationCachingTests depend on MobileNets.
        "ValidateBurst.cpp",
    ],
}
+137 −208

File changed.

Preview size limit exceeded, changes collapsed.

+262 −289

File changed.

Preview size limit exceeded, changes collapsed.

+4 −7

File changed.

Preview size limit exceeded, changes collapsed.

Loading