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

Commit e9da9852 authored by Xusong Wang's avatar Xusong Wang
Browse files

Add memory domain VTS generated tests.

Bug: 141353602
Bug: 141363565
Test: 1.3 VTS
Change-Id: Ifc7eb3fd6f15e28ba403f02bdf66b4568bddcb64
Merged-In: Ifc7eb3fd6f15e28ba403f02bdf66b4568bddcb64
(cherry picked from commit 1f50e54c)
parent b345a468
Loading
Loading
Loading
Loading
+16 −14
Original line number Original line Diff line number Diff line
@@ -456,7 +456,7 @@ TEST_P(CompilationCachingTest, CacheSavingAndRetrieval) {
    }
    }


    // Execute and verify results.
    // Execute and verify results.
    EvaluatePreparedModel(preparedModel, testModel, /*testKind=*/TestKind::GENERAL);
    EvaluatePreparedModel(kDevice, preparedModel, testModel, /*testKind=*/TestKind::GENERAL);
}
}


TEST_P(CompilationCachingTest, CacheSavingAndRetrievalNonZeroOffset) {
TEST_P(CompilationCachingTest, CacheSavingAndRetrievalNonZeroOffset) {
@@ -518,7 +518,7 @@ TEST_P(CompilationCachingTest, CacheSavingAndRetrievalNonZeroOffset) {
    }
    }


    // Execute and verify results.
    // Execute and verify results.
    EvaluatePreparedModel(preparedModel, testModel, /*testKind=*/TestKind::GENERAL);
    EvaluatePreparedModel(kDevice, preparedModel, testModel, /*testKind=*/TestKind::GENERAL);
}
}


TEST_P(CompilationCachingTest, SaveToCacheInvalidNumCache) {
TEST_P(CompilationCachingTest, SaveToCacheInvalidNumCache) {
@@ -539,7 +539,7 @@ TEST_P(CompilationCachingTest, SaveToCacheInvalidNumCache) {
        saveModelToCache(model, modelCache, dataCache, &preparedModel);
        saveModelToCache(model, modelCache, dataCache, &preparedModel);
        ASSERT_NE(preparedModel, nullptr);
        ASSERT_NE(preparedModel, nullptr);
        // Execute and verify results.
        // Execute and verify results.
        EvaluatePreparedModel(preparedModel, testModel, /*testKind=*/TestKind::GENERAL);
        EvaluatePreparedModel(kDevice, preparedModel, testModel, /*testKind=*/TestKind::GENERAL);
        // Check if prepareModelFromCache fails.
        // Check if prepareModelFromCache fails.
        preparedModel = nullptr;
        preparedModel = nullptr;
        ErrorStatus status;
        ErrorStatus status;
@@ -563,7 +563,7 @@ TEST_P(CompilationCachingTest, SaveToCacheInvalidNumCache) {
        saveModelToCache(model, modelCache, dataCache, &preparedModel);
        saveModelToCache(model, modelCache, dataCache, &preparedModel);
        ASSERT_NE(preparedModel, nullptr);
        ASSERT_NE(preparedModel, nullptr);
        // Execute and verify results.
        // Execute and verify results.
        EvaluatePreparedModel(preparedModel, testModel, /*testKind=*/TestKind::GENERAL);
        EvaluatePreparedModel(kDevice, preparedModel, testModel, /*testKind=*/TestKind::GENERAL);
        // Check if prepareModelFromCache fails.
        // Check if prepareModelFromCache fails.
        preparedModel = nullptr;
        preparedModel = nullptr;
        ErrorStatus status;
        ErrorStatus status;
@@ -586,7 +586,7 @@ TEST_P(CompilationCachingTest, SaveToCacheInvalidNumCache) {
        saveModelToCache(model, modelCache, dataCache, &preparedModel);
        saveModelToCache(model, modelCache, dataCache, &preparedModel);
        ASSERT_NE(preparedModel, nullptr);
        ASSERT_NE(preparedModel, nullptr);
        // Execute and verify results.
        // Execute and verify results.
        EvaluatePreparedModel(preparedModel, testModel, /*testKind=*/TestKind::GENERAL);
        EvaluatePreparedModel(kDevice, preparedModel, testModel, /*testKind=*/TestKind::GENERAL);
        // Check if prepareModelFromCache fails.
        // Check if prepareModelFromCache fails.
        preparedModel = nullptr;
        preparedModel = nullptr;
        ErrorStatus status;
        ErrorStatus status;
@@ -610,7 +610,7 @@ TEST_P(CompilationCachingTest, SaveToCacheInvalidNumCache) {
        saveModelToCache(model, modelCache, dataCache, &preparedModel);
        saveModelToCache(model, modelCache, dataCache, &preparedModel);
        ASSERT_NE(preparedModel, nullptr);
        ASSERT_NE(preparedModel, nullptr);
        // Execute and verify results.
        // Execute and verify results.
        EvaluatePreparedModel(preparedModel, testModel, /*testKind=*/TestKind::GENERAL);
        EvaluatePreparedModel(kDevice, preparedModel, testModel, /*testKind=*/TestKind::GENERAL);
        // Check if prepareModelFromCache fails.
        // Check if prepareModelFromCache fails.
        preparedModel = nullptr;
        preparedModel = nullptr;
        ErrorStatus status;
        ErrorStatus status;
@@ -721,7 +721,7 @@ TEST_P(CompilationCachingTest, SaveToCacheInvalidNumFd) {
        saveModelToCache(model, modelCache, dataCache, &preparedModel);
        saveModelToCache(model, modelCache, dataCache, &preparedModel);
        ASSERT_NE(preparedModel, nullptr);
        ASSERT_NE(preparedModel, nullptr);
        // Execute and verify results.
        // Execute and verify results.
        EvaluatePreparedModel(preparedModel, testModel, /*testKind=*/TestKind::GENERAL);
        EvaluatePreparedModel(kDevice, preparedModel, testModel, /*testKind=*/TestKind::GENERAL);
        // Check if prepareModelFromCache fails.
        // Check if prepareModelFromCache fails.
        preparedModel = nullptr;
        preparedModel = nullptr;
        ErrorStatus status;
        ErrorStatus status;
@@ -745,7 +745,7 @@ TEST_P(CompilationCachingTest, SaveToCacheInvalidNumFd) {
        saveModelToCache(model, modelCache, dataCache, &preparedModel);
        saveModelToCache(model, modelCache, dataCache, &preparedModel);
        ASSERT_NE(preparedModel, nullptr);
        ASSERT_NE(preparedModel, nullptr);
        // Execute and verify results.
        // Execute and verify results.
        EvaluatePreparedModel(preparedModel, testModel, /*testKind=*/TestKind::GENERAL);
        EvaluatePreparedModel(kDevice, preparedModel, testModel, /*testKind=*/TestKind::GENERAL);
        // Check if prepareModelFromCache fails.
        // Check if prepareModelFromCache fails.
        preparedModel = nullptr;
        preparedModel = nullptr;
        ErrorStatus status;
        ErrorStatus status;
@@ -768,7 +768,7 @@ TEST_P(CompilationCachingTest, SaveToCacheInvalidNumFd) {
        saveModelToCache(model, modelCache, dataCache, &preparedModel);
        saveModelToCache(model, modelCache, dataCache, &preparedModel);
        ASSERT_NE(preparedModel, nullptr);
        ASSERT_NE(preparedModel, nullptr);
        // Execute and verify results.
        // Execute and verify results.
        EvaluatePreparedModel(preparedModel, testModel, /*testKind=*/TestKind::GENERAL);
        EvaluatePreparedModel(kDevice, preparedModel, testModel, /*testKind=*/TestKind::GENERAL);
        // Check if prepareModelFromCache fails.
        // Check if prepareModelFromCache fails.
        preparedModel = nullptr;
        preparedModel = nullptr;
        ErrorStatus status;
        ErrorStatus status;
@@ -792,7 +792,7 @@ TEST_P(CompilationCachingTest, SaveToCacheInvalidNumFd) {
        saveModelToCache(model, modelCache, dataCache, &preparedModel);
        saveModelToCache(model, modelCache, dataCache, &preparedModel);
        ASSERT_NE(preparedModel, nullptr);
        ASSERT_NE(preparedModel, nullptr);
        // Execute and verify results.
        // Execute and verify results.
        EvaluatePreparedModel(preparedModel, testModel, /*testKind=*/TestKind::GENERAL);
        EvaluatePreparedModel(kDevice, preparedModel, testModel, /*testKind=*/TestKind::GENERAL);
        // Check if prepareModelFromCache fails.
        // Check if prepareModelFromCache fails.
        preparedModel = nullptr;
        preparedModel = nullptr;
        ErrorStatus status;
        ErrorStatus status;
@@ -904,7 +904,7 @@ TEST_P(CompilationCachingTest, SaveToCacheInvalidAccessMode) {
        saveModelToCache(model, modelCache, dataCache, &preparedModel);
        saveModelToCache(model, modelCache, dataCache, &preparedModel);
        ASSERT_NE(preparedModel, nullptr);
        ASSERT_NE(preparedModel, nullptr);
        // Execute and verify results.
        // Execute and verify results.
        EvaluatePreparedModel(preparedModel, testModel, /*testKind=*/TestKind::GENERAL);
        EvaluatePreparedModel(kDevice, preparedModel, testModel, /*testKind=*/TestKind::GENERAL);
        // Check if prepareModelFromCache fails.
        // Check if prepareModelFromCache fails.
        preparedModel = nullptr;
        preparedModel = nullptr;
        ErrorStatus status;
        ErrorStatus status;
@@ -926,7 +926,7 @@ TEST_P(CompilationCachingTest, SaveToCacheInvalidAccessMode) {
        saveModelToCache(model, modelCache, dataCache, &preparedModel);
        saveModelToCache(model, modelCache, dataCache, &preparedModel);
        ASSERT_NE(preparedModel, nullptr);
        ASSERT_NE(preparedModel, nullptr);
        // Execute and verify results.
        // Execute and verify results.
        EvaluatePreparedModel(preparedModel, testModel, /*testKind=*/TestKind::GENERAL);
        EvaluatePreparedModel(kDevice, preparedModel, testModel, /*testKind=*/TestKind::GENERAL);
        // Check if prepareModelFromCache fails.
        // Check if prepareModelFromCache fails.
        preparedModel = nullptr;
        preparedModel = nullptr;
        ErrorStatus status;
        ErrorStatus status;
@@ -1070,7 +1070,8 @@ TEST_P(CompilationCachingTest, SaveToCache_TOCTOU) {
                ASSERT_EQ(preparedModel, nullptr);
                ASSERT_EQ(preparedModel, nullptr);
            } else {
            } else {
                ASSERT_NE(preparedModel, nullptr);
                ASSERT_NE(preparedModel, nullptr);
                EvaluatePreparedModel(preparedModel, testModelAdd, /*testKind=*/TestKind::GENERAL);
                EvaluatePreparedModel(kDevice, preparedModel, testModelAdd,
                                      /*testKind=*/TestKind::GENERAL);
            }
            }
        }
        }
    }
    }
@@ -1131,7 +1132,8 @@ TEST_P(CompilationCachingTest, PrepareFromCache_TOCTOU) {
                ASSERT_EQ(preparedModel, nullptr);
                ASSERT_EQ(preparedModel, nullptr);
            } else {
            } else {
                ASSERT_NE(preparedModel, nullptr);
                ASSERT_NE(preparedModel, nullptr);
                EvaluatePreparedModel(preparedModel, testModelAdd, /*testKind=*/TestKind::GENERAL);
                EvaluatePreparedModel(kDevice, preparedModel, testModelAdd,
                                      /*testKind=*/TestKind::GENERAL);
            }
            }
        }
        }
    }
    }
+297 −25

File changed.

Preview size limit exceeded, changes collapsed.

+3 −1
Original line number Original line Diff line number Diff line
@@ -62,13 +62,15 @@ enum class TestKind {
    GENERAL,
    GENERAL,
    // Same as GENERAL but sets dimensions for the output tensors to zeros
    // Same as GENERAL but sets dimensions for the output tensors to zeros
    DYNAMIC_SHAPE,
    DYNAMIC_SHAPE,
    // Same as GENERAL but use device memories for inputs and outputs
    MEMORY_DOMAIN,
    // Tests if quantized model with TENSOR_QUANT8_ASYMM produces the same result
    // Tests if quantized model with TENSOR_QUANT8_ASYMM produces the same result
    // (OK/SKIPPED/FAILED) as the model with all such tensors converted to
    // (OK/SKIPPED/FAILED) as the model with all such tensors converted to
    // TENSOR_QUANT8_ASYMM_SIGNED.
    // TENSOR_QUANT8_ASYMM_SIGNED.
    QUANTIZATION_COUPLING
    QUANTIZATION_COUPLING
};
};


void EvaluatePreparedModel(const sp<IPreparedModel>& preparedModel,
void EvaluatePreparedModel(const sp<IDevice>& device, const sp<IPreparedModel>& preparedModel,
                           const test_helper::TestModel& testModel, TestKind testKind);
                           const test_helper::TestModel& testModel, TestKind testKind);


}  // namespace android::hardware::neuralnetworks::V1_3::vts::functional
}  // namespace android::hardware::neuralnetworks::V1_3::vts::functional