From 5403003d026f0f8fb3e29c99ce6f0dd43f0fb963 Mon Sep 17 00:00:00 2001 From: Nikolay Shchegolev Date: Thu, 10 Sep 2020 08:35:32 +0300 Subject: [PATCH] [CPU] statically analyzed issues. (#2139) --- .../src/mkldnn_plugin/nodes/mkldnn_eltwise_node.h | 1 - .../src/mkldnn_plugin/nodes/mkldnn_input_node.cpp | 4 ++-- .../mkldnn_plugin/nodes/mkldnn_normalize_node.cpp | 9 +++++++++ .../nodes/mkldnn_scatter_update_node.cpp | 20 ++++++++++++-------- 4 files changed, 23 insertions(+), 11 deletions(-) diff --git a/inference-engine/src/mkldnn_plugin/nodes/mkldnn_eltwise_node.h b/inference-engine/src/mkldnn_plugin/nodes/mkldnn_eltwise_node.h index 56227a9..15b13c1 100644 --- a/inference-engine/src/mkldnn_plugin/nodes/mkldnn_eltwise_node.h +++ b/inference-engine/src/mkldnn_plugin/nodes/mkldnn_eltwise_node.h @@ -71,7 +71,6 @@ private: std::vector sum_scales; bool broadcast = false; int batch_dim = 5; - std::vector PostOpsIntBlobMemory; mkldnn::primitive_attr attr; std::shared_ptr eltiwse_fq_kernel; 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 9571b4e..8c1ef5d 100644 --- a/inference-engine/src/mkldnn_plugin/nodes/mkldnn_input_node.cpp +++ b/inference-engine/src/mkldnn_plugin/nodes/mkldnn_input_node.cpp @@ -125,8 +125,8 @@ namespace { auto const &lhsBlockingDesc = lhs.getBlockingDesc(); auto const &rhsBlockingDesc = rhs.getBlockingDesc(); - bool lhsDefaultStrides, rhsDefaultStrides; - size_t lhsSize, rhsSize; + bool lhsDefaultStrides = false, rhsDefaultStrides = false; + size_t lhsSize = 0lu, rhsSize = 0lu; std::tie(lhsDefaultStrides, lhsSize) = isDefaultStrides(lhsBlockingDesc.getStrides(), lhs.getDims()); std::tie(rhsDefaultStrides, rhsSize) = isDefaultStrides(rhsBlockingDesc.getStrides(), rhs.getDims()); diff --git a/inference-engine/src/mkldnn_plugin/nodes/mkldnn_normalize_node.cpp b/inference-engine/src/mkldnn_plugin/nodes/mkldnn_normalize_node.cpp index 7f412e6..fd59bb9 100644 --- a/inference-engine/src/mkldnn_plugin/nodes/mkldnn_normalize_node.cpp +++ b/inference-engine/src/mkldnn_plugin/nodes/mkldnn_normalize_node.cpp @@ -633,9 +633,15 @@ private: for (int i = 0; i < p.len_; i++) { auto& post_op = p.entry_[i]; if (post_op.is_eltwise()) { + if (eltwise_injectors.size() <= eltwise_inj_idx + || eltwise_injectors[eltwise_inj_idx] == nullptr) + assert(!"Invalid eltwise injectors."); eltwise_injectors[eltwise_inj_idx]->compute_vector_range(vmm_val.getIdx(), vmm_val.getIdx() + 1); eltwise_inj_idx++; } else if (post_op.is_depthwise()) { + if (depthwise_injectors.size() <= depthwise_inj_idx + || depthwise_injectors[depthwise_inj_idx] == nullptr) + assert(!"Invalid depthwise injectors."); mov(reg_d_weights, reinterpret_cast(post_op.depthwise.weights_data)); mov(reg_d_bias, reinterpret_cast(post_op.depthwise.biases_data)); add(reg_d_weights, reg_oc_off); @@ -644,6 +650,9 @@ private: depthwise_injectors[depthwise_inj_idx]->compute_vector_range(vmm_val.getIdx(), vmm_val.getIdx() + 1, reg_d_weights, reg_d_bias, is_broadcast); depthwise_inj_idx++; } else if (post_op.is_quantization()) { + if (quantization_injectors.size() <= quantization_inj_idx + || quantization_injectors[quantization_inj_idx] == nullptr) + assert(!"Invalid quantization injectors."); bool do_dequantization = post_op.quantization.alg == alg_kind::quantization_quantize_dequantize; bool do_rounding = do_dequantization || dst_dt == memory::f32 || i != p.len_ - 1; diff --git a/inference-engine/src/mkldnn_plugin/nodes/mkldnn_scatter_update_node.cpp b/inference-engine/src/mkldnn_plugin/nodes/mkldnn_scatter_update_node.cpp index 2d74c87..a740111 100644 --- a/inference-engine/src/mkldnn_plugin/nodes/mkldnn_scatter_update_node.cpp +++ b/inference-engine/src/mkldnn_plugin/nodes/mkldnn_scatter_update_node.cpp @@ -289,6 +289,7 @@ void MKLDNNScatterUpdateNode::execute(mkldnn::stream strm) { SizeVector indicesDim = getParentEdgeAt(INDICES_ID)->getDesc().getDims(); size_t srcRank = srcDataDim.size(); int axis = 0; + std::string errorPrefix = std::string("'") + getTypeStr() + "'" + " layer with name '" + getName() + "'"; if (axisRelaxed) { auto &axisMemPtr = getParentEdgeAt(AXIS_ID)->getMemoryPtr(); uint8_t *axisPtr = reinterpret_cast(axisMemPtr->GetData()) + @@ -302,8 +303,8 @@ void MKLDNNScatterUpdateNode::execute(mkldnn::stream strm) { } if (axis >= static_cast(srcRank) || axis < (static_cast(srcRank) * - 1)) { - THROW_IE_EXCEPTION << "'" << getType() << "'" << " layer with name '" << getName() - << "' should have axis value in range [-r, r - 1], where r is the rank of input data"; + THROW_IE_EXCEPTION << errorPrefix + << " should have axis value in range [-r, r - 1], where r is the rank of input data"; } axis = axis < 0 ? (axis + srcRank) : axis; @@ -315,8 +316,8 @@ void MKLDNNScatterUpdateNode::execute(mkldnn::stream strm) { for (int i = start; i < end; i++) { int64_t idxValue = getIndicesValue(indicesPtr, i); if (idxValue >= static_cast(srcDimAxis) || idxValue < 0) { - THROW_IE_EXCEPTION << "'" << getType() << "'" << " layer with name '" << getName() - << "' have indices value that points to non-existing output tensor element"; + THROW_IE_EXCEPTION << errorPrefix + << " have indices value that points to non-existing output tensor element"; } } }); @@ -336,10 +337,13 @@ void MKLDNNScatterUpdateNode::execute(mkldnn::stream strm) { } } } + if (updateRank > expectUpdateShape.size()) + THROW_IE_EXCEPTION << errorPrefix << " cannot update shape. New rank: " + << updateRank << ", expected: " << expectUpdateShape.size(); for (size_t ru = 0; ru < updateRank; ru++) { if (updateDim[ru] != expectUpdateShape[ru]) { - THROW_IE_EXCEPTION << "'" << getType() << "'" << " layer with name '" << getName() - << "' do not have matched tensor shape relationship for input, indices and update"; + THROW_IE_EXCEPTION << errorPrefix + << " do not have matched tensor shape relationship for input, indices and update"; } } } @@ -370,8 +374,8 @@ void MKLDNNScatterUpdateNode::execute(mkldnn::stream strm) { break; } default: { - THROW_IE_EXCEPTION << "'" << getType() << "'" << " layer with name '" << getName() - << "' is not supported"; + THROW_IE_EXCEPTION << errorPrefix + << " is not supported"; } } } -- 2.7.4