Skip to content

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

[CPU] Apply De Morgan's law simplification as a part of 'readability-simplify-boolean-expr' clang-tidy check (#31342)

Arseniy Obolenskiy01822fcfff5c
diff --git a/src/plugins/intel_cpu/src/.clang-tidy b/src/plugins/intel_cpu/src/.clang-tidy
index 5e5eb343b3a..41d15746cbd 100644
--- a/src/plugins/intel_cpu/src/.clang-tidy
+++ b/src/plugins/intel_cpu/src/.clang-tidy
@@ -159,7 +159,7 @@ CheckOptions:
- key: readability-simplify-boolean-expr.ChainedConditionalAssignment
value: true
- key: readability-simplify-boolean-expr.SimplifyDeMorgan
- value: false
+ value: true
- key: readability-simplify-boolean-expr.SimplifyDeMorganRelaxed
- value: false
+ value: true
---
diff --git a/src/plugins/intel_cpu/src/dnnl_postops_composer.cpp b/src/plugins/intel_cpu/src/dnnl_postops_composer.cpp
index 281ad394ba3..08e425fa2a8 100644
--- a/src/plugins/intel_cpu/src/dnnl_postops_composer.cpp
+++ b/src/plugins/intel_cpu/src/dnnl_postops_composer.cpp
@@ -1098,7 +1098,9 @@ DnnlPrimitiveAttrs DnnlPostOpsComposer::compose() {
}
}
- return !(hasSubsequentSum && hasSubsequentFQ);
+ const bool no_subsequent_sum = !hasSubsequentSum;
+ const bool no_subsequent_fq = !hasSubsequentFQ;
+ return no_subsequent_sum || no_subsequent_fq;
};
auto round = i == 0 ? doRounding() : true;
diff --git a/src/plugins/intel_cpu/src/edge.cpp b/src/plugins/intel_cpu/src/edge.cpp
index dbd19a2ad05..920ea90d0fb 100644
--- a/src/plugins/intel_cpu/src/edge.cpp
+++ b/src/plugins/intel_cpu/src/edge.cpp
@@ -530,9 +530,9 @@ EdgePtr Edge::getBaseEdge(int look) {
const int parentInPlacePort = getParent()->inPlaceOutPort(inputNum);
const int childInPlacePort = getChild()->inPlaceInputPort(outputNum);
- OPENVINO_ASSERT(!(parentInPlacePort >= 0 && childInPlacePort >= 0),
- "Unresolved in place memory conflict detected on edge: ",
- *this);
+ const bool parent_valid = parentInPlacePort >= 0;
+ const bool child_valid = childInPlacePort >= 0;
+ OPENVINO_ASSERT(!parent_valid || !child_valid, "Unresolved in place memory conflict detected on edge: ", *this);
if ((childInPlacePort >= 0) && (look & LOOK_DOWN)) {
auto ch_edges = getChild()->getChildEdgesAtPort(childInPlacePort);
diff --git a/src/plugins/intel_cpu/src/graph_optimizer.cpp b/src/plugins/intel_cpu/src/graph_optimizer.cpp
index 9b6c4e6e436..e7f843e105a 100644
--- a/src/plugins/intel_cpu/src/graph_optimizer.cpp
+++ b/src/plugins/intel_cpu/src/graph_optimizer.cpp
@@ -1606,7 +1606,9 @@ void GraphOptimizer::FuseConvolutionSumAndConvolutionSumActivation(Graph& graph)
if (fuseCandidate->getAlgorithm() == Algorithm::EltwiseAdd) {
auto isNotSpecialConvolutionAddFusing = [](const NodePtr& fusedNode) {
const auto eltwise = std::dynamic_pointer_cast<Eltwise>(fusedNode);
- return !(eltwise && eltwise->isSpecialConvolutionAddFusing());
+ const auto has_eltwise = static_cast<bool>(eltwise);
+ const bool is_special_fusing = has_eltwise && eltwise->isSpecialConvolutionAddFusing();
+ return !is_special_fusing;
};
auto allFusedNodesNotSpecial = [&]() {
return std::all_of(binConv->fusedWith.begin(),
@@ -2532,7 +2534,8 @@ bool GraphOptimizer::canBeInplaced(const NodePtr& parentNode, const NodePtr& chi
const auto childInPlace = std::any_of(childEdges.begin(), childEdges.end(), [](const EdgePtr& edge) {
return edge->inPlace(Edge::LOOK_DOWN);
});
- return !(parentInPlace && childInPlace);
+ const bool both_in_place = parentInPlace && childInPlace;
+ return !both_in_place;
}
bool GraphOptimizer::checkAscendingFinalOrder(const VectorDims& transposeOrder,
diff --git a/src/plugins/intel_cpu/src/node.cpp b/src/plugins/intel_cpu/src/node.cpp
index 87b24136a6e..959bb2845c2 100644
--- a/src/plugins/intel_cpu/src/node.cpp
+++ b/src/plugins/intel_cpu/src/node.cpp
@@ -365,7 +365,8 @@ bool Node::isReorderRequired(const ov::intel_cpu::MemoryDescPtr& desc1, const ov
bool samePrec = desc1->getPrecision() == desc2->getPrecision();
bool isOneDimShape1 = isOneDimShape(desc1->getShape().toPartialShape());
bool isOneDimShape2 = isOneDimShape(desc2->getShape().toPartialShape());
- return !(isOneDimShape1 && isOneDimShape2 && samePrec);
+ const bool all_conditions_true = isOneDimShape1 && isOneDimShape2 && samePrec;
+ return !all_conditions_true;
}
void Node::selectPreferPrimitiveDescriptorWithShape(const std::vector<impl_desc_type>& priority,
diff --git a/src/plugins/intel_cpu/src/nodes/executors/convolution_implementations.cpp b/src/plugins/intel_cpu/src/nodes/executors/convolution_implementations.cpp
index 819f7ffcc4e..3c526794303 100644
--- a/src/plugins/intel_cpu/src/nodes/executors/convolution_implementations.cpp
+++ b/src/plugins/intel_cpu/src/nodes/executors/convolution_implementations.cpp
@@ -91,7 +91,10 @@ const std::vector<ExecutorImplementation<ConvAttrs>>& getImplementations() {
memoryFormatFilter, dnnlConvolutionMappingNotation), MEMORY_FORMAT_MISMATCH);
VERIFY(!hasPostOp<DepthwiseConvolutionPostOp>(config.attrs.postOps), UNSUPPORTED_POST_OPS);
- VERIFY(isQuantized(config) || DnnlConvolutionPrimitive::isBrgConvAvailable(config), "is not quantized or brgemm convolution is not available");
+ const bool is_quantized = isQuantized(config);
+ const bool brg_conv_available = DnnlConvolutionPrimitive::isBrgConvAvailable(config);
+ const bool valid_config = is_quantized || brg_conv_available;
+ VERIFY(valid_config, "is not quantized or brgemm convolution is not available");
return true;
},
diff --git a/src/plugins/intel_cpu/src/nodes/executors/fullyconnected_implementations.cpp b/src/plugins/intel_cpu/src/nodes/executors/fullyconnected_implementations.cpp
index 4ddee08f5df..a83aa5dc392 100644
--- a/src/plugins/intel_cpu/src/nodes/executors/fullyconnected_implementations.cpp
+++ b/src/plugins/intel_cpu/src/nodes/executors/fullyconnected_implementations.cpp
@@ -255,8 +255,11 @@ const std::vector<ExecutorImplementation<FCAttrs>>& getImplementations() {
// Disable Conv1x1 when weight size >= 16M to avoid different weight layout when having different input
// activation shapes. As a consuquence, peak memory consumption in LLM can be decreased.
VERIFY(weightsSize < (16 * 1 << 20), " weights size is to big");
- VERIFY(widthInConv >= 2 && widthInConv <= 3136 && K >= 96 && K <= 4096 && N >= 96 && N <= K * 4,
- HEURISTICS_MISMATCH);
+ const bool width_in_range = widthInConv >= 2 && widthInConv <= 3136;
+ const bool k_in_range = K >= 96 && K <= 4096;
+ const bool n_in_range = N >= 96 && N <= K * 4;
+ const bool all_conditions_met = width_in_range && k_in_range && n_in_range;
+ VERIFY(all_conditions_met, HEURISTICS_MISMATCH);
return true;
},
diff --git a/src/plugins/intel_cpu/src/nodes/executors/shl/shl_eltwise.cpp b/src/plugins/intel_cpu/src/nodes/executors/shl/shl_eltwise.cpp
index a240357ff54..f90fe468c0d 100644
--- a/src/plugins/intel_cpu/src/nodes/executors/shl/shl_eltwise.cpp
+++ b/src/plugins/intel_cpu/src/nodes/executors/shl/shl_eltwise.cpp
@@ -63,8 +63,8 @@ bool ShlEltwiseExecutor::supports(const EltwiseConfig& config) {
auto is_precision_supported = [supported_prec](const MemoryDescPtr& desc) {
return desc->getPrecision() == supported_prec;
};
- if (!(std::all_of(srcDescs.cbegin(), srcDescs.cend(), is_precision_supported) &&
- std::all_of(dstDescs.cbegin(), dstDescs.cend(), is_precision_supported))) {
+ if (!std::all_of(srcDescs.cbegin(), srcDescs.cend(), is_precision_supported) ||
+ !std::all_of(dstDescs.cbegin(), dstDescs.cend(), is_precision_supported)) {
DEBUG_LOG("ShlEltwise supports only f32");
return false;
}
@@ -84,8 +84,8 @@ bool ShlEltwiseExecutor::supports(const EltwiseConfig& config) {
}
return desc->hasLayoutType(unifiedLayout);
};
- if (!(std::all_of(srcDescs.cbegin(), srcDescs.cend(), has_unified_layout) &&
- std::all_of(dstDescs.cbegin(), dstDescs.cend(), has_unified_layout))) {
+ if (!std::all_of(srcDescs.cbegin(), srcDescs.cend(), has_unified_layout) ||
+ !std::all_of(dstDescs.cbegin(), dstDescs.cend(), has_unified_layout)) {
DEBUG_LOG("ShlEltwise needs to ensure all inputs and outputs are in the same 'ncsp' or 'nspc' layouts");
return false;
}
@@ -95,8 +95,8 @@ bool ShlEltwiseExecutor::supports(const EltwiseConfig& config) {
switch (eltwiseAttrs.data.algo) {
case Algorithm::EltwisePrelu:
// SHL PRelu op only supports these two kinds of layout
- if (!(supportedLayout == csinn_layout_enum::CSINN_LAYOUT_NC1HWC0 ||
- supportedLayout == csinn_layout_enum::CSINN_LAYOUT_NCHW)) {
+ if (supportedLayout != csinn_layout_enum::CSINN_LAYOUT_NC1HWC0 &&
+ supportedLayout != csinn_layout_enum::CSINN_LAYOUT_NCHW) {
DEBUG_LOG("src descriptor layout is unsupported by SHL Prelu op: ", srcDesc->serializeFormat());
return false;
}
diff --git a/src/plugins/intel_cpu/src/nodes/fake_quantize.cpp b/src/plugins/intel_cpu/src/nodes/fake_quantize.cpp
index dcabc77fa45..27abf821518 100644
--- a/src/plugins/intel_cpu/src/nodes/fake_quantize.cpp
+++ b/src/plugins/intel_cpu/src/nodes/fake_quantize.cpp
@@ -1877,10 +1877,12 @@ void FakeQuantize::executeQuantization(const std::unique_ptr<jit_uni_quantize_ke
bool is_blk_format = !srcDesc.hasLayoutType(LayoutType::nspc) && any_of(srcDesc.getShape().getRank(), 4U, 5U);
int blk_size = 1;
- if (!(srcDesc.hasLayoutType(LayoutType::ncsp) && any_of(srcDesc.getShape().getRank(), 3U, 4U, 5U)) &&
- mayiuse(cpu::x64::avx512_core)) {
+ const bool has_ncsp_layout = srcDesc.hasLayoutType(LayoutType::ncsp);
+ const bool has_valid_rank = any_of(srcDesc.getShape().getRank(), 3U, 4U, 5U);
+ const bool is_ncsp_with_valid_rank = has_ncsp_layout && has_valid_rank;
+ if (!is_ncsp_with_valid_rank && mayiuse(cpu::x64::avx512_core)) {
blk_size = 16;
- } else if (!(srcDesc.hasLayoutType(LayoutType::ncsp) && any_of(srcDesc.getShape().getRank(), 3U, 4U, 5U))) {
+ } else if (!is_ncsp_with_valid_rank) {
blk_size = 8;
}
diff --git a/src/plugins/intel_cpu/src/nodes/istft.cpp b/src/plugins/intel_cpu/src/nodes/istft.cpp
index 1708a6c4c08..7a264e709d1 100644
--- a/src/plugins/intel_cpu/src/nodes/istft.cpp
+++ b/src/plugins/intel_cpu/src/nodes/istft.cpp
@@ -267,7 +267,7 @@ void ISTFT::executeDynamicImpl(const dnnl::stream& strm) {
bool ISTFT::needShapeInfer() const {
return (m_has_signal_length_input && !m_is_signal_length_const) ||
- (!m_has_signal_length_input && !(m_is_frame_size_const && m_is_frame_step_const)) || Node::needShapeInfer();
+ (!m_has_signal_length_input && (!m_is_frame_size_const || !m_is_frame_step_const)) || Node::needShapeInfer();
}
void ISTFT::createPrimitive() {
diff --git a/src/plugins/intel_cpu/src/nodes/kernels/x64/gather_uni_kernel.cpp b/src/plugins/intel_cpu/src/nodes/kernels/x64/gather_uni_kernel.cpp
index 0e367b2ac3c..59523454cf6 100644
--- a/src/plugins/intel_cpu/src/nodes/kernels/x64/gather_uni_kernel.cpp
+++ b/src/plugins/intel_cpu/src/nodes/kernels/x64/gather_uni_kernel.cpp
@@ -1190,7 +1190,8 @@ bool jitUniGatherKernel<isa>::isSupportedConfiguration(uint64_t afterAxisSize) {
// There are no enough registers for these cases.
const bool isSmallDataType = (jcp.dataTypeSize == 1 || jcp.dataTypeSize == 2);
const bool isAvx2WithBlockedAfterAxis = (afterAxisSize > 1 && isa == x64::avx2);
- return !(isAvx2WithBlockedAfterAxis && isSmallDataType);
+ const bool incompatible_config = isAvx2WithBlockedAfterAxis && isSmallDataType;
+ return !incompatible_config;
}
return static_cast<bool>(jcp.dynamicShapes && afterAxisSize == 1);
}
diff --git a/src/plugins/intel_cpu/src/nodes/kernels/x64/jit_matmul_small.cpp b/src/plugins/intel_cpu/src/nodes/kernels/x64/jit_matmul_small.cpp
index 9403732d417..e745d364da8 100644
--- a/src/plugins/intel_cpu/src/nodes/kernels/x64/jit_matmul_small.cpp
+++ b/src/plugins/intel_cpu/src/nodes/kernels/x64/jit_matmul_small.cpp
@@ -55,9 +55,6 @@ void jit_uni_matmul_small_kernel_f32<isa>::generate() {
mov(reg_input2, ptr[reg_params + GET_OFF(input2)]);
mov(reg_out, ptr[reg_params + GET_OFF(output)]);
mov(reg_work_amount, ptr[reg_params + GET_OFF(B)]);
- if (jcp_.M > 2 || jcp_.N > 2 || jcp_.K > 2) {
- assert("matmul_small_kernel only support M/N/K smaller than 3.");
- }
if (attr_.post_ops_.len() != 0) {
mov(reg_post_ops_data, ptr[reg_params + GET_OFF(post_op_data)]);
diff --git a/src/plugins/intel_cpu/src/nodes/multinomial.cpp b/src/plugins/intel_cpu/src/nodes/multinomial.cpp
index fa7367b3951..348428f85b6 100644
--- a/src/plugins/intel_cpu/src/nodes/multinomial.cpp
+++ b/src/plugins/intel_cpu/src/nodes/multinomial.cpp
@@ -89,7 +89,9 @@ void Multinomial::initSupportedPrimitiveDescriptors() {
}
bool Multinomial::needShapeInfer() const {
- return !(m_const_inputs[NUM_SAMPLES_PORT] && m_const_batch);
+ const bool has_const_samples = m_const_inputs[NUM_SAMPLES_PORT];
+ const bool both_const = has_const_samples && m_const_batch;
+ return !both_const;
}
bool Multinomial::needPrepareParams() const {
diff --git a/src/plugins/intel_cpu/src/nodes/reduce.cpp b/src/plugins/intel_cpu/src/nodes/reduce.cpp
index ea65a9fbc8c..3318e20e53a 100644
--- a/src/plugins/intel_cpu/src/nodes/reduce.cpp
+++ b/src/plugins/intel_cpu/src/nodes/reduce.cpp
@@ -2107,9 +2107,9 @@ void Reduce::getSupportedDescriptors() {
// But for now, 0d tensor (scalar) is emulated as 1d tensor. Skip checking in such cases.
bool is_emulated_0d_as_1d =
getInputShapeAtPort(REDUCE_DATA).getRank() == 1 && getOutputShapeAtPort(0).getRank() == 1;
- CPU_NODE_ASSERT(
- !(getInputShapeAtPort(REDUCE_DATA).getRank() <= getOutputShapeAtPort(0).getRank() && !is_emulated_0d_as_1d),
- "gets incorrect number of input/output dimensions!");
+ const bool rank_condition = getInputShapeAtPort(REDUCE_DATA).getRank() <= getOutputShapeAtPort(0).getRank();
+ const bool invalid_config = rank_condition && !is_emulated_0d_as_1d;
+ CPU_NODE_ASSERT(!invalid_config, "gets incorrect number of input/output dimensions!");
}
}
diff --git a/src/plugins/intel_cpu/src/nodes/reorder.cpp b/src/plugins/intel_cpu/src/nodes/reorder.cpp
index 3bf7a201794..8c4100e7adf 100644
--- a/src/plugins/intel_cpu/src/nodes/reorder.cpp
+++ b/src/plugins/intel_cpu/src/nodes/reorder.cpp
@@ -110,7 +110,10 @@ void Reorder::initSupportedPrimitiveDescriptors() {
supportedPrimitiveDescriptors.emplace_back(config, impl_desc_type::reorder);
// must be to initialize here since shapes are unknown at the time of Reorder node creation
- isDynamic = !(config.inConfs[0].getMemDesc()->isDefined() && config.outConfs[0].getMemDesc()->isDefined());
+ const bool input_defined = config.inConfs[0].getMemDesc()->isDefined();
+ const bool output_defined = config.outConfs[0].getMemDesc()->isDefined();
+ const bool both_defined = input_defined && output_defined;
+ isDynamic = !both_defined;
if (isDynamicNode() && !shapeInference) {
shapeInference = std::make_shared<ShapeInferPassThrough>();
}
diff --git a/src/plugins/intel_cpu/src/nodes/rnn.cpp b/src/plugins/intel_cpu/src/nodes/rnn.cpp
index 437ec0f474b..79e57898490 100644
--- a/src/plugins/intel_cpu/src/nodes/rnn.cpp
+++ b/src/plugins/intel_cpu/src/nodes/rnn.cpp
@@ -654,7 +654,8 @@ void RNN::initCell() {
"; Hidden state rank: ",
getInputShapeAtPort(1).getRank());
}
- CPU_NODE_ASSERT(!(is_augru && getInputShapeAtPort(5).getRank() != 2LU),
+ const bool is_augru_with_wrong_rank = is_augru && getInputShapeAtPort(5).getRank() != 2LU;
+ CPU_NODE_ASSERT(!is_augru_with_wrong_rank,
"has incorrect input ranks. Attention rank: ",
getInputShapeAtPort(2).getRank());
@@ -694,7 +695,10 @@ void RNN::initCell() {
if (is_augru) {
const Shape shapeA{B, 1};
- CPU_NODE_ASSERT(!(getInputShapeAtPort(5).isStatic() && getInputShapeAtPort(5) != shapeA),
+ const bool is_static = getInputShapeAtPort(5).isStatic();
+ const bool wrong_shape = getInputShapeAtPort(5) != shapeA;
+ const bool static_with_wrong_shape = is_static && wrong_shape;
+ CPU_NODE_ASSERT(!static_with_wrong_shape,
"has incorrect input shapes. Attention shape: ",
getInputShapeAtPort(5).toString());
}
diff --git a/src/plugins/intel_cpu/src/nodes/stft.cpp b/src/plugins/intel_cpu/src/nodes/stft.cpp
index 679640ba003..ec6545fbf60 100644
--- a/src/plugins/intel_cpu/src/nodes/stft.cpp
+++ b/src/plugins/intel_cpu/src/nodes/stft.cpp
@@ -188,7 +188,8 @@ void STFT::executeDynamicImpl(const dnnl::stream& strm) {
}
bool STFT::needShapeInfer() const {
- return !(m_is_frame_size_const && m_is_frame_step_const) || Node::needShapeInfer();
+ const bool both_const = m_is_frame_size_const && m_is_frame_step_const;
+ return !both_const || Node::needShapeInfer();
}
void STFT::createPrimitive() {
diff --git a/src/plugins/intel_cpu/src/nodes/strided_slice.cpp b/src/plugins/intel_cpu/src/nodes/strided_slice.cpp
index 01264ae7794..5ae1de579d0 100644
--- a/src/plugins/intel_cpu/src/nodes/strided_slice.cpp
+++ b/src/plugins/intel_cpu/src/nodes/strided_slice.cpp
@@ -75,10 +75,14 @@ StridedSlice::StridedSlice(const std::shared_ptr<ov::Node>& op, const GraphConte
attrs.AXES_ID = 5;
}
- CPU_NODE_ASSERT(!(attrs.isStridedSliceOp && (inputShapes.size() < 3 || inputShapes.size() > 4)) &&
- !(!attrs.isStridedSliceOp &&
- (inputShapes.size() < (attrs.STRIDE_ID + 1) || inputShapes.size() > (attrs.AXES_ID + 1))),
- "has incorrect number of input edges");
+ const bool is_strided_slice = attrs.isStridedSliceOp;
+ const bool wrong_size_for_strided = inputShapes.size() < 3 || inputShapes.size() > 4;
+ const bool wrong_size_for_slice =
+ inputShapes.size() < (attrs.STRIDE_ID + 1) || inputShapes.size() > (attrs.AXES_ID + 1);
+ const bool strided_slice_with_wrong_size = is_strided_slice && wrong_size_for_strided;
+ const bool slice_with_wrong_size = !is_strided_slice && wrong_size_for_slice;
+ const bool valid_config = !strided_slice_with_wrong_size && !slice_with_wrong_size;
+ CPU_NODE_ASSERT(valid_config, "has incorrect number of input edges");
CPU_NODE_ASSERT(outputShapes.size() == 1, "has incorrect number of output edges");
if (inputShapes.size() > attrs.STRIDE_ID) {
diff --git a/src/plugins/intel_cpu/src/nodes/string_tensor_pack.cpp b/src/plugins/intel_cpu/src/nodes/string_tensor_pack.cpp
index ea393f3e8af..fe1c483f1e3 100644
--- a/src/plugins/intel_cpu/src/nodes/string_tensor_pack.cpp
+++ b/src/plugins/intel_cpu/src/nodes/string_tensor_pack.cpp
@@ -98,7 +98,10 @@ struct StringTensorPack::StringTensorPackExecute {
};
bool StringTensorPack::isExecutable() const {
- return !(isInputTensorAtPortEmpty(0) || isInputTensorAtPortEmpty(1));
+ const bool port0_empty = isInputTensorAtPortEmpty(0);
+ const bool port1_empty = isInputTensorAtPortEmpty(1);
+ const bool any_empty = port0_empty || port1_empty;
+ return !any_empty;
}
void StringTensorPack::execute([[maybe_unused]] const dnnl::stream& strm) {
diff --git a/src/plugins/intel_cpu/src/transformations/cpu_opset/x64/pass/sdpa_fuse_transpose_reshape.cpp b/src/plugins/intel_cpu/src/transformations/cpu_opset/x64/pass/sdpa_fuse_transpose_reshape.cpp
index 0e5eb4cafba..f0845e0e1fb 100644
--- a/src/plugins/intel_cpu/src/transformations/cpu_opset/x64/pass/sdpa_fuse_transpose_reshape.cpp
+++ b/src/plugins/intel_cpu/src/transformations/cpu_opset/x64/pass/sdpa_fuse_transpose_reshape.cpp
@@ -116,7 +116,11 @@ intel_cpu::SDPAFuseTransposeReshape::SDPAFuseTransposeReshape() {
auto k_reshape = as_type_ptr<op::v1::Reshape>(pattern_map.at(k_reshape_node).get_node_shared_ptr());
auto v_reshape = as_type_ptr<op::v1::Reshape>(pattern_map.at(v_reshape_node).get_node_shared_ptr());
- if (!(is_expected_reshape(q_reshape) && is_expected_reshape(k_reshape) && is_expected_reshape(v_reshape))) {
+ const bool q_reshape_valid = is_expected_reshape(q_reshape);
+ const bool k_reshape_valid = is_expected_reshape(k_reshape);
+ const bool v_reshape_valid = is_expected_reshape(v_reshape);
+ const bool all_reshapes_valid = q_reshape_valid && k_reshape_valid && v_reshape_valid;
+ if (!all_reshapes_valid) {
return false;
}
// K,V Reshape's order should be same node.
@@ -145,8 +149,11 @@ intel_cpu::SDPAFuseTransposeReshape::SDPAFuseTransposeReshape() {
auto out_transpose_order =
as_type_ptr<op::v0::Constant>(pattern_map.at(out_transpose_order_node).get_node_shared_ptr());
- if (!(is_expected_transpose(qkv_transpose[0]) && is_expected_transpose(qkv_transpose[1]) &&
- is_expected_transpose(qkv_transpose[2]))) {
+ const bool q_transpose_valid = is_expected_transpose(qkv_transpose[0]);
+ const bool k_transpose_valid = is_expected_transpose(qkv_transpose[1]);
+ const bool v_transpose_valid = is_expected_transpose(qkv_transpose[2]);
+ const bool all_transposes_valid = q_transpose_valid && k_transpose_valid && v_transpose_valid;
+ if (!all_transposes_valid) {
return false;
}
if (!is_expected_transpose(out_tranpose)) {
diff --git a/src/plugins/intel_cpu/src/transformations/snippets/x64/pass/snippets_mark_skipped.cpp b/src/plugins/intel_cpu/src/transformations/snippets/x64/pass/snippets_mark_skipped.cpp
index 9740ffb792b..604fcdfb4fe 100644
--- a/src/plugins/intel_cpu/src/transformations/snippets/x64/pass/snippets_mark_skipped.cpp
+++ b/src/plugins/intel_cpu/src/transformations/snippets/x64/pass/snippets_mark_skipped.cpp
@@ -267,7 +267,8 @@ bool isSuitableSubtractAsZeroPointsParent(const std::shared_ptr<const Node>& nod
const auto out = node->outputs();
const bool has_only_child = all_of(1U, out.size(), out[0].get_target_inputs().size());
const bool has_two_parents = node->get_input_size() == 2;
- if (!(is_suitable_node && has_only_child && has_two_parents)) {
+ const bool all_conditions_met = is_suitable_node && has_only_child && has_two_parents;
+ if (!all_conditions_met) {
return false;
}
@@ -445,8 +446,10 @@ bool isSuitableParentForFusingSumActivation(const std::shared_ptr<const Node>& n
}
const auto conv = n->get_input_source_output(0);
const auto bias = n->get_input_source_output(1);
- if (!(ov::is_type<ov::op::v0::Constant>(bias.get_node_shared_ptr()) &&
- isSuitableConvolutionParent(conv.get_node_shared_ptr()))) {
+ const bool is_bias_constant = ov::is_type<ov::op::v0::Constant>(bias.get_node_shared_ptr());
+ const bool is_conv_suitable = isSuitableConvolutionParent(conv.get_node_shared_ptr());
+ const bool valid_bias_conv_pair = is_bias_constant && is_conv_suitable;
+ if (!valid_bias_conv_pair) {
return false;
}
const auto& conv_shape = conv.get_partial_shape();
diff --git a/src/plugins/intel_cpu/src/utils/verbose.cpp b/src/plugins/intel_cpu/src/utils/verbose.cpp
index 8b70fa09ac3..faf6d9b2487 100644
--- a/src/plugins/intel_cpu/src/utils/verbose.cpp
+++ b/src/plugins/intel_cpu/src/utils/verbose.cpp
@@ -37,7 +37,10 @@ bool Verbose::shouldBePrinted() const {
return false;
}
- return !(lvl < 3 && node->isConstant());
+ const bool low_level = lvl < 3;
+ const bool is_constant = node->isConstant();
+ const bool skip_node = low_level && is_constant;
+ return !skip_node;
}
/**