From fe968502a9835afec951a669d64224e411746605 Mon Sep 17 00:00:00 2001 From: Chao Mei <chaomei@google.com> Date: Sun, 9 Aug 2020 23:59:01 -0700 Subject: [PATCH] Stop support of --use_legacy_nnapi in the benchmark tool as Interpreter:UseNNAPI(bool) is marked deprecated now. Instead, use "--use_nnapi" and other NNAPI options. PiperOrigin-RevId: 325748539 Change-Id: Ie2c1c4ac3054239e9355b85092020ed36f06f0ff --- tensorflow/lite/interpreter.cc | 2 +- tensorflow/lite/tools/benchmark/README.md | 10 +--------- .../lite/tools/benchmark/benchmark_tflite_model.cc | 7 ------- 3 files changed, 2 insertions(+), 17 deletions(-) diff --git a/tensorflow/lite/interpreter.cc b/tensorflow/lite/interpreter.cc index 307ede187b2..1d702dd8397 100644 --- a/tensorflow/lite/interpreter.cc +++ b/tensorflow/lite/interpreter.cc @@ -113,7 +113,7 @@ Interpreter::Interpreter(ErrorReporter* error_reporter) external_contexts_[kTfLiteCpuBackendContext] = own_external_cpu_backend_context_.get(); - UseNNAPI(false); + primary_subgraph().UseNNAPI(false); } Interpreter::~Interpreter() { diff --git a/tensorflow/lite/tools/benchmark/README.md b/tensorflow/lite/tools/benchmark/README.md index 8d7e6643d79..68cc59dd371 100644 --- a/tensorflow/lite/tools/benchmark/README.md +++ b/tensorflow/lite/tools/benchmark/README.md @@ -34,13 +34,6 @@ and the following optional parameters: * `run_delay`: `float` (default=-1.0) \ The delay in seconds between subsequent benchmark runs. Non-positive values mean use no delay. -* `use_legacy_nnapi`: `bool` (default=false) \ - Whether to use the legacy - [Android NNAPI](https://developer.android.com/ndk/guides/neuralnetworks/) - TFLite path, which requires the graph to be fully compatible with NNAPI. - This is available on recent Android devices. Note that some Android P - devices will fail to use NNAPI for models in `/data/local/tmp/` and this - benchmark tool will not correctly use NNAPI. * `enable_op_profiling`: `bool` (default=false) \ Whether to enable per-operator profiling measurement. * `enable_platform_tracing`: `bool` (default=false) \ @@ -65,8 +58,7 @@ The following simply lists the names of these parameters and additional notes where applicable. For details about each parameter, please refer to [this page](https://github.com/tensorflow/tensorflow/blob/master/tensorflow/lite/tools/delegates/README.md#tflite-delegate-registrar). #### Common parameters -* `max_delegated_partitions`: `int` (default=0) \ -Note when `use_legacy_nnapi` is selected, this parameter won't work. +* `max_delegated_partitions`: `int` (default=0) * `min_nodes_per_partition`:`int` (default=0) #### GPU delegate diff --git a/tensorflow/lite/tools/benchmark/benchmark_tflite_model.cc b/tensorflow/lite/tools/benchmark/benchmark_tflite_model.cc index 39ecded5484..ef9742eaac7 100644 --- a/tensorflow/lite/tools/benchmark/benchmark_tflite_model.cc +++ b/tensorflow/lite/tools/benchmark/benchmark_tflite_model.cc @@ -259,8 +259,6 @@ BenchmarkParams BenchmarkTfLiteModel::DefaultParams() { BenchmarkParam::Create<std::string>("")); default_params.AddParam("input_layer_value_files", BenchmarkParam::Create<std::string>("")); - default_params.AddParam("use_legacy_nnapi", - BenchmarkParam::Create<bool>(false)); default_params.AddParam("allow_fp16", BenchmarkParam::Create<bool>(false)); default_params.AddParam("require_full_delegation", BenchmarkParam::Create<bool>(false)); @@ -324,7 +322,6 @@ std::vector<Flag> BenchmarkTfLiteModel::GetFlags() { "input_layer_value_range of the input_name will be ignored. The file " "format is binary and it should be array format or null separated " "strings format."), - CreateFlag<bool>("use_legacy_nnapi", ¶ms_, "use legacy nnapi api"), CreateFlag<bool>("allow_fp16", ¶ms_, "allow fp16"), CreateFlag<bool>("require_full_delegation", ¶ms_, "require delegate to run the entire graph"), @@ -363,9 +360,6 @@ void BenchmarkTfLiteModel::LogParams() { LOG_BENCHMARK_PARAM(std::string, "input_layer_value_files", "Input value files", verbose); -#if defined(__ANDROID__) - LOG_BENCHMARK_PARAM(bool, "use_legacy_nnapi", "Use legacy nnapi", verbose); -#endif LOG_BENCHMARK_PARAM(bool, "allow_fp16", "Allow fp16", verbose); LOG_BENCHMARK_PARAM(bool, "require_full_delegation", "Require full delegation", verbose); @@ -635,7 +629,6 @@ TfLiteStatus BenchmarkTfLiteModel::Init() { profiling_listener_ = MayCreateProfilingListener(); if (profiling_listener_) AddListener(profiling_listener_.get()); - interpreter_->UseNNAPI(params_.Get<bool>("use_legacy_nnapi")); interpreter_->SetAllowFp16PrecisionForFp32(params_.Get<bool>("allow_fp16")); owned_delegates_.clear();