From 821d23fc3475a2dcaeb3dbaf9be20c1c7bdcc85c Mon Sep 17 00:00:00 2001 From: "Wang, Yang" Date: Fri, 29 Nov 2024 16:58:01 +0800 Subject: [PATCH] release the cloned model if passthrough mode for AUTO --- src/plugins/auto/src/auto_schedule.cpp | 2 ++ src/plugins/auto/src/plugin.cpp | 9 ++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/plugins/auto/src/auto_schedule.cpp b/src/plugins/auto/src/auto_schedule.cpp index c504e8e4457870..3c32bc506b184b 100644 --- a/src/plugins/auto/src/auto_schedule.cpp +++ b/src/plugins/auto/src/auto_schedule.cpp @@ -101,6 +101,8 @@ void AutoSchedule::init() { auto load_device_task = [&](AutoCompileContext* context_ptr, const std::shared_ptr& model) { try_to_compile_model(*context_ptr, model); if (context_ptr->m_is_load_success) { + // release cloned model here + const_cast&>(model).reset(); if (context_ptr->m_worker_name.empty()) { context_ptr->m_worker_name = context_ptr->m_device_info.device_name; } diff --git a/src/plugins/auto/src/plugin.cpp b/src/plugins/auto/src/plugin.cpp index cac505c668dfaa..b0b2b72cbb0e75 100644 --- a/src/plugins/auto/src/plugin.cpp +++ b/src/plugins/auto/src/plugin.cpp @@ -481,7 +481,14 @@ std::shared_ptr Plugin::compile_model_impl(const std::string if (is_cumulative) { impl = std::make_shared(cloned_model, shared_from_this(), device_context, auto_s_context, scheduler); } else { - impl = std::make_shared(cloned_model, shared_from_this(), device_context, auto_s_context, scheduler); + auto model = auto_s_context->m_model; + if (std::static_pointer_cast(scheduler)->m_compile_context[ACTUALDEVICE].m_is_already) { + // release cloned model here if actual device finish compiling model. + model.reset(); + auto_s_context->m_model.reset(); + } + impl = + std::make_shared(model, shared_from_this(), device_context, auto_s_context, scheduler); } return impl; }