[MSLITE] runtime convert

This commit is contained in:
ling 2021-12-02 16:04:21 +08:00
parent acbaff17f7
commit 586e607392
2 changed files with 9 additions and 3 deletions

View File

@ -52,7 +52,7 @@ Status Serialization::Load(const void *model_data, size_t data_size, ModelType m
MS_LOG(ERROR) << "graph is nullptr."; MS_LOG(ERROR) << "graph is nullptr.";
return kLiteNullptr; return kLiteNullptr;
} }
if (model_type != kMindIR) { if (model_type != kMindIR && model_type != kMindIR_Opt) {
MS_LOG(ERROR) << "Unsupported IR."; MS_LOG(ERROR) << "Unsupported IR.";
return kLiteInputParamInvalid; return kLiteInputParamInvalid;
} }
@ -82,7 +82,7 @@ Status Serialization::Load(const std::vector<char> &file, ModelType model_type,
MS_LOG(ERROR) << "graph is nullptr."; MS_LOG(ERROR) << "graph is nullptr.";
return kLiteNullptr; return kLiteNullptr;
} }
if (model_type != kMindIR) { if (model_type != kMindIR && model_type != kMindIR_Opt) {
MS_LOG(ERROR) << "Unsupported IR."; MS_LOG(ERROR) << "Unsupported IR.";
return kLiteInputParamInvalid; return kLiteInputParamInvalid;
} }

View File

@ -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, int lite::LiteSession::CreateSessionByPath(const std::string &model_path, mindspore::ModelType model_type,
session::LiteSession *session) { 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) { if (model == nullptr) {
MS_LOG(ERROR) << "Import model failed"; MS_LOG(ERROR) << "Import model failed";
return RET_ERROR; return RET_ERROR;