Skip to content

Commit 45bf77b

Browse files
[CPU] Introduce clang-format (openvinotoolkit#27944)
1 parent b61a685 commit 45bf77b

File tree

649 files changed

+30396
-23430
lines changed

Some content is hidden

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

649 files changed

+30396
-23430
lines changed

src/plugins/intel_cpu/CMakeLists.txt

+2-1
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,8 @@ ov_add_plugin(NAME ${TARGET_NAME}
242242
DEVICE_NAME "CPU"
243243
AS_EXTENSION
244244
VERSION_DEFINES_FOR src/plugin.cpp
245-
SOURCES ${SOURCES} ${HEADERS})
245+
SOURCES ${SOURCES} ${HEADERS}
246+
ADD_CLANG_FORMAT)
246247

247248
# give a different file name depending on target platform architecture
248249
if(ARM OR AARCH64)

src/plugins/intel_cpu/src/cache/cache_entry.h

+15-16
Original file line numberDiff line numberDiff line change
@@ -4,36 +4,34 @@
44

55
#pragma once
66

7-
#include <memory>
87
#include <functional>
8+
#include <memory>
9+
910
#include "lru_cache.h"
1011

1112
namespace ov {
1213
namespace intel_cpu {
1314

1415
class CacheEntryBase {
1516
public:
16-
enum class LookUpStatus : int8_t {
17-
Hit,
18-
Miss
19-
};
17+
enum class LookUpStatus : int8_t { Hit, Miss };
18+
2019
public:
2120
virtual ~CacheEntryBase() = default;
2221
};
2322

2423
/**
2524
* @brief Class represents a templated record in multi cache
26-
* @tparam KeyType is a key type that must define hash() const method with return type convertible to size_t and define comparison operator.
25+
* @tparam KeyType is a key type that must define hash() const method with return type convertible to size_t and define
26+
* comparison operator.
2727
* @tparam ValType is a type that must meet all the requirements to the std::unordered_map mapped type
28-
* @tparam ImplType is a type for the internal storage. It must provide put(KeyType, ValueType) and ValueType get(const KeyType&)
29-
* interface and must have constructor of type ImplType(size_t).
28+
* @tparam ImplType is a type for the internal storage. It must provide put(KeyType, ValueType) and ValueType get(const
29+
* KeyType&) interface and must have constructor of type ImplType(size_t).
3030
*
3131
* @note In this implementation default constructed value objects are treated as empty objects.
3232
*/
3333

34-
template<typename KeyType,
35-
typename ValType,
36-
typename ImplType = LruCache<KeyType, ValType>>
34+
template <typename KeyType, typename ValType, typename ImplType = LruCache<KeyType, ValType>>
3735
class CacheEntry : public CacheEntryBase {
3836
public:
3937
using ResultType = std::pair<ValType, LookUpStatus>;
@@ -42,11 +40,12 @@ class CacheEntry : public CacheEntryBase {
4240
explicit CacheEntry(size_t capacity) : _impl(capacity) {}
4341

4442
/**
45-
* @brief Searches the key in the underlying storage and returns value if it exists, or creates a value using the builder functor and adds it to
46-
* the underlying storage.
43+
* @brief Searches the key in the underlying storage and returns value if it exists, or creates a value using the
44+
* builder functor and adds it to the underlying storage.
4745
* @param key is the search key
4846
* @param builder is a callable object that creates the ValType object from the KeyType lval reference
49-
* @return result of the operation which is a pair of the requested object of ValType and the status of whether the cache hit or miss occurred
47+
* @return result of the operation which is a pair of the requested object of ValType and the status of whether the
48+
* cache hit or miss occurred
5049
*/
5150

5251
ResultType getOrCreate(const KeyType& key, std::function<ValType(const KeyType&)> builder) {
@@ -70,5 +69,5 @@ class CacheEntry : public CacheEntryBase {
7069
ImplType _impl;
7170
};
7271

73-
} // namespace intel_cpu
74-
} // namespace ov
72+
} // namespace intel_cpu
73+
} // namespace ov

src/plugins/intel_cpu/src/cache/lru_cache.h

+11-10
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@
1010

1111
/**
1212
* @brief This is yet another implementation of a preemptive cache with LRU eviction policy.
13-
* @tparam Key is a key type that must define hash() const method with return type convertible to size_t and define comparison operator.
13+
* @tparam Key is a key type that must define hash() const method with return type convertible to size_t and define
14+
* comparison operator.
1415
* @tparam Value is a type that must meet all the requirements to the std::unordered_map mapped type
1516
*
1617
* @attention This cache implementation IS NOT THREAD SAFE!
@@ -19,7 +20,7 @@
1920
namespace ov {
2021
namespace intel_cpu {
2122

22-
template<typename Key, typename Value>
23+
template <typename Key, typename Value>
2324
class LruCache {
2425
public:
2526
using value_type = std::pair<Key, Value>;
@@ -33,7 +34,7 @@ class LruCache {
3334
* @param value
3435
*/
3536

36-
void put(const Key &key, const Value &val) {
37+
void put(const Key& key, const Value& val) {
3738
if (0 == _capacity) {
3839
return;
3940
}
@@ -56,7 +57,7 @@ class LruCache {
5657
* @return Value associated with the key or default constructed instance of the Value type.
5758
*/
5859

59-
Value get(const Key &key) {
60+
Value get(const Key& key) {
6061
auto itr = _cacheMapper.find(key);
6162
if (itr == _cacheMapper.end()) {
6263
return Value();
@@ -82,13 +83,13 @@ class LruCache {
8283
* @brief Returns the current capacity value
8384
* @return the current capacity value
8485
*/
85-
size_t getCapacity() const noexcept {
86-
return _capacity;
87-
}
86+
size_t getCapacity() const noexcept {
87+
return _capacity;
88+
}
8889

8990
private:
9091
struct key_hasher {
91-
std::size_t operator()(const Key &k) const {
92+
std::size_t operator()(const Key& k) const {
9293
return k.hash();
9394
}
9495
};
@@ -105,5 +106,5 @@ class LruCache {
105106
size_t _capacity;
106107
};
107108

108-
} // namespace intel_cpu
109-
} // namespace ov
109+
} // namespace intel_cpu
110+
} // namespace ov

src/plugins/intel_cpu/src/cache/multi_cache.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,5 @@ namespace intel_cpu {
99

1010
std::atomic_size_t MultiCache::_typeIdCounter{0};
1111

12-
} // namespace intel_cpu
13-
} // namespace ov
12+
} // namespace intel_cpu
13+
} // namespace ov

src/plugins/intel_cpu/src/cache/multi_cache.h

+21-19
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@
44

55
#pragma once
66

7+
#include <atomic>
78
#include <functional>
89
#include <unordered_map>
9-
#include <atomic>
10+
1011
#include "cache_entry.h"
1112

1213
namespace ov {
@@ -20,27 +21,28 @@ namespace intel_cpu {
2021

2122
class MultiCache {
2223
public:
23-
template<typename KeyType, typename ValueType>
24+
template <typename KeyType, typename ValueType>
2425
using EntryTypeT = CacheEntry<KeyType, ValueType>;
2526
using EntryBasePtr = std::shared_ptr<CacheEntryBase>;
26-
template<typename KeyType, typename ValueType>
27+
template <typename KeyType, typename ValueType>
2728
using EntryPtr = std::shared_ptr<EntryTypeT<KeyType, ValueType>>;
2829

2930
public:
3031
/**
31-
* @param capacity here means maximum records limit FOR EACH entry specified by a pair of Key/Value types.
32-
* @note zero capacity means empty cache so no records are stored and no entries are created
33-
*/
32+
* @param capacity here means maximum records limit FOR EACH entry specified by a pair of Key/Value types.
33+
* @note zero capacity means empty cache so no records are stored and no entries are created
34+
*/
3435
explicit MultiCache(size_t capacity) : _capacity(capacity) {}
3536

3637
/**
37-
* @brief Searches a value of ValueType in the cache using the provided key or creates a new ValueType instance (if nothing was found)
38-
* using the key and the builder functor and adds the new record to the cache
39-
* @param key is the search key
40-
* @param builder is a callable object that creates the ValType object from the KeyType lval reference.
41-
* Also the builder type is used for the ValueType deduction
42-
* @return result of the operation which is a pair of the requested object of ValType and the status of whether the cache hit or miss occurred
43-
*/
38+
* @brief Searches a value of ValueType in the cache using the provided key or creates a new ValueType instance (if
39+
* nothing was found) using the key and the builder functor and adds the new record to the cache
40+
* @param key is the search key
41+
* @param builder is a callable object that creates the ValType object from the KeyType lval reference.
42+
* Also the builder type is used for the ValueType deduction
43+
* @return result of the operation which is a pair of the requested object of ValType and the status of whether the
44+
* cache hit or miss occurred
45+
*/
4446
template <typename KeyType,
4547
typename BuilderType,
4648
#if (defined(_MSVC_LANG) && (_MSVC_LANG > 201703L)) || (defined(__cplusplus) && (__cplusplus > 201703L))
@@ -54,9 +56,9 @@ class MultiCache {
5456
}
5557

5658
private:
57-
template<typename T>
59+
template <typename T>
5860
size_t getTypeId();
59-
template<typename KeyType, typename ValueType>
61+
template <typename KeyType, typename ValueType>
6062
EntryPtr<KeyType, ValueType> getEntry();
6163

6264
private:
@@ -65,13 +67,13 @@ class MultiCache {
6567
std::unordered_map<size_t, EntryBasePtr> _storage;
6668
};
6769

68-
template<typename T>
70+
template <typename T>
6971
size_t MultiCache::getTypeId() {
7072
static size_t id = _typeIdCounter.fetch_add(1);
7173
return id;
7274
}
7375

74-
template<typename KeyType, typename ValueType>
76+
template <typename KeyType, typename ValueType>
7577
MultiCache::EntryPtr<KeyType, ValueType> MultiCache::getEntry() {
7678
using EntryType = EntryTypeT<KeyType, ValueType>;
7779
size_t id = getTypeId<EntryType>();
@@ -88,5 +90,5 @@ using MultiCacheWeakCPtr = std::weak_ptr<const MultiCache>;
8890
using MultiCachePtr = std::shared_ptr<MultiCache>;
8991
using MultiCacheCPtr = std::shared_ptr<const MultiCache>;
9092

91-
} // namespace intel_cpu
92-
} // namespace ov
93+
} // namespace intel_cpu
94+
} // namespace ov

src/plugins/intel_cpu/src/compiled_model.cpp

+12-12
Original file line numberDiff line numberDiff line change
@@ -3,29 +3,30 @@
33
//
44

55
#include "compiled_model.h"
6+
7+
#include <cstring>
8+
#include <utility>
9+
610
#include "async_infer_request.h"
11+
#include "cpu/x64/cpu_isa_traits.hpp"
712
#include "infer_request.h"
813
#include "itt.h"
914
#include "low_precision/low_precision.hpp"
1015
#include "memory_state.h"
1116
#include "openvino/core/type/element_type.hpp"
1217
#include "openvino/runtime/intel_cpu/properties.hpp"
13-
#include "openvino/runtime/threading/executor_manager.hpp"
14-
#include "transformations/transformation_pipeline.h"
1518
#include "openvino/runtime/properties.hpp"
16-
#include "openvino/util/common_util.hpp"
19+
#include "openvino/runtime/threading/cpu_message.hpp"
1720
#include "openvino/runtime/threading/cpu_streams_executor.hpp"
18-
#include "transformations/utils/utils.hpp"
1921
#include "openvino/runtime/threading/cpu_streams_info.hpp"
20-
#include "openvino/runtime/threading/cpu_message.hpp"
22+
#include "openvino/runtime/threading/executor_manager.hpp"
23+
#include "openvino/util/common_util.hpp"
24+
#include "transformations/transformation_pipeline.h"
25+
#include "transformations/utils/utils.hpp"
2126
#include "utils/serialize.hpp"
2227

23-
#include "cpu/x64/cpu_isa_traits.hpp"
24-
#include <cstring>
25-
#include <utility>
26-
2728
#if defined(OV_CPU_WITH_ACL)
28-
#include "nodes/executors/acl/acl_ie_scheduler.hpp"
29+
# include "nodes/executors/acl/acl_ie_scheduler.hpp"
2930
#endif
3031

3132
using namespace ov::threading;
@@ -329,8 +330,7 @@ ov::Any CompiledModel::get_property(const std::string& name) const {
329330
return decltype(ov::intel_cpu::sparse_weights_decompression_rate)::value_type(
330331
config.fcSparseWeiDecompressionRate);
331332
} else if (name == ov::hint::dynamic_quantization_group_size) {
332-
return decltype(ov::hint::dynamic_quantization_group_size)::value_type(
333-
config.fcDynamicQuantizationGroupSize);
333+
return decltype(ov::hint::dynamic_quantization_group_size)::value_type(config.fcDynamicQuantizationGroupSize);
334334
} else if (name == ov::hint::kv_cache_precision) {
335335
return decltype(ov::hint::kv_cache_precision)::value_type(config.kvCachePrecision);
336336
}

src/plugins/intel_cpu/src/compiled_model.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -94,5 +94,5 @@ class CompiledModel : public ov::ICompiledModel {
9494
bool m_has_sub_compiled_models = false;
9595
};
9696

97-
} // namespace intel_cpu
98-
} // namespace ov
97+
} // namespace intel_cpu
98+
} // namespace ov

