!46927 support CoreML for SetBuiltInDelegate

Merge pull request !46927 from qinzheng/fix_coreml
This commit is contained in:
i-robot 2023-02-11 06:48:57 +00:00 committed by Gitee
commit 7326fb6d84
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
1 changed files with 18 additions and 0 deletions

View File

@ -53,6 +53,9 @@
#if SUPPORT_NNAPI
#include "src/litert/delegate/nnapi/nnapi_delegate.h"
#endif
#ifdef ENABLE_COREML
#include "src/litert/delegate/coreml/coreml_delegate.h"
#endif
#include "src/litert/runtime_convert.h"
#include "extendrt/mindir_loader/model_loader.h"
#ifndef __ANDROID__
@ -950,6 +953,18 @@ int LiteSession::CreateNNAPIDelegate() {
return RET_OK;
}
int LiteSession::CreateCoreMLDelegate() {
#ifdef ENABLE_COREML
delegate_ = std::make_shared<CoreMLDelegate>();
if (delegate_ == nullptr) {
MS_LOG(ERROR) << "New delegate_ failed";
return RET_ERROR;
}
this->context_->delegate = delegate_;
#endif
return RET_OK;
}
int LiteSession::DelegateInit() {
#ifndef DELEGATE_CLIP
int ret = RET_OK;
@ -961,6 +976,9 @@ int LiteSession::DelegateInit() {
case kNNAPI:
ret = CreateNNAPIDelegate();
break;
case kCoreML:
ret = CreateCoreMLDelegate();
break;
default:
MS_LOG(ERROR) << "Unsupported built-in delegate mode: " << context_->delegate_mode_;
return RET_ERROR;