diff options
author | Michael Butler <butlermichael@google.com> | 2018-04-13 17:26:47 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2018-04-13 17:26:47 +0000 |
commit | 984b07d42ce0ed8629a6be2229862d0db4684890 (patch) | |
tree | 4452e26bcffe8933858f4b1612a6447699d13bb7 /nn/driver/sample/SampleDriver.cpp | |
parent | 665fe302d261cce3261a7bb6fa41ef519312e3f2 (diff) | |
parent | 1e9666208595bc251a8958155b1e41eca90b69db (diff) | |
download | ml-984b07d42ce0ed8629a6be2229862d0db4684890.tar.gz |
Merge changes from topic "nnapi-execution-preference" into pi-dev
* changes:
NNAPI: Add execution preference to prepareModel (runtime)
Upgrade NeuralNetworks v1.0 to v1.1 followup CL
Diffstat (limited to 'nn/driver/sample/SampleDriver.cpp')
-rw-r--r-- | nn/driver/sample/SampleDriver.cpp | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/nn/driver/sample/SampleDriver.cpp b/nn/driver/sample/SampleDriver.cpp index d537299df..9ebefe580 100644 --- a/nn/driver/sample/SampleDriver.cpp +++ b/nn/driver/sample/SampleDriver.cpp @@ -61,10 +61,12 @@ Return<ErrorStatus> SampleDriver::prepareModel(const V1_0::Model& model, callback->notify(ErrorStatus::INVALID_ARGUMENT, nullptr); return ErrorStatus::INVALID_ARGUMENT; } - return prepareModel_1_1(convertToV1_1(model), callback); + return prepareModel_1_1(convertToV1_1(model), ExecutionPreference::FAST_SINGLE_ANSWER, + callback); } Return<ErrorStatus> SampleDriver::prepareModel_1_1(const V1_1::Model& model, + ExecutionPreference preference, const sp<IPreparedModelCallback>& callback) { if (VLOG_IS_ON(DRIVER)) { VLOG(DRIVER) << "prepareModel_1_1"; @@ -74,7 +76,7 @@ Return<ErrorStatus> SampleDriver::prepareModel_1_1(const V1_1::Model& model, LOG(ERROR) << "invalid callback passed to prepareModel"; return ErrorStatus::INVALID_ARGUMENT; } - if (!validateModel(model)) { + if (!validateModel(model) || !validateExecutionPreference(preference)) { callback->notify(ErrorStatus::INVALID_ARGUMENT, nullptr); return ErrorStatus::INVALID_ARGUMENT; } @@ -118,8 +120,7 @@ void SamplePreparedModel::asyncExecute(const Request& request, } CpuExecutor executor; - V1_1::Model model = convertToV1_1(mModel); - int n = executor.run(model, request, mPoolInfos, requestPoolInfos); + int n = executor.run(mModel, request, mPoolInfos, requestPoolInfos); VLOG(DRIVER) << "executor.run returned " << n; ErrorStatus executionStatus = n == ANEURALNETWORKS_NO_ERROR ? ErrorStatus::NONE : ErrorStatus::GENERAL_FAILURE; |