From d167f4c7339d8a3e5c846dc08c7056c71be287dc Mon Sep 17 00:00:00 2001 From: Nikolay Shchegolev Date: Thu, 2 Feb 2023 16:10:21 +0400 Subject: [PATCH] =?UTF-8?q?[CPU]=20MEMC=20loading=20failed=20RuntimeError:?= =?UTF-8?q?=20There=20should=20be=20only=20one=20inst=E2=80=A6=20(#15380)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * [CPU] MEMC loading failed RuntimeError: There should be only one instance of RegistersPool per thread. * Fixes as per comments. --- .../intel_cpu/src/nodes/kernels/registers_pool.hpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/plugins/intel_cpu/src/nodes/kernels/registers_pool.hpp b/src/plugins/intel_cpu/src/nodes/kernels/registers_pool.hpp index ed12fa71182..a052d2be3d5 100644 --- a/src/plugins/intel_cpu/src/nodes/kernels/registers_pool.hpp +++ b/src/plugins/intel_cpu/src/nodes/kernels/registers_pool.hpp @@ -30,6 +30,7 @@ using namespace dnnl::impl::cpu; class RegistersPool { public: using Ptr = std::shared_ptr; + using WeakPtr = std::weak_ptr; static constexpr int anyIdx = -1; /** @@ -65,12 +66,12 @@ public: return lhs.operator Xbyak::RegExp() + rhs; } void release() { - if (regPool) { - regPool->returnToPool(reg); + if (auto pool = regPool.lock()) { + pool->returnToPool(reg); regPool.reset(); } } - bool isInitialized() const { return static_cast(regPool); } + bool isInitialized() const { return !regPool.expired(); } private: void ensureValid() const { @@ -91,7 +92,7 @@ public: private: TReg reg; - RegistersPool::Ptr regPool; + RegistersPool::WeakPtr regPool; }; virtual ~RegistersPool() {