forked from mindspore-Ecosystem/mindspore
!13568 [MS][LITE] fix memory leak
From: @probiotics_53 Reviewed-by: @hangangqiang,@zhang_xue_tong Signed-off-by: @hangangqiang
This commit is contained in:
commit
e8cb23e35e
|
@ -116,7 +116,7 @@ std::vector<Tensor *> ConvertTensorToLiteTensor(MetaGraphT *graph, const std::ve
|
|||
return lite_tensors;
|
||||
}
|
||||
|
||||
STATUS NodeInferShpae(const std::unique_ptr<schema::CNodeT> &node, const std::vector<Tensor *> &inputs,
|
||||
STATUS NodeInferShape(const std::unique_ptr<schema::CNodeT> &node, const std::vector<Tensor *> &inputs,
|
||||
std::vector<Tensor *> *outputs) {
|
||||
flatbuffers::FlatBufferBuilder fbb(INITIAL_SIZE);
|
||||
auto prim = ConvertToPrimitive(node->primitive.get(), &fbb);
|
||||
|
@ -197,7 +197,7 @@ STATUS InferShapePass::Run(MetaGraphT *graph) {
|
|||
FreeTensors(input_tensors, output_tensors);
|
||||
return RET_INFER_ERR;
|
||||
}
|
||||
auto status = NodeInferShpae(node, input_tensors, &output_tensors);
|
||||
auto status = NodeInferShape(node, input_tensors, &output_tensors);
|
||||
MS_LOG(DEBUG) << "cur node:" << node->name;
|
||||
if (status == RET_INFER_INVALID) {
|
||||
MS_LOG(INFO) << "InferShape shouldn't be done before runtime, name: " << node->name
|
||||
|
|
|
@ -121,6 +121,7 @@ kernel::LiteKernel *GetLiteKernel(std::vector<Tensor *> inputs, std::vector<Tens
|
|||
auto prim_t = lite::GetPrimitiveT(cnode->input(0));
|
||||
flatbuffers::FlatBufferBuilder fbb(INITIAL_SIZE);
|
||||
auto prim = lite::ConvertToPrimitive(prim_t, &fbb);
|
||||
delete prim_t;
|
||||
if (prim == nullptr) {
|
||||
fbb.Clear();
|
||||
MS_LOG(ERROR) << "get primitive failed.";
|
||||
|
|
|
@ -397,6 +397,7 @@ bool InferShapePass::Run(const FuncGraphPtr &func_graph) {
|
|||
|
||||
flatbuffers::FlatBufferBuilder fbb(INITIAL_SIZE);
|
||||
auto prim = lite::ConvertToPrimitive(prim_t, &fbb);
|
||||
delete prim_t;
|
||||
if (prim == nullptr) {
|
||||
MS_LOG(ERROR) << "get primitive failed.";
|
||||
FreeTensors(&input_tensors);
|
||||
|
|
Loading…
Reference in New Issue