diff --git a/tensorflow/lite/tools/benchmark/README.md b/tensorflow/lite/tools/benchmark/README.md index 7ea236120f4..70728f41db1 100644 --- a/tensorflow/lite/tools/benchmark/README.md +++ b/tensorflow/lite/tools/benchmark/README.md @@ -69,8 +69,14 @@ and the following optional parameters: benchmark tool will not correctly use NNAPI. * `max_delegated_partitions`: `int` (default=0, i.e. no limit) \ The maximum number of partitions that will be delegated. \ - Currently supported only by the NNAPI Delegate and it won't work \ - if `use_legacy_nnapi` has been selected. + Currently supported by the Hexagon delegate or the NNAPI delegate but won't + work if `use_legacy_nnapi` has been selected. +* `min_nodes_per_partition`: `int` (default=0, i.e. default choice implemented + by each delegate) \ + The minimal number of TFLite graph nodes of a partition that needs to be + reached to be delegated. A negative value or 0 means to use the default + choice of each delegate. \ + This option is currently only supported by the Hexagon delegate. * `disable_nnapi_cpu`: `bool` (default=false) \ Excludes the [NNAPI CPU reference implementation](https://developer.android.com/ndk/guides/neuralnetworks#device-assignment) diff --git a/tensorflow/lite/tools/benchmark/default_execution_provider.cc b/tensorflow/lite/tools/benchmark/default_execution_provider.cc index f7204cba954..1dd8aebccca 100644 --- a/tensorflow/lite/tools/benchmark/default_execution_provider.cc +++ b/tensorflow/lite/tools/benchmark/default_execution_provider.cc @@ -28,6 +28,8 @@ class DefaultExecutionProvider : public DelegateProvider { default_params_.AddParam("num_threads", BenchmarkParam::Create(1)); default_params_.AddParam("max_delegated_partitions", BenchmarkParam::Create(0)); + default_params_.AddParam("min_nodes_per_partition", + BenchmarkParam::Create(0)); } std::vector CreateFlags(BenchmarkParams* params) const final; @@ -44,7 +46,12 @@ std::vector DefaultExecutionProvider::CreateFlags( CreateFlag("num_threads", params, "number of threads used for inference on CPU."), CreateFlag("max_delegated_partitions", params, - "Max number of partitions to be delegated.")}; + "Max number of partitions to be delegated."), + CreateFlag( + "min_nodes_per_partition", params, + "The minimal number of TFLite graph nodes of a partition that has to " + "be reached for it to be delegated.A negative value or 0 means to " + "use the default choice of each delegate.")}; return flags; } @@ -53,6 +60,8 @@ void DefaultExecutionProvider::LogParams(const BenchmarkParams& params) const { << params.Get("num_threads") << "]"; TFLITE_LOG(INFO) << "Max number of delegated partitions : [" << params.Get("max_delegated_partitions") << "]"; + TFLITE_LOG(INFO) << "Min nodes per partition : [" + << params.Get("min_nodes_per_partition") << "]"; } TfLiteDelegatePtr DefaultExecutionProvider::CreateTfLiteDelegate( diff --git a/tensorflow/lite/tools/benchmark/hexagon_delegate_provider.cc b/tensorflow/lite/tools/benchmark/hexagon_delegate_provider.cc index 465c71c0a91..1904dd5eebb 100644 --- a/tensorflow/lite/tools/benchmark/hexagon_delegate_provider.cc +++ b/tensorflow/lite/tools/benchmark/hexagon_delegate_provider.cc @@ -90,6 +90,8 @@ TfLiteDelegatePtr HexagonDelegateProvider::CreateTfLiteDelegate( options.print_graph_profile = params.Get("hexagon_profiling"); options.max_delegated_partitions = params.Get("max_delegated_partitions"); + options.min_nodes_per_partition = + params.Get("min_nodes_per_partition"); delegate = evaluation::CreateHexagonDelegate( &options, params.Get("hexagon_lib_path"));