diff --git a/src/plugins/intel_cpu/src/nodes/mkldnn_matrix_nms_node.cpp b/src/plugins/intel_cpu/src/nodes/mkldnn_matrix_nms_node.cpp index c9668785548..120f4544ad6 100644 --- a/src/plugins/intel_cpu/src/nodes/mkldnn_matrix_nms_node.cpp +++ b/src/plugins/intel_cpu/src/nodes/mkldnn_matrix_nms_node.cpp @@ -287,12 +287,7 @@ bool MKLDNNMatrixNmsNode::isExecutable() const { void MKLDNNMatrixNmsNode::executeDynamicImpl(mkldnn::stream strm) { if (hasEmptyInputTensors()) { - getChildEdgesAtPort(NMS_SELECTED_OUTPUTS)[0]->getMemoryPtr()->redefineDesc( - getBaseMemDescAtOutputPort(NMS_SELECTED_OUTPUTS)->cloneWithNewDims({0, 6})); - getChildEdgesAtPort(NMS_SELECTED_INDICES)[0]->getMemoryPtr()->redefineDesc( - getBaseMemDescAtOutputPort(NMS_SELECTED_INDICES)->cloneWithNewDims({0, 1})); - getChildEdgesAtPort(NMS_VALID_OUTPUTS)[0]->getMemoryPtr()->redefineDesc( - getBaseMemDescAtOutputPort(NMS_VALID_OUTPUTS)->cloneWithNewDims({0})); + redefineOutputMemory({{0, 6}, {0, 1}, {0}}); return; } execute(strm); @@ -375,9 +370,7 @@ void MKLDNNMatrixNmsNode::execute(mkldnn::stream strm) { // TODO [DS NMS]: remove when nodes from models where nms is not last node in model supports DS if (isDynamicNode()) { size_t totalBox = std::accumulate(m_numPerBatch.begin(), m_numPerBatch.end(), 0); - selectedOutputsMemPtr->redefineDesc(getBaseMemDescAtOutputPort(NMS_SELECTED_OUTPUTS)->cloneWithNewDims({totalBox, 6})); - selectedIndicesMemPtr->redefineDesc(getBaseMemDescAtOutputPort(NMS_SELECTED_INDICES)->cloneWithNewDims({totalBox, 1})); - validOutputsMemPtr->redefineDesc(getBaseMemDescAtOutputPort(NMS_VALID_OUTPUTS)->cloneWithNewDims({m_numBatches})); + redefineOutputMemory({{totalBox, 6}, {totalBox, 1}, {m_numBatches}}); } float* selectedOutputs = reinterpret_cast(selectedOutputsMemPtr->GetPtr()); int* selectedIndices = reinterpret_cast(selectedIndicesMemPtr->GetPtr()); diff --git a/src/plugins/intel_cpu/src/nodes/mkldnn_multiclass_nms.cpp b/src/plugins/intel_cpu/src/nodes/mkldnn_multiclass_nms.cpp index 15d810fbb4d..9d21c37338e 100644 --- a/src/plugins/intel_cpu/src/nodes/mkldnn_multiclass_nms.cpp +++ b/src/plugins/intel_cpu/src/nodes/mkldnn_multiclass_nms.cpp @@ -144,12 +144,7 @@ bool MKLDNNMultiClassNmsNode::isExecutable() const { void MKLDNNMultiClassNmsNode::executeDynamicImpl(mkldnn::stream strm) { if (hasEmptyInputTensors()) { - getChildEdgesAtPort(NMS_SELECTEDOUTPUTS)[0]->getMemoryPtr()->redefineDesc( - getBaseMemDescAtOutputPort(NMS_SELECTEDOUTPUTS)->cloneWithNewDims({0, 6})); - getChildEdgesAtPort(NMS_SELECTEDINDICES)[0]->getMemoryPtr()->redefineDesc( - getBaseMemDescAtOutputPort(NMS_SELECTEDINDICES)->cloneWithNewDims({0, 1})); - getChildEdgesAtPort(NMS_SELECTEDNUM)[0]->getMemoryPtr()->redefineDesc( - getBaseMemDescAtOutputPort(NMS_SELECTEDNUM)->cloneWithNewDims({0})); + redefineOutputMemory({{0, 6}, {0, 1}, {0}}); return; } execute(strm); @@ -268,9 +263,7 @@ void MKLDNNMultiClassNmsNode::execute(mkldnn::stream strm) { // TODO [DS NMS]: remove when nodes from models where nms is not last node in model supports DS if (isDynamicNode()) { size_t totalBox = std::accumulate(m_selected_num.begin(), m_selected_num.end(), 0); - selectedOutputsMemPtr->redefineDesc(getBaseMemDescAtOutputPort(NMS_SELECTEDOUTPUTS)->cloneWithNewDims({totalBox, 6})); - selectedIndicesMemPtr->redefineDesc(getBaseMemDescAtOutputPort(NMS_SELECTEDINDICES)->cloneWithNewDims({totalBox, 1})); - validOutputsMemPtr->redefineDesc(getBaseMemDescAtOutputPort(NMS_SELECTEDNUM)->cloneWithNewDims({m_numBatches})); + redefineOutputMemory({{totalBox, 6}, {totalBox, 1}, {m_numBatches}}); } int* selected_indices = reinterpret_cast(selectedIndicesMemPtr->GetPtr()); float* selected_outputs = reinterpret_cast(selectedOutputsMemPtr->GetPtr()); diff --git a/src/plugins/intel_cpu/src/nodes/mkldnn_non_max_suppression_node.cpp b/src/plugins/intel_cpu/src/nodes/mkldnn_non_max_suppression_node.cpp index 3cc419f03dd..a921c16b51a 100644 --- a/src/plugins/intel_cpu/src/nodes/mkldnn_non_max_suppression_node.cpp +++ b/src/plugins/intel_cpu/src/nodes/mkldnn_non_max_suppression_node.cpp @@ -713,10 +713,7 @@ void MKLDNNNonMaxSuppressionNode::createJitKernel() { void MKLDNNNonMaxSuppressionNode::executeDynamicImpl(mkldnn::stream strm) { if (hasEmptyInputTensors() || (inputShapes.size() > NMS_MAXOUTPUTBOXESPERCLASS && reinterpret_cast(getParentEdgeAt(NMS_MAXOUTPUTBOXESPERCLASS)->getMemoryPtr()->GetPtr())[0] == 0)) { - getChildEdgesAtPort(NMS_SELECTEDINDICES)[0]->getMemoryPtr()->redefineDesc( - getBaseMemDescAtOutputPort(NMS_SELECTEDINDICES)->cloneWithNewDims({0, 3})); - getChildEdgesAtPort(NMS_SELECTEDSCORES)[0]->getMemoryPtr()->redefineDesc( - getBaseMemDescAtOutputPort(NMS_SELECTEDSCORES)->cloneWithNewDims({0, 3})); + redefineOutputMemory({{0, 3}, {0, 3}, {1}}); *reinterpret_cast(getChildEdgesAtPort(NMS_VALIDOUTPUTS)[0]->getMemoryPtr()->GetPtr()) = 0; return; } @@ -794,8 +791,7 @@ void MKLDNNNonMaxSuppressionNode::execute(mkldnn::stream strm) { // TODO [DS NMS]: remove when nodes from models where nms is not last node in model supports DS if (isDynamicNode()) { VectorDims newDims{validOutputs, 3}; - indicesMemPtr->redefineDesc(getBaseMemDescAtOutputPort(NMS_SELECTEDINDICES)->cloneWithNewDims(newDims)); - scoresMemPtr->redefineDesc(getBaseMemDescAtOutputPort(NMS_SELECTEDSCORES)->cloneWithNewDims(newDims)); + redefineOutputMemory({newDims, newDims, {1}}); } int selectedIndicesStride = indicesMemPtr->GetDescWithType()->getStrides()[0]; diff --git a/src/plugins/intel_cpu/src/nodes/mkldnn_non_zero.cpp b/src/plugins/intel_cpu/src/nodes/mkldnn_non_zero.cpp index 5e270ba56cc..c836937e1f5 100644 --- a/src/plugins/intel_cpu/src/nodes/mkldnn_non_zero.cpp +++ b/src/plugins/intel_cpu/src/nodes/mkldnn_non_zero.cpp @@ -112,7 +112,7 @@ void MKLDNNNonZeroNode::executeSpecified() { if (isDynamicNode()) { VectorDims newDims{inRank, nonZeroCount}; - dstMemPtr->redefineDesc(getBaseMemDescAtOutputPort(0)->cloneWithNewDims(newDims)); + redefineOutputMemory({newDims}); } int *dst = reinterpret_cast(dstMemPtr->GetPtr()); size_t inSize = inShape.getElementsCount(); diff --git a/src/plugins/intel_cpu/src/nodes/mkldnn_range_node.cpp b/src/plugins/intel_cpu/src/nodes/mkldnn_range_node.cpp index 10e9d14c6ba..48175474b79 100644 --- a/src/plugins/intel_cpu/src/nodes/mkldnn_range_node.cpp +++ b/src/plugins/intel_cpu/src/nodes/mkldnn_range_node.cpp @@ -104,6 +104,7 @@ void MKLDNNRangeNode::execute(mkldnn::stream strm) { IE_THROW() << errorMsg; } } + template size_t MKLDNNRangeNode::getWorkAmount(data_t *startPtr, data_t *stopPtr, data_t *stepPtr) const { data_t start = 0, limit = 0, delta = 0; @@ -126,13 +127,14 @@ size_t MKLDNNRangeNode::getWorkAmount(data_t *startPtr, data_t *stopPtr, data_t return static_cast(std::ceil(std::fabs(span) / std::fabs(step))); } } + template InferenceEngine::StatusCode MKLDNNRangeNode::rangeKernel() { data_t start = 0, delta = 0; size_t work_amount_dst = getWorkAmount(&start, nullptr, &delta); if (isDynamicNode()) { VectorDims newOutputShape {work_amount_dst}; - getChildEdgeAt(0)->getMemoryPtr()->redefineDesc(getBaseMemDescAtOutputPort(0)->cloneWithNewDims(newOutputShape)); + redefineOutputMemory({newOutputShape}); } data_t* dst_data = reinterpret_cast(getChildEdgesAtPort(0)[0]->getMemoryPtr()->GetPtr()); parallel_nt(0, [&](const int ithr, const int nthr) {