Browse Source

!27386 [MSLITE] buffer malloc and free match

Merge pull request !27386 from ling/sr
tags/v1.6.0
i-robot Gitee 4 years ago
parent
commit
2592fa0ffb
2 changed files with 3 additions and 3 deletions
  1. +2
    -2
      mindspore/lite/src/lite_session.cc
  2. +1
    -1
      mindspore/lite/tools/common/graph_util.cc

+ 2
- 2
mindspore/lite/src/lite_session.cc View File

@@ -1508,7 +1508,7 @@ const char *lite::LiteSession::LoadModelByPath(const std::string &file, mindspor
return nullptr;
}
if (buf_model_type == mindspore::ModelType::kMindIR) {
free(model_buf);
delete[] model_buf;
model_buf = nullptr;
}
return lite_buf;
@@ -1532,7 +1532,7 @@ int lite::LiteSession::CreateSessionByBuf(const char *model_buf, mindspore::Mode
auto ret = session->CompileGraph(model);
model->buf = nullptr;
if (buf_model_type == mindspore::ModelType::kMindIR) {
free(lite_buf);
delete[] lite_buf;
lite_buf = nullptr;
}
if (ret != lite::RET_OK) {


+ 1
- 1
mindspore/lite/tools/common/graph_util.cc View File

@@ -528,7 +528,7 @@ int TransferMetaGraph(const schema::MetaGraphT &graph, void **model_buf, size_t
MS_LOG(ERROR) << "GetBufferPointer nullptr";
return RET_ERROR;
}
*model_buf = malloc(*size);
*model_buf = new char[*size];
if (*model_buf == nullptr) {
MS_LOG(ERROR) << "malloc model_buf failed";
return RET_ERROR;


Loading…
Cancel
Save