aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMiao Wang <miaowang@google.com>2019-08-27 18:30:54 -0700
committerandroid-build-merger <android-build-merger@google.com>2019-08-27 18:30:54 -0700
commitff6c3d2ffd95b2835d3ecbe36ab0a979cc6b8d01 (patch)
treebe4b0e3b1c0a10b3a4ee01e7b315226a52696acd
parent382756dea0bcd0b4797dfb5ec0a884233acfb7fe (diff)
parentdbe1288786f12e74baffbff8fe098918f551d46a (diff)
downloadplatform_test_mlts_benchmark-ff6c3d2ffd95b2835d3ecbe36ab0a979cc6b8d01.tar.gz
platform_test_mlts_benchmark-ff6c3d2ffd95b2835d3ecbe36ab0a979cc6b8d01.tar.bz2
platform_test_mlts_benchmark-ff6c3d2ffd95b2835d3ecbe36ab0a979cc6b8d01.zip
Update NNAPI benchmark to use StatefulNNAPIDelegate am: f1ce746a59 am: f3d14b938c am: 603ef8d7f3 am: 364bfc8719
am: dbe1288786 Change-Id: I8e017b74041569ebc02ae7669e8d920cf9ac3cd6
-rw-r--r--jni/run_tflite.cpp6
-rw-r--r--jni/run_tflite.h1
2 files changed, 5 insertions, 2 deletions
diff --git a/jni/run_tflite.cpp b/jni/run_tflite.cpp
index 5ca88a8..4e03b36 100644
--- a/jni/run_tflite.cpp
+++ b/jni/run_tflite.cpp
@@ -118,8 +118,10 @@ bool BenchmarkModel::init(const char* modelfile, bool use_nnapi,
__android_log_print(ANDROID_LOG_INFO, LOG_TAG, "Running NNAPI on device %s",
nnapi_device_name);
}
- if (mTfliteInterpreter->ModifyGraphWithDelegate(
- tflite::NnApiDelegate(nnapi_device_name)) != kTfLiteOk) {
+ tflite::StatefulNnApiDelegate::Options nnapi_options;
+ nnapi_options.accelerator_name = nnapi_device_name;
+ mTfliteNnapiDelegate = std::make_unique<tflite::StatefulNnApiDelegate>(nnapi_options);
+ if (mTfliteInterpreter->ModifyGraphWithDelegate(mTfliteNnapiDelegate.get()) != kTfLiteOk) {
__android_log_print(ANDROID_LOG_ERROR, LOG_TAG,
"Failed to initialize NNAPI Delegate");
return false;
diff --git a/jni/run_tflite.h b/jni/run_tflite.h
index 4a533db..2119ab1 100644
--- a/jni/run_tflite.h
+++ b/jni/run_tflite.h
@@ -94,6 +94,7 @@ class BenchmarkModel {
std::unique_ptr<tflite::FlatBufferModel> mTfliteModel;
std::unique_ptr<tflite::Interpreter> mTfliteInterpreter;
+ std::unique_ptr<tflite::StatefulNnApiDelegate> mTfliteNnapiDelegate;
// Store indices of output tensors, used to dump intermediate tensors
std::vector<int> outputs;
};