diff --git a/mindspore/lite/src/runtime/agent/npu/npu_executor.cc b/mindspore/lite/src/runtime/agent/npu/npu_executor.cc index 39640df1dbe..da34dc233b9 100644 --- a/mindspore/lite/src/runtime/agent/npu/npu_executor.cc +++ b/mindspore/lite/src/runtime/agent/npu/npu_executor.cc @@ -19,6 +19,11 @@ #include "src/runtime/agent/npu/npu_manager.h" #include "nnacl/pack.h" namespace mindspore::lite { +NPUExecutor::~NPUExecutor() { + npu_input_tensors_.clear(); + npu_output_tensors_.clear(); +} + int NPUExecutor::Prepare(const std::vector &kernels) { this->client_ = mindspore::lite::NPUManager::GetInstance()->GetClient(model_name_); if (this->client_ == nullptr) { diff --git a/mindspore/lite/src/runtime/agent/npu/npu_executor.h b/mindspore/lite/src/runtime/agent/npu/npu_executor.h index 95a82c79c09..b6d107f347a 100644 --- a/mindspore/lite/src/runtime/agent/npu/npu_executor.h +++ b/mindspore/lite/src/runtime/agent/npu/npu_executor.h @@ -28,7 +28,7 @@ namespace mindspore::lite { class NPUExecutor : public Executor { public: explicit NPUExecutor(const std::string &model_name) { this->model_name_ = model_name; } - ~NPUExecutor() override = default; + ~NPUExecutor() override; int Prepare(const std::vector &kernels) override; int Run(const std::vector &in_tensors, const std::vector &out_tensors, diff --git a/mindspore/lite/src/runtime/agent/npu/npu_manager.cc b/mindspore/lite/src/runtime/agent/npu/npu_manager.cc index fc0cc9e0ef5..c4c8263ca8a 100644 --- a/mindspore/lite/src/runtime/agent/npu/npu_manager.cc +++ b/mindspore/lite/src/runtime/agent/npu/npu_manager.cc @@ -70,6 +70,7 @@ void NPUManager::Reset() { } models_.clear(); for (auto client : clients_) { + client->UnLoadModel(); client.reset(); } clients_.clear(); @@ -213,7 +214,6 @@ int NPUManager::LoadModel(const std::shared_ptr &clien } for (const auto &desc : desc_list) { - MS_LOG(ERROR) << desc->GetName(); auto it = models_.find(desc->GetName()); it->second->is_loaded = true; it->second->client_ = client; diff --git a/mindspore/lite/src/runtime/agent/npu/npu_manager.h b/mindspore/lite/src/runtime/agent/npu/npu_manager.h index d7a8728a00f..3c0675b45c9 100644 --- a/mindspore/lite/src/runtime/agent/npu/npu_manager.h +++ b/mindspore/lite/src/runtime/agent/npu/npu_manager.h @@ -42,7 +42,7 @@ struct SubGraphModel { bool is_loaded = false; int index_; std::string model_name_; - domi::ModelBufferData *model_buffer_data_; + std::shared_ptr model_buffer_data_; std::shared_ptr client_; std::shared_ptr desc_; }; diff --git a/mindspore/lite/src/runtime/agent/npu/optimizer/npu_fusion_pass.cc b/mindspore/lite/src/runtime/agent/npu/optimizer/npu_fusion_pass.cc index 2cea2677320..10ecb4593f7 100644 --- a/mindspore/lite/src/runtime/agent/npu/optimizer/npu_fusion_pass.cc +++ b/mindspore/lite/src/runtime/agent/npu/optimizer/npu_fusion_pass.cc @@ -55,7 +55,6 @@ void NPUFusionPass::UpdatePreKernels(kernel::LiteKernel *cur_kernel) { } } cur_kernel->set_in_kernels(cur_in_kernels); - kernels->erase(find(kernels->begin(), kernels->end(), in_kernel)); } } @@ -80,7 +79,6 @@ void NPUFusionPass::UpdatePostKernels(kernel::LiteKernel *cur_kernel) { } } cur_kernel->set_out_kernels(cur_out_kernels); - kernels->erase(find(kernels->begin(), kernels->end(), out_kernel)); } } @@ -191,10 +189,8 @@ int NPUFusionPass::FormatFusion(kernel::LiteKernel *kernel) { post_kernel->set_in_kernels(post_in_kernels); pre_out_kernels.push_back(post_kernel); } - kernels->erase(find(kernels->begin(), kernels->end(), nc2nh)); } pre_kernel->set_out_kernels(pre_out_kernels); - kernels->erase(find(kernels->begin(), kernels->end(), kernel)); return RET_OK; } diff --git a/mindspore/lite/src/runtime/agent/npu/subgraph_npu_kernel.cc b/mindspore/lite/src/runtime/agent/npu/subgraph_npu_kernel.cc index 5fb4f92c2ea..365315e7bfc 100644 --- a/mindspore/lite/src/runtime/agent/npu/subgraph_npu_kernel.cc +++ b/mindspore/lite/src/runtime/agent/npu/subgraph_npu_kernel.cc @@ -33,6 +33,14 @@ namespace mindspore::kernel { using mindspore::lite::RET_ERROR; using mindspore::lite::RET_OK; +SubGraphNpuKernel::~SubGraphNpuKernel() { + subgraph_input_op_.clear(); + subgraph_output_op_.clear(); + if (executor_ != nullptr) { + delete executor_; + } +} + domi::ModelBufferData *SubGraphNpuKernel::BuildIRModel() { ge::Graph graph("NPUGraph"); diff --git a/mindspore/lite/src/runtime/agent/npu/subgraph_npu_kernel.h b/mindspore/lite/src/runtime/agent/npu/subgraph_npu_kernel.h index eed57206918..513a2b41476 100644 --- a/mindspore/lite/src/runtime/agent/npu/subgraph_npu_kernel.h +++ b/mindspore/lite/src/runtime/agent/npu/subgraph_npu_kernel.h @@ -36,7 +36,7 @@ class SubGraphNpuKernel : public SubGraphKernel { subgraph_type_ = kNpuSubGraph; } - ~SubGraphNpuKernel() override = default; + ~SubGraphNpuKernel() override; int Init() override;