From 4aed10f552e097e1021db7f0e04b0bec0c746aa4 Mon Sep 17 00:00:00 2001 From: zengxianglong Date: Thu, 18 Mar 2021 21:45:30 +0800 Subject: [PATCH] fix memory leak --- .../tools/converter/legacy_optimizer/graph/infershape_pass.cc | 4 ++-- .../lite/tools/optimizer/fusion/constant_folding_fusion.cc | 1 + mindspore/lite/tools/optimizer/graph/infershape_pass.cc | 1 + 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/mindspore/lite/tools/converter/legacy_optimizer/graph/infershape_pass.cc b/mindspore/lite/tools/converter/legacy_optimizer/graph/infershape_pass.cc index 33176e76396..4e910bd76d7 100644 --- a/mindspore/lite/tools/converter/legacy_optimizer/graph/infershape_pass.cc +++ b/mindspore/lite/tools/converter/legacy_optimizer/graph/infershape_pass.cc @@ -116,7 +116,7 @@ std::vector ConvertTensorToLiteTensor(MetaGraphT *graph, const std::ve return lite_tensors; } -STATUS NodeInferShpae(const std::unique_ptr &node, const std::vector &inputs, +STATUS NodeInferShape(const std::unique_ptr &node, const std::vector &inputs, std::vector *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 diff --git a/mindspore/lite/tools/optimizer/fusion/constant_folding_fusion.cc b/mindspore/lite/tools/optimizer/fusion/constant_folding_fusion.cc index 45e11d06e4f..93928d3a0c3 100644 --- a/mindspore/lite/tools/optimizer/fusion/constant_folding_fusion.cc +++ b/mindspore/lite/tools/optimizer/fusion/constant_folding_fusion.cc @@ -121,6 +121,7 @@ kernel::LiteKernel *GetLiteKernel(std::vector inputs, std::vectorinput(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."; diff --git a/mindspore/lite/tools/optimizer/graph/infershape_pass.cc b/mindspore/lite/tools/optimizer/graph/infershape_pass.cc index a4367f22832..94471e9545f 100644 --- a/mindspore/lite/tools/optimizer/graph/infershape_pass.cc +++ b/mindspore/lite/tools/optimizer/graph/infershape_pass.cc @@ -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);