OpenVINO™ is an open source toolkit for optimizing and deploying AI inference
C++ aicomputer-visiondeep-learningdeploy-aidiffusion-modelsgenerative-aigood-first-issueinferencellm-inferencenatural-language-processingnlpopenvinooptimize-aiperformance-boostrecommendation-systemspeech-recognitionstable-diffusiontransformersyolo
[CPU][SNIPPETS] Simplify and unify SFINAE (#31430)
Egor Duplenskii1f6db97a9811
diff --git a/src/plugins/intel_cpu/src/cpu_memory.cpp b/src/plugins/intel_cpu/src/cpu_memory.cppindex f49aaaaec3f..df194aec4a9 100644--- a/src/plugins/intel_cpu/src/cpu_memory.cpp+++ b/src/plugins/intel_cpu/src/cpu_memory.cpp@@ -46,12 +46,12 @@namespace ov::intel_cpu {template <>-DnnlMemoryDescPtr IMemory::getDescWithType<DnnlMemoryDesc, 0, 0>() const {+DnnlMemoryDescPtr IMemory::getDescWithType<DnnlMemoryDesc>() const {return MemoryDescUtils::convertToDnnlMemoryDesc(getDescPtr());}template <>-BlockedMemoryDescPtr IMemory::getDescWithType<BlockedMemoryDesc, 0, 0>() const {+BlockedMemoryDescPtr IMemory::getDescWithType<BlockedMemoryDesc>() const {return MemoryDescUtils::convertToBlockedMemoryDesc(getDescPtr());}diff --git a/src/plugins/intel_cpu/src/cpu_memory.h b/src/plugins/intel_cpu/src/cpu_memory.hindex de83894def7..f9593cecc0d 100644--- a/src/plugins/intel_cpu/src/cpu_memory.h+++ b/src/plugins/intel_cpu/src/cpu_memory.h@@ -217,8 +217,8 @@ public:}template <typename T,- std::enable_if_t<!std::is_pointer_v<T> && !std::is_reference_v<T>, int> = 0,- std::enable_if_t<std::is_base_of_v<MemoryDesc, T>, int> = 0>+ typename = std::enable_if_t<!std::is_pointer_v<T> && !std::is_reference_v<T> &&+ std::is_base_of_v<MemoryDesc, T>>>[[nodiscard]] std::shared_ptr<T> getDescWithType() const;};diff --git a/src/plugins/intel_cpu/src/emitters/plugin/x64/debug_capabilities.hpp b/src/plugins/intel_cpu/src/emitters/plugin/x64/debug_capabilities.hppindex 1fff2322432..eb5e10daa59 100644--- a/src/plugins/intel_cpu/src/emitters/plugin/x64/debug_capabilities.hpp+++ b/src/plugins/intel_cpu/src/emitters/plugin/x64/debug_capabilities.hpp@@ -59,13 +59,13 @@ namespace ov::intel_cpu {class RegPrinter {public:using jit_generator_t = dnnl::impl::cpu::x64::jit_generator_t;- template <typename PRC_T, typename REG_T, std::enable_if_t<std::is_base_of_v<Xbyak::Xmm, REG_T>, int> = 0>- static void print(jit_generator_t& h, REG_T reg, const char* name = nullptr) {- print_vmm<PRC_T, REG_T>(h, reg, name);- }- template <typename PRC_T, typename REG_T, std::enable_if_t<!std::is_base_of_v<Xbyak::Xmm, REG_T>, int> = 0>+ template <typename PRC_T, typename REG_T>static void print(jit_generator_t& h, REG_T reg, const char* name = nullptr) {- print_reg<PRC_T, REG_T>(h, reg, name);+ if constexpr (std::is_base_of_v<Xbyak::Xmm, REG_T>) {+ print_vmm<PRC_T, REG_T>(h, reg, name);+ } else {+ print_reg<PRC_T, REG_T>(h, reg, name);+ }}private:diff --git a/src/plugins/intel_cpu/src/emitters/snippets/input_repacker.hpp b/src/plugins/intel_cpu/src/emitters/snippets/input_repacker.hppindex 4d27a6fb365..321767b6f53 100644--- a/src/plugins/intel_cpu/src/emitters/snippets/input_repacker.hpp+++ b/src/plugins/intel_cpu/src/emitters/snippets/input_repacker.hpp@@ -28,7 +28,7 @@ struct InputRepacker {VectorDims in_offsets,VectorDims out_offsets);- template <class T = InputRepackerKernel, std::enable_if_t<std::is_base_of_v<InputRepackerKernel, T>, bool> = true>+ template <class T = InputRepackerKernel, typename = std::enable_if_t<std::is_base_of_v<InputRepackerKernel, T>>>[[nodiscard]] std::shared_ptr<const T> kernel() const {const auto ker = std::dynamic_pointer_cast<const T>(m_kernel);OPENVINO_ASSERT(ker, "Kernel is empty!");diff --git a/src/plugins/intel_cpu/src/emitters/snippets/x64/jit_brgemm_emitter.cpp b/src/plugins/intel_cpu/src/emitters/snippets/x64/jit_brgemm_emitter.cppindex 115430b9d1a..9cc0fe84a06 100644--- a/src/plugins/intel_cpu/src/emitters/snippets/x64/jit_brgemm_emitter.cpp+++ b/src/plugins/intel_cpu/src/emitters/snippets/x64/jit_brgemm_emitter.cpp@@ -23,7 +23,6 @@#include "emitters/snippets/x64/jit_binary_call_emitter.hpp"#include "emitters/snippets/x64/kernel_executors/brgemm.hpp"#include "emitters/snippets/x64/kernel_executors/brgemm_amx.hpp"-#include "emitters/snippets/x64/kernel_executors/brgemm_base.hpp"#include "emitters/utils.hpp"#include "openvino/core/except.hpp"#include "openvino/core/node.hpp"@@ -156,7 +155,7 @@ void jit_brgemm_emitter::emit_impl(const std::vector<size_t>& in, const std::vec}}-template <typename T, std::enable_if_t<std::is_base_of_v<BrgemmBaseKernelExecutor, T>, bool>>+template <typename T, typename Enable>void jit_brgemm_emitter::emit_call(const std::vector<size_t>& mem_ptrs_idxs) const {const Xbyak::Reg64& aux_reg = get_call_address_reg();const Xbyak::Reg64& callee_saved_reg = get_callee_saved_reg();diff --git a/src/plugins/intel_cpu/src/emitters/snippets/x64/jit_brgemm_emitter.hpp b/src/plugins/intel_cpu/src/emitters/snippets/x64/jit_brgemm_emitter.hppindex 3f60116a890..6ae0b0fccf3 100644--- a/src/plugins/intel_cpu/src/emitters/snippets/x64/jit_brgemm_emitter.hpp+++ b/src/plugins/intel_cpu/src/emitters/snippets/x64/jit_brgemm_emitter.hpp@@ -42,7 +42,7 @@ private:void validate_arguments(const std::vector<size_t>& in, const std::vector<size_t>& out) const override;void emit_impl(const std::vector<size_t>& in, const std::vector<size_t>& out) const override;- template <typename T, std::enable_if_t<std::is_base_of_v<x64::BrgemmBaseKernelExecutor, T>, bool> = true>+ template <typename T, typename Enable = std::enable_if_t<std::is_base_of_v<x64::BrgemmBaseKernelExecutor, T>>>void emit_call(const std::vector<size_t>& mem_ptrs_idxs) const;// Note: offsets order: A, B, C (+ scratchpad, if needed). Values can be dynamic_value if offset is calculated indiff --git a/src/plugins/intel_cpu/src/emitters/tpp/x64/jit_eltwise_emitters.hpp b/src/plugins/intel_cpu/src/emitters/tpp/x64/jit_eltwise_emitters.hppindex cefa1528cd4..4a7d59ae611 100644--- a/src/plugins/intel_cpu/src/emitters/tpp/x64/jit_eltwise_emitters.hpp+++ b/src/plugins/intel_cpu/src/emitters/tpp/x64/jit_eltwise_emitters.hpp@@ -6,6 +6,7 @@#include <libxsmm.h>#include <libxsmm_typedefs.h>+#include <utils/general_utils.h>#include <cassert>#include <cpu/x64/cpu_isa_traits.hpp>@@ -107,9 +108,7 @@ public:private:executor_function executor{nullptr};- template <class Tin,- class Tout,- std::enable_if_t<!std::is_same_v<Tin, Tout> || !std::is_same_v<Tin, float>, bool> = true>+ template <class Tin, class Tout, typename = std::enable_if_t<!all_of_v<Tin, Tout, float>>>void evaluate_reference_impl(Tin* in0, Tout* out0) {for (int n = 0; n < m_shape.n; n++) {auto in0_row = in0;diff --git a/src/plugins/intel_cpu/src/hash_builder.hpp b/src/plugins/intel_cpu/src/hash_builder.hppindex 461795db8bb..ebbd1e2a5bb 100644--- a/src/plugins/intel_cpu/src/hash_builder.hpp+++ b/src/plugins/intel_cpu/src/hash_builder.hpp@@ -15,12 +15,12 @@ namespace ov::intel_cpu::hash {// Copyright 2005-2014 Daniel James.// Distributed under the Boost Software License, Version 1.0. (See accompanying// file LICENSE or copy at http://www.boost.org/LICENSE_1_0.txt)-template <typename T, std::enable_if_t<!std::is_enum_v<T>, int> = 0>+template <typename T, typename = std::enable_if_t<!std::is_enum_v<T>>>size_t combine(size_t seed, const T& v) {return seed ^= std::hash<T>{}(v) + 0x9e3779b9 + (seed << 6) + (seed >> 2);}-template <typename T, std::enable_if_t<std::is_enum_v<T>, int> = 0>+template <typename T, typename = std::enable_if_t<std::is_enum_v<T>>>size_t combine(size_t seed, const T& v) {using underlying_t = std::underlying_type_t<T>;return combine(seed, static_cast<underlying_t>(v));diff --git a/src/plugins/intel_cpu/src/memory_desc/cpu_memory_desc.h b/src/plugins/intel_cpu/src/memory_desc/cpu_memory_desc.hindex 7f6b1bdc329..fe3ebf0936d 100644--- a/src/plugins/intel_cpu/src/memory_desc/cpu_memory_desc.h+++ b/src/plugins/intel_cpu/src/memory_desc/cpu_memory_desc.h@@ -147,8 +147,8 @@ public:}template <typename T,- std::enable_if_t<!std::is_pointer_v<T> && !std::is_reference_v<T>, int> = 0,- std::enable_if_t<std::is_base_of_v<MemoryDesc, T>, int> = 0>+ typename = std::enable_if_t<!std::is_pointer_v<T> && !std::is_reference_v<T>>,+ typename = std::enable_if_t<std::is_base_of_v<MemoryDesc, T>>>T* as() {T* casted = dynamic_cast<T*>(this);OPENVINO_ASSERT(casted, "Cannot dynamically cast MemoryDesc");@@ -156,8 +156,8 @@ public:}template <typename T,- std::enable_if_t<!std::is_pointer_v<T> && !std::is_reference_v<T>, int> = 0,- std::enable_if_t<std::is_base_of_v<MemoryDesc, T>, int> = 0>+ typename = std::enable_if_t<!std::is_pointer_v<T> && !std::is_reference_v<T>>,+ typename = std::enable_if_t<std::is_base_of_v<MemoryDesc, T>>>const T* as() const {const T* casted = dynamic_cast<const T*>(this);OPENVINO_ASSERT(casted, "Cannot dynamically cast MemoryDesc");diff --git a/src/plugins/intel_cpu/src/node.h b/src/plugins/intel_cpu/src/node.hindex bd7d8163bdc..c360f68179b 100644--- a/src/plugins/intel_cpu/src/node.h+++ b/src/plugins/intel_cpu/src/node.h@@ -124,8 +124,8 @@ public:}template <typename T,- std::enable_if_t<!std::is_pointer_v<T> && !std::is_reference_v<T>, int> = 0,- std::enable_if_t<std::is_base_of_v<ExecutorFactoryLegacy, T>, int> = 0>+ typename = std::enable_if_t<!std::is_pointer_v<T> && !std::is_reference_v<T>>,+ typename = std::enable_if_t<std::is_base_of_v<ExecutorFactoryLegacy, T>>>std::shared_ptr<T> getExecutorFactoryAs() {auto casted = std::dynamic_pointer_cast<T>(executorFactory);OPENVINO_ASSERT(casted, "Cannot dynamically cast ExecutorFactory");diff --git a/src/plugins/intel_cpu/src/nodes/executors/mlas/mlas_transpose.cpp b/src/plugins/intel_cpu/src/nodes/executors/mlas/mlas_transpose.cppindex e2d30275be7..cfc506a27a3 100644--- a/src/plugins/intel_cpu/src/nodes/executors/mlas/mlas_transpose.cpp+++ b/src/plugins/intel_cpu/src/nodes/executors/mlas/mlas_transpose.cpp@@ -10,7 +10,6 @@#include <limits>#include <memory>#include <oneapi/dnnl/dnnl.hpp>-#include <type_traits>#include <vector>#include "cpu_memory.h"@@ -25,103 +24,70 @@namespace ov::intel_cpu {template <typename T>-struct has_mlas_transpose : std::false_type {};--template <>-struct has_mlas_transpose<uint8_t> : std::true_type {};--template <>-struct has_mlas_transpose<uint16_t> : std::true_type {};--template <>-struct has_mlas_transpose<uint32_t> : std::true_type {};+inline constexpr bool has_mlas_transpose = any_of_v<T, uint8_t, uint16_t, uint32_t>;template <typename T>-std::enable_if_t<!has_mlas_transpose<T>::value, void> SimpleTransposeSingleAxisOutwards(- const T* input_data,- T* output_data,- int64_t num_loops,- int64_t num_writers,- int64_t writes_per_loop,- int64_t writes_per_writer_per_loop) {- const T* end = nullptr;+void SimpleTransposeSingleAxisOutwards(const T* input_data,+ T* output_data,+ int64_t num_loops,+ int64_t num_writers,+ int64_t writes_per_loop,+ int64_t writes_per_writer_per_loop) {for (int64_t l = 0; l < num_loops; ++l) {- T* output_for_first_writer = output_data;- for (auto wwpl = 0; wwpl < writes_per_writer_per_loop; ++wwpl) {- T* output_for_current_writer = output_for_first_writer;- end = input_data + num_writers;- for (; input_data != end;) {- *output_for_current_writer = *input_data++;- // skip to output position for next writer- output_for_current_writer += writes_per_writer_per_loop;+ if constexpr (has_mlas_transpose<T>) {+ MlasTranspose(input_data,+ output_data,+ static_cast<size_t>(writes_per_writer_per_loop),+ static_cast<size_t>(num_writers));+ input_data += writes_per_loop;+ } else {+ T* output_for_first_writer = output_data;+ for (auto wwpl = 0; wwpl < writes_per_writer_per_loop; ++wwpl) {+ T* output_for_current_writer = output_for_first_writer;+ const T* end = input_data + num_writers;+ for (; input_data != end;) {+ *output_for_current_writer = *input_data++;+ // skip to output position for next writer+ output_for_current_writer += writes_per_writer_per_loop;+ }+ ++output_for_first_writer;}- ++output_for_first_writer;}output_data += writes_per_loop;}}template <typename T>-std::enable_if_t<has_mlas_transpose<T>::value, void> SimpleTransposeSingleAxisOutwards(- const T* input_data,- T* output_data,- int64_t num_loops,- int64_t num_writers,- int64_t writes_per_loop,- int64_t writes_per_writer_per_loop) {+void SimpleTransposeSingleAxisInwards(const T* input_data,+ T* output_data,+ int64_t num_loops,+ int64_t num_readers,+ int64_t reads_per_loop,+ int64_t reads_per_reader_per_loop) {for (int64_t l = 0; l < num_loops; ++l) {- MlasTranspose(input_data,- output_data,- static_cast<size_t>(writes_per_writer_per_loop),- static_cast<size_t>(num_writers));- input_data += writes_per_loop;- output_data += writes_per_loop;- }-}--template <typename T>-std::enable_if_t<!has_mlas_transpose<T>::value, void> SimpleTransposeSingleAxisInwards(- const T* input_data,- T* output_data,- int64_t num_loops,- int64_t num_readers,- int64_t reads_per_loop,- int64_t reads_per_reader_per_loop) {- T* end = nullptr;- for (int64_t l = 0; l < num_loops; ++l) {- const T* input_for_first_reader = input_data;- for (auto rrpl = 0; rrpl < reads_per_reader_per_loop; ++rrpl) {- const T* input_for_current_reader = input_for_first_reader;- end = output_data + num_readers;- for (; output_data != end;) {- *output_data++ = *input_for_current_reader;- // skip to input position for next reader- input_for_current_reader += reads_per_reader_per_loop;+ if constexpr (has_mlas_transpose<T>) {+ MlasTranspose(input_data,+ output_data,+ static_cast<size_t>(num_readers),+ static_cast<size_t>(reads_per_reader_per_loop));+ output_data += reads_per_loop;+ } else {+ const T* input_for_first_reader = input_data;+ for (auto rrpl = 0; rrpl < reads_per_reader_per_loop; ++rrpl) {+ const T* input_for_current_reader = input_for_first_reader;+ const T* end = output_data + num_readers;+ for (; output_data != end;) {+ *output_data++ = *input_for_current_reader;+ // skip to input position for next reader+ input_for_current_reader += reads_per_reader_per_loop;+ }+ ++input_for_first_reader;}- ++input_for_first_reader;}input_data += reads_per_loop;}}-template <typename T>-std::enable_if_t<has_mlas_transpose<T>::value, void> SimpleTransposeSingleAxisInwards(- const T* input_data,- T* output_data,- int64_t num_loops,- int64_t num_readers,- int64_t reads_per_loop,- int64_t reads_per_reader_per_loop) {- for (int64_t l = 0; l < num_loops; ++l) {- MlasTranspose(input_data,- output_data,- static_cast<size_t>(num_readers),- static_cast<size_t>(reads_per_reader_per_loop));- input_data += reads_per_loop;- output_data += reads_per_loop;- }-}-int64_t MlasTransposeExecutor::calcShapeSize(const Shape& shape, size_t start, size_t end) {int64_t size = 1;for (size_t i = start; i < end; i++) {diff --git a/src/plugins/intel_cpu/src/nodes/kernels/scaled_attn/attn_quant_kernel.hpp b/src/plugins/intel_cpu/src/nodes/kernels/scaled_attn/attn_quant_kernel.hppindex 4b3a39d4166..6fb902598de 100644--- a/src/plugins/intel_cpu/src/nodes/kernels/scaled_attn/attn_quant_kernel.hpp+++ b/src/plugins/intel_cpu/src/nodes/kernels/scaled_attn/attn_quant_kernel.hpp@@ -5,6 +5,7 @@#include "nodes/kernels/scaled_attn/common.hpp"#include "openvino/core/type/element_type.hpp"+#include "utils/general_utils.h"#include "utils/plain_tensor.hpp"#if defined(HAVE_SSE) || defined(HAVE_AVX2) || defined(HAVE_AVX512F)# include <immintrin.h>@@ -532,7 +533,7 @@ void quantize_q_by_dims(const ov::intel_cpu::PlainTensor& src,template <typename TDST,ov::element::Type_t SRC_PREC,- typename std::enable_if<SRC_PREC == ov::element::u8, bool>::type = true>+ typename std::enable_if_t<SRC_PREC == ov::element::u8, bool> = true>void attn_dequant_kernel(const void* src, TDST* dst, size_t n, float* params) {size_t i = 0;// loadu_si128/epi64 does not support const qualifier@@ -571,7 +572,7 @@ void attn_dequant_kernel(const void* src, TDST* dst, size_t n, float* params) {template <typename TDST,ov::element::Type_t SRC_PREC,- typename std::enable_if<SRC_PREC == ov::element::i8, bool>::type = true>+ typename std::enable_if_t<SRC_PREC == ov::element::i8, bool> = true>void attn_dequant_kernel(const void* src, TDST* dst, size_t n, float* params) {size_t i = 0;// loadu_si128/epi64 does not support const qualifier@@ -811,4 +812,4 @@ void inline attn_dequant_u8_kernel(const uint8_t* src, float* dst, size_t n, flo}#endif-} // namespace ov::Extensions::Cpu::XARCH\ No newline at end of file+} // namespace ov::Extensions::Cpu::XARCHdiff --git a/src/plugins/intel_cpu/src/nodes/kernels/scaled_attn/executor_pa.cpp b/src/plugins/intel_cpu/src/nodes/kernels/scaled_attn/executor_pa.cppindex 39397afb179..e09e1924030 100644--- a/src/plugins/intel_cpu/src/nodes/kernels/scaled_attn/executor_pa.cpp+++ b/src/plugins/intel_cpu/src/nodes/kernels/scaled_attn/executor_pa.cpp@@ -106,7 +106,7 @@ void transpose_16NxK(TDST* dst,# if defined(HAVE_AVX512F)template <typename T,ov::element::Type_t SRC_PREC,- typename std::enable_if<(SRC_PREC == ov::element::bf16 || SRC_PREC == ov::element::f16) &&+ typename std::enable_if<any_of(SRC_PREC, ov::element::bf16, ov::element::f16) &&(SRC_PREC == precision_of<T>::value),bool>::type = true>static void transpose_16NxK(T* dst,@@ -171,7 +171,7 @@ void transpose_16NxK(TDST* dst,size_t src_offset = 0;size_t dst_offset = 0;while (dst_offset < K) {- auto params = reinterpret_cast<float*>(s + src_offset);+ auto* params = reinterpret_cast<float*>(s + src_offset);attn_dequant_kernel<TDST, SRC_PREC>(s + src_offset + sizeof(float) * param_count,t + dst_offset,group_size,@@ -228,7 +228,7 @@ static inline void dequant(float* dst,template <typename TDST,ov::element::Type_t SRC_PREC,- std::enable_if_t<SRC_PREC == ov::element::u4 || SRC_PREC == ov::element::u8, bool> = true>+ std::enable_if_t<any_of(SRC_PREC, ov::element::u4, ov::element::u8), bool> = true>void dequant(TDST* dst,void* src,const size_t N,@@ -254,7 +254,7 @@ void dequant(TDST* dst,size_t src_offset = 0;size_t dst_offset = 0;while (dst_offset < K) {- auto params = reinterpret_cast<float*>(s + src_offset);+ auto* params = reinterpret_cast<float*>(s + src_offset);attn_dequant_kernel<TDST, SRC_PREC>(s + src_offset + params_offset,dst + dst_offset,group_size,@@ -275,7 +275,7 @@ void dequant(TDST* dst,# if defined(HAVE_AVX512F)template <typename T,- typename = typename std::enable_if<(std::is_same_v<T, ov::bfloat16> || std::is_same_v<T, ov::float16>), bool>::type>+ typename = typename std::enable_if_t<(std::is_same_v<T, ov::bfloat16> || std::is_same_v<T, ov::float16>), bool>>static void pack_32x32_kernel(T* dst, T* src, size_t dst_stride, size_t src_stride) {static const uint64_t idx[8] = {0, 4, 1, 5, 2, 6, 3, 7};auto midx = _mm512_loadu_si512(idx);@@ -299,7 +299,7 @@ static void pack_32x32_kernel(T* dst, T* src, size_t dst_stride, size_t src_stritemplate <typename T,- typename = typename std::enable_if<(std::is_same_v<T, ov::bfloat16> || std::is_same_v<T, ov::float16>), bool>::type>+ typename = typename std::enable_if_t<(std::is_same_v<T, ov::bfloat16> || std::is_same_v<T, ov::float16>), bool>>static void pack_32x16_kernel(T* dst, T* src, size_t dst_stride, size_t src_stride) {static const uint64_t idx[8] = {0, 4, 1, 5, 2, 6, 3, 7};auto midx = _mm512_loadu_si512(idx);@@ -320,7 +320,7 @@ static void pack_32x16_kernel(T* dst, T* src, size_t dst_stride, size_t src_stritemplate <typename T,- typename = typename std::enable_if<(std::is_same_v<T, ov::bfloat16> || std::is_same_v<T, ov::float16>), bool>::type>+ typename = typename std::enable_if_t<(std::is_same_v<T, ov::bfloat16> || std::is_same_v<T, ov::float16>), bool>>static void pack_32xK_kernel(T* dst, T* src, size_t dst_stride, size_t src_stride, size_t K) {static const uint64_t idx[8] = {0, 4, 1, 5, 2, 6, 3, 7};auto midx = _mm512_loadu_si512(idx);@@ -341,9 +341,9 @@ static void pack_32xK_kernel(T* dst, T* src, size_t dst_stride, size_t src_stridtemplate <typename TDST,ov::element::Type_t SRC_PREC,- typename std::enable_if<precision_of<TDST>::value != ov::element::f32 &&- (SRC_PREC == ov::element::bf16 || SRC_PREC == ov::element::f16),- bool>::type = true>+ typename std::enable_if_t<precision_of<TDST>::value != ov::element::f32 &&+ any_of(SRC_PREC, ov::element::bf16, ov::element::f16),+ bool> = true>static void pack_32NxK(TDST* dst,void* src,TDST* tmp,@@ -855,8 +855,8 @@ struct MHAHelper {# if defined(OPENVINO_ARCH_X86_64)auto* q_ptr = _quantized_q.ptr<int8_t>(ithr);auto* k_ptr = qk_scratch_b.ptr<int8_t>(k_blk, hk);- int32_t* temp_C = reinterpret_cast<int32_t*>(_output.ptr<float>(ithr, 0, 0, 0));- float* scale_b = reinterpret_cast<float*>(qk_scratch_b.ptr<int8_t>(k_blk, hk, _block_size * S));+ auto* temp_C = reinterpret_cast<int32_t*>(_output.ptr<float>(ithr, 0, 0, 0));+ auto* scale_b = reinterpret_cast<float*>(qk_scratch_b.ptr<int8_t>(k_blk, hk, _block_size * S));float* dst_f32 = c_ptr + k_blk * _block_size;_qk_gemm[q_cnt - 1]->executeGemm(q_cnt < _block_size,q_ptr + sizeof(float),@@ -1524,13 +1524,13 @@ struct MHA {const auto batch_in_seq = item.batch_in_seq;const auto batch_in_reorder = item.batch_in_reorder;const auto kv_block = item.kv_block_id;- auto block_number =+ const auto block_number =block_indices.ptr<int32_t>()[block_indices_begins.ptr<int32_t>()[batch_in_seq] + kv_block];if (block_number < 0) {return;}- size_t ithr = static_cast<size_t>(parallel_get_thread_num());+ const auto ithr = static_cast<size_t>(parallel_get_thread_num());const size_t valid_len = item.valid_block_len;if (_helper._params.is_sage_attn) {# if defined(OPENVINO_ARCH_X86_64)@@ -1640,7 +1640,7 @@ struct MHA {const auto batch_in_seq = item.batch_in_seq;const auto batch_in_token = subsequence_begins.ptr<int32_t>()[batch_in_seq];const auto q_len = static_cast<size_t>(item.q_len);- size_t ithr = static_cast<size_t>(parallel_get_thread_num());+ const auto ithr = static_cast<size_t>(parallel_get_thread_num());if (q_len == 1) {const auto cur_kv_len = static_cast<size_t>(past_lens.ptr<int32_t>()[batch_in_seq]) + 1;@@ -2040,8 +2040,7 @@ struct AttentionExecutor : public PagedAttentionExecutor {// Only K entries are needed to be rotated, since position is encoded at the Q^T @ (effective_RoPE_matrix) @// K matrix multiplicationrotation_deltas.assert_dims({rotated_block_indices.size(0), 0}, /* special_zero = */ true);- OPENVINO_ASSERT(rotation_deltas.shape()[1] == 1 ||- rotation_deltas.shape()[1] == block_size); // per-block or per-token granularity+ OPENVINO_ASSERT(any_of(rotation_deltas.shape()[1], 1U, block_size)); // per-block or per-token granularityrotation_trig_lut.assert_dims({0, S}, /* special_zero = */ true);init_rotation_coefficient_scratch = true;}@@ -2316,7 +2315,7 @@ std::shared_ptr<PagedAttentionExecutor> make_pa_executor(ov::element::Type data_value_cache_type);executor = std::make_shared<AttentionExecutor<float, ov::element::f16, ov::element::f16>>(params);} else {- OPENVINO_ASSERT(key_cache_type == ov::element::f32 && value_cache_type == ov::element::f32,+ OPENVINO_ASSERT(all_of(ov::element::f32, key_cache_type, value_cache_type),"expect kvcache type f32, current: ",key_cache_type," , ",diff --git a/src/plugins/intel_cpu/src/nodes/kernels/scaled_attn/paged_attn_kernel.hpp b/src/plugins/intel_cpu/src/nodes/kernels/scaled_attn/paged_attn_kernel.hppindex aa42ce9fc74..49062da4ee5 100644--- a/src/plugins/intel_cpu/src/nodes/kernels/scaled_attn/paged_attn_kernel.hpp+++ b/src/plugins/intel_cpu/src/nodes/kernels/scaled_attn/paged_attn_kernel.hpp@@ -26,7 +26,7 @@ template <std::enable_if_t<(std::is_same_v<T, ov::bfloat16> || std::is_same_v<T, ov::float16> || std::is_same_v<T, float>),bool> = true>void attn_acc_value_block(float* out,- float* weight,+ const float* weight,T* v,const size_t S,const size_t block_size,@@ -160,7 +160,7 @@ void attn_acc_value_block(float* out,}template <typename T, ov::element::Type_t SRC_PREC, std::enable_if_t<SRC_PREC == ov::element::u8, bool> = true>void attn_acc_value_block_by_dim(float* out,- float* weight,+ const float* weight,uint8_t* v,const size_t S,const size_t block_size,@@ -327,7 +327,7 @@ void attn_acc_value_block_by_dim(float* out,dst_offset = 0;src_offset = 0;while (dst_offset < S) {- auto v0 = reinterpret_cast<float*>(v + src_offset);+ auto* v0 = reinterpret_cast<float*>(v + src_offset);for (size_t i = 0; i < group_size; i++) {out[dst_offset + i] += weight[j] * (v[i + src_offset + params_offset] - v0[1]) * v0[0];}@@ -341,7 +341,7 @@ void attn_acc_value_block_by_dim(float* out,template <typename T, ov::element::Type_t SRC_PREC, std::enable_if_t<SRC_PREC == ov::element::u4, bool> = true>void attn_acc_value_block_by_dim(float* out,- float* weight,+ const float* weight,uint8_t* v_ptr,const size_t S,const size_t block_size,@@ -355,7 +355,7 @@ void attn_acc_value_block_by_dim(float* out,dst_offset = 0;src_offset = 0;while (dst_offset < S) {- auto v0 = reinterpret_cast<float*>(v_ptr + src_offset);+ auto* v0 = reinterpret_cast<float*>(v_ptr + src_offset);size_t i = 0;#if defined(HAVE_AVX512F)auto attn_w_vec0 = _mm512_set1_ps(weight[j] * v0[0]);@@ -433,10 +433,14 @@ void attn_acc_value_block_by_dim(float* out,}template <typename T, ov::element::Type_t SRC_PREC, std::enable_if_t<SRC_PREC == ov::element::u8, bool> = true>-void attn_acc_value_block_by_channel(float* out, float* weight, void* v, const size_t S, const size_t block_size) {- auto p_scales = reinterpret_cast<float*>(v);- auto p_zps = p_scales + S;- auto v_data_ptr = reinterpret_cast<uint8_t*>(v) + 2 * sizeof(float) * S;+void attn_acc_value_block_by_channel(float* out,+ const float* weight,+ void* v,+ const size_t S,+ const size_t block_size) {+ auto* p_scales = reinterpret_cast<float*>(v);+ auto* p_zps = p_scales + S;+ auto* v_data_ptr = reinterpret_cast<uint8_t*>(v) + 2 * sizeof(float) * S;size_t src_stride = S;size_t j = 0;for (; j + 4 <= block_size; j += 4) {@@ -521,10 +525,14 @@ void attn_acc_value_block_by_channel(float* out, float* weight, void* v, const s}template <typename T, ov::element::Type_t SRC_PREC, std::enable_if_t<SRC_PREC == ov::element::u4, bool> = true>-void attn_acc_value_block_by_channel(float* out, float* weight, void* v, const size_t S, const size_t block_size) {- auto p_scales = reinterpret_cast<float*>(v);- auto p_zps = p_scales + S;- auto v_data_ptr = reinterpret_cast<uint8_t*>(v) + 2 * sizeof(float) * S;+void attn_acc_value_block_by_channel(float* out,+ const float* weight,+ void* v,+ const size_t S,+ const size_t block_size) {+ auto* p_scales = reinterpret_cast<float*>(v);+ auto* p_zps = p_scales + S;+ auto* v_data_ptr = reinterpret_cast<uint8_t*>(v) + 2 * sizeof(float) * S;size_t src_stride = S / get_sub_byte_multiplier(SRC_PREC);size_t j = 0;for (; j + 4 <= block_size; j += 4) {@@ -685,7 +693,7 @@ void attn_acc_value_block_by_channel(float* out, float* weight, void* v, const stemplate <typename TA,ov::element::Type_t SRC_PREC,- std::enable_if_t<(SRC_PREC == ov::element::u8 || SRC_PREC == ov::element::u4), bool> = true>+ std::enable_if_t<(ov::intel_cpu::any_of(SRC_PREC, ov::element::u8, ov::element::u4)), bool> = true>void attn_acc_value_block_quantized(float* out,float* weight,uint8_t* v,@@ -826,10 +834,10 @@ template <typename TA, ov::element::Type_t SRC_PREC, std::enable_if_t<(SRC_PRECvoid dot_product_block_quantized_by_channel(TA* a, uint8_t* b, float* c, const size_t n, const size_t block_size) {const size_t params_offset = sizeof(float) * 2 * n;const size_t src_stride = n;- auto p_scales = reinterpret_cast<float*>(b);- auto p_zps = p_scales + n;+ auto* p_scales = reinterpret_cast<float*>(b);+ auto* p_zps = p_scales + n;for (size_t j = 0; j < block_size; j++) {- float sum = 0.0f;+ float sum = 0.0F;size_t i = 0;#if defined(HAVE_AVX512F)auto v512_sum0 = _mm512_set1_ps(0.0f);@@ -1040,10 +1048,10 @@ void dot_product_block_quantized_by_channel(TA* a, uint8_t* b, float* c, const sconst size_t params_offset = sizeof(float) * 2 * n;// src_stride must / 2 because of u4const size_t src_stride = n / sub_byte_multiplier;- auto p_scales = reinterpret_cast<float*>(b);- auto p_zps = p_scales + n;+ auto* p_scales = reinterpret_cast<float*>(b);+ auto* p_zps = p_scales + n;for (size_t j = 0; j < block_size; j++) {- float sum = 0.0f;+ float sum = 0.0F;size_t i = 0;#if defined(HAVE_AVX512F)auto v512_sum0 = _mm512_set1_ps(0.0f);@@ -1312,8 +1320,8 @@ void dot_product_block_quantized_by_dims(TA* a,dst_offset = 0;src_offset = 0;while (dst_offset < n) {- auto b0 = reinterpret_cast<float*>(b_src + src_offset);- float group_sum = 0.0f;+ auto* b0 = reinterpret_cast<float*>(b_src + src_offset);+ float group_sum = 0.0F;for (size_t i = 0; i < group_size; i++) {group_sum += a[dst_offset + i] * (b_src[src_offset + params_offset + i]);}@@ -1586,8 +1594,8 @@ void dot_product_block_quantized_by_dims(TA* a,dst_offset = 0;src_offset = 0;while (dst_offset < n) {- auto b0 = reinterpret_cast<float*>(b + src_offset);- float group_sum = 0.0f;+ auto* b0 = reinterpret_cast<float*>(b + src_offset);+ float group_sum = 0.0F;for (size_t i = 0; i < group_size; i++) {group_sum += a[dst_offset + i] * (b[src_offset + params_offset + i] - b0[1]);}@@ -1829,8 +1837,8 @@ void dot_product_block_quantized_by_dims(TA* a,dst_offset = 0;src_offset = 0;while (dst_offset < n) {- auto b0 = reinterpret_cast<float*>(b + src_offset);- float group_sum = 0.0f;+ auto* b0 = reinterpret_cast<float*>(b + src_offset);+ float group_sum = 0.0F;for (size_t i = 0; i < group_size; i += 2) {uint8_t data = b[i / 2 + src_offset + params_offset];float tmp0 = extract_half_byte(data, static_cast<bool>(i % 2));@@ -1896,7 +1904,7 @@ void attn_reduce(T* dst, float* temp, size_t M, size_t S, size_t temp_stride) {#endiffor (; i < S; i++) {auto* src = temp + i;- float sum = 0.0f;+ float sum = 0.0F;// sum result from all threads partitionfor (size_t m = 0; m < M; m++) {sum += src[0];@@ -1906,4 +1914,4 @@ void attn_reduce(T* dst, float* temp, size_t M, size_t S, size_t temp_stride) {}}-} // namespace ov::Extensions::Cpu::XARCH\ No newline at end of file+} // namespace ov::Extensions::Cpu::XARCHdiff --git a/src/plugins/intel_cpu/src/nodes/kernels/scaled_attn/softmax_kernel.hpp b/src/plugins/intel_cpu/src/nodes/kernels/scaled_attn/softmax_kernel.hppindex 5d59e3ad766..733765a4732 100644--- a/src/plugins/intel_cpu/src/nodes/kernels/scaled_attn/softmax_kernel.hpp+++ b/src/plugins/intel_cpu/src/nodes/kernels/scaled_attn/softmax_kernel.hpp@@ -14,6 +14,7 @@#include "openvino/core/type/bfloat16.hpp"#include "openvino/core/type/element_type.hpp"#include "openvino/core/type/float16.hpp"+#include "utils/general_utils.h"#if defined(HAVE_AVX2) || defined(HAVE_AVX512F)# include <immintrin.h>@@ -956,8 +957,7 @@ inline void multiply_scalar(float* a, float* a_dst, const float val, const size_}}-template <typename T,- typename = std::enable_if_t<(std::is_same_v<T, ov::bfloat16> || std::is_same_v<T, ov::float16>), bool>>+template <typename T, typename = std::enable_if_t<ov::intel_cpu::any_of_v<T, ov::bfloat16, ov::float16>>>inline void multiply_scalar(float* a, T* a_dst, const float val, const size_t size) {size_t i = 0;#if defined(HAVE_AVX512F)diff --git a/src/plugins/intel_cpu/src/nodes/kernels/x64/mlp_kernel.cpp b/src/plugins/intel_cpu/src/nodes/kernels/x64/mlp_kernel.cppindex 1702e162797..a387000aa32 100644--- a/src/plugins/intel_cpu/src/nodes/kernels/x64/mlp_kernel.cpp+++ b/src/plugins/intel_cpu/src/nodes/kernels/x64/mlp_kernel.cpp@@ -23,6 +23,7 @@#include "openvino/core/parallel.hpp"#include "openvino/core/type/bfloat16.hpp"#include "openvino/core/type/float16.hpp"+#include "utils/general_utils.h"using namespace dnnl::impl;using namespace dnnl::impl::utils;@@ -316,9 +317,8 @@ public:}};-template <typename Tdst>-static std::enable_if_t<std::is_same_v<ov::bfloat16, Tdst> || std::is_same_v<ov::float16, Tdst>>-repackB(Tdst* dst, ov::float16* src, int N_stride, int N, int K) {+template <typename Tdst, typename = std::enable_if_t<any_of_v<Tdst, ov::bfloat16, ov::float16>>>+static void repackB(Tdst* dst, ov::float16* src, int N_stride, int N, int K) {static FP16ToBF16Kernel fp16_to_bf16;if (N == 16 && K == 32) {// SIMD optimized versiondiff --git a/src/plugins/intel_cpu/src/nodes/random_uniform.cpp b/src/plugins/intel_cpu/src/nodes/random_uniform.cppindex 2a082127d98..7490c03050c 100644--- a/src/plugins/intel_cpu/src/nodes/random_uniform.cpp+++ b/src/plugins/intel_cpu/src/nodes/random_uniform.cpp@@ -512,7 +512,7 @@ inline void runPhilox(uint64_t key, uint64_t counter, uint64_t n, uint32_t* res)inline void convertToOutputTypePhilox(const uint32_t* in, float min, float range, float* out, size_t el_to_copy) {for (size_t i = 0LU; i < el_to_copy; i++) {uint32_t bits = 0x3f800000 | (in[i] & 0x7fffffU);- float f = ov::intel_cpu::bit_cast<float>(bits);+ const auto f = ov::intel_cpu::bit_cast<float>(bits);out[i] = (f - 1.F) * range + min;}}@@ -521,7 +521,7 @@ inline void convertToOutputTypePhilox(const uint32_t* in, float16 min, float16 rfor (size_t i = 0LU; i < el_to_copy; i++) {auto x_uint16 = static_cast<uint16_t>(in[i]);uint16_t bits = 0x3c00 | (x_uint16 & 0x03ffU);- float16 f = ov::intel_cpu::bit_cast<float16>(bits);+ const auto f = ov::intel_cpu::bit_cast<float16>(bits);out[i] = (f - static_cast<float16>(1)) * range + min;}}@@ -534,7 +534,7 @@ inline void convertToOutputTypePhilox(const uint32_t* in,for (size_t i = 0LU; i < el_to_copy; i++) {auto x_uint16 = static_cast<uint16_t>(in[i]);uint16_t bits = 0x3f80 | (x_uint16 & 0x7fU);- bfloat16 f = ov::intel_cpu::bit_cast<bfloat16>(bits);+ const auto f = ov::intel_cpu::bit_cast<bfloat16>(bits);out[i] = (f - static_cast<bfloat16>(1)) * range + min;}}diff --git a/src/plugins/intel_cpu/src/shape_inference/static_shape.hpp b/src/plugins/intel_cpu/src/shape_inference/static_shape.hppindex 76ca40a10b6..4c77a045793 100644--- a/src/plugins/intel_cpu/src/shape_inference/static_shape.hpp+++ b/src/plugins/intel_cpu/src/shape_inference/static_shape.hpp@@ -19,6 +19,7 @@#include "openvino/core/rank.hpp"#include "openvino/core/shape.hpp"#include "static_dimension.hpp"+#include "utils/general_utils.h"namespace ov {namespace op {@@ -38,7 +39,7 @@ using StaticShape = StaticShapeAdapter<VectorDims>;template <class T>constexpr bool is_static_shape_adapter() {using U = std::decay_t<T>;- return std::is_same_v<U, StaticShapeRef> || std::is_same_v<U, StaticShape>;+ return ov::intel_cpu::any_of_v<U, StaticShapeRef, StaticShape>;}// NOLINTBEGIN(google-explicit-constructor)@@ -109,14 +110,14 @@ public:return !is_static();}- template <class T>- constexpr std::enable_if_t<is_static_shape_adapter<T>(), bool> compatible(const T& other) const {+ template <class T, typename = std::enable_if_t<is_static_shape_adapter<T>()>>+ constexpr bool compatible(const T& other) const {// for static shape compatible == both shape equalsreturn *this == other;}- template <class T>- constexpr std::enable_if_t<is_static_shape_adapter<T>(), bool> same_scheme(const T& other) const {+ template <class T, typename = std::enable_if_t<is_static_shape_adapter<T>()>>+ constexpr bool same_scheme(const T& other) const {// for static shape same_scheme == compatible;return compatible(other);}@@ -257,14 +258,14 @@ public:return !is_static();}- template <class T>- [[nodiscard]] constexpr std::enable_if_t<is_static_shape_adapter<T>(), bool> compatible(const T& other) const {+ template <class T, typename = std::enable_if_t<is_static_shape_adapter<T>()>>+ [[nodiscard]] constexpr bool compatible(const T& other) const {// for static shape compatible == both shape equalsreturn *this == other;}- template <class T>- constexpr std::enable_if_t<is_static_shape_adapter<T>(), bool> same_scheme(const T& other) const {+ template <class T, typename = std::enable_if_t<is_static_shape_adapter<T>()>>+ constexpr bool same_scheme(const T& other) const {// for static shape same_scheme == compatible;return compatible(other);}@@ -305,11 +306,10 @@ public:private:const TDims* m_dims = nullptr;};-// NOLINTEND(google-explicit-constructor)-template <class T>-std::enable_if_t<is_static_shape_adapter<T>(), std::ostream&> operator<<(std::ostream& out, const T& shape) {+template <class T, typename = std::enable_if_t<is_static_shape_adapter<T>()>>+std::ostream& operator<<(std::ostream& out, const T& shape) {out << '{';if (!shape.empty()) {std::copy(shape.cbegin(), shape.cend() - 1, std::ostream_iterator<StaticDimension>(out, ","));@@ -319,10 +319,8 @@ std::enable_if_t<is_static_shape_adapter<T>(), std::ostream&> operator<<(std::osreturn out;}-template <class T, class U>-constexpr std::enable_if_t<is_static_shape_adapter<T>() && is_static_shape_adapter<U>(), bool> operator==(- const T& lhs,- const U& rhs) {+template <class T, class U, typename = std::enable_if_t<is_static_shape_adapter<T>() && is_static_shape_adapter<U>()>>+constexpr bool operator==(const T& lhs, const U& rhs) {// The CPU dimension type and StaticDimension::value_type is same,// use CPU dimension type to compare in order to reduce number of conversions to StaticDimension.return (lhs.size() == rhs.size()) && (lhs.empty() || std::equal(lhs.cbegin(), lhs.cend(), rhs.cbegin()));diff --git a/src/plugins/intel_cpu/src/transformations/snippets/x64/op/brgemm_utils.hpp b/src/plugins/intel_cpu/src/transformations/snippets/x64/op/brgemm_utils.hppindex b6b14885316..704c45b112a 100644--- a/src/plugins/intel_cpu/src/transformations/snippets/x64/op/brgemm_utils.hpp+++ b/src/plugins/intel_cpu/src/transformations/snippets/x64/op/brgemm_utils.hpp@@ -16,6 +16,7 @@#include "snippets/op/subgraph.hpp"#include "snippets/shape_types.hpp"#include "snippets/utils/utils.hpp"+#include "utils/general_utils.h"namespace ov {@@ -132,16 +133,14 @@ inline bool is_i8_supported() {namespace repacking {/// \brief Computes Blocked (N/K) dim in output blocked shape of BrgemmCopyB-template <typename T,- typename = typename std::enable_if_t<(std::is_same_v<T, size_t> || std::is_same_v<T, int64_t>), bool>>+template <typename T, typename = std::enable_if_t<ov::intel_cpu::any_of_v<T, size_t, int64_t>>>inline T compute_blocked_dim(T dim, size_t blk) {assert(!ov::snippets::utils::is_dynamic_value(blk) && "blk cannot be dynamic");return ov::snippets::utils::rnd_up(dim, static_cast<T>(blk));}/// \brief Computes stride for N dim in blocked shape-template <typename T,- typename = typename std::enable_if_t<(std::is_same_v<T, size_t> || std::is_same_v<T, int64_t>), bool>>+template <typename T, typename = std::enable_if_t<ov::intel_cpu::any_of_v<T, size_t, int64_t>>>inline T compute_N_blocked_stride(T K, size_t wei_k_blk, const ov::element::Type& prc, bool are_wei_blocked) {// - if weights are not in blocked format, account for the VNNI format// - if weights are blocked, account for zero padding in K dimension@@ -159,8 +158,7 @@ inline T compute_N_blocked_stride(T K, size_t wei_k_blk, const ov::element::Type}/// \brief Computes stride for K dim in blocked shape-template <typename T,- typename = typename std::enable_if_t<(std::is_same_v<T, size_t> || std::is_same_v<T, int64_t>), bool>>+template <typename T, typename = std::enable_if_t<ov::intel_cpu::any_of_v<T, size_t, int64_t>>>inline T compute_K_blocked_stride(T N, size_t wei_n_blk, bool are_wei_blocked) {assert(!ov::snippets::utils::is_dynamic_value(wei_n_blk) && "wei_n_blk cannot be dynamic");return are_wei_blocked ? wei_n_blk : compute_blocked_dim(N, wei_n_blk);diff --git a/src/plugins/intel_cpu/src/utils/bfloat16.hpp b/src/plugins/intel_cpu/src/utils/bfloat16.hppindex 04d429f1e69..fe10ed7fb8a 100644--- a/src/plugins/intel_cpu/src/utils/bfloat16.hpp+++ b/src/plugins/intel_cpu/src/utils/bfloat16.hpp@@ -8,7 +8,7 @@#include <cstdint>#include <limits>-#include "utils/cpp/bit_cast.hpp"+#include "cpp/bit_cast.hpp"/*** The bfloat16_t class can be used as an arithmetic type. All arithmetic operations goes through conversion to the@@ -51,17 +51,17 @@ public:}static uint16_t round_to_nearest_even(float x) {- uint32_t bits = ov::intel_cpu::bit_cast<uint32_t>(x);+ auto bits = ov::intel_cpu::bit_cast<uint32_t>(x);return static_cast<uint16_t>((bits + ((bits & 0x00010000U) >> 1)) >> 16);}static uint16_t round_to_nearest(float x) {- uint32_t bits = ov::intel_cpu::bit_cast<uint32_t>(x);+ auto bits = ov::intel_cpu::bit_cast<uint32_t>(x);return static_cast<uint16_t>((bits + 0x8000U) >> 16);}static uint16_t truncate(float x) {- uint32_t bits = ov::intel_cpu::bit_cast<uint32_t>(x);+ auto bits = ov::intel_cpu::bit_cast<uint32_t>(x);return static_cast<uint16_t>(bits >> 16);}diff --git a/src/plugins/intel_cpu/src/utils/cpp/bit_cast.hpp b/src/plugins/intel_cpu/src/utils/cpp/bit_cast.hppindex 99c5063c8fe..b3b5a49b879 100644--- a/src/plugins/intel_cpu/src/utils/cpp/bit_cast.hpp+++ b/src/plugins/intel_cpu/src/utils/cpp/bit_cast.hpp@@ -15,11 +15,11 @@ namespace ov::intel_cpu {#if defined(OPENVINO_CPP_VER_AT_LEAST_20)using std::bit_cast;#else-template <typename To, typename From>-inline std::enable_if_t<sizeof(To) == sizeof(From) && std::is_trivially_copyable_v<From> &&- std::is_trivially_copyable_v<To>,- To>-bit_cast(const From& src) noexcept {+template <typename To,+ typename From,+ typename = std::enable_if_t<sizeof(To) == sizeof(From) && std::is_trivially_copyable_v<From> &&+ std::is_trivially_copyable_v<To>>>+To bit_cast(const From& src) noexcept {static_assert(std::is_trivially_constructible_v<To>, "Destination type must be trivially constructible");To dst{};# if defined(__GNUC__) && !defined(__clang__)diff --git a/src/plugins/intel_cpu/src/utils/general_utils.h b/src/plugins/intel_cpu/src/utils/general_utils.hindex 31c13d0e775..cc204e09fe5 100644--- a/src/plugins/intel_cpu/src/utils/general_utils.h+++ b/src/plugins/intel_cpu/src/utils/general_utils.h@@ -59,6 +59,15 @@ constexpr bool implication(bool cause, bool cond) {return !cause || !!cond;}+template <typename T, typename... Ts>+constexpr bool all_of_v = std::conjunction_v<std::is_same<T, Ts>...>;++template <typename T, typename... Ts>+constexpr bool any_of_v = std::disjunction_v<std::is_same<T, Ts>...>;++template <typename T, typename... Ts>+constexpr bool none_of_v = std::negation_v<std::disjunction<std::is_same<T, Ts>...>>;+template <typename T>std::string vec2str(const std::vector<T>& vec) {if (!vec.empty()) {@@ -145,7 +154,7 @@ inline bool dimsEqualWeak(const std::vector<size_t>& lhs,return true;}-inline ov::element::Type getMaxPrecision(std::vector<ov::element::Type> precisions) {+inline ov::element::Type getMaxPrecision(const std::vector<ov::element::Type>& precisions) {if (!precisions.empty()) {return *std::max_element(precisions.begin(),precisions.end(),diff --git a/src/plugins/intel_cpu/src/utils/plain_tensor.hpp b/src/plugins/intel_cpu/src/utils/plain_tensor.hppindex 12b4d7cc234..cc317e23825 100644--- a/src/plugins/intel_cpu/src/utils/plain_tensor.hpp+++ b/src/plugins/intel_cpu/src/utils/plain_tensor.hpp@@ -420,25 +420,12 @@ struct PlainTensor {[[nodiscard]] int64_t offset(I i, Is... indices) const {return i * m_strides[dim] + offset<dim + 1>(indices...);}- template <typename DT, typename... Is>- [[nodiscard]] DT* ptr(Is... indices) const {- return reinterpret_cast<DT*>(m_ptr.get()) + offset<0>(indices...);- }- template <typename DT,- ov::element::Type_t SRC_PREC,- std::enable_if_t<SRC_PREC != ov::element::u4, bool> = true,- typename... Is>- DT* ptr(Is... indices) const {- return reinterpret_cast<DT*>(m_ptr.get()) + offset<0>(indices...);- }-- template <typename DT,- ov::element::Type_t SRC_PREC,- std::enable_if_t<SRC_PREC == ov::element::u4, bool> = true,- typename... Is>- DT* ptr(Is... indices) const {- return reinterpret_cast<DT*>(m_ptr.get()) + offset<0>(indices...) / 2;+ template <typename DT, ov::element::Type_t SRC_PREC = ov::element::u8, typename... Is>+ [[nodiscard]] DT* ptr(Is... indices) const {+ constexpr size_t stride_div = SRC_PREC == ov::element::u4 ? 2 : 1;+ const size_t off = offset<0>(indices...) / stride_div;+ return reinterpret_cast<DT*>(m_ptr.get()) + off;}template <typename... Is>