Skip to content

Commit e570253

Browse files
authoredFeb 27, 2025
[CPU] Fix readability-else-after-return clang-tidy remarks (#28969)
### Details: - Fix "readability-else-after-return" remarks reported by clang-tidy - Enable "readability-else-after-return" clang-tidy checks on CI by default ### Tickets: - N/A
1 parent 8db08c1 commit e570253

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

73 files changed

+593
-634
lines changed
 

‎src/plugins/intel_cpu/src/.clang-tidy

+1
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ Checks: >
3838
modernize-loop-convert,
3939
modernize-pass-by-value,
4040
cppcoreguidelines-prefer-member-initializer,
41+
readability-else-after-return,
4142
-bugprone-easily-swappable-parameters,
4243
-bugprone-implicit-widening-of-multiplication-result,
4344
-bugprone-narrowing-conversions,

‎src/plugins/intel_cpu/src/compiled_model.cpp

+46-23
Original file line numberDiff line numberDiff line change
@@ -280,65 +280,88 @@ ov::Any CompiledModel::get_property(const std::string& name) const {
280280
// @todo Does not seem ok to 'dump()' the whole graph everytime in order to get a name
281281
const std::string modelName = graph.dump()->get_friendly_name();
282282
return decltype(ov::model_name)::value_type(modelName);
283-
} else if (name == ov::optimal_number_of_infer_requests) {
283+
}
284+
if (name == ov::optimal_number_of_infer_requests) {
284285
const auto streams = config.streamExecutorConfig.get_streams();
285286
return static_cast<decltype(ov::optimal_number_of_infer_requests)::value_type>(
286287
streams > 0 ? streams : 1); // ov::optimal_number_of_infer_requests has no negative values
287-
} else if (name == ov::num_streams) {
288+
}
289+
if (name == ov::num_streams) {
288290
const auto streams = config.streamExecutorConfig.get_streams();
289291
return decltype(ov::num_streams)::value_type(
290292
streams); // ov::num_streams has special negative values (AUTO = -1, NUMA = -2)
291-
} else if (name == ov::inference_num_threads) {
293+
}
294+
if (name == ov::inference_num_threads) {
292295
const auto num_threads = config.streamExecutorConfig.get_threads();
293296
return static_cast<decltype(ov::inference_num_threads)::value_type>(num_threads);
294-
} else if (name == ov::enable_profiling.name()) {
297+
}
298+
if (name == ov::enable_profiling.name()) {
295299
const bool perfCount = config.collectPerfCounters;
296300
return static_cast<decltype(ov::enable_profiling)::value_type>(perfCount);
297-
} else if (name == ov::hint::inference_precision) {
301+
}
302+
if (name == ov::hint::inference_precision) {
298303
return decltype(ov::hint::inference_precision)::value_type(config.inferencePrecision);
299-
} else if (name == ov::hint::performance_mode) {
304+
}
305+
if (name == ov::hint::performance_mode) {
300306
return static_cast<decltype(ov::hint::performance_mode)::value_type>(config.hintPerfMode);
301-
} else if (name == ov::log::level) {
307+
}
308+
if (name == ov::log::level) {
302309
return static_cast<decltype(ov::log::level)::value_type>(config.logLevel);
303-
} else if (name == ov::hint::enable_cpu_pinning.name()) {
310+
}
311+
if (name == ov::hint::enable_cpu_pinning.name()) {
304312
const bool use_pin = config.enableCpuPinning;
305313
return static_cast<decltype(ov::hint::enable_cpu_pinning)::value_type>(use_pin);
306-
} else if (name == ov::hint::enable_cpu_reservation.name()) {
314+
}
315+
if (name == ov::hint::enable_cpu_reservation.name()) {
307316
const bool use_reserve = config.enableCpuReservation;
308317
return static_cast<decltype(ov::hint::enable_cpu_reservation)::value_type>(use_reserve);
309-
} else if (name == ov::hint::scheduling_core_type) {
318+
}
319+
if (name == ov::hint::scheduling_core_type) {
310320
const auto stream_mode = config.schedulingCoreType;
311321
return stream_mode;
312-
} else if (name == ov::hint::model_distribution_policy) {
322+
}
323+
if (name == ov::hint::model_distribution_policy) {
313324
const auto& distribution_policy = config.modelDistributionPolicy;
314325
return distribution_policy;
315-
} else if (name == ov::hint::enable_hyper_threading.name()) {
326+
}
327+
if (name == ov::hint::enable_hyper_threading.name()) {
316328
const bool use_ht = config.enableHyperThreading;
317329
return static_cast<decltype(ov::hint::enable_hyper_threading)::value_type>(use_ht);
318-
} else if (name == ov::hint::execution_mode) {
330+
}
331+
if (name == ov::hint::execution_mode) {
319332
return config.executionMode;
320-
} else if (name == ov::hint::num_requests) {
333+
}
334+
if (name == ov::hint::num_requests) {
321335
return static_cast<decltype(ov::hint::num_requests)::value_type>(config.hintNumRequests);
322-
} else if (name == ov::execution_devices) {
336+
}
337+
if (name == ov::execution_devices) {
323338
return decltype(ov::execution_devices)::value_type{m_plugin->get_device_name()};
324-
} else if (name == ov::intel_cpu::denormals_optimization) {
339+
}
340+
if (name == ov::intel_cpu::denormals_optimization) {
325341
return static_cast<decltype(ov::intel_cpu::denormals_optimization)::value_type>(
326342
config.denormalsOptMode == Config::DenormalsOptMode::DO_On);
327-
} else if (name == ov::intel_cpu::sparse_weights_decompression_rate) {
343+
}
344+
if (name == ov::intel_cpu::sparse_weights_decompression_rate) {
328345
return static_cast<decltype(ov::intel_cpu::sparse_weights_decompression_rate)::value_type>(
329346
config.fcSparseWeiDecompressionRate);
330-
} else if (name == ov::hint::dynamic_quantization_group_size) {
347+
}
348+
if (name == ov::hint::dynamic_quantization_group_size) {
331349
return static_cast<decltype(ov::hint::dynamic_quantization_group_size)::value_type>(
332350
config.fcDynamicQuantizationGroupSize);
333-
} else if (name == ov::hint::kv_cache_precision) {
351+
}
352+
if (name == ov::hint::kv_cache_precision) {
334353
return decltype(ov::hint::kv_cache_precision)::value_type(config.kvCachePrecision);
335-
} else if (name == ov::key_cache_precision) {
354+
}
355+
if (name == ov::key_cache_precision) {
336356
return decltype(ov::key_cache_precision)::value_type(config.keyCachePrecision);
337-
} else if (name == ov::value_cache_precision) {
357+
}
358+
if (name == ov::value_cache_precision) {
338359
return decltype(ov::value_cache_precision)::value_type(config.valueCachePrecision);
339-
} else if (name == ov::key_cache_group_size) {
360+
}
361+
if (name == ov::key_cache_group_size) {
340362
return static_cast<decltype(ov::key_cache_group_size)::value_type>(config.keyCacheGroupSize);
341-
} else if (name == ov::value_cache_group_size) {
363+
}
364+
if (name == ov::value_cache_group_size) {
342365
return static_cast<decltype(ov::value_cache_group_size)::value_type>(config.valueCacheGroupSize);
343366
}
344367
OPENVINO_THROW("Unsupported property: ", name);

0 commit comments

Comments
 (0)