From 10f6c7c4173ea64f10ffc4a4ea8bc2973971e74e Mon Sep 17 00:00:00 2001 From: Vladislav Volkov Date: Tue, 25 May 2021 17:32:35 +0300 Subject: [PATCH] Review comments --- .../src/mkldnn_plugin/mkldnn_graph.cpp | 2 +- .../mkldnn_plugin/mkldnn_graph_optimizer.cpp | 8 +- .../src/mkldnn_plugin/mkldnn_memory.h | 1 + .../src/mkldnn_plugin/mkldnn_node.cpp | 12 +- .../nodes/mkldnn_deconv_node.cpp | 10 +- .../mkldnn_plugin/nodes/mkldnn_input_node.cpp | 225 ++++++------------ .../mkldnn_plugin/nodes/mkldnn_input_node.h | 11 +- .../src/mkldnn_plugin/nodes/mkldnn_rnn.cpp | 22 +- .../nodes/mkldnn_strided_slice_node.cpp | 6 +- 9 files changed, 120 insertions(+), 177 deletions(-) diff --git a/inference-engine/src/mkldnn_plugin/mkldnn_graph.cpp b/inference-engine/src/mkldnn_plugin/mkldnn_graph.cpp index 90ae71de7f9a23..197373005c5055 100644 --- a/inference-engine/src/mkldnn_plugin/mkldnn_graph.cpp +++ b/inference-engine/src/mkldnn_plugin/mkldnn_graph.cpp @@ -574,7 +574,7 @@ void MKLDNNGraph::AllocateWithReuse() { && edge->getParent()->isConstant()) { if (edge->getParent()->getType() == Input) { auto constNode = std::static_pointer_cast(edge->getParent()); - edge->reuse(constNode->getMemoryPtr()); + edge->reuse(std::const_pointer_cast(constNode->getMemoryPtr())); } else { edge->externalAllocate(weightsCache); } diff --git a/inference-engine/src/mkldnn_plugin/mkldnn_graph_optimizer.cpp b/inference-engine/src/mkldnn_plugin/mkldnn_graph_optimizer.cpp index 2189ea529935cf..17c27928112609 100644 --- a/inference-engine/src/mkldnn_plugin/mkldnn_graph_optimizer.cpp +++ b/inference-engine/src/mkldnn_plugin/mkldnn_graph_optimizer.cpp @@ -478,11 +478,11 @@ void MKLDNNGraphOptimizer::FuseConvolutionAndZeroPoints(MKLDNNGraph &graph) { if (zeroPointsConstant == nullptr) IE_THROW() << "Cannot cast to Input node"; - auto zeroPointsBlob = dynamic_cast*>(zeroPointsConstant->getConstBlob().get()); + auto zeroPointsBlob = zeroPointsConstant->getMemoryPtr(); if (zeroPointsBlob == nullptr) IE_THROW() << "Cannot cast to TBlob internal zero points blob"; - auto zeroPointsData = zeroPointsBlob->cbuffer().as(); + auto zeroPointsData = static_cast(zeroPointsBlob->GetPtr()); if (zeroPointsData == nullptr) IE_THROW() << "zeroPointsBlob has not allocated buffer"; @@ -515,11 +515,11 @@ void MKLDNNGraphOptimizer::FuseConvolutionAndZeroPoints(MKLDNNGraph &graph) { if (!weightsConstant || !weightsConstant->isConstant()) return; - auto weightsBlob = dynamic_cast*>(weightsConstant->getConstBlob().get()); + auto weightsBlob = weightsConstant->getMemoryPtr(); if (weightsBlob == nullptr) IE_THROW() << "Cannot cast to TBlob internal weights blob"; - auto weightsPtr = weightsBlob->cbuffer().as(); + auto weightsPtr = static_cast(weightsBlob->GetPtr()); if (weightsPtr == nullptr) IE_THROW() << "weightsBlob has not allocated buffer"; diff --git a/inference-engine/src/mkldnn_plugin/mkldnn_memory.h b/inference-engine/src/mkldnn_plugin/mkldnn_memory.h index 80c92bc74bcc11..5de42240dbadc4 100644 --- a/inference-engine/src/mkldnn_plugin/mkldnn_memory.h +++ b/inference-engine/src/mkldnn_plugin/mkldnn_memory.h @@ -172,5 +172,6 @@ class MKLDNNMemory { }; using MKLDNNMemoryPtr = std::shared_ptr; +using MKLDNNMemoryCPtr = std::shared_ptr; } // namespace MKLDNNPlugin diff --git a/inference-engine/src/mkldnn_plugin/mkldnn_node.cpp b/inference-engine/src/mkldnn_plugin/mkldnn_node.cpp index 16660d8df7ec90..65c662b15c0e49 100644 --- a/inference-engine/src/mkldnn_plugin/mkldnn_node.cpp +++ b/inference-engine/src/mkldnn_plugin/mkldnn_node.cpp @@ -1345,10 +1345,14 @@ void MKLDNNNode::fillScalesAndShifts(const MKLDNNNode *parentNode, std::vector& buffer) { auto *constInputNode = dynamic_cast(constInput.get()); - auto constBlob = constInputNode->getConstBlob(); - auto srtPtr = constBlob->cbuffer().as(); - buffer.resize(constBlob->size()); - cpu_convert(srtPtr, &buffer[0], constBlob->getTensorDesc().getPrecision(), Precision::FP32, constBlob->size()); + auto constBlob = constInputNode->getMemoryPtr(); + auto const elementsCount = constBlob->GetElementsCount(); + buffer.resize(elementsCount); + cpu_convert(constBlob->GetPtr(), + &buffer[0], + MKLDNNExtensionUtils::DataTypeToIEPrecision(constBlob->GetDataType()), + Precision::FP32, + elementsCount); }; const size_t constPort = getParentEdgesAtPort(0)[0]->getParent().get() == parentNode ? 1 : 0; diff --git a/inference-engine/src/mkldnn_plugin/nodes/mkldnn_deconv_node.cpp b/inference-engine/src/mkldnn_plugin/nodes/mkldnn_deconv_node.cpp index fd8a140997d523..169efc18625ddf 100644 --- a/inference-engine/src/mkldnn_plugin/nodes/mkldnn_deconv_node.cpp +++ b/inference-engine/src/mkldnn_plugin/nodes/mkldnn_deconv_node.cpp @@ -97,10 +97,12 @@ InferenceEngine::Blob::Ptr MKLDNNDeconvolutionNode::createWeiBlobAsIO(InferenceE auto constNode = std::dynamic_pointer_cast(getParentEdgeAt(1)->getParent()); if (!constNode) IE_THROW() << "Cannot cast const input node for node " << getName() << "."; - auto blb = constNode->getConstBlob(); + auto blb = constNode->getMemoryPtr(); if (!blb) IE_THROW() << "Cannot get const weights blob for node " << getName() << "."; + auto const blbSize = blb->GetSize(); + // WA: In int8 case, we are processing weights using internal blob. // So we disconnect constant node containing weights from the graph and then don't use it. if (getParentEdges().size() == 3) { @@ -123,7 +125,7 @@ InferenceEngine::Blob::Ptr MKLDNNDeconvolutionNode::createWeiBlobAsIO(InferenceE orderForBlockedDesc.push_back(i); BlockingDesc blkDesc(dimsForBlockedDesc, orderForBlockedDesc); - InferenceEngine::TensorDesc tensorDesc(blb->getTensorDesc().getPrecision(), dims, blkDesc); + InferenceEngine::TensorDesc tensorDesc(MKLDNNExtensionUtils::DataTypeToIEPrecision(blb->GetDataType()), dims, blkDesc); Blob::Ptr internalBlob = InferenceEngine::make_shared_blob(tensorDesc); internalBlob->allocate(); @@ -132,11 +134,11 @@ InferenceEngine::Blob::Ptr MKLDNNDeconvolutionNode::createWeiBlobAsIO(InferenceE IE_THROW(NotAllocated) << "Internal blob was not allocated for node " << getName() << "."; size_t intBuffSize = internalBlob->byteSize(); - size_t offset = blb->byteSize(); + size_t offset = blbSize; if (intBuffSize < offset) { IE_THROW() << "Cannot create internal buffer. Buffer can be overrun."; } - cpu_memcpy_s(data, intBuffSize, blb->cbuffer(), blb->byteSize()); + cpu_memcpy_s(data, intBuffSize, blb->GetPtr(), blbSize); return internalBlob; } diff --git a/inference-engine/src/mkldnn_plugin/nodes/mkldnn_input_node.cpp b/inference-engine/src/mkldnn_plugin/nodes/mkldnn_input_node.cpp index d720df8978e6a9..486724043265f5 100644 --- a/inference-engine/src/mkldnn_plugin/nodes/mkldnn_input_node.cpp +++ b/inference-engine/src/mkldnn_plugin/nodes/mkldnn_input_node.cpp @@ -9,6 +9,7 @@ #include #include #include +#include #include #include #include @@ -30,8 +31,8 @@ using namespace Xbyak; namespace { -struct jit_has_subnormals : public jit_generator { - DECLARE_CPU_JIT_AUX_FUNCTIONS(jit_has_subnormals) +struct jit_has_subnormals_base : public jit_generator { + DECLARE_CPU_JIT_AUX_FUNCTIONS(jit_has_subnormals_base) typedef struct { const float* src; @@ -41,7 +42,7 @@ struct jit_has_subnormals : public jit_generator { typedef void (*fn_t)(const args_t*); - jit_has_subnormals() { + jit_has_subnormals_base() { jit_ker_ = nullptr; } @@ -85,10 +86,6 @@ struct jit_has_subnormals : public jit_generator { pop(r15); pop(rsi); } -}; - -struct jit_has_subnormals_avx2 : public jit_has_subnormals { - static const uint32_t vlen = 8u; // floats vector length for AVX2 instructions void check_subnormals(const Xbyak::Reg64& src, const Xbyak::Ymm &mask, const Xbyak::Ymm &zero) { auto a = ymm1; @@ -102,80 +99,6 @@ struct jit_has_subnormals_avx2 : public jit_has_subnormals { vptest(b, c); // if ((!b & c) == 0) CF = 1 else CF = 0 } - void generate() final { - Label exit, has_subnormals, no_subnormals; - - auto reg_src = rax; - auto reg_dst = rbx; - auto reg_sz = rdx; - auto reg_mask_addr = r15; - auto zero = ymm4; - auto mask = ymm5; - - preamble(); - - // Initialize necessary consts - vpxor(zero, zero, zero); - - static const uint32_t mask_data[8] = { - 0xFF << 23, 0xFF << 23, 0xFF << 23, 0xFF << 23, - 0xFF << 23, 0xFF << 23, 0xFF << 23, 0xFF << 23 - }; - - mov(reg_mask_addr, (size_t)mask_data); - vmovdqu(mask, yword[reg_mask_addr]); - - // Get arguments addresses - mov(reg_src, ptr[param1 + offsetof(args_t, src)]); - lea(reg_dst, ptr[param1 + offsetof(args_t, hasSubnormals)]); - mov(reg_sz, ptr[param1 + offsetof(args_t, count)]); - - // Main loop - xor_(rsi, rsi); - mov(r8, reg_sz); - shr(r8, 3); - - foreach(rsi, 1, r8, [&, this](const Xbyak::Reg64& idx) { - check_subnormals(reg_src, mask, zero); - jnc(has_subnormals); - add(reg_src, sizeof(float) * vlen); - }); - - // Tail - shl(rsi, 3); - sub(reg_sz, rsi); - test(reg_sz, reg_sz); - jz(exit); - - // use space on stack for 8 floats - sub(rsp, vlen * sizeof(float)); - mov(r8, rsp); - - vmovups(yword[r8], zero); - - copy_floats(r8, reg_src, reg_sz); - check_subnormals(r8, mask, zero); - jc(no_subnormals); - add(rsp, vlen * sizeof(float)); - - L(has_subnormals); - - mov(rax, 1); - mov(byte[reg_dst], al); - jmp(exit); - - L(no_subnormals); - add(rsp, vlen * sizeof(float)); - - L(exit); - - postamble(); - } -}; - -struct jit_has_subnormals_sse41 : public jit_has_subnormals { - static const uint32_t vlen = 4u; // floats vector length for SSE41 instructions - void check_subnormals(const Xbyak::Reg64& src, const Xbyak::Xmm &mask, const Xbyak::Xmm &zero) { auto a = xmm1; auto b = xmm2; @@ -190,55 +113,83 @@ struct jit_has_subnormals_sse41 : public jit_has_subnormals { ptest(b, c); // if ((!b & c) == 0) CF = 1 else CF = 0 } - void generate() final { - Label exit, has_subnormals, no_subnormals; + template + struct reg; - auto reg_src = rax; - auto reg_dst = rbx; - auto reg_sz = rdx; - auto reg_mask_addr = r15; - auto zero = xmm4; - auto mask = xmm5; +protected: + Label exit, has_subnormals, no_subnormals; - preamble(); + const Reg64 ®_src = rax; + const Reg64 ®_dst = rbx; + const Reg64 ®_sz = rdx; + const Reg64 ®_idx = rsi; + const Reg64 ®_mask_addr = r15; - // Initialize necessary consts - pxor(zero, zero); + static const uint32_t mask_data[8]; +}; - static const uint32_t mask_data[4] = { - 0xFF << 23, 0xFF << 23, 0xFF << 23, 0xFF << 23 - }; +const uint32_t jit_has_subnormals_base::mask_data[8] = { + 0xFF << 23, 0xFF << 23, 0xFF << 23, 0xFF << 23, + 0xFF << 23, 0xFF << 23, 0xFF << 23, 0xFF << 23 +}; - mov(reg_mask_addr, (size_t)mask_data); - movdqu(mask, xword[reg_mask_addr]); +template<> +struct jit_has_subnormals_base::reg { + constexpr static uint32_t length = 8; + constexpr static const Xbyak::Ymm & rmm4 = Xbyak::util::ymm4; + constexpr static const Xbyak::Ymm & rmm5 = Xbyak::util::ymm5; +}; + +template<> +struct jit_has_subnormals_base::reg { + constexpr static uint32_t length = 4; + constexpr static const Xbyak::Xmm & rmm4 = Xbyak::util::xmm4; + constexpr static const Xbyak::Xmm & rmm5 = Xbyak::util::xmm5; +}; + +template +struct jit_has_subnormals : public jit_has_subnormals_base { + void generate() final { + size_t const vlen = reg::length; + const int sh_bits = std::ilogb(vlen); + + auto zero = reg::rmm4; + auto mask = reg::rmm5; + + preamble(); // Get arguments addresses mov(reg_src, ptr[param1 + offsetof(args_t, src)]); lea(reg_dst, ptr[param1 + offsetof(args_t, hasSubnormals)]); mov(reg_sz, ptr[param1 + offsetof(args_t, count)]); + mov(reg_mask_addr, (size_t)mask_data); + + // Initialize necessary consts + uni_vpxor(zero, zero, zero); + uni_vmovdqu(mask, ptr[reg_mask_addr]); // Main loop - xor_(rsi, rsi); + xor_(reg_idx, reg_idx); mov(r8, reg_sz); - shr(r8, 2); + shr(r8, sh_bits); - foreach(rsi, 1, r8, [&, this](const Xbyak::Reg64& idx) { + foreach(reg_idx, 1, r8, [&, this](const Xbyak::Reg64& idx) { check_subnormals(reg_src, mask, zero); jnc(has_subnormals); add(reg_src, sizeof(float) * vlen); }); // Tail - shl(rsi, 2); - sub(reg_sz, rsi); + shl(reg_idx, sh_bits); + sub(reg_sz, reg_idx); test(reg_sz, reg_sz); jz(exit); - // use space on stack for 4 floats + // use space on stack for 4 or 8 floats sub(rsp, vlen * sizeof(float)); mov(r8, rsp); - movups(xword[r8], zero); + uni_vmovdqu(ptr[r8], zero); copy_floats(r8, reg_src, reg_sz); check_subnormals(r8, mask, zero); @@ -260,13 +211,13 @@ struct jit_has_subnormals_sse41 : public jit_has_subnormals { } }; -jit_has_subnormals::fn_t jit_has_subnormals_function() { +jit_has_subnormals_base::fn_t jit_has_subnormals_function() { if (mayiuse(cpu_isa_t::avx2)) { - static jit_has_subnormals_avx2 generator; + static jit_has_subnormals generator; static auto fn = generator.get(); return fn; } else if (mayiuse(cpu_isa_t::sse41)) { - static jit_has_subnormals_sse41 generator; + static jit_has_subnormals generator; static auto fn = generator.get(); return fn; } @@ -276,7 +227,7 @@ jit_has_subnormals::fn_t jit_has_subnormals_function() { } // namespace MKLDNNInputNode::MKLDNNInputNode(const std::shared_ptr& op, const mkldnn::engine& eng, MKLDNNWeightsSharing::Ptr &cache) - : MKLDNNNode(op, eng, cache), origLayer(op) { + : MKLDNNNode(op, eng, cache) { if (!one_of(op->get_type_info(), v0::Parameter::type_info, v0::Constant::type_info, @@ -287,34 +238,22 @@ MKLDNNInputNode::MKLDNNInputNode(const std::shared_ptr& op, const constant = ConstantType::NoConst; - auto constOp = ngraph::as_type_ptr(op); + constOp = ngraph::as_type_ptr(op); if (constOp) { constant = ConstantType::Const; - - auto dataPrecision = convertPrecision(op->get_element_type()); - - size_t shapeSize = ngraph::shape_size(op->get_shape()); - constexpr size_t byte_size{8}; - if (dataPrecision == Precision::BIN) { - shapeSize = (shapeSize + (byte_size - 1)) / byte_size; - } - - TensorDesc td(dataPrecision, {shapeSize}, Layout::C); - - constBlob = make_blob_with_precision(td, const_cast(constOp->get_data_ptr())); - - MKLDNNDims dims(op->get_shape().empty() ? ngraph::Shape(1, 1) : op->get_shape()); - - cloneBlobIfRequired(dims, dataPrecision); + cloneBlobIfRequired(); } } -void MKLDNNInputNode::cloneBlobIfRequired(const MKLDNNDims& dims, const InferenceEngine::Precision& prec) { +void MKLDNNInputNode::cloneBlobIfRequired() { + MKLDNNDims dims(constOp->get_shape().empty() ? ngraph::Shape(1, 1) : constOp->get_shape()); + const auto prec = convertPrecision(constOp->get_element_type()); + const size_t size = dims.size(); MKLDNNMemoryDesc memDesc(dims, MKLDNNExtensionUtils::IEPrecisionToDataType(prec)); auto cloneBlob = [&, this] () { MKLDNNMemory memory{ getEngine() }; - memory.Create(memDesc, constBlob->buffer()); + memory.Create(memDesc, constOp->get_data_ptr()); MKLDNNMemoryPtr ptr = MKLDNNMemoryPtr(new MKLDNNMemory(getEngine())); ptr->Create(memDesc); @@ -324,15 +263,14 @@ void MKLDNNInputNode::cloneBlobIfRequired(const MKLDNNDims& dims, const Inferenc }; auto isBlobAligned = [&, this] () { - const void *ptr = constBlob->cbuffer().as(); + const void *ptr = constOp->get_data_ptr(); return prec.size() > 1 ? (reinterpret_cast(ptr) % prec.size()) == 0 : true; }; // The presence of subnormals is better to determined at IR read time. auto hasSubnormals = [&, this] () { if (prec == InferenceEngine::Precision::FP32) { - uint32_t const *u32data = constBlob->cbuffer().as(); - const size_t size = constBlob->byteSize() / prec.size(); + uint32_t const *u32data = constOp->get_data_ptr(); if (!size) return false; @@ -345,7 +283,7 @@ void MKLDNNInputNode::cloneBlobIfRequired(const MKLDNNDims& dims, const Inferenc parallel_for(iterations_num, [&](int n) { auto ptr = u32data + n * batch_size; - const jit_has_subnormals::args_t args = { + const jit_has_subnormals_base::args_t args = { reinterpret_cast(ptr), std::min(batch_size, (size_t)(u32data + size - ptr)), false @@ -369,24 +307,23 @@ void MKLDNNInputNode::cloneBlobIfRequired(const MKLDNNDims& dims, const Inferenc return false; }; - auto blobKey = [this] () { + auto blobKey = [&, this] () { char ptr[32]; - snprintf(ptr, sizeof ptr, "%p", constBlob->cbuffer().as()); + snprintf(ptr, sizeof ptr, "%p", constOp->get_data_ptr()); return getName() - + "_" + std::to_string(constBlob->byteSize()) + + "_" + std::to_string(size * prec.size()) + "_" + ptr; }; - const void *data = constBlob->buffer(); - (void)data; - if (weightCache) { - memoryPtr = *weightCache->findOrCreate(blobKey(), cloneBlob); + MKLDNNMemoryPtr ptr = *weightCache->findOrCreate(blobKey(), cloneBlob); + memoryPtr = std::const_pointer_cast(ptr); } else if (isBlobAligned() && !hasSubnormals()) { - memoryPtr = MKLDNNMemoryPtr(new MKLDNNMemory(getEngine())); - memoryPtr->Create(memDesc, constBlob->buffer()); + auto ptr = new MKLDNNMemory(getEngine()); + ptr->Create(memDesc, constOp->get_data_ptr()); + memoryPtr = MKLDNNMemoryCPtr(ptr); } else { - memoryPtr = cloneBlob(); + memoryPtr = std::const_pointer_cast(cloneBlob()); } } @@ -407,11 +344,7 @@ void MKLDNNInputNode::withMeanImage() { isMeanImage = true; } -const InferenceEngine::Blob::CPtr MKLDNNInputNode::getConstBlob() const { - return constBlob; -} - -MKLDNNMemoryPtr MKLDNNInputNode::getMemoryPtr() const { +MKLDNNMemoryCPtr MKLDNNInputNode::getMemoryPtr() const { return memoryPtr; } diff --git a/inference-engine/src/mkldnn_plugin/nodes/mkldnn_input_node.h b/inference-engine/src/mkldnn_plugin/nodes/mkldnn_input_node.h index d5943d60743528..872f8e14f8e295 100644 --- a/inference-engine/src/mkldnn_plugin/nodes/mkldnn_input_node.h +++ b/inference-engine/src/mkldnn_plugin/nodes/mkldnn_input_node.h @@ -6,6 +6,7 @@ #include #include +#include #include namespace MKLDNNPlugin { @@ -22,17 +23,15 @@ class MKLDNNInputNode : public MKLDNNNode { bool created() const override; void withMeanImage(); - const InferenceEngine::Blob::CPtr getConstBlob() const; - MKLDNNMemoryPtr getMemoryPtr() const; + MKLDNNMemoryCPtr getMemoryPtr() const; private: - void cloneBlobIfRequired(const MKLDNNDims& dims, const InferenceEngine::Precision& prec); + void cloneBlobIfRequired(); private: - std::shared_ptr origLayer; + std::shared_ptr constOp; InferenceEngine::Precision precision; - InferenceEngine::Blob::Ptr constBlob = nullptr; - MKLDNNMemoryPtr memoryPtr; + MKLDNNMemoryCPtr memoryPtr; bool isMeanImage = false; }; diff --git a/inference-engine/src/mkldnn_plugin/nodes/mkldnn_rnn.cpp b/inference-engine/src/mkldnn_plugin/nodes/mkldnn_rnn.cpp index 608df078925cea..a85544e9e96aa7 100644 --- a/inference-engine/src/mkldnn_plugin/nodes/mkldnn_rnn.cpp +++ b/inference-engine/src/mkldnn_plugin/nodes/mkldnn_rnn.cpp @@ -457,17 +457,17 @@ void MKLDNNRNN::fillWeights(const int *gate_map, const size_t wIdx, const size_t const size_t ie_r_vec_size = getParentEdgesAtPort(rIdx)[0]->getDims().size(); auto *wInputNode = dynamic_cast(getParentEdgesAtPort(wIdx)[0]->getParent().get()); - auto wConstBlob = wInputNode->getConstBlob(); + auto wConstBlob = wInputNode->getMemoryPtr(); auto *rInputNode = dynamic_cast(getParentEdgesAtPort(rIdx)[0]->getParent().get()); - auto rConstBlob = rInputNode->getConstBlob(); + auto rConstBlob = rInputNode->getMemoryPtr(); std::vector ie_w_vec(ie_w_vec_size), ie_r_vec(ie_r_vec_size); auto ie_w_ptr = ie_w_vec.data(); auto ie_r_ptr = ie_r_vec.data(); - cpu_convert(wConstBlob->cbuffer().as(), ie_w_ptr, weightPrec, runtimePrecision, ie_w_vec_size); - cpu_convert(rConstBlob->cbuffer().as(), ie_r_ptr, weightPrec, runtimePrecision, ie_r_vec_size); + cpu_convert(wConstBlob->GetPtr(), ie_w_ptr, weightPrec, runtimePrecision, ie_w_vec_size); + cpu_convert(rConstBlob->GetPtr(), ie_r_ptr, weightPrec, runtimePrecision, ie_r_vec_size); auto w_ptr = static_cast(w_data_mem->GetData()); auto r_ptr = static_cast(w_state_mem->GetData()); @@ -508,11 +508,15 @@ void MKLDNNRNN::fillBiases(const int *gate_map) { internalBlobMemory.push_back(w_bias_mem); auto *constInputNode = dynamic_cast(getParentEdgesAtPort(bIdx)[0]->getParent().get()); - auto constBlob = constInputNode->getConstBlob(); - auto srtPtr = constBlob->cbuffer().as(); - - std::vector ie_b_vec(constBlob->size()); - cpu_convert(srtPtr, &ie_b_vec[0], constBlob->getTensorDesc().getPrecision(), Prec, constBlob->size()); + auto constBlob = constInputNode->getMemoryPtr(); + auto const elementsCount = constBlob->GetElementsCount(); + + std::vector ie_b_vec(elementsCount); + cpu_convert(constBlob->GetPtr(), + &ie_b_vec[0], + MKLDNNExtensionUtils::DataTypeToIEPrecision(constBlob->GetDataType()), + Prec, + elementsCount); auto b_ptr = static_cast(w_bias_mem->GetData()); for (int g = 0; g < Gb; g++) { diff --git a/inference-engine/src/mkldnn_plugin/nodes/mkldnn_strided_slice_node.cpp b/inference-engine/src/mkldnn_plugin/nodes/mkldnn_strided_slice_node.cpp index e50296f6c230bd..07cc72247a5eff 100644 --- a/inference-engine/src/mkldnn_plugin/nodes/mkldnn_strided_slice_node.cpp +++ b/inference-engine/src/mkldnn_plugin/nodes/mkldnn_strided_slice_node.cpp @@ -138,10 +138,10 @@ void MKLDNNStridedSliceNode::getSupportedDescriptors() { if (params.parametersAreConstant) { auto fillingInParameters = [&](std::vector ¶meter, const size_t type, const size_t size, const int value) { - auto blob = std::dynamic_pointer_cast(getParentEdgesAtPort(type)[0]->getParent())->getConstBlob(); - if (blob->getTensorDesc().getPrecision() != Precision::I32) + auto blob = std::dynamic_pointer_cast(getParentEdgesAtPort(type)[0]->getParent())->getMemoryPtr(); + if (blob->GetDataType() != mkldnn::memory::data_type::s32) THROW_ERROR << "supports only parameters input with precision I32"; - const int *ptr = blob->cbuffer().as() + blob->getTensorDesc().getBlockingDesc().getOffsetPadding(); + const int *ptr = static_cast(blob->GetPtr()); parameter.assign(ptr, ptr + size); if (ellipsisMaskCounter == 0 && size < nDims) {