src/plugins/intel_cpu/src/config.cpp

+19-18
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,19 @@
44

55
#include "config.h"
66

7+
#include <algorithm>
8+
#include <map>
9+
#include <string>
10+
711
#include "cpu/x64/cpu_isa_traits.hpp"
812
#include "openvino/core/parallel.hpp"
913
#include "openvino/core/type/element_type_traits.hpp"
1014
#include "openvino/runtime/intel_cpu/properties.hpp"
1115
#include "openvino/runtime/internal_properties.hpp"
1216
#include "openvino/runtime/properties.hpp"
17+
#include "utils/cpu_utils.hpp"
1318
#include "utils/debug_capabilities.h"
1419
#include "utils/precision_support.h"
15-
#include "utils/cpu_utils.hpp"
16-
17-
#include <algorithm>
18-
#include <map>
19-
#include <string>
2020

2121
namespace ov {
2222
namespace intel_cpu {
@@ -61,9 +61,7 @@ Config::Config() {
6161
*/
6262
void Config::applyDebugCapsProperties() {
6363
// always enable perf counters for verbose, performance summary and average counters
64-
if (!debugCaps.verbose.empty() ||
65-
!debugCaps.summaryPerf.empty() ||
66-
!debugCaps.averageCountersPath.empty()) {
64+
if (!debugCaps.verbose.empty() || !debugCaps.summaryPerf.empty() || !debugCaps.averageCountersPath.empty()) {
6765
collectPerfCounters = true;
6866
}
6967
}
@@ -151,10 +149,10 @@ void Config::readProperties(const ov::AnyMap& prop, const ModelType modelType) {
151149
logLevel = val.as<ov::log::Level>();
152150
} catch (const ov::Exception&) {
153151
OPENVINO_THROW("Wrong value ",
154-
val.as<std::string>(),
155-
" for property key ",
156-
key,
157-
". Expected only ov::log::Level::NO/ERR/WARNING/INFO/DEBUG/TRACE.");
152+
val.as<std::string>(),
153+
" for property key ",
154+
key,
155+
". Expected only ov::log::Level::NO/ERR/WARNING/INFO/DEBUG/TRACE.");
158156
}
159157
} else if (key == ov::hint::num_requests.name()) {
160158
try {
@@ -243,8 +241,8 @@ void Config::readProperties(const ov::AnyMap& prop, const ModelType modelType) {
243241
fcDynamicQuantizationGroupSize = val.as<uint64_t>();
244242
} catch (const ov::Exception&) {
245243
OPENVINO_THROW("Wrong value for property key ",
246-
ov::hint::dynamic_quantization_group_size.name(),
247-
". Expected only unsinged integer numbers");
244+
ov::hint::dynamic_quantization_group_size.name(),
245+
". Expected only unsinged integer numbers");
248246
}
249247
} else if (key == ov::enable_profiling.name()) {
250248
try {
@@ -366,7 +364,7 @@ void Config::readProperties(const ov::AnyMap& prop, const ModelType modelType) {
366364
if (one_of(prec, ov::element::f32, ov::element::f16, ov::element::bf16, ov::element::u8)) {
367365
kvCachePrecision = prec;
368366
} else {
369-
OPENVINO_THROW("invalid value");
367+
OPENVINO_THROW("invalid value");
370368
}
371369
} catch (ov::Exception&) {
372370
OPENVINO_THROW("Wrong value ",
@@ -462,10 +460,13 @@ void Config::updateProperties() {
462460

463461
void Config::applyRtInfo(const std::shared_ptr<const ov::Model>& model) {
464462
// if user sets explicitly, it will be higher priority than rt_info
465-
if (!kvCachePrecisionSetExplicitly && model->has_rt_info({"runtime_options", ov::hint::kv_cache_precision.name()})) {
466-
this->kvCachePrecision = model->get_rt_info<ov::element::Type>({"runtime_options", ov::hint::kv_cache_precision.name()});
463+
if (!kvCachePrecisionSetExplicitly &&
464+
model->has_rt_info({"runtime_options", ov::hint::kv_cache_precision.name()})) {
465+
this->kvCachePrecision =
466+
model->get_rt_info<ov::element::Type>({"runtime_options", ov::hint::kv_cache_precision.name()});
467467
}
468-
if (!fcDynamicQuantizationGroupSizeSetExplicitly && model->has_rt_info({"runtime_options", ov::hint::dynamic_quantization_group_size.name()})) {
468+
if (!fcDynamicQuantizationGroupSizeSetExplicitly &&
469+
model->has_rt_info({"runtime_options", ov::hint::dynamic_quantization_group_size.name()})) {
469470
this->fcDynamicQuantizationGroupSize =
470471
model->get_rt_info<uint64_t>({"runtime_options", ov::hint::dynamic_quantization_group_size.name()});
471472
}

0 commit comments

Comments
 (0)