[CPU] MEMC loading failed RuntimeError: There should be only one inst… (#15380)

* [CPU] MEMC loading failed RuntimeError: There should be only one instance of RegistersPool per thread.

* Fixes as per comments.
This commit is contained in:
Nikolay Shchegolev 2023-02-02 16:10:21 +04:00 committed by GitHub
parent 5388a6f2af
commit d167f4c733
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -30,6 +30,7 @@ using namespace dnnl::impl::cpu;
class RegistersPool {
public:
using Ptr = std::shared_ptr<RegistersPool>;
using WeakPtr = std::weak_ptr<RegistersPool>;
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<bool>(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() {