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;