Support to configure the 'min_nodes_per_partition' hexagon delegate option for tflite tools (including benchmark tool).

PiperOrigin-RevId: 306976354
Change-Id: Ib2bc30b6ac1a39b5736eab5f5ea3f72577d0ca6a
This commit is contained in:
Chao Mei 2020-04-16 20:48:57 -07:00 committed by TensorFlower Gardener
parent 78580b371b
commit b5f7f775aa
3 changed files with 20 additions and 3 deletions

View File

@ -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)

View File

@ -28,6 +28,8 @@ class DefaultExecutionProvider : public DelegateProvider {
default_params_.AddParam("num_threads", BenchmarkParam::Create<int32_t>(1));
default_params_.AddParam("max_delegated_partitions",
BenchmarkParam::Create<int32_t>(0));
default_params_.AddParam("min_nodes_per_partition",
BenchmarkParam::Create<int32_t>(0));
}
std::vector<Flag> CreateFlags(BenchmarkParams* params) const final;
@ -44,7 +46,12 @@ std::vector<Flag> DefaultExecutionProvider::CreateFlags(
CreateFlag<int32_t>("num_threads", params,
"number of threads used for inference on CPU."),
CreateFlag<int32_t>("max_delegated_partitions", params,
"Max number of partitions to be delegated.")};
"Max number of partitions to be delegated."),
CreateFlag<int32_t>(
"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<int32_t>("num_threads") << "]";
TFLITE_LOG(INFO) << "Max number of delegated partitions : ["
<< params.Get<int32_t>("max_delegated_partitions") << "]";
TFLITE_LOG(INFO) << "Min nodes per partition : ["
<< params.Get<int32_t>("min_nodes_per_partition") << "]";
}
TfLiteDelegatePtr DefaultExecutionProvider::CreateTfLiteDelegate(

View File

@ -90,6 +90,8 @@ TfLiteDelegatePtr HexagonDelegateProvider::CreateTfLiteDelegate(
options.print_graph_profile = params.Get<bool>("hexagon_profiling");
options.max_delegated_partitions =
params.Get<int>("max_delegated_partitions");
options.min_nodes_per_partition =
params.Get<int>("min_nodes_per_partition");
delegate = evaluation::CreateHexagonDelegate(
&options, params.Get<std::string>("hexagon_lib_path"));