Support setting Core ML delegate's target Core ML version in benchmark
PiperOrigin-RevId: 311269200 Change-Id: I343794d6af948c554d05a89c9e432c0975ddfa6c
This commit is contained in:
parent
e71443f838
commit
088fc3a9b5
@ -87,6 +87,7 @@ the reported data on hexagon is in cycles, not in ms like on cpu.
|
|||||||
|
|
||||||
#### CoreML delegate
|
#### CoreML delegate
|
||||||
* `use_coreml`: `bool` (default=false)
|
* `use_coreml`: `bool` (default=false)
|
||||||
|
* `coreml_version`: `int` (default=0)
|
||||||
|
|
||||||
#### External delegate
|
#### External delegate
|
||||||
* `external_delegate_path`: `string` (default="")
|
* `external_delegate_path`: `string` (default="")
|
||||||
|
@ -93,6 +93,9 @@ TFLite delegate.
|
|||||||
* `use_coreml`: `bool` (default=false) \
|
* `use_coreml`: `bool` (default=false) \
|
||||||
Whether to use the [Core ML delegate](https://github.com/tensorflow/tensorflow/tree/master/tensorflow/lite/experimental/delegates/coreml).
|
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.
|
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 provider
|
||||||
* `external_delegate_path`: `string` (default="") \
|
* `external_delegate_path`: `string` (default="") \
|
||||||
|
@ -32,6 +32,7 @@ class CoreMlDelegateProvider : public DelegateProvider {
|
|||||||
CoreMlDelegateProvider() {
|
CoreMlDelegateProvider() {
|
||||||
#if defined(REAL_IPHONE_DEVICE)
|
#if defined(REAL_IPHONE_DEVICE)
|
||||||
default_params_.AddParam("use_coreml", ToolParam::Create<bool>(true));
|
default_params_.AddParam("use_coreml", ToolParam::Create<bool>(true));
|
||||||
|
default_params_.AddParam("coreml_version", ToolParam::Create<int>(0));
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
std::vector<Flag> CreateFlags(ToolParams* params) const final;
|
std::vector<Flag> CreateFlags(ToolParams* params) const final;
|
||||||
@ -49,6 +50,10 @@ std::vector<Flag> CoreMlDelegateProvider::CreateFlags(
|
|||||||
#if defined(REAL_IPHONE_DEVICE)
|
#if defined(REAL_IPHONE_DEVICE)
|
||||||
std::vector<Flag> flags = {
|
std::vector<Flag> flags = {
|
||||||
CreateFlag<bool>("use_coreml", params, "use Core ML"),
|
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;
|
return flags;
|
||||||
#else
|
#else
|
||||||
@ -71,6 +76,7 @@ TfLiteDelegatePtr CoreMlDelegateProvider::CreateTfLiteDelegate(
|
|||||||
if (params.Get<bool>("use_coreml")) {
|
if (params.Get<bool>("use_coreml")) {
|
||||||
TfLiteCoreMlDelegateOptions coreml_opts = {
|
TfLiteCoreMlDelegateOptions coreml_opts = {
|
||||||
.enabled_devices = TfLiteCoreMlDelegateAllDevices};
|
.enabled_devices = TfLiteCoreMlDelegateAllDevices};
|
||||||
|
coreml_opts.coreml_version = params.Get<int>("coreml_version");
|
||||||
coreml_opts.max_delegated_partitions =
|
coreml_opts.max_delegated_partitions =
|
||||||
params.Get<int>("max_delegated_partitions");
|
params.Get<int>("max_delegated_partitions");
|
||||||
coreml_opts.min_nodes_per_partition =
|
coreml_opts.min_nodes_per_partition =
|
||||||
|
Loading…
Reference in New Issue
Block a user