From 9c5c5de35b2dae4740fe398d069b7bb703016acb Mon Sep 17 00:00:00 2001 From: yangruoqi713 Date: Mon, 21 Dec 2020 15:41:17 +0800 Subject: [PATCH] [MSLITE][DEVELOP] fix bug of npu benchmark --- mindspore/lite/src/runtime/agent/npu/npu_executor.cc | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/mindspore/lite/src/runtime/agent/npu/npu_executor.cc b/mindspore/lite/src/runtime/agent/npu/npu_executor.cc index 1c5d70e711..082a18966b 100644 --- a/mindspore/lite/src/runtime/agent/npu/npu_executor.cc +++ b/mindspore/lite/src/runtime/agent/npu/npu_executor.cc @@ -42,6 +42,14 @@ int NPUExecutor::Run(const std::vector &in_tensors, const std::vector< return RET_ERROR; } memcpy(npu_input_tensors_[i]->GetBuffer(), data, in_tensors[i]->Size()); + in_tensors[i]->set_ref_count(in_tensors[i]->ref_count() - 1); + if (in_tensors[i]->ref_count() <= 0) { + auto ret = in_tensors[i]->FreeData(); + if (ret != RET_OK) { + MS_LOG(ERROR) << "Free tensor data failed"; + return RET_ERROR; + } + } } context.AddPara("model_name", model_name_); if (this->client_ == nullptr) {