Support setting Core ML delegate's target Core ML version in benchmark

PiperOrigin-RevId: 311269200
Change-Id: I343794d6af948c554d05a89c9e432c0975ddfa6c
This commit is contained in:
Taehee Jeong 2020-05-12 22:46:26 -07:00 committed by TensorFlower Gardener
parent e71443f838
commit 088fc3a9b5
3 changed files with 10 additions and 0 deletions

View File

@ -87,6 +87,7 @@ the reported data on hexagon is in cycles, not in ms like on cpu.
#### CoreML delegate
* `use_coreml`: `bool` (default=false)
* `coreml_version`: `int` (default=0)
#### External delegate
* `external_delegate_path`: `string` (default="")

View File

@ -93,6 +93,9 @@ TFLite delegate.
* `use_coreml`: `bool` (default=false) \
Whether to use the [Core ML delegate](https://github.com/tensorflow/tensorflow/tree/master/tensorflow/lite/experimental/delegates/coreml).
This option is only available in iOS.
* `coreml_version`: `int` (default=0) \
Target Core ML version for model conversion. The default value is 0 and it
means using the newest version that's available on the device.
### External delegate provider
* `external_delegate_path`: `string` (default="") \

View File

@ -32,6 +32,7 @@ class CoreMlDelegateProvider : public DelegateProvider {
CoreMlDelegateProvider() {
#if defined(REAL_IPHONE_DEVICE)
default_params_.AddParam("use_coreml", ToolParam::Create<bool>(true));
default_params_.AddParam("coreml_version", ToolParam::Create<int>(0));
#endif
}
std::vector<Flag> CreateFlags(ToolParams* params) const final;
@ -49,6 +50,10 @@ std::vector<Flag> CoreMlDelegateProvider::CreateFlags(
#if defined(REAL_IPHONE_DEVICE)
std::vector<Flag> flags = {
CreateFlag<bool>("use_coreml", params, "use Core ML"),
CreateFlag<int>("coreml_version", params,
"Target Core ML version for model conversion. "
"The default value is 0 and it means using the newest "
"version that's available on the device."),
};
return flags;
#else
@ -71,6 +76,7 @@ TfLiteDelegatePtr CoreMlDelegateProvider::CreateTfLiteDelegate(
if (params.Get<bool>("use_coreml")) {
TfLiteCoreMlDelegateOptions coreml_opts = {
.enabled_devices = TfLiteCoreMlDelegateAllDevices};
coreml_opts.coreml_version = params.Get<int>("coreml_version");
coreml_opts.max_delegated_partitions =
params.Get<int>("max_delegated_partitions");
coreml_opts.min_nodes_per_partition =