Skip to content

[CPU] Apply 'readability-avoid-nested-conditional-operator' clang-tidy remarks #30806

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

aobolensk
Copy link
Contributor

Details:

  • Fix "readability-avoid-nested-conditional-operator" remarks reported by clang-tidy
  • Enable "readability-avoid-nested-conditional-operator" clang-tidy checks on CI by default

Tickets:

  • N/A

@aobolensk aobolensk requested review from a team as code owners May 31, 2025 15:13
@github-actions github-actions bot added the category: CPU OpenVINO CPU plugin label May 31, 2025
@aobolensk aobolensk force-pushed the readability-avoid-nested-conditional-operator branch 2 times, most recently from 7b0b152 to d457eac Compare June 2, 2025 07:56
@aobolensk aobolensk force-pushed the readability-avoid-nested-conditional-operator branch from 357d5dd to 47778be Compare June 2, 2025 17:16
@aobolensk aobolensk requested a review from Copilot June 2, 2025 18:35
@aobolensk aobolensk force-pushed the readability-avoid-nested-conditional-operator branch from 26ead9e to d271499 Compare June 2, 2025 18:35
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes readability-avoid-nested-conditional-operator clang-tidy remarks by replacing nested ternary expressions with equivalent if/else structures (often wrapped in immediately-invoked lambdas) across the Intel CPU plugin code and re-enables the check in CI.

  • Converted deeply nested ?: chains to clear if/else logic or lambdas in various nodes and kernels
  • Added <utility> include to support structured bindings
  • Re-enabled the readability-avoid-nested-conditional-operator check in .clang-tidy

Reviewed Changes

Copilot reviewed 32 out of 32 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/plugins/intel_cpu/src/nodes/multiclass_nms.cpp Replaced nested ternary for real_num_classes
src/plugins/intel_cpu/src/nodes/matrix_nms.cpp Replaced nested ternary for real_num_classes
src/plugins/intel_cpu/src/nodes/kernels/x64/brgemm_kernel.cpp Broke ternaries into if/else for several fields
src/plugins/intel_cpu/src/nodes/istft.cpp Expanded ternary to if/else for final length
src/plugins/intel_cpu/src/nodes/interpolate.cpp Replaced ternary for eltInGrid with if/else
src/plugins/intel_cpu/src/nodes/executors/interpolate.cpp Replaced ternary for eltInGrid with lambda
src/plugins/intel_cpu/src/nodes/input.cpp Normalized auto const* to const auto*
src/plugins/intel_cpu/src/nodes/gather.cpp Expanded ISA detection ternary to if/else
src/plugins/intel_cpu/src/nodes/fake_quantize.cpp Multiple nested ternaries refactored
src/plugins/intel_cpu/src/nodes/eltwise.cpp Converted nested conditional for implType
src/plugins/intel_cpu/src/nodes/depth_to_space.cpp Replaced ternary for layoutType
src/plugins/intel_cpu/src/nodes/deconv.cpp Expanded channel block and format tag ternaries
src/plugins/intel_cpu/src/nodes/conv.cpp Expanded ternaries for autoPadding
src/plugins/intel_cpu/src/nodes/bin_conv.cpp Replaced multiple nested ternaries
src/plugins/intel_cpu/src/infer_request.cpp Replaced nested conditional for shape
src/plugins/intel_cpu/src/emitters/plugin/x64/jit_emitter.cpp Expanded vector length ternary
src/plugins/intel_cpu/src/emitters/plugin/x64/debug_capabilities.cpp Broke VMM save/restore ternaries into if/else
src/plugins/intel_cpu/src/cpu_streams_calculation.cpp Expanded thread/stream selection ternaries
src/plugins/intel_cpu/src/cpu_memory.cpp Replaced clamp ternary with std::min/std::max
src/plugins/intel_cpu/src/.clang-tidy Re-enabled nested-conditional-operator check

@aobolensk aobolensk requested a review from EgorDuplensky June 2, 2025 19:50
@EgorDuplensky EgorDuplensky added this pull request to the merge queue Jun 4, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Jun 4, 2025
@aobolensk aobolensk added this pull request to the merge queue Jun 4, 2025
@aobolensk aobolensk force-pushed the readability-avoid-nested-conditional-operator branch from 7bc7a7f to 8cad289 Compare June 4, 2025 13:53
@aobolensk aobolensk removed this pull request from the merge queue due to a manual request Jun 4, 2025
@aobolensk aobolensk force-pushed the readability-avoid-nested-conditional-operator branch 2 times, most recently from 7723bd6 to 718ccf2 Compare June 4, 2025 14:51
@aobolensk aobolensk requested review from itikhono and removed request for a team June 5, 2025 06:24
@github-actions github-actions bot added category: IE Tests OpenVINO Test: plugins and common category: GPU OpenVINO GPU plugin category: transformations OpenVINO Runtime library - Transformations category: PyTorch FE OpenVINO PyTorch Frontend category: JS API OpenVino JS API Bindings labels Jun 5, 2025
@aobolensk aobolensk force-pushed the readability-avoid-nested-conditional-operator branch from 5221909 to 56f8453 Compare June 5, 2025 06:25
@aobolensk aobolensk removed request for a team, PiotrKrzem, cavusmustafa and itikhono June 5, 2025 06:25
@aobolensk aobolensk disabled auto-merge June 5, 2025 06:25
@github-actions github-actions bot removed category: IE Tests OpenVINO Test: plugins and common category: GPU OpenVINO GPU plugin category: transformations OpenVINO Runtime library - Transformations category: PyTorch FE OpenVINO PyTorch Frontend category: JS API OpenVino JS API Bindings labels Jun 5, 2025
@aobolensk aobolensk enabled auto-merge June 5, 2025 12:51
@aobolensk aobolensk added this pull request to the merge queue Jun 5, 2025
auto-merge was automatically disabled June 5, 2025 14:19

Pull Request is not mergeable

Merged via the queue into openvinotoolkit:master with commit 32839e7 Jun 5, 2025
209 checks passed
@aobolensk aobolensk deleted the readability-avoid-nested-conditional-operator branch June 5, 2025 15:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
category: CPU OpenVINO CPU plugin
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants