summaryrefslogtreecommitdiff
path: root/nn/runtime/test/TestCompilationCaching.cpp
diff options
context:
space:
mode:
authorXusong Wang <xusongw@google.com>2019-10-23 10:35:51 -0700
committerXusong Wang <xusongw@google.com>2019-11-06 15:31:34 -0800
commit6ddafbc3e680038df547adeea321ca88d333c9a2 (patch)
treeb2f38171f11dd56ad83aafa14d92c9a7b697bc33 /nn/runtime/test/TestCompilationCaching.cpp
parent5125a2d2a886ebf9721e85a25b8a561814d38a5d (diff)
downloadml-6ddafbc3e680038df547adeea321ca88d333c9a2.tar.gz
NN Runtime: Upgrade IPreparedModelCallback::notify to 1.3.
Bug: 143242728 Test: NNT_static Change-Id: Id35e1984bb9920dab7be0a30db3d1925da72e80d
Diffstat (limited to 'nn/runtime/test/TestCompilationCaching.cpp')
-rw-r--r--nn/runtime/test/TestCompilationCaching.cpp41
1 files changed, 21 insertions, 20 deletions
diff --git a/nn/runtime/test/TestCompilationCaching.cpp b/nn/runtime/test/TestCompilationCaching.cpp
index bce2836d2..22fab70f6 100644
--- a/nn/runtime/test/TestCompilationCaching.cpp
+++ b/nn/runtime/test/TestCompilationCaching.cpp
@@ -81,12 +81,12 @@ bool isCachingSupported(uint32_t numModelCache, uint32_t numDataCache) {
// This is an IDevice for testing purposes which overrides several methods from sample driver:
// - supports all the operations and is faster than cpu fallback.
// - overrides getNumberOfCacheFilesNeeded to report according to given parameters.
-// - overrides prepareModelFromCache to return error status according to
+// - overrides prepareModelFromCache_1_3 to return error status according to
// mErrorStatusPrepareFromCache.
-// - produces CachingPreparedModel on prepareModel and prepareModelFromCache.
+// - produces CachingPreparedModel on prepareModel and prepareModelFromCache_1_3.
//
-// The cache entry is written by prepareModel_1_2 and is checked later by
-// CachingDriver::prepareModelFromCache.
+// The cache entry is written by prepareModel_1_3 and is checked later by
+// CachingDriver::prepareModelFromCache_1_3.
//
// The CachingDriver has 2 flags mHasCalledPrepareModelFromCache and mHasCalledPrepareModel
// to check if the correct methods are invoked by the runtime.
@@ -167,7 +167,7 @@ class CachingDriver : public sample_driver::SampleDriver {
const hidl_vec<hidl_handle>& modelCacheHandle,
const hidl_vec<hidl_handle>& dataCacheHandle,
const CacheToken&,
- const sp<IPreparedModelCallback>& cb) override {
+ const sp<V1_3::IPreparedModelCallback>& cb) override {
checkNumberOfCacheHandles(modelCacheHandle.size(), dataCacheHandle.size());
if (modelCacheHandle.size() != 0 || dataCacheHandle.size() != 0) {
writeToCache(modelCacheHandle, mModelCacheData);
@@ -176,23 +176,23 @@ class CachingDriver : public sample_driver::SampleDriver {
} else {
mHasCalledPrepareModel = HasCalledPrepareModel::WITHOUT_CACHING;
}
- cb->notify_1_2(ErrorStatus::NONE, new CachingPreparedModel());
+ cb->notify_1_3(ErrorStatus::NONE, new CachingPreparedModel());
return ErrorStatus::NONE;
}
// Checks if the cache entry is correct, notifies error status according to
// mErrorStatusPrepareFromCache, sets mHasCalledPrepareModelFromCache.
- Return<ErrorStatus> prepareModelFromCache(
+ Return<ErrorStatus> prepareModelFromCache_1_3(
const hidl_vec<hidl_handle>& modelCacheHandle,
const hidl_vec<hidl_handle>& dataCacheHandle, const CacheToken&,
- const sp<V1_2::IPreparedModelCallback>& callback) override {
+ const sp<V1_3::IPreparedModelCallback>& callback) override {
readFromCache(modelCacheHandle, mModelCacheData);
readFromCache(dataCacheHandle, mDataCacheData);
mHasCalledPrepareModelFromCache = true;
if (mErrorStatusPrepareFromCache == ErrorStatus::NONE) {
- callback->notify_1_2(mErrorStatusPrepareFromCache, new CachingPreparedModel());
+ callback->notify_1_3(mErrorStatusPrepareFromCache, new CachingPreparedModel());
} else {
- callback->notify_1_2(mErrorStatusPrepareFromCache, nullptr);
+ callback->notify_1_3(mErrorStatusPrepareFromCache, nullptr);
}
return ErrorStatus::NONE;
};
@@ -321,7 +321,7 @@ TEST_P(DeviceRegistrationTest, CachingFailure) {
// Test model compilation with a driver parameterized with
// - Number of model cache files returning from getNumberOfCacheFilesNeeded
// - Number of data cache files returning from getNumberOfCacheFilesNeeded
-// - ErrorStatus returning from prepareModelFromCache
+// - ErrorStatus returning from prepareModelFromCache_1_3
using CompilationCachingTestParam = std::tuple<uint32_t, uint32_t, ErrorStatus>;
class CompilationCachingTest : public ::testing::TestWithParam<CompilationCachingTestParam> {
@@ -387,10 +387,10 @@ TEST_P(CompilationCachingTest, TokenProvidedAndCacheNotExist) {
kNumDataCache, kErrorStatusPrepareFromCache);
compileModel(driver, /*withToken=*/true);
- // When cache file does not exist, the runtime should never call prepareModelFromCache.
+ // When cache file does not exist, the runtime should never call prepareModelFromCache_1_3.
EXPECT_FALSE(driver->hasCalledPrepareModelFromCache());
- // The runtime should call prepareModel_1_2. It should request caching iff caching supported.
+ // The runtime should call prepareModel_1_3. It should request caching iff caching supported.
EXPECT_EQ(driver->hasCalledPrepareModel(), kIsCachingSupported
? HasCalledPrepareModel::WITH_CACHING
: HasCalledPrepareModel::WITHOUT_CACHING);
@@ -405,22 +405,23 @@ TEST_P(CompilationCachingTest, TokenProvidedAndCacheExist) {
kNumDataCache, kErrorStatusPrepareFromCache);
compileModel(driver, /*withToken=*/true);
- // When cache files exist, the runtime should call prepareModelFromCache iff caching supported.
+ // When cache files exist, the runtime should call prepareModelFromCache_1_3 iff caching
+ // supported.
EXPECT_EQ(driver->hasCalledPrepareModelFromCache(), kIsCachingSupported);
HasCalledPrepareModel expectHasCalledPrepareModel;
if (kIsCachingSupported) {
if (kErrorStatusPrepareFromCache == ErrorStatus::NONE) {
- // The runtime should not call prepareModel_1_2 iff caching supported and
- // prepareModelFromCache succeeds.
+ // The runtime should not call prepareModel_1_3 iff caching supported and
+ // prepareModelFromCache_1_3 succeeds.
expectHasCalledPrepareModel = HasCalledPrepareModel::NO;
} else {
- // The runtime should call prepareModel_1_2 and request caching iff caching supported
- // but prepareModelFromCache fails.
+ // The runtime should call prepareModel_1_3 and request caching iff caching supported
+ // but prepareModelFromCache_1_3 fails.
expectHasCalledPrepareModel = HasCalledPrepareModel::WITH_CACHING;
}
} else {
- // The runtime should call prepareModel_1_2 without caching iff caching not supported.
+ // The runtime should call prepareModel_1_3 without caching iff caching not supported.
expectHasCalledPrepareModel = HasCalledPrepareModel::WITHOUT_CACHING;
}
EXPECT_EQ(driver->hasCalledPrepareModel(), expectHasCalledPrepareModel);
@@ -435,7 +436,7 @@ TEST_P(CompilationCachingTest, TokenNotProvided) {
compileModel(driver, /*withToken=*/false);
// When no NDK token is provided by the client, the runtime should never call
- // prepareModelFromCache or request caching with prepareModel_1_2.
+ // prepareModelFromCache_1_3 or request caching with prepareModel_1_3.
EXPECT_FALSE(driver->hasCalledPrepareModelFromCache());
EXPECT_EQ(driver->hasCalledPrepareModel(), HasCalledPrepareModel::WITHOUT_CACHING);
}