Skip to content

OpenVINO™ is an open source toolkit for optimizing and deploying AI inference

[CPU] Weights hash mismatch (#26023)

Nikolay Shchegolevfa2d87aab6a3
diff --git a/src/plugins/intel_cpu/src/dnnl_extension_utils.cpp b/src/plugins/intel_cpu/src/dnnl_extension_utils.cpp
index 6b2c83ecc5d..ca5e6ab6c14 100644
--- a/src/plugins/intel_cpu/src/dnnl_extension_utils.cpp
+++ b/src/plugins/intel_cpu/src/dnnl_extension_utils.cpp
@@ -266,8 +266,8 @@ bool DnnlExtensionUtils::isUnarySupportedAsPostOp(Algorithm alg) {
#endif
}
-std::string DnnlExtensionUtils::computeWeightsStringHash(const std::shared_ptr<const IMemory> memory,
- const std::shared_ptr<DnnlMemoryDesc> dstDesc) {
+std::string DnnlExtensionUtils::computeWeightsStringHash(const std::shared_ptr<const IMemory>& memory,
+ const std::shared_ptr<DnnlMemoryDesc>& dstDesc) {
const auto desc_hash = dnnl::impl::primitive_hashing::get_md_hash(*dstDesc->getDnnlDesc().get());
return std::to_string(desc_hash) + "_" + std::to_string(reinterpret_cast<uint64_t>(memory->getData()));
}
diff --git a/src/plugins/intel_cpu/src/dnnl_extension_utils.h b/src/plugins/intel_cpu/src/dnnl_extension_utils.h
index cdc6342e896..7a968ea3c71 100644
--- a/src/plugins/intel_cpu/src/dnnl_extension_utils.h
+++ b/src/plugins/intel_cpu/src/dnnl_extension_utils.h
@@ -102,13 +102,15 @@ public:
static dnnl_memory_desc_t clone_desc(const_dnnl_memory_desc_t cdesc);
static const char* query_pd_info(const_dnnl_primitive_desc_t pd);
static bool isUnarySupportedAsPostOp(Algorithm alg);
+
/**
* @brief Computes weights string hash based on weights memory and requested descriptor
* @param memory Weights memory pointer
* @param dstDesc descriptor defining weights representation after repacking
* @return string hash
*/
- static std::string computeWeightsStringHash(const std::shared_ptr<const IMemory> memory, const std::shared_ptr<DnnlMemoryDesc> dstDesc);
+ static std::string computeWeightsStringHash(const std::shared_ptr<const IMemory>& memory,
+ const std::shared_ptr<DnnlMemoryDesc>& dstDesc);
};
} // namespace intel_cpu
diff --git a/src/plugins/intel_cpu/src/node.h b/src/plugins/intel_cpu/src/node.h
index f3eb606bf3e..a336e45c020 100644
--- a/src/plugins/intel_cpu/src/node.h
+++ b/src/plugins/intel_cpu/src/node.h
@@ -737,7 +737,7 @@ protected:
impl_desc_type implType);
void prepareMemory(const std::vector<DnnlMemoryDescPtr>& intDescs);
- void prepareMemory(const DnnlMemoryDescPtr& intDesc, size_t indx);
+ virtual void prepareMemory(const DnnlMemoryDescPtr& intDesc, size_t indx);
void prepareMemory(dnnl::primitive_desc_iterator& itpd);
MemoryPtr prepareWeightMemory(DnnlMemoryDescPtr dstWeightDesc, DnnlMemoryDescPtr srcWeightDesc = nullptr);
diff --git a/src/plugins/intel_cpu/src/nodes/executors/dnnl/dnnl_utils.cpp b/src/plugins/intel_cpu/src/nodes/executors/dnnl/dnnl_utils.cpp
index bdcece78b28..fa273ac3d6c 100644
--- a/src/plugins/intel_cpu/src/nodes/executors/dnnl/dnnl_utils.cpp
+++ b/src/plugins/intel_cpu/src/nodes/executors/dnnl/dnnl_utils.cpp
@@ -81,8 +81,7 @@ MemoryPtr prepareWeightsMemory(const DnnlMemoryDescPtr srcWeightDesc,
MemoryPtr ptr;
if (globalWeightCache &&
dnnl::memory::format_kind::blocked == dstWeightDesc->getDnnlDesc().get_format_kind()) {
- const auto string_hash = DnnlExtensionUtils::computeWeightsStringHash(weightsMem, dstWeightDesc);
- ptr = *globalWeightCache->findOrCreate(string_hash, create);
+ ptr = *globalWeightCache->findOrCreate(DnnlExtensionUtils::computeWeightsStringHash(weightsMem, dstWeightDesc), create);
} else {
ptr = create();
}
diff --git a/src/plugins/intel_cpu/src/nodes/rnn.cpp b/src/plugins/intel_cpu/src/nodes/rnn.cpp
index 40c61e2a2b0..22154923407 100644
--- a/src/plugins/intel_cpu/src/nodes/rnn.cpp
+++ b/src/plugins/intel_cpu/src/nodes/rnn.cpp
@@ -3,31 +3,24 @@
//
#include "rnn.h"
-#include "utils/general_utils.h"
-#include "nodes/common/cpu_memcpy.h"
-#include "nodes/common/cpu_convert.h"
-#include "input.h"
-#include "dnnl_extension_utils.h"
-#include "memory_desc/dnnl_blocked_memory_desc.h"
-#include "memory_desc/cpu_memory_desc_utils.h"
+
#include "common/primitive_hashing_utils.hpp"
-#include <memory>
+#include "memory_desc/cpu_memory_desc_utils.h"
+#include "nodes/common/cpu_convert.h"
+#include "nodes/common/cpu_memcpy.h"
+#include "nodes/input.h"
+#include "nodes/reorder.h"
+#include "openvino/core/parallel.hpp"
#include "shape_inference/shape_inference_ngraph.hpp"
#include "transformations/utils/utils.hpp"
#include "ov_ops/augru_cell.hpp"
#include "ov_ops/augru_sequence.hpp"
-
#include "openvino/op/gru_cell.hpp"
#include "openvino/op/gru_sequence.hpp"
#include "openvino/op/lstm_sequence.hpp"
#include "openvino/op/rnn_cell.hpp"
#include "openvino/op/rnn_sequence.hpp"
-#include "openvino/core/node.hpp"
-
-#include <oneapi/dnnl/dnnl.hpp>
-#include <string>
-#include <utility>
using namespace dnnl;
@@ -768,75 +761,116 @@ void RNN::fillSequenceDesc() {
createDescriptor(inCandidate, outCandidate);
}
-template <typename Prec>
-void RNN::fillWeights(const int *gate_map, const size_t wIdx, const size_t rIdx) {
- const auto& weightPrec = DnnlExtensionUtils::DataTypeToElementType(inDataTypes[wIdx]);
- const auto& targetWeightDataType = weightsByinputDataType.at(inDataTypes[xIdx]);
- const auto& targetWeightPrec = DnnlExtensionUtils::DataTypeToElementType(targetWeightDataType);
-
- // create weight blobs (data and state part)
- const VectorDims dims_w = {L, D, DC, G, SC};
- auto w_data_desc = DnnlBlockedMemoryDesc(Shape(dims_w), targetWeightDataType, getWeightsFormatTagByDims(dims_w));
- MemoryPtr w_data_mem = std::make_shared<Memory>(getEngine(), w_data_desc);
- auto w_ptr = static_cast<Prec*>(w_data_mem->getData());
-
- if (w_ptr == nullptr)
- THROW_CPU_NODE_ERR("has unallocated internal blob.");
-
- const VectorDims dims_s = {L, D, SC, G, SC};
- auto w_state_desc = DnnlBlockedMemoryDesc(Shape(dims_s), targetWeightDataType, getWeightsFormatTagByDims(dims_s));
- MemoryPtr w_state_mem = std::make_shared<Memory>(getEngine(), w_state_desc);
- auto r_ptr = static_cast<Prec*>(w_state_mem->getData());
- if (r_ptr == nullptr)
- THROW_CPU_NODE_ERR("has unallocated internal blob.");
-
- const size_t ie_w_vec_size = getInputShapeAtPort(wIdx).getElementsCount();
- const size_t ie_r_vec_size = getInputShapeAtPort(rIdx).getElementsCount();
-
+template <element::Type_t ET>
+void RNN::fillWeights() {
+ using DataType = typename element_type_traits<ET>::value_type;
if (getParentEdgeAt(wIdx)->getParent()->getType() != Type::Input) {
THROW_CPU_NODE_ERR("expects Constant for port ", wIdx);
}
- auto wConstBlob = static_cast<Input *>(getParentEdgeAt(wIdx)->getParent().get())->getMemoryPtr();
-
+ auto w_const_blob = static_cast<Input *>(getParentEdgeAt(wIdx)->getParent().get())->getMemoryPtr();
if (getParentEdgeAt(rIdx)->getParent()->getType() != Type::Input) {
THROW_CPU_NODE_ERR("expects Constant for port ", rIdx);
}
- auto rConstBlob = static_cast<Input *>(getParentEdgeAt(rIdx)->getParent().get())->getMemoryPtr();
+ auto r_const_blob = static_cast<Input *>(getParentEdgeAt(rIdx)->getParent().get())->getMemoryPtr();
- std::vector<Prec> ie_w_vec(ie_w_vec_size), ie_r_vec(ie_r_vec_size);
+ const auto& weightPrec = DnnlExtensionUtils::DataTypeToElementType(inDataTypes[wIdx]);
+ const auto& targetWeightDataType = weightsByinputDataType.at(inDataTypes[xIdx]);
+ const auto& targetWeightPrec = DnnlExtensionUtils::DataTypeToElementType(targetWeightDataType);
- auto ie_w_ptr = ie_w_vec.data();
- auto ie_r_ptr = ie_r_vec.data();
+ const VectorDims dims_w = {L, D, DC, G, SC};
+ auto w_data_desc = std::make_shared<DnnlBlockedMemoryDesc>(Shape(dims_w), targetWeightDataType, getWeightsFormatTagByDims(dims_w));
- cpu_convert(wConstBlob->getData(), ie_w_ptr, weightPrec, targetWeightPrec, ie_w_vec_size);
- cpu_convert(rConstBlob->getData(), ie_r_ptr, weightPrec, targetWeightPrec, ie_r_vec_size);
+ auto create_w = [&]() {
+ MemoryPtr w_data_mem = std::make_shared<Memory>(getEngine(), w_data_desc);
+ auto w_ptr = reinterpret_cast<DataType*>(w_data_mem->getData());
+ if (w_ptr == nullptr) {
+ THROW_CPU_NODE_ERR("has unallocated internal blob.");
+ }
+ std::vector<DataType> ie_w_vec;
+ DataType* ie_w_ptr = nullptr;
- const int step = SC * G;
+ if (weightPrec != targetWeightPrec) {
+ const size_t ie_w_vec_size = getInputShapeAtPort(wIdx).getElementsCount();
+ ie_w_vec.resize(ie_w_vec_size);
+ ie_w_ptr = ie_w_vec.data();
- for (size_t g = 0; g < G; g++) {
- for (size_t out_i = 0; out_i < SC; out_i++) {
- Prec *l_w_ptr = w_ptr + gate_map[g] * SC + out_i;
+ cpu_convert(w_const_blob->getData(), ie_w_ptr, weightPrec, targetWeightPrec, ie_w_vec_size);
+ } else {
+ ie_w_ptr = reinterpret_cast<DataType*>(w_const_blob->getData());
+ }
+
+ const uint64_t step = SC * G;
+ const uint64_t SC_DC = SC * DC;
+ parallel_for2d(G, SC, [&](size_t g, size_t out_i) {
+ DataType* l_w_ptr = w_ptr + m_gate_map[g] * SC + out_i;
+ DataType* s_w_ptr = ie_w_ptr + out_i * DC + g * SC_DC;
for (size_t in_i = 0; in_i < DC; in_i++) {
- *l_w_ptr = *ie_w_ptr;
- ie_w_ptr++;
+ *l_w_ptr = *s_w_ptr;
+ s_w_ptr++;
l_w_ptr += step;
}
+ });
+
+ return w_data_mem;
+ };
+
+ const VectorDims dims_s = {L, D, SC, G, SC};
+ auto w_state_desc = std::make_shared<DnnlBlockedMemoryDesc>(Shape(dims_s), targetWeightDataType, getWeightsFormatTagByDims(dims_s));
+
+ auto create_r = [&]() {
+ MemoryPtr w_state_mem = std::make_shared<Memory>(getEngine(), w_state_desc);
+ auto r_ptr = reinterpret_cast<DataType*>(w_state_mem->getData());
+ if (r_ptr == nullptr) {
+ THROW_CPU_NODE_ERR("has unallocated internal blob.");
+ }
+ std::vector<DataType> ie_r_vec;
+ DataType* ie_r_ptr = nullptr;
+
+ if (weightPrec != targetWeightPrec) {
+ const size_t ie_r_vec_size = getInputShapeAtPort(rIdx).getElementsCount();
+ ie_r_vec.resize(ie_r_vec_size);
+ ie_r_ptr = ie_r_vec.data();
- Prec *l_r_ptr = r_ptr + gate_map[g] * SC + out_i;
+ cpu_convert(r_const_blob->getData(), ie_r_ptr, weightPrec, targetWeightPrec, ie_r_vec_size);
+ } else {
+ ie_r_ptr = reinterpret_cast<DataType*>(r_const_blob->getData());
+ }
+
+ const uint64_t step = SC * G;
+ const uint64_t SC_2 = SC * SC;
+ parallel_for2d(G, SC, [&](size_t g, size_t out_i) {
+ DataType* l_r_ptr = r_ptr + m_gate_map[g] * SC + out_i;
+ DataType* s_r_ptr = ie_r_ptr + out_i * SC + g * SC_2;
for (size_t in_i = 0; in_i < SC; in_i++) {
- *l_r_ptr = *ie_r_ptr;
- ie_r_ptr++;
+ *l_r_ptr = *s_r_ptr;
+ s_r_ptr++;
l_r_ptr += step;
}
- }
+ });
+
+ return w_state_mem;
+ };
+
+ if (auto weight_cache = context->getWeightsCache()) {
+ const std::string hash_w = getName() + "_0_" + std::to_string(dnnl::impl::primitive_hashing::get_md_hash(*w_data_desc->getDnnlDesc().get()));
+ m_initial_weights[0] = *weight_cache->findOrCreate(hash_w, create_w);
+
+ const std::string hash_r = getName() + "_1_" + std::to_string(dnnl::impl::primitive_hashing::get_md_hash(*w_state_desc->getDnnlDesc().get()));
+ m_initial_weights[1] = *weight_cache->findOrCreate(hash_r, create_r);
+ } else {
+ m_initial_weights[0] = create_w();
+ m_initial_weights[1] = create_r();
}
- internalBlobs.push_back(w_data_mem);
- internalBlobs.push_back(w_state_mem);
}
-template <ov::element::Type_t Prec>
-void RNN::fillBiases(const int *gate_map) {
- using dataType = typename element_type_traits<Prec>::value_type;
+template <element::Type_t ET>
+void RNN::fillBiases() {
+ using DataType = typename element_type_traits<ET>::value_type;
+
+ if (getParentEdgeAt(bIdx)->getParent()->getType() != Type::Input) {
+ THROW_CPU_NODE_ERR("expects Constant for port ", bIdx);
+ }
+ auto b_const_blob = static_cast<Input *>(getParentEdgeAt(bIdx)->getParent().get())->getMemoryPtr();
if (inDataTypes[bIdx] != memory::data_type::f32) {
THROW_CPU_NODE_ERR("doesn't support bias data type: ", DnnlExtensionUtils::DataTypeToElementType(inDataTypes[bIdx]));
@@ -844,31 +878,70 @@ void RNN::fillBiases(const int *gate_map) {
VectorDims dims_b = { L, D, Gb, SC };
- auto _data_type = DnnlExtensionUtils::ElementTypeToDataType(Prec);
- auto w_bias_data_desc = DnnlBlockedMemoryDesc(Shape(dims_b), _data_type, getWeightsFormatTagByDims(dims_b));
- MemoryPtr w_bias_data_mem = std::make_shared<Memory>(getEngine(), w_bias_data_desc);
- auto b_ptr = static_cast<dataType*>(w_bias_data_mem->getData());
- if (b_ptr == nullptr)
- THROW_CPU_NODE_ERR("has unallocated internal blob.");
-
- auto *constInputNode = dynamic_cast<Input *>(getParentEdgeAt(bIdx)->getParent().get());
- auto constBlob = constInputNode->getMemoryPtr();
- auto const elementsCount = constBlob->getSize() / constBlob->getDesc().getPrecision().size();
-
- std::vector<dataType> ie_b_vec(elementsCount);
- cpu_convert(constBlob->getData(),
- &ie_b_vec[0],
- DnnlExtensionUtils::DataTypeToElementType(constBlob->getDataType()),
- Prec,
- elementsCount);
-
- for (size_t g = 0; g < Gb; g++) {
- dataType *l_b_ptr = b_ptr + gate_map[g] * SC;
- const dataType *l_ie_b_ptr = &ie_b_vec[g * SC];
- cpu_memcpy(l_b_ptr, l_ie_b_ptr, SC * sizeof(typename element_type_traits<Prec>::value_type));
+ auto dnnl_type = DnnlExtensionUtils::ElementTypeToDataType(ET);
+ auto w_bias_data_desc = std::make_shared<DnnlBlockedMemoryDesc>(Shape(dims_b), dnnl_type, getWeightsFormatTagByDims(dims_b));
+
+ auto create = [&]() {
+ MemoryPtr w_bias_data_mem = std::make_shared<Memory>(getEngine(), w_bias_data_desc);
+ auto b_ptr = reinterpret_cast<DataType*>(w_bias_data_mem->getData());
+ if (b_ptr == nullptr) {
+ THROW_CPU_NODE_ERR("has unallocated internal blob.");
+ }
+
+ std::vector<DataType> ie_b_vec;
+ DataType* ie_b_ptr = nullptr;
+
+ if (dnnl_type != b_const_blob->getDataType()) {
+ const size_t ie_b_vec_size = getInputShapeAtPort(bIdx).getElementsCount();
+ ie_b_vec.resize(ie_b_vec_size);
+ ie_b_ptr = ie_b_vec.data();
+
+ cpu_convert(b_const_blob->getData(), ie_b_ptr, DnnlExtensionUtils::DataTypeToElementType(b_const_blob->getDataType()), ET, ie_b_vec_size);
+ } else {
+ ie_b_ptr = reinterpret_cast<DataType*>(b_const_blob->getData());
+ }
+
+ const uint64_t step = SC * sizeof(DataType);
+ parallel_for(Gb, [&](size_t g) {
+ DataType* l_b_ptr = b_ptr + m_gate_map[g] * SC;
+ const DataType* l_ie_b_ptr = ie_b_ptr + g * SC;
+ cpu_memcpy(l_b_ptr, l_ie_b_ptr, step);
+ });
+
+ return w_bias_data_mem;
+ };
+
+ if (auto weight_cache = context->getWeightsCache()) {
+ const std::string hash_str = getName() + "_2_" + std::to_string(dnnl::impl::primitive_hashing::get_md_hash(*w_bias_data_desc->getDnnlDesc().get()));
+ m_initial_weights[2] = *weight_cache->findOrCreate(hash_str, create);
+ } else {
+ m_initial_weights[2] = create();
+ }
+}
+
+void RNN::prepareMemory(const DnnlMemoryDescPtr& new_desc, size_t idx) {
+ if (idx >= 3lu) {
+ THROW_CPU_NODE_ERR("got invalid weights index: ", idx);
+ }
+
+ auto create = [&]() {
+ Memory memory{getEngine(), m_initial_weights[idx]->getDescPtr(), m_initial_weights[idx]->getData()};
+ MemoryPtr res_ptr = std::make_shared<Memory>(getEngine(), new_desc);
+ node::Reorder::reorderData(memory, *res_ptr, context->getParamsCache());
+ return res_ptr;
+ };
+
+ MemoryPtr res_ptr;
+ if (auto weight_cache = context->getWeightsCache()) {
+ const std::string hash_str = getName() + "_" + std::to_string(idx) + "_"
+ + std::to_string(dnnl::impl::primitive_hashing::get_md_hash(*new_desc->getDnnlDesc().get()));
+ res_ptr = *weight_cache->findOrCreate(hash_str, create);
+ m_weights_pull.insert(res_ptr);
+ } else {
+ res_ptr = create();
}
- // @todo replace push_back with copy assignment by index, since order matters
- internalBlobs.push_back(w_bias_data_mem);
+
+ internalBlobMemory[idx] = res_ptr;
}
void RNN::copyWeightsData() {
@@ -891,52 +964,58 @@ void RNN::copyWeightsData() {
* ====== GRU ======
* OV - URO, onednn - URO
*/
- const int gate_map_lstm[] = {1, 0, 2, 3}; // FICO -> IFCO
- const int gate_map_gru[] = {0, 1, 2, 3};
- const int gate_map_rnn[] = {0};
- const int *gate_map;
- const int gate_map_lstm_size = sizeof(gate_map_lstm) / sizeof(int);
- const int gate_map_gru_size = sizeof(gate_map_gru) / sizeof(int);
- const int gate_map_rnn_size = sizeof(gate_map_rnn) / sizeof(int);
+ static const uint64_t gate_map_lstm[] = {1, 0, 2, 3}; // FICO -> IFCO
+ static const uint64_t gate_map_gru[] = {0, 1, 2, 3};
+ static const uint64_t gate_map_rnn[] = {0};
+ const uint64_t gate_map_lstm_size = sizeof(gate_map_lstm) / sizeof(uint64_t);
+ const uint64_t gate_map_gru_size = sizeof(gate_map_gru) / sizeof(uint64_t);
+ const uint64_t gate_map_rnn_size = sizeof(gate_map_rnn) / sizeof(uint64_t);
if (cell_type == dnnl::algorithm::vanilla_lstm) {
- gate_map = gate_map_lstm;
+ m_gate_map = gate_map_lstm;
if (G > gate_map_lstm_size) {
THROW_CPU_NODE_ERR(". G isn't equal to the size of gate_map.");
}
} else if (cell_type == dnnl::algorithm::vanilla_gru || cell_type == dnnl::algorithm::vanilla_augru) {
- gate_map = gate_map_gru;
+ m_gate_map = gate_map_gru;
if (G > gate_map_gru_size) {
THROW_CPU_NODE_ERR(". G isn't equal to the size of gate_map");
}
} else if (cell_type == dnnl::algorithm::lbr_gru || cell_type == dnnl::algorithm::lbr_augru) {
- gate_map = gate_map_gru;
+ m_gate_map = gate_map_gru;
if (G > gate_map_gru_size) {
THROW_CPU_NODE_ERR(". G isn't equal to the size of gate_map.");
}
} else if (cell_type == dnnl::algorithm::vanilla_rnn) {
- gate_map = gate_map_rnn;
+ m_gate_map = gate_map_rnn;
if (G > gate_map_rnn_size) {
THROW_CPU_NODE_ERR(". G isn't equal to the size of gate_map.");
}
} else {
- gate_map = gate_map_gru;
+ m_gate_map = gate_map_gru;
if (G > gate_map_gru_size) {
THROW_CPU_NODE_ERR(". G isn't equal to the size of gate_map.");
}
}
- const auto& dataType = inDataTypes[xIdx];
- if (one_of(dataType, memory::data_type::bf16, memory::data_type::f16)) {
- fillWeights<uint16_t>(gate_map, wIdx, rIdx);
- } else if (dataType == memory::data_type::f32) {
- fillWeights<float>(gate_map, wIdx, rIdx);
- } else if (dataType == memory::data_type::u8 || dataType == memory::data_type::s8) {
- fillWeights<int8_t>(gate_map, wIdx, rIdx);
- } else {
- THROW_CPU_NODE_ERR("has unsupported data type: ", DnnlExtensionUtils::DataTypeToElementType(dataType));
+ switch (inDataTypes[xIdx]) {
+ case memory::data_type::bf16:
+ case memory::data_type::f16:
+ fillWeights<element::u16>();
+ break;
+ case memory::data_type::f32:
+ fillWeights<element::f32>();
+ break;
+ case memory::data_type::u8:
+ case memory::data_type::s8:
+ fillWeights<element::i8>();
+ break;
+ default:
+ THROW_CPU_NODE_ERR("has unsupported data type: ", DnnlExtensionUtils::DataTypeToElementType(inDataTypes[xIdx]));
}
- fillBiases<ov::element::f32>(gate_map);
+ fillBiases<element::f32>();
+
+ internalBlobMemory.resize(3);
}
namespace {
@@ -1253,7 +1332,9 @@ void RNN::executeDynamicImpl(dnnl::stream strm) {
void RNN::cleanup() {
if (!isDynamicNode()) {
- internalBlobs.clear();
+ m_initial_weights[0].reset();
+ m_initial_weights[1].reset();
+ m_initial_weights[2].reset();
}
for (auto it : fusedWith) {
diff --git a/src/plugins/intel_cpu/src/nodes/rnn.h b/src/plugins/intel_cpu/src/nodes/rnn.h
index 2ee4c6c9341..937a67f5f1f 100644
--- a/src/plugins/intel_cpu/src/nodes/rnn.h
+++ b/src/plugins/intel_cpu/src/nodes/rnn.h
@@ -4,14 +4,10 @@
#pragma once
-#include <node.h>
+#include "node.h"
+#include "common/dnnl_executor.h"
#include "memory_desc/dnnl_blocked_memory_desc.h"
-#include <string>
-#include <memory>
-#include <vector>
-
-#include "common/dnnl_executor.h"
namespace ov {
namespace intel_cpu {
@@ -61,13 +57,14 @@ private:
bool verifyWeightsPrecision(const ov::element::Type& layerPrec,
const ov::element::Type& weightsPrec);
- template <typename Prec>
- void fillWeights(const int* gate_map, const size_t wIdx, const size_t rIdx);
- template <ov::element::Type_t Prec>
- void fillBiases(const int* gate_map);
+ template <ov::element::Type_t ET>
+ void fillWeights();
+ template <ov::element::Type_t ET>
+ void fillBiases();
void copyWeightsData();
+ void prepareMemory(const DnnlMemoryDescPtr& intDesc, size_t indx) override;
class RnnDnnlExecutor : public DnnlExecutor {
public:
RnnDnnlExecutor(const dnnl::primitive_desc& pd);
@@ -161,6 +158,12 @@ private:
float inputScale = 0.f;
float inputShift = 0.f;
std::vector<float> weightsScales;
+
+ const uint64_t* m_gate_map;
+ // Need to reorder from the initial memory descs due to limited Reorders set.
+ MemoryPtr m_initial_weights[3] = { nullptr, nullptr, nullptr };
+ // Need to keep cache objects. Otherwise, they will be erased from the global cache.
+ std::unordered_set<MemoryPtr> m_weights_pull;
};
} // namespace node