diff options
author | David Gross <dgross@google.com> | 2018-12-21 11:34:19 -0800 |
---|---|---|
committer | David Gross <dgross@google.com> | 2018-12-21 11:34:19 -0800 |
commit | 1120420f54c73803a9b3a03c19b34ac3ed197904 (patch) | |
tree | 37e3f0edf6751f6058e8886e8f1df0b9a4e958b2 /nn/runtime/test/TestMain.cpp | |
parent | cc72c1b5c7123e3f80f44288a937d6e7a1ba4495 (diff) | |
download | ml-1120420f54c73803a9b3a03c19b34ac3ed197904.tar.gz |
Support @1.2::IPreparedModel::executeSynchronously().
- Implement SamplePreparedModel::executeSynchronously().
- Call executeSynchronously() when available.
Add two more iterations to NeuralNetworksTest, in which
we do not call executeSynchronously() even if it is available.
Add new property debug.nn.syncexec-hal that defaults to 1.
When set to 0, the runtime WILL NOT call executeSynchronously()
even if it is available.
Bug: 119274127
Test: NeuralNetworksTest_static
Change-Id: I6d842519db732bfca057981d7abceebe69499087
Diffstat (limited to 'nn/runtime/test/TestMain.cpp')
-rw-r--r-- | nn/runtime/test/TestMain.cpp | 27 |
1 files changed, 22 insertions, 5 deletions
diff --git a/nn/runtime/test/TestMain.cpp b/nn/runtime/test/TestMain.cpp index ed846a54b..87528f13e 100644 --- a/nn/runtime/test/TestMain.cpp +++ b/nn/runtime/test/TestMain.cpp @@ -35,21 +35,29 @@ using namespace android::nn::test_wrapper; // non-public DeviceManager::setUseCpuOnly(); we assume the setting is always // false, and if we are asked to set it to true, we return 0 ("success") without // running tests. -static int test(bool useCpuOnly, bool computeUsesSynchronousAPI) { +// +// EXCEPTION: If NNTEST_ONLY_PUBLIC_API is defined, then we cannot call +// non-public DeviceManager::setSyncExecHal(); we assume the setting is always +// true, and if we are asked to set it to false, we return 0 ("success") without +// running tests. +static int test(bool useCpuOnly, bool computeUsesSynchronousAPI, bool allowSyncExecHal = true) { #ifdef NNTEST_ONLY_PUBLIC_API - if (useCpuOnly) { + if (useCpuOnly || !allowSyncExecHal) { return 0; } #else android::nn::DeviceManager::get()->setUseCpuOnly(useCpuOnly); + android::nn::DeviceManager::get()->setSyncExecHal(allowSyncExecHal); #endif Execution::setComputeUsesSynchronousAPI(computeUsesSynchronousAPI); LOG(INFO) << "test(useCpuOnly = " << useCpuOnly - << ", computeUsesSynchronousAPI = " << computeUsesSynchronousAPI << ")"; + << ", computeUsesSynchronousAPI = " << computeUsesSynchronousAPI + << ", allowSyncExecHal = " << allowSyncExecHal << ")"; std::cout << "[**********] useCpuOnly = " << useCpuOnly - << ", computeUsesSynchronousAPI = " << computeUsesSynchronousAPI << std::endl; + << ", computeUsesSynchronousAPI = " << computeUsesSynchronousAPI + << ", allowSyncExecHal = " << allowSyncExecHal << std::endl; return RUN_ALL_TESTS(); } @@ -60,5 +68,14 @@ int main(int argc, char** argv) { android::nn::initVLogMask(); #endif - return test(false, false) | test(false, true) | test(true, false) | test(true, true); + int n = test(false, false) | test(false, true) | test(true, false) | test(true, true); + + // Now try disabling use of synchronous execution HAL. + // + // Whether or not the use of synchronous execution HAL is enabled should make no + // difference when useCpuOnly = true; we already ran test(true, *, true) above, + // so there's no reason to run test(true, *, false) now. + n |= test(false, false, false) | test(false, true, false); + + return n; } |