From 586e607392971a52b0eefee81244d6543efb29e4 Mon Sep 17 00:00:00 2001 From: ling Date: Thu, 2 Dec 2021 16:04:21 +0800 Subject: [PATCH] [MSLITE] runtime convert --- mindspore/lite/src/cxx_api/serialization.cc | 4 ++-- mindspore/lite/src/lite_session.cc | 8 +++++++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/mindspore/lite/src/cxx_api/serialization.cc b/mindspore/lite/src/cxx_api/serialization.cc index c95dccc5f17..ea26036ea50 100644 --- a/mindspore/lite/src/cxx_api/serialization.cc +++ b/mindspore/lite/src/cxx_api/serialization.cc @@ -52,7 +52,7 @@ Status Serialization::Load(const void *model_data, size_t data_size, ModelType m MS_LOG(ERROR) << "graph is nullptr."; return kLiteNullptr; } - if (model_type != kMindIR) { + if (model_type != kMindIR && model_type != kMindIR_Opt) { MS_LOG(ERROR) << "Unsupported IR."; return kLiteInputParamInvalid; } @@ -82,7 +82,7 @@ Status Serialization::Load(const std::vector &file, ModelType model_type, MS_LOG(ERROR) << "graph is nullptr."; return kLiteNullptr; } - if (model_type != kMindIR) { + if (model_type != kMindIR && model_type != kMindIR_Opt) { MS_LOG(ERROR) << "Unsupported IR."; return kLiteInputParamInvalid; } diff --git a/mindspore/lite/src/lite_session.cc b/mindspore/lite/src/lite_session.cc index 44e3feb00f5..c76e0a5b557 100644 --- a/mindspore/lite/src/lite_session.cc +++ b/mindspore/lite/src/lite_session.cc @@ -1543,7 +1543,13 @@ int lite::LiteSession::CreateSessionByBuf(const char *model_buf, mindspore::Mode int lite::LiteSession::CreateSessionByPath(const std::string &model_path, mindspore::ModelType model_type, session::LiteSession *session) { - auto *model = lite::ImportFromPath(model_path.c_str()); + size_t model_size; + auto model_buf = LoadModelByPath(model_path, model_type, &model_size); + if (model_buf == nullptr) { + MS_LOG(ERROR) << "Read model file failed"; + return RET_ERROR; + } + auto *model = lite::ImportFromBuffer(model_buf, model_size, true); if (model == nullptr) { MS_LOG(ERROR) << "Import model failed"; return RET_ERROR;