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

Commit d22c5232 authored by Xusong Wang's avatar Xusong Wang Committed by Miao Wang
Browse files

Test dynamic output shape in GeneratedTests.

Enable VTS unit test for dynamic output shape deduction.

Only test dynamic output shape for V1_2::IDevice with V1_2::Model.

Bug: 73506513
Test: VtsHalNeuralnetworksV1_xTargetTest with 1.2 sample driver
Change-Id: I4134e1ec54a15554eb8533134897279651b57da3
Merged-In: I4134e1ec54a15554eb8533134897279651b57da3
(cherry picked from commit a316581b)
parent 55a3d328
Loading
Loading
Loading
Loading
+12 −1
Original line number Original line Diff line number Diff line
@@ -20,7 +20,11 @@ cc_test {
    defaults: ["VtsHalNeuralNetworksTargetTestDefaults"],
    defaults: ["VtsHalNeuralNetworksTargetTestDefaults"],
    srcs: [
    srcs: [
        "GeneratedTestsV1_0.cpp",
        "GeneratedTestsV1_0.cpp",
    ]
    ],
    cflags: [
        "-DNN_TEST_DYNAMIC_OUTPUT_SHAPE"
    ],
    test_suites: ["general-tests"],
}
}


// Tests for V1_1 models using the V1_2 HAL.
// Tests for V1_1 models using the V1_2 HAL.
@@ -30,6 +34,10 @@ cc_test {
    srcs: [
    srcs: [
        "GeneratedTestsV1_1.cpp",
        "GeneratedTestsV1_1.cpp",
    ],
    ],
    cflags: [
        "-DNN_TEST_DYNAMIC_OUTPUT_SHAPE"
    ],
    test_suites: ["general-tests"],
}
}


// Tests for V1_2 models.
// Tests for V1_2 models.
@@ -40,5 +48,8 @@ cc_test {
        "BasicTests.cpp",
        "BasicTests.cpp",
        "GeneratedTests.cpp",
        "GeneratedTests.cpp",
    ],
    ],
    cflags: [
        "-DNN_TEST_DYNAMIC_OUTPUT_SHAPE"
    ],
    test_suites: ["general-tests"],
    test_suites: ["general-tests"],
}
}
+2 −1
Original line number Original line Diff line number Diff line
@@ -33,7 +33,8 @@ namespace neuralnetworks {
namespace generated_tests {
namespace generated_tests {
using ::test_helper::MixedTypedExample;
using ::test_helper::MixedTypedExample;
extern void Execute(const sp<V1_2::IDevice>&, std::function<V1_2::Model(void)>,
extern void Execute(const sp<V1_2::IDevice>&, std::function<V1_2::Model(void)>,
                    std::function<bool(int)>, const std::vector<MixedTypedExample>&);
                    std::function<bool(int)>, const std::vector<MixedTypedExample>&,
                    bool testDynamicOutputShape = false);
}  // namespace generated_tests
}  // namespace generated_tests


namespace V1_2 {
namespace V1_2 {
+2 −1
Original line number Original line Diff line number Diff line
@@ -33,7 +33,8 @@ namespace neuralnetworks {
namespace generated_tests {
namespace generated_tests {
using ::test_helper::MixedTypedExample;
using ::test_helper::MixedTypedExample;
extern void Execute(const sp<V1_2::IDevice>&, std::function<V1_2::Model(void)>,
extern void Execute(const sp<V1_2::IDevice>&, std::function<V1_2::Model(void)>,
                    std::function<bool(int)>, const std::vector<MixedTypedExample>&);
                    std::function<bool(int)>, const std::vector<MixedTypedExample>&,
                    bool testDynamicOutputShape = false);
}  // namespace generated_tests
}  // namespace generated_tests


namespace V1_2 {
namespace V1_2 {
+2 −1
Original line number Original line Diff line number Diff line
@@ -33,7 +33,8 @@ namespace neuralnetworks {
namespace generated_tests {
namespace generated_tests {
using ::test_helper::MixedTypedExample;
using ::test_helper::MixedTypedExample;
extern void Execute(const sp<V1_2::IDevice>&, std::function<V1_2::Model(void)>,
extern void Execute(const sp<V1_2::IDevice>&, std::function<V1_2::Model(void)>,
                    std::function<bool(int)>, const std::vector<MixedTypedExample>&);
                    std::function<bool(int)>, const std::vector<MixedTypedExample>&,
                    bool testDynamicOutputShape = false);
}  // namespace generated_tests
}  // namespace generated_tests


namespace V1_2 {
namespace V1_2 {
+3 −0
Original line number Original line Diff line number Diff line
@@ -172,6 +172,9 @@ static uint32_t getInvalidRank(OperandType type) {
static void mutateOperandRankTest(const sp<IDevice>& device, const Model& model) {
static void mutateOperandRankTest(const sp<IDevice>& device, const Model& model) {
    for (size_t operand = 0; operand < model.operands.size(); ++operand) {
    for (size_t operand = 0; operand < model.operands.size(); ++operand) {
        const uint32_t invalidRank = getInvalidRank(model.operands[operand].type);
        const uint32_t invalidRank = getInvalidRank(model.operands[operand].type);
        if (invalidRank == 0) {
            continue;
        }
        const std::string message = "mutateOperandRankTest: operand " + std::to_string(operand) +
        const std::string message = "mutateOperandRankTest: operand " + std::to_string(operand) +
                                    " has rank of " + std::to_string(invalidRank);
                                    " has rank of " + std::to_string(invalidRank);
        validate(device, message, model, [operand, invalidRank](Model* model) {
        validate(device, message, model, [operand, invalidRank](Model* model) {
Loading