Skip to content

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

[CPU] Moved jit_uni_eltwise_generic x64 to another files (#28749)

Alexandra Sidorova3571d18b9bd6
diff --git a/src/plugins/intel_cpu/src/nodes/eltwise.cpp b/src/plugins/intel_cpu/src/nodes/eltwise.cpp
index 094ebbff01e..3ab561f9c5b 100644
--- a/src/plugins/intel_cpu/src/nodes/eltwise.cpp
+++ b/src/plugins/intel_cpu/src/nodes/eltwise.cpp
@@ -6,8 +6,6 @@
#include <algorithm>
#include <cmath>
-#include <cpu/x64/cpu_isa_traits.hpp>
-#include <cpu/x64/injectors/jit_uni_quantization_injector.hpp>
#include <functional>
#include <map>
#include <memory>
@@ -15,17 +13,12 @@
#include <string>
#include <vector>
-#include "common/cpu_convert.h"
#include "common/float16.hpp"
#include "common/primitive_hashing_utils.hpp"
#include "config.h"
#include "cpu/ref_eltwise.hpp"
#include "cpu_types.h"
#include "dnnl_extension_utils.h"
-#include "emitters/plugin/x64/jit_bf16_emitters.hpp"
-#include "emitters/plugin/x64/jit_dnnl_emitters.hpp"
-#include "emitters/plugin/x64/jit_eltwise_emitters.hpp"
-#include "emitters/plugin/x64/jit_emitter.hpp"
#include "fake_quantize.h"
#include "input.h"
#include "memory_desc/dnnl_blocked_memory_desc.h"
@@ -55,14 +48,17 @@
# include "cpu/aarch64/cpu_isa_traits.hpp"
# include "executors/aarch64/jit_eltwise.hpp"
# include "kernels/aarch64/jit_uni_eltwise_generic.hpp"
+#elif defined(OPENVINO_ARCH_X86_64)
+# include "cpu/x64/cpu_isa_traits.hpp"
+# include "kernels/x64/jit_uni_eltwise_generic.hpp"
#endif
using namespace dnnl::impl::utils;
using namespace dnnl::impl::cpu;
-#ifndef OPENVINO_ARCH_ARM64
+#if defined(OPENVINO_ARCH_X86_64)
+using namespace ov::intel_cpu::x64;
using namespace dnnl::impl::cpu::x64;
-using namespace Xbyak;
#endif
#if defined(OPENVINO_ARCH_ARM64)
@@ -70,8 +66,6 @@ using namespace ov::intel_cpu::aarch64;
using namespace dnnl::impl::cpu::aarch64;
#endif
-#define GET_OFF(field) offsetof(jit_eltwise_call_args_ptrs, field)
-
namespace ov {
namespace intel_cpu {
namespace node {
@@ -94,1052 +88,6 @@ bool jitIsSupported(const Node* node,
} // namespace
#endif
-#if defined(OPENVINO_ARCH_X86_64)
-
-template <typename T>
-struct SupportedPrecisions {
- void operator()(std::set<std::vector<element::Type>>& precisions) {
- precisions = T::get_supported_precisions();
- }
-};
-
-struct EltwiseEmitterContext {
- std::shared_ptr<jit_emitter> emitter;
- jit_generator* host;
- cpu_isa_t host_isa;
- const EltwiseData& opData;
- ov::element::Type exec_prc;
-};
-
-template <typename T>
-struct EltwiseEmitter {
- void operator()(EltwiseEmitterContext& ctx) {
- ctx.emitter = std::make_shared<T>(ctx.host, ctx.host_isa, ctx.exec_prc);
- }
-};
-
-template <>
-struct EltwiseEmitter<jit_dnnl_aux_emitter> {
- void operator()(EltwiseEmitterContext& ctx) {
- auto algKind = static_cast<dnnl_alg_kind_t>(ctx.opData.onednnAlgorithm);
- ctx.emitter = std::make_shared<jit_dnnl_aux_emitter>(ctx.host,
- ctx.host_isa,
- algKind,
- ctx.opData.alpha,
- ctx.opData.beta,
- ctx.exec_prc);
- }
-};
-
-template <>
-struct EltwiseEmitter<jit_power_static_emitter> {
- void operator()(EltwiseEmitterContext& ctx) {
- ctx.emitter = std::make_shared<jit_power_static_emitter>(ctx.host,
- ctx.host_isa,
- ctx.opData.alpha,
- ctx.opData.beta,
- ctx.opData.gamma,
- ctx.exec_prc);
- }
-};
-
-template <>
-struct EltwiseEmitter<jit_is_inf_emitter> {
- void operator()(EltwiseEmitterContext& ctx) {
- ctx.emitter = std::make_shared<jit_is_inf_emitter>(ctx.host,
- ctx.host_isa,
- ctx.exec_prc,
- ctx.opData.alpha,
- ctx.opData.beta);
- }
-};
-
-static void set_intersection(const std::set<std::vector<element::Type>>& precisions1,
- const std::set<std::vector<element::Type>>& precisions2,
- std::set<std::vector<element::Type>>& intersection) {
- std::map<element::Type, size_t> intersection_types;
-
- for (auto it1 = precisions1.begin(); it1 != precisions1.end(); ++it1) {
- for (auto it2 = precisions2.begin(); it2 != precisions2.end(); ++it2) {
- const auto& it1_precisions = *it1;
- // all element types are equal
- if (it1_precisions[0] == (*it2)[0]) {
- // first precisions size is used
- intersection_types.emplace(it1_precisions[0], it1_precisions.size());
- }
- }
- }
-
- for (auto it = intersection_types.begin(); it != intersection_types.end(); ++it) {
- intersection.insert(std::vector<element::Type>(it->second, it->first));
- }
-}
-
-ov::element::Type eltwise_precision_helper::get_precision(const size_t inputs_number,
- const ov::element::Type (&src_prc)[MAX_ELTWISE_INPUTS],
- const std::vector<EltwiseData>& eltwise_data) {
- ov::element::Type exec_prc = ov::element::undefined;
-
- std::set<std::vector<element::Type>> supported_precision_intersection =
- get_supported_precisions(eltwise_data.front().algo);
-
- // for element-wise operations all inputs must to have the same precisions
- auto has_same_precision = [](const std::vector<element::Type>& precisions) {
- return std::all_of(precisions.begin(), precisions.end(), [&precisions](const element::Type precision) {
- return precision == precisions[0];
- });
- };
-
- assert(std::all_of(supported_precision_intersection.begin(),
- supported_precision_intersection.end(),
- has_same_precision));
-
- for (size_t i = 1; i < eltwise_data.size(); ++i) {
- std::set<std::vector<element::Type>> prcs = get_supported_precisions(eltwise_data[i].algo);
- std::set<std::vector<element::Type>> prcs_intersect = {};
-
- OPENVINO_ASSERT(std::all_of(prcs.begin(), prcs.end(), has_same_precision),
- "for element-wise nodes all precisions have to be equal");
-
- set_intersection(supported_precision_intersection, prcs, prcs_intersect);
-
- supported_precision_intersection = prcs_intersect;
- }
-
- static const element::Type exec_precisions_priority[] =
- {element::u8, element::i8, element::u16, element::i16, element::bf16, element::i32, element::f32};
-
- for (const auto prc : exec_precisions_priority) {
- if (std::any_of(supported_precision_intersection.begin(),
- supported_precision_intersection.end(),
- [&prc, &src_prc](const std::vector<element::Type>& precisions) {
- return (std::find(precisions.begin(), precisions.end(), prc) != precisions.end()) &&
- (src_prc[0] == prc);
- })) {
- exec_prc = prc;
- break;
- }
- }
-
- for (size_t i = 0; i < inputs_number; i++) {
- if (src_prc[i] != exec_prc) {
- exec_prc = ov::element::f32;
- break;
- }
- }
-
- if (exec_prc == ov::element::undefined) {
- OPENVINO_THROW("Eltwise jitter failed to specify execution precision for Eltwise node");
- }
-
- return exec_prc;
-}
-
-std::set<std::vector<element::Type>> eltwise_precision_helper::get_supported_precisions(const Algorithm& algo) {
- std::set<std::vector<element::Type>> precisions;
-
- OV_SWITCH(intel_cpu,
- SupportedPrecisions,
- precisions,
- algo,
- OV_CASE(Algorithm::EltwiseRelu, jit_dnnl_aux_emitter),
- OV_CASE(Algorithm::EltwiseGeluErf, jit_dnnl_aux_emitter),
- OV_CASE(Algorithm::EltwiseGeluTanh, jit_dnnl_aux_emitter),
- OV_CASE(Algorithm::EltwiseElu, jit_dnnl_aux_emitter),
- OV_CASE(Algorithm::EltwiseTanh, jit_dnnl_aux_emitter),
- OV_CASE(Algorithm::EltwiseSigmoid, jit_dnnl_aux_emitter),
- OV_CASE(Algorithm::EltwiseAbs, jit_dnnl_aux_emitter),
- OV_CASE(Algorithm::EltwiseSqrt, jit_dnnl_aux_emitter),
- OV_CASE(Algorithm::EltwiseSoftRelu, jit_dnnl_aux_emitter),
- OV_CASE(Algorithm::EltwiseClamp, jit_dnnl_aux_emitter),
- OV_CASE(Algorithm::EltwiseSwish, jit_dnnl_aux_emitter),
- OV_CASE(Algorithm::EltwiseHswish, jit_dnnl_aux_emitter),
- OV_CASE(Algorithm::EltwiseMish, jit_dnnl_aux_emitter),
- OV_CASE(Algorithm::EltwiseHsigmoid, jit_dnnl_aux_emitter),
- OV_CASE(Algorithm::EltwiseRoundHalfToEven, jit_dnnl_aux_emitter),
- OV_CASE(Algorithm::EltwiseRoundHalfAwayFromZero, jit_dnnl_aux_emitter),
- OV_CASE(Algorithm::EltwiseAdd, jit_add_emitter),
- OV_CASE(Algorithm::EltwiseMulAdd, jit_mul_add_emitter),
- OV_CASE(Algorithm::EltwiseSubtract, jit_subtract_emitter),
- OV_CASE(Algorithm::EltwiseMultiply, jit_multiply_emitter),
- OV_CASE(Algorithm::EltwiseDivide, jit_divide_emitter),
- OV_CASE(Algorithm::EltwiseFloor, jit_floor_emitter),
- OV_CASE(Algorithm::EltwiseCeiling, jit_ceiling_emitter),
- OV_CASE(Algorithm::EltwiseNegative, jit_negative_emitter),
- OV_CASE(Algorithm::EltwiseFloorMod, jit_floor_mod_emitter),
- OV_CASE(Algorithm::EltwiseMod, jit_mod_emitter),
- OV_CASE(Algorithm::EltwiseMaximum, jit_maximum_emitter),
- OV_CASE(Algorithm::EltwiseMinimum, jit_minimum_emitter),
- OV_CASE(Algorithm::EltwiseExp, jit_exp_emitter),
- OV_CASE(Algorithm::EltwiseSquaredDifference, jit_squared_difference_emitter),
- OV_CASE(Algorithm::EltwisePowerDynamic, jit_power_dynamic_emitter),
- OV_CASE(Algorithm::EltwiseEqual, jit_equal_emitter),
- OV_CASE(Algorithm::EltwiseNotEqual, jit_not_equal_emitter),
- OV_CASE(Algorithm::EltwiseGreater, jit_greater_emitter),
- OV_CASE(Algorithm::EltwiseGreaterEqual, jit_greater_equal_emitter),
- OV_CASE(Algorithm::EltwiseLess, jit_less_emitter),
- OV_CASE(Algorithm::EltwiseLessEqual, jit_less_equal_emitter),
- OV_CASE(Algorithm::EltwiseLogicalAnd, jit_logical_and_emitter),
- OV_CASE(Algorithm::EltwiseLogicalOr, jit_logical_or_emitter),
- OV_CASE(Algorithm::EltwiseLogicalXor, jit_logical_xor_emitter),
- OV_CASE(Algorithm::EltwiseLogicalNot, jit_logical_not_emitter),
- OV_CASE(Algorithm::EltwisePowerStatic, jit_power_static_emitter),
- OV_CASE(Algorithm::EltwisePrelu, jit_prelu_emitter),
- OV_CASE(Algorithm::EltwiseErf, jit_erf_emitter),
- OV_CASE(Algorithm::EltwiseSoftSign, jit_soft_sign_emitter),
- OV_CASE(Algorithm::EltwiseIsFinite, jit_is_finite_emitter),
- OV_CASE(Algorithm::EltwiseIsInf, jit_is_inf_emitter),
- OV_CASE(Algorithm::EltwiseIsNaN, jit_is_nan_emitter),
- OV_CASE(Algorithm::EltwiseSelect, jit_select_emitter),
- OV_CASE(Algorithm::EltwiseBitwiseAnd, jit_bitwise_and_emitter),
- OV_CASE(Algorithm::EltwiseBitwiseNot, jit_bitwise_not_emitter),
- OV_CASE(Algorithm::EltwiseBitwiseOr, jit_bitwise_or_emitter),
- OV_CASE(Algorithm::EltwiseBitwiseXor, jit_bitwise_xor_emitter));
-
- if (precisions.empty()) {
- OPENVINO_THROW("Unsupported operation type for Eltwise emitter");
- }
-
- return precisions;
-}
-
-template <cpu_isa_t isa>
-struct jit_uni_eltwise_generic : public jit_uni_eltwise_kernel, public jit_generator {
- DECLARE_CPU_JIT_AUX_FUNCTIONS(jit_uni_eltwise_generic)
-
- explicit jit_uni_eltwise_generic(const jit_eltwise_params& jep,
- const std::vector<EltwiseData>& eltwise_data,
- const std::vector<ov::intel_cpu::Type>& ops_list,
- const dnnl::post_ops& post_ops)
- : jit_uni_eltwise_kernel(jep),
- jit_generator(jit_name()),
- eltwise_data_(eltwise_data),
- ops_list_(ops_list),
- post_ops_(post_ops) {}
-
- void create_ker() override {
- jit_generator::create_kernel();
- ker_ = (decltype(ker_))jit_ker();
- }
-
- void generate() override {
- auto const exec_prc = eltwise_precision_helper::get_precision(jep_.inputs_number, jep_.src_prc, eltwise_data_);
-
- eltwise_emitter = create_eltwise_emitter(eltwise_data_.front(), exec_prc);
- for (size_t i = 1; i < eltwise_data_.size(); ++i) {
- post_op_emitters.push_back(create_eltwise_emitter(eltwise_data_[i], exec_prc));
- }
-
- const auto& p = post_ops_.get();
- for (int i = 0; i < post_ops_.len(); ++i) {
- if (!p->entry_[i].is_quantization()) {
- OPENVINO_THROW("Eltwise jitter error. Unsupported post op detected");
- }
- quantization_injectors.push_back(std::make_shared<jit_uni_quantization_injector_f32<isa>>(this,
- p->entry_[i],
- vmm_d_weights,
- vmm_d_bias,
- reg_d_weights,
- reg_d_bias));
- }
-
- if (mayiuse(avx512_core) || mayiuse(avx2_vnni_2)) {
- auto const mode = jep_.do_output_saturation ? jit_uni_vcvtneps2bf16::conversion_mode::saturation_mode
- : jit_uni_vcvtneps2bf16::conversion_mode::default_mode;
- uni_vcvtneps2bf16.reset(new jit_uni_vcvtneps2bf16(this, isa, element::bf16, mode));
- }
-
- const auto& jep = jep_;
-
- this->preamble();
-
- const int offset_count = jep.input_size - 1;
-
- // ptrs initializing
- if (jep.use_runtime_ptrs) {
- for (size_t i = 0; i < jep.inputs_number; i++) {
- mov(start_to_offsets, ptr[reg_const_params + GET_OFF(src_offsets) + i * sizeof(size_t)]);
- mov(get_src_reg(i), ptr[reg_const_params + GET_OFF(src_ptr[0]) + i * sizeof(size_t)]);
- for (int j = 0; j < offset_count; j++) {
- mov(reg_tmp_64, ptr[start_to_offsets + j * sizeof(size_t)]);
- imul(reg_tmp_64, ptr[reg_indexes + j * sizeof(size_t)]);
- add(get_src_reg(i), reg_tmp_64);
- }
- }
-
- mov(start_to_offsets, ptr[reg_const_params + GET_OFF(dst_offsets)]);
- mov(reg_dst, ptr[reg_const_params + GET_OFF(dst_ptr)]);
- for (int j = 0; j < offset_count; j++) {
- mov(reg_tmp_64, ptr[start_to_offsets + j * sizeof(size_t)]);
- imul(reg_tmp_64, ptr[reg_indexes + j * sizeof(size_t)]);
- add(reg_dst, reg_tmp_64);
- }
-
- xor_(reg_oc_off, reg_oc_off);
-
- mov(reg_work_amount, ptr[reg_const_params + GET_OFF(work_amount)]);
- } else {
- auto init_ptrs_with_offsets = [this, offset_count](Reg64 pointer, const std::vector<size_t>& offsets) {
- for (int j = 0; j < offset_count; j++) {
- if (jep_.dims[j] != 1 && offsets[j] != 0) {
- mov(reg_tmp_64, offsets[j]);
- imul(reg_tmp_64, ptr[reg_indexes + j * sizeof(size_t)]);
- add(pointer, reg_tmp_64);
- }
- }
- };
-
- for (size_t i = 0; i < jep.inputs_number; i++) {
- mov(get_src_reg(i), ptr[reg_const_params + GET_OFF(src_ptr[0]) + i * sizeof(size_t)]);
- init_ptrs_with_offsets(get_src_reg(i), jep.src_offsets[i]);
- }
-
- mov(reg_dst, ptr[reg_const_params + GET_OFF(dst_ptr)]);
- init_ptrs_with_offsets(reg_dst, jep.dst_offsets);
-
- xor_(reg_oc_off, reg_oc_off);
- init_ptrs_with_offsets(reg_oc_off, jep.oc_offsets);
-
- mov(reg_work_amount, jep.work_amount);
- }
-
- mov(reg_post_op_ptrs, ptr[reg_const_params + GET_OFF(post_op_data)]);
-
- Xbyak::Label unroll_loop_label;
- Xbyak::Label unroll_loop_end_label;
- Xbyak::Label main_loop_label;
- Xbyak::Label main_loop_end_label;
- Xbyak::Label tail_loop_label;
- Xbyak::Label tail_loop_end_label;
-
- if (isa == x64::avx512_core) {
- vpxord(vmm_zero, vmm_zero, vmm_zero);
- }
-
- for (size_t i = 0; i < jep.inputs_number; i++) {
- if (jep.src_size[i] == 1) {
- load_vector(get_vmm_reg(i), ptr[get_src_reg(i)], jep.src_prc[i], exec_prc, true);
- }
- }
-
- size_t min_src_size = jep.dst_size;
- for (size_t i = 0; i < jep.inputs_number; i++) {
- if (jep.src_size[i] != 1) {
- min_src_size = std::min(min_src_size, jep.src_size[i]);
- }
- }
- if (jep_.oc_size > 1) {
- min_src_size = std::min(min_src_size, jep_.oc_size);
- }
-
- if (min_src_size != jep.dst_size) {
- bool is_valid_configuration = true;
- if (jep.dst_size % min_src_size != 0) {
- is_valid_configuration = false;
- }
-
- for (size_t i = 0; i < jep.inputs_number; i++) {
- if (jep.src_size[i] != 1 && jep.src_size[i] != min_src_size && jep.src_size[i] != jep.dst_size) {
- is_valid_configuration = false;
- }
- }
-
- if (jep_.oc_size > 1 && jep_.oc_size != min_src_size && jep_.oc_size != jep.dst_size) {
- is_valid_configuration = false;
- }
-
- if (!is_valid_configuration) {
- OPENVINO_THROW("Eltwise jitter has invalid configuration for Eltwise node");
- }
-
- L(unroll_loop_label);
- {
- size_t loop_step = min_src_size;
- size_t vec_step = cpu_isa_traits<isa>::vlen / exec_prc.size();
-
- cmp(reg_work_amount, loop_step);
- jl(unroll_loop_end_label, T_NEAR);
-
- for (size_t j = 0; j < min_src_size / vec_step; j++) {
- for (size_t i = 0; i < jep.inputs_number; i++) {
- if (jep.src_size[i] != 1) {
- load_vector(get_vmm_reg(i),
- ptr[get_src_reg(i) + j * vec_step * jep.src_prc[i].size()],
- jep.src_prc[i],
- exec_prc,
- false);
- }
- }
-
- compute_eltwise_op();
-
- apply_post_ops(false, jep_.oc_size > 1 ? j * vec_step * sizeof(float) : 0);
-
- store_vector(ptr[reg_dst + j * vec_step * jep.dst_prc.size()], vmm_dst, exec_prc, jep.dst_prc);
- }
-
- size_t tail_start = min_src_size - min_src_size % vec_step;
- for (size_t j = tail_start; j < min_src_size; j++) {
- for (size_t i = 0; i < jep.inputs_number; i++) {
- if (jep.src_size[i] != 1) {
- load_scalar(get_xmm_reg(i),
- ptr[get_src_reg(i) + j * jep.src_prc[i].size()],
- jep.src_prc[i],
- exec_prc);
- }
- }
-
- compute_eltwise_op();
-
- apply_post_ops(true, jep_.oc_size > 1 ? j * sizeof(float) : 0);
-
- store_scalar(ptr[reg_dst + j * jep.dst_prc.size()],
- xmm_dst,
- exec_prc,
- jep.dst_prc,
- jep.do_output_saturation);
- }
-
- for (size_t i = 0; i < jep.inputs_number; i++) {
- if (jep.src_size[i] == jep.dst_size) {
- add(get_src_reg(i), jep.src_prc[i].size() * loop_step);
- }
- }
-
- add(reg_dst, jep.dst_prc.size() * loop_step);
- sub(reg_work_amount, loop_step);
- if (jep_.oc_size > 1 && jep_.oc_size != min_src_size) {
- add(reg_oc_off, loop_step * sizeof(float));
- }
-
- jmp(unroll_loop_label, T_NEAR);
- }
-
- L(unroll_loop_end_label);
- }
-
- if (min_src_size == jep.dst_size) {
- L(main_loop_label);
- {
- size_t loop_step = cpu_isa_traits<isa>::vlen / exec_prc.size();
-
- cmp(reg_work_amount, loop_step);
- jl(main_loop_end_label, T_NEAR);
-
- for (size_t i = 0; i < jep.inputs_number; i++) {
- if (jep.src_size[i] != 1) {
- load_vector(get_vmm_reg(i), ptr[get_src_reg(i)], jep.src_prc[i], exec_prc, false);
- }
- }
-
- compute_eltwise_op();
-
- apply_post_ops(false);
-
- store_vector(ptr[reg_dst], vmm_dst, exec_prc, jep.dst_prc);
-
- for (size_t i = 0; i < jep.inputs_number; i++) {
- if (jep.src_size[i] != 1) {
- add(get_src_reg(i), jep.src_prc[i].size() * loop_step);
- }
- }
-
- add(reg_dst, jep.dst_prc.size() * loop_step);
- sub(reg_work_amount, loop_step);
- if (jep_.oc_size > 1) {
- add(reg_oc_off, loop_step * sizeof(float));
- }
-
- jmp(main_loop_label, T_NEAR);
- }
-
- L(main_loop_end_label);
- }
-
- L(tail_loop_label);
- {
- size_t loop_step = 1;
-
- cmp(reg_work_amount, loop_step);
- jl(tail_loop_end_label, T_NEAR);
-
- for (size_t i = 0; i < jep.inputs_number; i++) {
- if (jep.src_size[i] != 1) {
- load_scalar(get_xmm_reg(i), ptr[get_src_reg(i)], jep.src_prc[i], exec_prc);
- }
- }
-
- compute_eltwise_op();
-
- apply_post_ops(true);
-
- store_scalar(ptr[reg_dst], xmm_dst, exec_prc, jep.dst_prc, jep.do_output_saturation);
-
- for (size_t i = 0; i < jep.inputs_number; i++) {
- if (jep.src_size[i] != 1) {
- add(get_src_reg(i), jep.src_prc[i].size() * loop_step);
- }
- }
-
- add(reg_dst, jep.dst_prc.size() * loop_step);
- sub(reg_work_amount, loop_step);
- if (jep_.oc_size > 1) {
- add(reg_oc_off, loop_step * sizeof(float));
- }
-
- jmp(tail_loop_label, T_NEAR);
- }
-
- L(tail_loop_end_label);
-
- this->postamble();
-
- if (uni_vcvtneps2bf16) {
- uni_vcvtneps2bf16->emit_data();
- }
-
- eltwise_emitter->emit_data();
- for (size_t i = 0; i < post_op_emitters.size(); i++) {
- post_op_emitters[i]->emit_data();
- }
- }
-
-private:
- using Vmm = typename conditional3<isa == x64::sse41, Xmm, isa == x64::avx2, Ymm, Zmm>::type;
-
- Reg64 get_src_reg(int idx) {
- return Reg64(r8.getIdx() + idx);
- }
-
- Vmm get_vmm_reg(int idx) {
- return Vmm(1 + idx);
- }
-
- Vmm get_aux_vmm(int idx) {
- return Vmm(10 + idx);
- }
-
- Xmm get_xmm_reg(int idx) {
- return Xmm(get_vmm_reg(idx).getIdx());
- }
-
- Reg64 reg_post_op_ptrs = rax;
- Reg64 start_to_offsets = reg_post_op_ptrs; // rax
- Reg64 reg_dst = rbx;
- Reg64 reg_work_amount = rdx;
-
- Reg64 reg_oc_off = abi_not_param1;
- Reg64 reg_const_params = abi_param1;
- Reg64 reg_indexes = abi_param2; // reg_d_bias
-
- Reg8 reg_tmp_8 = Reg8(r15.getIdx());
- Reg16 reg_tmp_16 = Reg16(r15.getIdx());
- Reg32 reg_tmp_32 = Reg32(r15.getIdx());
- Reg64 reg_tmp_64 = Reg64(r15.getIdx());
-
- Reg64 reg_d_weights = rbp;
- Reg64 reg_d_bias = rsi;
-
- Vmm vmm_dst = Vmm(9);
- Xmm xmm_dst = Xmm(9);
-
- Vmm vmm_d_weights = Vmm(12);
- Vmm vmm_d_bias = Vmm(13);
- Vmm vmm_zero = Vmm(15);
-
- std::shared_ptr<jit_uni_vcvtneps2bf16> uni_vcvtneps2bf16;
-
- std::shared_ptr<jit_emitter> eltwise_emitter = nullptr;
- std::vector<std::shared_ptr<jit_emitter>> post_op_emitters = {};
-
- std::vector<std::shared_ptr<jit_uni_quantization_injector_f32<isa>>> quantization_injectors = {};
-
- const std::vector<EltwiseData>& eltwise_data_;
- const std::vector<ov::intel_cpu::Type>& ops_list_;
- const dnnl::post_ops& post_ops_;
-
- std::shared_ptr<jit_emitter> create_eltwise_emitter(const EltwiseData& data, ov::element::Type exec_prec) {
- EltwiseEmitterContext ctx = {nullptr, this, isa, data, exec_prec};
-
- OV_SWITCH(intel_cpu,
- EltwiseEmitter,
- ctx,
- data.algo,
- OV_CASE(Algorithm::EltwiseRelu, jit_dnnl_aux_emitter),
- OV_CASE(Algorithm::EltwiseGeluErf, jit_dnnl_aux_emitter),
- OV_CASE(Algorithm::EltwiseGeluTanh, jit_dnnl_aux_emitter),
- OV_CASE(Algorithm::EltwiseElu, jit_dnnl_aux_emitter),
- OV_CASE(Algorithm::EltwiseTanh, jit_dnnl_aux_emitter),
- OV_CASE(Algorithm::EltwiseSigmoid, jit_dnnl_aux_emitter),
- OV_CASE(Algorithm::EltwiseAbs, jit_dnnl_aux_emitter),
- OV_CASE(Algorithm::EltwiseSqrt, jit_dnnl_aux_emitter),
- OV_CASE(Algorithm::EltwiseSoftRelu, jit_dnnl_aux_emitter),
- OV_CASE(Algorithm::EltwiseClamp, jit_dnnl_aux_emitter),
- OV_CASE(Algorithm::EltwiseSwish, jit_dnnl_aux_emitter),
- OV_CASE(Algorithm::EltwiseHswish, jit_dnnl_aux_emitter),
- OV_CASE(Algorithm::EltwiseMish, jit_dnnl_aux_emitter),
- OV_CASE(Algorithm::EltwiseHsigmoid, jit_dnnl_aux_emitter),
- OV_CASE(Algorithm::EltwiseRoundHalfToEven, jit_dnnl_aux_emitter),
- OV_CASE(Algorithm::EltwiseRoundHalfAwayFromZero, jit_dnnl_aux_emitter),
- OV_CASE(Algorithm::EltwiseAdd, jit_add_emitter),
- OV_CASE(Algorithm::EltwiseMulAdd, jit_mul_add_emitter),
- OV_CASE(Algorithm::EltwiseSubtract, jit_subtract_emitter),
- OV_CASE(Algorithm::EltwiseMultiply, jit_multiply_emitter),
- OV_CASE(Algorithm::EltwiseDivide, jit_divide_emitter),
- OV_CASE(Algorithm::EltwiseFloor, jit_floor_emitter),
- OV_CASE(Algorithm::EltwiseCeiling, jit_ceiling_emitter),
- OV_CASE(Algorithm::EltwiseNegative, jit_negative_emitter),
- OV_CASE(Algorithm::EltwiseFloorMod, jit_floor_mod_emitter),
- OV_CASE(Algorithm::EltwiseMod, jit_mod_emitter),
- OV_CASE(Algorithm::EltwiseMaximum, jit_maximum_emitter),
- OV_CASE(Algorithm::EltwiseMinimum, jit_minimum_emitter),
- OV_CASE(Algorithm::EltwiseExp, jit_exp_emitter),
- OV_CASE(Algorithm::EltwiseSquaredDifference, jit_squared_difference_emitter),
- OV_CASE(Algorithm::EltwisePowerDynamic, jit_power_dynamic_emitter),
- OV_CASE(Algorithm::EltwiseEqual, jit_equal_emitter),
- OV_CASE(Algorithm::EltwiseNotEqual, jit_not_equal_emitter),
- OV_CASE(Algorithm::EltwiseGreater, jit_greater_emitter),
- OV_CASE(Algorithm::EltwiseGreaterEqual, jit_greater_equal_emitter),
- OV_CASE(Algorithm::EltwiseLess, jit_less_emitter),
- OV_CASE(Algorithm::EltwiseLessEqual, jit_less_equal_emitter),
- OV_CASE(Algorithm::EltwiseLogicalAnd, jit_logical_and_emitter),
- OV_CASE(Algorithm::EltwiseLogicalOr, jit_logical_or_emitter),
- OV_CASE(Algorithm::EltwiseLogicalXor, jit_logical_xor_emitter),
- OV_CASE(Algorithm::EltwiseLogicalNot, jit_logical_not_emitter),
- OV_CASE(Algorithm::EltwisePowerStatic, jit_power_static_emitter),
- OV_CASE(Algorithm::EltwisePrelu, jit_prelu_emitter),
- OV_CASE(Algorithm::EltwiseErf, jit_erf_emitter),
- OV_CASE(Algorithm::EltwiseSoftSign, jit_soft_sign_emitter),
- OV_CASE(Algorithm::EltwiseIsFinite, jit_is_finite_emitter),
- OV_CASE(Algorithm::EltwiseIsInf, jit_is_inf_emitter),
- OV_CASE(Algorithm::EltwiseIsNaN, jit_is_nan_emitter),
- OV_CASE(Algorithm::EltwiseSelect, jit_select_emitter),
- OV_CASE(Algorithm::EltwiseBitwiseAnd, jit_bitwise_and_emitter),
- OV_CASE(Algorithm::EltwiseBitwiseNot, jit_bitwise_not_emitter),
- OV_CASE(Algorithm::EltwiseBitwiseOr, jit_bitwise_or_emitter),
- OV_CASE(Algorithm::EltwiseBitwiseXor, jit_bitwise_xor_emitter));
-
- if (!ctx.emitter) {
- OPENVINO_THROW("Unsupported operation type for Eltwise emitter");
- }
-
- return ctx.emitter;
- }
-
- inline void compute_eltwise_op() {
- std::vector<size_t> in_idxs;
- std::vector<size_t> aux_idxs;
- for (size_t i = 0; i < eltwise_emitter->get_inputs_num(); i++) {
- in_idxs.push_back(get_vmm_reg(i).getIdx());
- }
- for (size_t i = 0; i < eltwise_emitter->aux_vecs_count(); i++) {
- aux_idxs.push_back(get_aux_vmm(i).getIdx());
- }
-
- std::vector<size_t> out_idxs;
- out_idxs.push_back(vmm_dst.getIdx());
-
- eltwise_emitter->emit_code(in_idxs, out_idxs, aux_idxs);
- }
-
- inline void apply_post_ops(bool is_scalar, int offset = 0) {
- int input_idx = eltwise_emitter->get_inputs_num();
- int eltwise_post_op_idx = 0;
- int quantization_post_op_idx = 0;
- for (size_t i = 1; i < ops_list_.size(); i++) {
- if (ops_list_[i] == ov::intel_cpu::Type::Eltwise) {
- std::vector<size_t> in_idxs;
- std::vector<size_t> aux_idxs;
- in_idxs.push_back(vmm_dst.getIdx());
- for (size_t j = 1; j < post_op_emitters[eltwise_post_op_idx]->get_inputs_num(); j++) {
- in_idxs.push_back(get_vmm_reg(input_idx++).getIdx());
- }
- for (size_t j = 0; j < post_op_emitters[eltwise_post_op_idx]->aux_vecs_count(); j++) {
- aux_idxs.push_back(get_aux_vmm(j).getIdx());
- }
-
- std::vector<size_t> out_idxs;
- out_idxs.push_back(vmm_dst.getIdx());
-
- post_op_emitters[eltwise_post_op_idx]->emit_code(in_idxs, out_idxs, aux_idxs);
-
- eltwise_post_op_idx++;
- } else if (ops_list_[i] == ov::intel_cpu::Type::FakeQuantize) {
- auto& p = post_ops_.get()->entry_[quantization_post_op_idx];
- bool do_dequantization = p.quantization.alg == dnnl::impl::alg_kind::quantization_quantize_dequantize;
- bool do_rounding = do_dequantization || jep_.dst_prc == ov::element::f32 || i != ops_list_.size() - 1;
- int s_idx = vmm_dst.getIdx();
-
- size_t ptrs_table_off =
- quantization_post_op_idx * quantization_injectors[quantization_post_op_idx]->memoryStep();
-
- quantization_injectors[quantization_post_op_idx]->init_crop_ptrs(reg_post_op_ptrs + ptrs_table_off,
- reg_oc_off);
- quantization_injectors[quantization_post_op_idx]->compute_crop(s_idx,
- s_idx + 1,
- offset,
- is_scalar,
- jep_.oc_size == 1);
-
- quantization_injectors[quantization_post_op_idx]->init_input_scale_shift_ptrs(
- reg_post_op_ptrs + ptrs_table_off,
- reg_oc_off);
- quantization_injectors[quantization_post_op_idx]
- ->compute_input_scale_shift(s_idx, s_idx + 1, offset, do_rounding, is_scalar, jep_.oc_size == 1);
-
- quantization_injectors[quantization_post_op_idx]->init_output_scale_shift_ptrs(
- reg_post_op_ptrs + ptrs_table_off,
- reg_oc_off);
- quantization_injectors[quantization_post_op_idx]->compute_output_scale_shift(s_idx,
- s_idx + 1,
- offset,
- is_scalar,
- jep_.oc_size == 1);
-
- quantization_post_op_idx++;
- } else {
- OPENVINO_THROW("Unexpected: Eltwise jit kernel: unexpected operation type");
- }
- }
- }
-
- inline void load_vector(Vmm vmm_src,
- const Xbyak::Address& op,
- ov::element::Type src_prc,
- ov::element::Type dst_prc,
- bool broadcast) {
- Xmm xmm_src = Xmm(vmm_src.getIdx());
-
- if (src_prc == dst_prc) {
- if (broadcast) {
- load_scalar(xmm_src, op, src_prc, dst_prc);
- uni_vbroadcastss(vmm_src, xmm_src);
- } else {
- uni_vmovups(vmm_src, op);
- }
- return;
- }
-
- if (broadcast) {
- load_scalar(xmm_src, op, src_prc, dst_prc);
- uni_vbroadcastss(vmm_src, xmm_src);
- } else {
- switch (src_prc) {
- case ov::element::f32:
- case ov::element::i32:
- uni_vmovups(vmm_src, op);
- break;
- case ov::element::bf16:
- vpmovzxwd(vmm_src, op);
- uni_vpslld(vmm_src, vmm_src, 16);
- break;
- case ov::element::f16:
- vcvtph2ps(vmm_src, op);
- break;
- case ov::element::u16:
- uni_vpmovzxwd(vmm_src, op);
- break;
- case ov::element::i16:
- uni_vpmovsxwd(vmm_src, op);
- break;
- case ov::element::i8:
- uni_vpmovsxbd(vmm_src, op);
- break;
- case ov::element::u8:
- uni_vpmovzxbd(vmm_src, op);
- break;
- default:
- OPENVINO_THROW("unknown src_prc");
- }
-
- switch (dst_prc) {
- case ov::element::f32:
- if (!src_prc.is_real()) {
- uni_vcvtdq2ps(vmm_src, vmm_src);
- }
- break;
- case ov::element::i32:
- if (src_prc.is_real()) {
- uni_vcvtps2dq(vmm_src, vmm_src);
- }
- break;
- default:
- OPENVINO_THROW("unknown dst_prc");
- }
- }
- }
-
- inline void load_scalar(Xmm xmm_src,
- const Xbyak::Address& op,
- ov::element::Type src_prc,
- ov::element::Type dst_prc) {
- if (src_prc == dst_prc) {
- switch (src_prc.size()) {
- case 4:
- uni_vmovss(xmm_src, op);
- break;
- case 1:
- mov(reg_tmp_8, op);
- movzx(reg_tmp_32, reg_tmp_8);
- uni_vmovd(xmm_src, reg_tmp_32);
- break;
- default:
- OPENVINO_THROW("unknown prc");
- }
- return;
- }
-
- switch (src_prc) {
- case ov::element::f32:
- case ov::element::i32:
- uni_vmovss(xmm_src, op);
- break;
- case ov::element::bf16:
- if (isa == x64::avx2_vnni_2) {
- vbcstnebf162ps(xmm_src, op);
- } else {
- uni_vpinsrw(xmm_src, xmm_src, op, 0);
- uni_vpslld(xmm_src, xmm_src, 16);
- }
- break;
- case ov::element::f16:
- if (isa == x64::avx2_vnni_2) {
- vbcstnesh2ps(xmm_src, op);
- } else {
- vcvtph2ps(xmm_src, op);
- }
- break;
- case ov::element::i16:
- uni_vpinsrw(xmm_src, xmm_src, op, 0);
- uni_vpmovsxwd(xmm_src, op);
- break;
- case ov::element::u16:
- uni_vpinsrw(xmm_src, xmm_src, op, 0);
- uni_vpmovzxwd(xmm_src, op);
- break;
- case ov::element::i8:
- movsx(reg_tmp_32, op);
- uni_vmovq(xmm_src, reg_tmp_64);
- break;
- case ov::element::u8:
- movzx(reg_tmp_32, op);
- uni_vmovq(xmm_src, reg_tmp_64);
- break;
- default:
- OPENVINO_THROW("unknown src_prc");
- }
-
- switch (dst_prc) {
- case ov::element::f32:
- if (!src_prc.is_real()) {
- uni_vcvtdq2ps(xmm_src, xmm_src);
- }
- break;
- case ov::element::i32:
- if (src_prc.is_real()) {
- uni_vcvtps2dq(xmm_src, xmm_src);
- }
- break;
- default:
- OPENVINO_THROW("unknown dst_prc");
- }
- }
-
- inline void store_vector(const Xbyak::Address& op,
- Vmm vmm_dst,
- ov::element::Type src_prc,
- ov::element::Type dst_prc) {
- Xmm xmm_dst = Xmm(vmm_dst.getIdx());
- Ymm ymm_dst = Ymm(vmm_dst.getIdx());
-
- if (src_prc == dst_prc) {
- uni_vmovups(op, vmm_dst);
- return;
- }
-
- switch (src_prc) {
- case ov::element::f32:
- if (!dst_prc.is_real()) {
- uni_vcvtps2dq(vmm_dst, vmm_dst);
- }
- break;
- case ov::element::i32:
- if (dst_prc.is_real()) {
- uni_vcvtdq2ps(vmm_dst, vmm_dst);
- }
- break;
- default:
- OPENVINO_THROW("unknown src_prc");
- }
-
- switch (dst_prc) {
- case ov::element::f32:
- case ov::element::i32:
- uni_vmovups(op, vmm_dst);
- break;
- case ov::element::bf16:
- if (isa == x64::avx512_core) {
- uni_vcvtneps2bf16->emit_code({static_cast<size_t>(vmm_dst.getIdx())},
- {static_cast<size_t>(ymm_dst.getIdx())});
- vmovdqu16(op, ymm_dst);
- } else {
- uni_vcvtneps2bf16->emit_code({static_cast<size_t>(vmm_dst.getIdx())},
- {static_cast<size_t>(xmm_dst.getIdx())});
- uni_vmovdqu(op, xmm_dst);
- }
- break;
- case ov::element::f16:
- vcvtps2ph(op, vmm_dst, 0x4);
- break;
- case ov::element::i16:
- if (isa == x64::avx512_core) {
- vpmovsdw(op, vmm_dst);
- } else {
- uni_vpackssdw(vmm_dst, vmm_dst, vmm_dst);
- if (isa != x64::sse41) {
- vpermq(ymm_dst, ymm_dst, 0x08);
- uni_vmovdqu(op, xmm_dst);
- } else {
- movq(op, xmm_dst);
- }
- }
- break;
- case ov::element::u16:
- if (isa == x64::avx512_core) {
- vpmaxsd(vmm_dst, vmm_zero, vmm_dst);
- vpmovusdw(op, vmm_dst);
- } else {
- uni_vpackusdw(vmm_dst, vmm_dst, vmm_dst);
- if (isa != x64::sse41) {
- vpermq(ymm_dst, ymm_dst, 0x08);
- uni_vmovdqu(op, xmm_dst);
- } else {
- movq(op, xmm_dst);
- }
- }
- break;
- case ov::element::i8:
- if (isa == x64::avx512_core) {
- vpmovsdb(op, vmm_dst);
- } else {
- uni_vpackssdw(vmm_dst, vmm_dst, vmm_dst);
- if (isa != x64::sse41) {
- vpermq(ymm_dst, ymm_dst, 0x08);
- }
- uni_vpacksswb(vmm_dst, vmm_dst, vmm_dst);
- if (isa != x64::sse41) {
- vmovq(op, xmm_dst);
- } else {
- movd(op, xmm_dst);
- }
- }
- break;
- case ov::element::u8:
- if (isa == x64::avx512_core) {
- vpmaxsd(vmm_dst, vmm_zero, vmm_dst);
- vpmovusdb(op, vmm_dst);
- } else {
- uni_vpackusdw(vmm_dst, vmm_dst, vmm_dst);
- if (isa != x64::sse41) {
- vpermq(ymm_dst, ymm_dst, 0x08);
- }
- uni_vpackuswb(vmm_dst, vmm_dst, vmm_dst);
- if (isa != x64::sse41) {
- vmovq(op, xmm_dst);
- } else {
- movd(op, xmm_dst);
- }
- }
- break;
- default:
- OPENVINO_THROW("unknown dst_prc");
- }
- }
-
- inline void store_scalar(const Xbyak::Address& op,
- Xmm xmm_dst,
- ov::element::Type src_prc,
- ov::element::Type dst_prc,
- const bool do_output_saturation) {
- if (src_prc == dst_prc) {
- switch (src_prc.size()) {
- case 4:
- uni_vmovss(op, xmm_dst);
- break;
- case 1:
- movq(reg_tmp_64, xmm_dst);
- mov(op, reg_tmp_8);
- break;
- default:
- OPENVINO_THROW("unknown prc");
- }
- return;
- }
-
- switch (src_prc) {
- case ov::element::f32:
- if (!dst_prc.is_real()) {
- uni_vcvtps2dq(xmm_dst, xmm_dst);
- }
- break;
- case ov::element::i32:
- if (dst_prc.is_real()) {
- uni_vcvtdq2ps(xmm_dst, xmm_dst);
- }
- break;
- default:
- OPENVINO_THROW("unknown src_prc");
- }
-
- switch (dst_prc) {
- case ov::element::f32:
- case ov::element::i32:
- uni_vmovss(op, xmm_dst);
- break;
- case ov::element::bf16:
- if (do_output_saturation) {
- uni_vpsrld(xmm_dst, xmm_dst, 16);
- } else {
- uni_vcvtneps2bf16->emit_code({static_cast<size_t>(xmm_dst.getIdx())},
- {static_cast<size_t>(xmm_dst.getIdx())});
- }
- uni_vpextrw(op, xmm_dst, 0x0);
- break;
- case ov::element::f16:
- vcvtps2ph(xmm_dst, xmm_dst, 0x4);
- movq(reg_tmp_64, xmm_dst);
- mov(op, reg_tmp_16);
- break;
- case ov::element::i16:
- uni_vpackssdw(xmm_dst, xmm_dst, xmm_dst);
- movq(reg_tmp_64, xmm_dst);
- mov(op, reg_tmp_16);
- break;
- case ov::element::u16:
- uni_vpackusdw(xmm_dst, xmm_dst, xmm_dst);
- movq(reg_tmp_64, xmm_dst);
- mov(op, reg_tmp_16);
- break;
- case ov::element::i8:
- uni_vpackssdw(xmm_dst, xmm_dst, xmm_dst);
- uni_vpacksswb(xmm_dst, xmm_dst, xmm_dst);
- movq(reg_tmp_64, xmm_dst);
- mov(op, reg_tmp_8);
- break;
- case ov::element::u8:
- uni_vpackusdw(xmm_dst, xmm_dst, xmm_dst);
- uni_vpackuswb(xmm_dst, xmm_dst, xmm_dst);
- movq(reg_tmp_64, xmm_dst);
- mov(op, reg_tmp_8);
- break;
- default:
- OPENVINO_THROW("unknown dst_prc");
- }
- }
-};
-
-#endif // OPENVINO_ARCH_X86_64
-
Eltwise::BroadcastingPolicy Eltwise::determineBroadcastingPolicy(const std::shared_ptr<ov::Node>& op) {
const auto const1 = ov::as_type_ptr<ov::opset1::Constant>(op->get_input_node_shared_ptr(0));
const auto const2 = ov::as_type_ptr<ov::opset1::Constant>(op->get_input_node_shared_ptr(1));
@@ -1718,12 +666,15 @@ public:
});
#if defined(OPENVINO_ARCH_X86_64)
- if (mayiuse(x64::avx512_core)) {
- _pKernel.reset(new jit_uni_eltwise_generic<x64::avx512_core>(jep, eltwise_data, ops_list, post_ops));
- } else if (mayiuse(x64::avx2)) {
- _pKernel.reset(new jit_uni_eltwise_generic<x64::avx2>(jep, eltwise_data, ops_list, post_ops));
- } else if (mayiuse(x64::sse41)) {
- _pKernel.reset(new jit_uni_eltwise_generic<x64::sse41>(jep, eltwise_data, ops_list, post_ops));
+ if (mayiuse(dnnl::impl::cpu::x64::avx512_core)) {
+ _pKernel.reset(
+ new jit_uni_eltwise_generic<dnnl::impl::cpu::x64::avx512_core>(jep, eltwise_data, ops_list, post_ops));
+ } else if (mayiuse(dnnl::impl::cpu::x64::avx2)) {
+ _pKernel.reset(
+ new jit_uni_eltwise_generic<dnnl::impl::cpu::x64::avx2>(jep, eltwise_data, ops_list, post_ops));
+ } else if (mayiuse(dnnl::impl::cpu::x64::sse41)) {
+ _pKernel.reset(
+ new jit_uni_eltwise_generic<dnnl::impl::cpu::x64::sse41>(jep, eltwise_data, ops_list, post_ops));
} else {
OPENVINO_THROW("Can't create jit eltwise kernel");
}
@@ -2404,8 +1355,9 @@ void Eltwise::initSupportedPrimitiveDescriptors() {
bool canUseOptimizedImpl =
mayiuse(dnnl::impl::cpu::aarch64::asimd) && (getInputShapeAtPort(0).getRank() <= MAX_ELTWISE_DIM_RANK);
bool canUseOptimizedShapeAgnosticImpl = isDynamicNode() && canUseOptimizedImpl;
-#else
- bool canUseOptimizedImpl = mayiuse(x64::sse41) && getInputShapeAtPort(0).getRank() <= MAX_ELTWISE_DIM_RANK;
+#elif defined(OPENVINO_ARCH_X86_64)
+ bool canUseOptimizedImpl =
+ mayiuse(dnnl::impl::cpu::x64::sse41) && getInputShapeAtPort(0).getRank() <= MAX_ELTWISE_DIM_RANK;
// TODO: Add EltwiseLog algorithm support for JIT implementation
canUseOptimizedImpl &= !one_of(getAlgorithm(),
Algorithm::EltwiseLog,
@@ -2413,6 +1365,9 @@ void Eltwise::initSupportedPrimitiveDescriptors() {
Algorithm::EltwiseBitwiseRightShift);
bool canUseOptimizedShapeAgnosticImpl = isDynamicNode() && canUseOptimizedImpl;
+#else
+ bool canUseOptimizedImpl = false;
+ bool canUseOptimizedShapeAgnosticImpl = false;
#endif
if (!canUseOptimizedImpl && !fusedWith.empty()) {
@@ -2633,7 +1588,11 @@ void Eltwise::initSupportedPrimitiveDescriptors() {
// same for disabled collapse dims
} else if (lt == Blocked && shape.getRank() != 1 &&
(shape.getMinDims()[1] != Shape::UNDEFINED_DIM && shape.getMinDims()[1] > 1)) {
- size_t blockSize = dnnl::impl::cpu::x64::mayiuse(x64::avx512_core) ? 16 : 8;
+#if defined(OPENVINO_ARCH_X86_64)
+ size_t blockSize = dnnl::impl::cpu::x64::mayiuse(dnnl::impl::cpu::x64::avx512_core) ? 16 : 8;
+#else
+ size_t blockSize = 1;
+#endif
VectorDims blocks = dims;
VectorDims order(blocks.size());
std::iota(order.begin(), order.end(), 0);
@@ -2721,12 +1680,12 @@ void Eltwise::initSupportedPrimitiveDescriptors() {
} else {
OPENVINO_THROW("not supported architecture");
}
-#else
- if (mayiuse(x64::avx512_core)) {
+#elif defined(OPENVINO_ARCH_X86_64)
+ if (mayiuse(dnnl::impl::cpu::x64::avx512_core)) {
impl_type = impl_desc_type::jit_avx512;
- } else if (mayiuse(x64::avx2)) {
+ } else if (mayiuse(dnnl::impl::cpu::x64::avx2)) {
impl_type = impl_desc_type::jit_avx2;
- } else if (mayiuse(x64::sse41)) {
+ } else if (mayiuse(dnnl::impl::cpu::x64::sse41)) {
impl_type = impl_desc_type::jit_sse42;
}
#endif
@@ -3392,10 +2351,12 @@ bool Eltwise::canFuse(const NodePtr& node) const {
(!jitIsSupported(eltwise, eltwise->getAlpha(), eltwise->getBeta(), eltwise->getGamma()))) {
return false;
}
-#else
- if (!mayiuse(x64::sse41) || getInputShapeAtPort(0).getRank() > MAX_ELTWISE_DIM_RANK) {
+#elif defined(OPENVINO_ARCH_X86_64)
+ if (!mayiuse(dnnl::impl::cpu::x64::sse41) || getInputShapeAtPort(0).getRank() > MAX_ELTWISE_DIM_RANK) {
return false;
}
+#else
+ return false;
#endif
// TODO: EltwiseLog is supported only via reference executor
diff --git a/src/plugins/intel_cpu/src/nodes/eltwise.h b/src/plugins/intel_cpu/src/nodes/eltwise.h
index b8e544eb49f..5175ca61cbf 100644
--- a/src/plugins/intel_cpu/src/nodes/eltwise.h
+++ b/src/plugins/intel_cpu/src/nodes/eltwise.h
@@ -14,65 +14,13 @@
#include "dnnl_postops_composer_legacy.h"
#include "executors/eltwise_list.hpp"
#include "nodes/executors/eltwise.hpp"
-#include "nodes/kernels/jit_eltwise_call_args_ptrs.hpp"
-
-#if defined(OPENVINO_ARCH_ARM64)
-# include "kernels/aarch64/jit_uni_eltwise_generic.hpp"
-#endif
+#include "nodes/kernels/jit_eltwise_common.hpp"
namespace ov {
namespace intel_cpu {
namespace node {
-#ifndef OPENVINO_ARCH_ARM64
-
-struct jit_eltwise_params {
- size_t inputs_number;
- size_t input_size;
-
- ov::element::Type src_prc[MAX_ELTWISE_INPUTS];
- ov::element::Type dst_prc;
-
- VectorDims dims;
- VectorDims src_offsets[MAX_ELTWISE_INPUTS];
- VectorDims dst_offsets;
- VectorDims oc_offsets;
-
- size_t src_size[MAX_ELTWISE_INPUTS];
- size_t dst_size;
- size_t oc_size;
-
- size_t work_amount;
- bool use_runtime_ptrs;
- bool do_output_saturation;
-};
-
-struct jit_eltwise_call_args_indexes {
- size_t indexes[MAX_ELTWISE_DIM_RANK];
-};
-
-class Eltwise;
-
-struct jit_uni_eltwise_kernel {
- void (*ker_)(const jit_eltwise_call_args_ptrs*, const jit_eltwise_call_args_indexes*);
-
- void operator()(const jit_eltwise_call_args_ptrs* const_args, const jit_eltwise_call_args_indexes* indexes) {
- assert(ker_);
- ker_(const_args, indexes);
- }
-
- explicit jit_uni_eltwise_kernel(jit_eltwise_params jep) : ker_(nullptr), jep_(std::move(jep)) {}
- virtual ~jit_uni_eltwise_kernel() {}
-
- virtual void create_ker() = 0;
-
- jit_eltwise_params jep_;
-};
-
-#endif
-
enum class EltwiseImplType { reference = 0, optimized = 1, optimizedShapeAgnostic = 2 };
-
class Eltwise : public Node {
public:
class IEltwiseExecutor {
@@ -218,16 +166,6 @@ private:
std::shared_ptr<EltwiseExecutor> eltwiseExecPtr = nullptr;
};
-class eltwise_precision_helper {
-public:
- static ov::element::Type get_precision(const size_t inputs_number,
- const ov::element::Type (&src_prc)[MAX_ELTWISE_INPUTS],
- const std::vector<EltwiseData>& eltwise_data);
-
-private:
- static std::set<std::vector<element::Type>> get_supported_precisions(const Algorithm& algo);
-};
-
} // namespace node
} // namespace intel_cpu
} // namespace ov
diff --git a/src/plugins/intel_cpu/src/nodes/kernels/aarch64/jit_uni_eltwise_generic.cpp b/src/plugins/intel_cpu/src/nodes/kernels/aarch64/jit_uni_eltwise_generic.cpp
index 0462e728917..6501b334097 100644
--- a/src/plugins/intel_cpu/src/nodes/kernels/aarch64/jit_uni_eltwise_generic.cpp
+++ b/src/plugins/intel_cpu/src/nodes/kernels/aarch64/jit_uni_eltwise_generic.cpp
@@ -14,12 +14,6 @@ using namespace Xbyak_aarch64;
using namespace dnnl::impl::cpu;
using namespace dnnl::impl::cpu::aarch64;
-void jit_uni_eltwise_kernel::operator()(const node::jit_eltwise_call_args_ptrs* const_args,
- const jit_eltwise_call_args_indexes* indexes) {
- assert(ker_);
- ker_(const_args, indexes);
-}
-
template <dnnl::impl::cpu::aarch64::cpu_isa_t isa>
jit_uni_eltwise_generic<isa>::jit_uni_eltwise_generic(jit_eltwise_params jep,
std::vector<EltwiseData> eltwise_data,
@@ -35,7 +29,8 @@ template <dnnl::impl::cpu::aarch64::cpu_isa_t isa>
void jit_uni_eltwise_generic<isa>::generate() {
preamble();
- auto const exec_prc = eltwise_precision_helper::get_precision(jep_.inputs_number, jep_.src_prc, eltwise_data_);
+ static const std::vector<element::Type> exec_precisions_priority = {element::f16, element::f32};
+ auto const exec_prc = eltwise_precision_helper::get_precision(jep_.inputs_number, jep_.src_prc, eltwise_data_, exec_precisions_priority);
eltwise_emitter = create_eltwise_emitter(eltwise_data_.front(), exec_prc);
for (size_t i = 1; i < eltwise_data_.size(); ++i) {
@@ -52,11 +47,11 @@ void jit_uni_eltwise_generic<isa>::generate() {
for (size_t i = 0; i < jep.inputs_number; i++) {
ldr(start_to_offsets,
ptr(reg_const_params,
- static_cast<int32_t>(offsetof(node::jit_eltwise_call_args_ptrs, src_offsets) +
+ static_cast<int32_t>(offsetof(jit_eltwise_call_args_ptrs, src_offsets) +
i * sizeof(size_t))));
ldr(get_src_reg(i),
ptr(reg_const_params,
- static_cast<int32_t>(offsetof(node::jit_eltwise_call_args_ptrs, src_ptr[0]) + i * sizeof(size_t))));
+ static_cast<int32_t>(offsetof(jit_eltwise_call_args_ptrs, src_ptr[0]) + i * sizeof(size_t))));
XReg offset_reg = get_aux_gpr(0); // X_TMP_0;
XReg index_reg = get_aux_gpr(1); // X_TMP_1;
for (int j = 0; j < offset_count; j++) {
@@ -67,8 +62,8 @@ void jit_uni_eltwise_generic<isa>::generate() {
}
ldr(start_to_offsets,
- ptr(reg_const_params, static_cast<int32_t>(offsetof(node::jit_eltwise_call_args_ptrs, dst_offsets))));
- ldr(reg_dst, ptr(reg_const_params, static_cast<int32_t>(offsetof(node::jit_eltwise_call_args_ptrs, dst_ptr))));
+ ptr(reg_const_params, static_cast<int32_t>(offsetof(jit_eltwise_call_args_ptrs, dst_offsets))));
+ ldr(reg_dst, ptr(reg_const_params, static_cast<int32_t>(offsetof(jit_eltwise_call_args_ptrs, dst_ptr))));
XReg offset_reg = get_aux_gpr(0); // X_TMP_0;
XReg index_reg = get_aux_gpr(1); // X_TMP_1;
for (int j = 0; j < offset_count; j++) {
@@ -80,7 +75,7 @@ void jit_uni_eltwise_generic<isa>::generate() {
mov(reg_oc_off, 0);
ldr(reg_work_amount,
- ptr(reg_const_params, static_cast<int32_t>(offsetof(node::jit_eltwise_call_args_ptrs, work_amount))));
+ ptr(reg_const_params, static_cast<int32_t>(offsetof(jit_eltwise_call_args_ptrs, work_amount))));
} else {
auto init_ptrs_with_offsets = [this, offset_count, param2](XReg pointer, const std::vector<size_t>& offsets) {
for (int j = 0; j < offset_count; j++) {
@@ -98,11 +93,11 @@ void jit_uni_eltwise_generic<isa>::generate() {
for (size_t i = 0; i < jep.inputs_number; i++) {
ldr(get_src_reg(i),
ptr(param1,
- static_cast<int32_t>(offsetof(node::jit_eltwise_call_args_ptrs, src_ptr) + i * sizeof(size_t))));
+ static_cast<int32_t>(offsetof(jit_eltwise_call_args_ptrs, src_ptr) + i * sizeof(size_t))));
init_ptrs_with_offsets(get_src_reg(i), jep.src_offsets[i]);
}
- ldr(reg_dst, ptr(reg_const_params, static_cast<int32_t>(offsetof(node::jit_eltwise_call_args_ptrs, dst_ptr))));
+ ldr(reg_dst, ptr(reg_const_params, static_cast<int32_t>(offsetof(jit_eltwise_call_args_ptrs, dst_ptr))));
init_ptrs_with_offsets(reg_dst, jep.dst_offsets);
mov(reg_oc_off, 0);
@@ -778,80 +773,21 @@ void jit_uni_eltwise_generic<isa>::apply_post_ops() {
}
}
-namespace {
+template struct jit_uni_eltwise_generic<cpu_isa_t::asimd>;
+} // namespace aarch64
+
+namespace {
template <typename T>
struct SupportedPrecisions {
void operator()(std::set<std::vector<element::Type>>& precisions) {
precisions = T::get_supported_precisions();
}
};
-
-static void set_intersection(const std::set<std::vector<element::Type>>& precisions1,
- const std::set<std::vector<element::Type>>& precisions2,
- std::set<std::vector<element::Type>>& intersection) {
- std::map<element::Type, size_t> intersection_types;
-
- for (auto it1 = precisions1.begin(); it1 != precisions1.end(); ++it1) {
- for (auto it2 = precisions2.begin(); it2 != precisions2.end(); ++it2) {
- const auto& it1_precisions = *it1;
- // all element types are equal
- if (it1_precisions[0] == (*it2)[0]) {
- // first precisions size is used
- intersection_types.emplace(it1_precisions[0], it1_precisions.size());
- }
- }
- }
-
- for (auto it = intersection_types.begin(); it != intersection_types.end(); ++it) {
- intersection.insert(std::vector<element::Type>(it->second, it->first));
- }
-}
} // namespace
-ov::element::Type eltwise_precision_helper::get_precision(const size_t inputs_number,
- const ov::element::Type (&src_prc)[MAX_ELTWISE_INPUTS],
- const std::vector<EltwiseData>& eltwise_data) {
- ov::element::Type exec_prc = ov::element::undefined;
-
- const auto algorithm = eltwise_data.front().algo;
- std::set<std::vector<element::Type>> supported_precision_intersection = get_supported_precisions(algorithm);
- for (size_t i = 1; i < eltwise_data.size(); ++i) {
- std::set<std::vector<element::Type>> prcs = get_supported_precisions(eltwise_data[i].algo);
- std::set<std::vector<element::Type>> prcs_intersect = {};
-
- set_intersection(supported_precision_intersection, prcs, prcs_intersect);
-
- supported_precision_intersection = prcs_intersect;
- }
-
- static const element::Type exec_precisions_priority[] = {element::f16, element::f32};
-
- for (const auto prc : exec_precisions_priority) {
- if (std::any_of(supported_precision_intersection.begin(),
- supported_precision_intersection.end(),
- [&prc](const std::vector<element::Type>& precisions) {
- return std::find(precisions.begin(), precisions.end(), prc) != precisions.end();
- })) {
- exec_prc = prc;
- break;
- }
- }
-
- for (size_t i = 0; i < inputs_number; i++) {
- if (src_prc[i] != exec_prc) {
- exec_prc = ov::element::f32;
- break;
- }
- }
-
- if (exec_prc == ov::element::undefined) {
- OPENVINO_THROW("Eltwise jitter failed to specify execution precision for Eltwise node");
- }
-
- return exec_prc;
-}
+using namespace aarch64;
std::set<std::vector<element::Type>> eltwise_precision_helper::get_supported_precisions(const Algorithm& algo) {
std::set<std::vector<element::Type>> precisions;
@@ -911,8 +847,5 @@ std::set<std::vector<element::Type>> eltwise_precision_helper::get_supported_pre
return precisions;
}
-template struct jit_uni_eltwise_generic<cpu_isa_t::asimd>;
-
-} // namespace aarch64
} // namespace intel_cpu
} // namespace ov
diff --git a/src/plugins/intel_cpu/src/nodes/kernels/aarch64/jit_uni_eltwise_generic.hpp b/src/plugins/intel_cpu/src/nodes/kernels/aarch64/jit_uni_eltwise_generic.hpp
index 107495a6934..93958b7cad4 100644
--- a/src/plugins/intel_cpu/src/nodes/kernels/aarch64/jit_uni_eltwise_generic.hpp
+++ b/src/plugins/intel_cpu/src/nodes/kernels/aarch64/jit_uni_eltwise_generic.hpp
@@ -28,7 +28,7 @@
#include "emitters/plugin/aarch64/jit_eltwise_emitters.hpp"
#include "emitters/plugin/aarch64/jit_emitter.hpp"
-#include "nodes/kernels/jit_eltwise_call_args_ptrs.hpp"
+#include "nodes/kernels/jit_eltwise_common.hpp"
#include "utils/cpu_utils.hpp"
#include "utils/general_utils.h"
@@ -40,45 +40,6 @@ using namespace Xbyak_aarch64;
using namespace dnnl::impl::cpu;
using namespace dnnl::impl::cpu::aarch64;
-struct jit_eltwise_params {
- size_t inputs_number;
- size_t input_size;
-
- ov::element::Type src_prc[MAX_ELTWISE_INPUTS];
- ov::element::Type dst_prc;
-
- VectorDims dims;
- VectorDims src_offsets[MAX_ELTWISE_INPUTS];
- VectorDims dst_offsets;
- VectorDims oc_offsets;
-
- size_t src_size[MAX_ELTWISE_INPUTS];
- size_t dst_size;
- size_t oc_size;
-
- size_t work_amount;
- bool use_runtime_ptrs;
- bool do_output_saturation;
-};
-
-struct jit_eltwise_call_args_indexes {
- size_t indexes[MAX_ELTWISE_DIM_RANK];
-};
-
-struct jit_uni_eltwise_kernel {
- void (*ker_)(const node::jit_eltwise_call_args_ptrs*, const jit_eltwise_call_args_indexes*);
-
- void operator()(const node::jit_eltwise_call_args_ptrs* const_args, const jit_eltwise_call_args_indexes* indexes);
-
- jit_uni_eltwise_kernel() {}
- jit_uni_eltwise_kernel(jit_eltwise_params jep) : ker_(nullptr), jep_(std::move(jep)) {}
- virtual ~jit_uni_eltwise_kernel() {}
-
- virtual void create_ker() = 0;
-
- jit_eltwise_params jep_;
-};
-
template <dnnl::impl::cpu::aarch64::cpu_isa_t isa>
struct jit_uni_eltwise_generic : public jit_uni_eltwise_kernel, jit_generator {
public:
@@ -89,8 +50,6 @@ public:
std::vector<ov::intel_cpu::Type> ops_list,
dnnl::post_ops post_ops);
- jit_uni_eltwise_generic() {}
-
void create_ker() override {
jit_generator::create_kernel();
ker_ = (decltype(ker_))jit_ker();
@@ -255,16 +214,6 @@ private:
std::vector<std::shared_ptr<jit_emitter>> post_op_emitters;
};
-class eltwise_precision_helper {
-public:
- static ov::element::Type get_precision(const size_t inputs_number,
- const ov::element::Type (&src_prc)[MAX_ELTWISE_INPUTS],
- const std::vector<EltwiseData>& eltwise_data);
-
-private:
- static std::set<std::vector<element::Type>> get_supported_precisions(const Algorithm& algo);
-};
-
} // namespace aarch64
} // namespace intel_cpu
} // namespace ov
diff --git a/src/plugins/intel_cpu/src/nodes/kernels/jit_eltwise_call_args_ptrs.hpp b/src/plugins/intel_cpu/src/nodes/kernels/jit_eltwise_call_args_ptrs.hpp
deleted file mode 100644
index 66f119ee839..00000000000
--- a/src/plugins/intel_cpu/src/nodes/kernels/jit_eltwise_call_args_ptrs.hpp
+++ /dev/null
@@ -1,29 +0,0 @@
-// Copyright (C) 2023 Intel Corporation
-// SPDX-License-Identifier: Apache-2.0
-//
-
-#pragma once
-#include <cstddef>
-
-namespace ov {
-namespace intel_cpu {
-namespace node {
-
-#define MAX_ELTWISE_INPUTS 7
-#define MAX_ELTWISE_DIM_RANK 12
-
-struct jit_eltwise_call_args_ptrs {
- const void* src_ptr[MAX_ELTWISE_INPUTS];
- void* dst_ptr;
- // ptr to array of post op inputs pointers (flat list)
- const void** post_op_data;
-
- // shape agnostic kernel
- size_t work_amount;
- const void* src_offsets[MAX_ELTWISE_INPUTS];
- const void* dst_offsets;
-};
-
-} // namespace node
-} // namespace intel_cpu
-} // namespace ov
\ No newline at end of file
diff --git a/src/plugins/intel_cpu/src/nodes/kernels/jit_eltwise_common.cpp b/src/plugins/intel_cpu/src/nodes/kernels/jit_eltwise_common.cpp
new file mode 100644
index 00000000000..0977a559fb1
--- /dev/null
+++ b/src/plugins/intel_cpu/src/nodes/kernels/jit_eltwise_common.cpp
@@ -0,0 +1,90 @@
+// Copyright (C) 2025 Intel Corporation
+// SPDX-License-Identifier: Apache-2.0
+//
+
+#include "jit_eltwise_common.hpp"
+
+namespace ov {
+namespace intel_cpu {
+
+static void set_intersection(const std::set<std::vector<element::Type>>& precisions1,
+ const std::set<std::vector<element::Type>>& precisions2,
+ std::set<std::vector<element::Type>>& intersection) {
+ std::map<element::Type, size_t> intersection_types;
+
+ for (auto it1 = precisions1.begin(); it1 != precisions1.end(); ++it1) {
+ for (auto it2 = precisions2.begin(); it2 != precisions2.end(); ++it2) {
+ const auto& it1_precisions = *it1;
+ // all element types are equal
+ if (it1_precisions[0] == (*it2)[0]) {
+ // first precisions size is used
+ intersection_types.emplace(it1_precisions[0], it1_precisions.size());
+ }
+ }
+ }
+
+ for (auto it = intersection_types.begin(); it != intersection_types.end(); ++it) {
+ intersection.insert(std::vector<element::Type>(it->second, it->first));
+ }
+}
+
+ov::element::Type eltwise_precision_helper::get_precision(const size_t inputs_number,
+ const ov::element::Type (&src_prc)[MAX_ELTWISE_INPUTS],
+ const std::vector<EltwiseData>& eltwise_data,
+ const std::vector<element::Type>& exec_precisions_priority) {
+ ov::element::Type exec_prc = ov::element::undefined;
+
+ std::set<std::vector<element::Type>> supported_precision_intersection =
+ get_supported_precisions(eltwise_data.front().algo);
+
+ // for element-wise operations all inputs must to have the same precisions
+ auto has_same_precision = [](const std::vector<element::Type>& precisions) {
+ return std::all_of(precisions.begin(), precisions.end(), [&precisions](const element::Type precision) {
+ return precision == precisions[0];
+ });
+ };
+
+ assert(std::all_of(supported_precision_intersection.begin(),
+ supported_precision_intersection.end(),
+ has_same_precision));
+
+ for (size_t i = 1; i < eltwise_data.size(); ++i) {
+ std::set<std::vector<element::Type>> prcs = get_supported_precisions(eltwise_data[i].algo);
+ std::set<std::vector<element::Type>> prcs_intersect = {};
+
+ OPENVINO_ASSERT(std::all_of(prcs.begin(), prcs.end(), has_same_precision),
+ "for element-wise nodes all precisions have to be equal");
+
+ set_intersection(supported_precision_intersection, prcs, prcs_intersect);
+
+ supported_precision_intersection = prcs_intersect;
+ }
+
+ for (const auto prc : exec_precisions_priority) {
+ if (std::any_of(supported_precision_intersection.begin(),
+ supported_precision_intersection.end(),
+ [&prc, &src_prc](const std::vector<element::Type>& precisions) {
+ return (std::find(precisions.begin(), precisions.end(), prc) != precisions.end()) &&
+ (src_prc[0] == prc);
+ })) {
+ exec_prc = prc;
+ break;
+ }
+ }
+
+ for (size_t i = 0; i < inputs_number; i++) {
+ if (src_prc[i] != exec_prc) {
+ exec_prc = ov::element::f32;
+ break;
+ }
+ }
+
+ if (exec_prc == ov::element::undefined) {
+ OPENVINO_THROW("Eltwise jitter failed to specify execution precision for Eltwise node");
+ }
+
+ return exec_prc;
+}
+
+} // namespace intel_cpu
+} // namespace ov
diff --git a/src/plugins/intel_cpu/src/nodes/kernels/jit_eltwise_common.hpp b/src/plugins/intel_cpu/src/nodes/kernels/jit_eltwise_common.hpp
new file mode 100644
index 00000000000..9e6ffa54e81
--- /dev/null
+++ b/src/plugins/intel_cpu/src/nodes/kernels/jit_eltwise_common.hpp
@@ -0,0 +1,85 @@
+// Copyright (C) 2025 Intel Corporation
+// SPDX-License-Identifier: Apache-2.0
+//
+
+#pragma once
+
+#include <cassert>
+#include <cstddef>
+
+#include "cpu_types.h"
+#include "nodes/executors/eltwise.hpp"
+#include "openvino/core/type/element_type.hpp"
+
+namespace ov {
+namespace intel_cpu {
+
+#define MAX_ELTWISE_INPUTS 7
+#define MAX_ELTWISE_DIM_RANK 12
+
+struct jit_eltwise_call_args_ptrs {
+ const void* src_ptr[MAX_ELTWISE_INPUTS];
+ void* dst_ptr;
+ // ptr to array of post op inputs pointers (flat list)
+ const void** post_op_data;
+
+ // shape agnostic kernel
+ size_t work_amount;
+ const void* src_offsets[MAX_ELTWISE_INPUTS];
+ const void* dst_offsets;
+};
+
+struct jit_eltwise_params {
+ size_t inputs_number;
+ size_t input_size;
+
+ ov::element::Type src_prc[MAX_ELTWISE_INPUTS];
+ ov::element::Type dst_prc;
+
+ VectorDims dims;
+ VectorDims src_offsets[MAX_ELTWISE_INPUTS];
+ VectorDims dst_offsets;
+ VectorDims oc_offsets;
+
+ size_t src_size[MAX_ELTWISE_INPUTS];
+ size_t dst_size;
+ size_t oc_size;
+
+ size_t work_amount;
+ bool use_runtime_ptrs;
+ bool do_output_saturation;
+};
+
+struct jit_eltwise_call_args_indexes {
+ size_t indexes[MAX_ELTWISE_DIM_RANK];
+};
+
+struct jit_uni_eltwise_kernel {
+ void (*ker_)(const jit_eltwise_call_args_ptrs*, const jit_eltwise_call_args_indexes*);
+
+ void operator()(const jit_eltwise_call_args_ptrs* const_args, const jit_eltwise_call_args_indexes* indexes) {
+ assert(ker_);
+ ker_(const_args, indexes);
+ }
+
+ explicit jit_uni_eltwise_kernel(jit_eltwise_params jep) : ker_(nullptr), jep_(std::move(jep)) {}
+ virtual ~jit_uni_eltwise_kernel() {}
+
+ virtual void create_ker() = 0;
+
+ jit_eltwise_params jep_;
+};
+
+class eltwise_precision_helper {
+public:
+ static ov::element::Type get_precision(const size_t inputs_number,
+ const ov::element::Type (&src_prc)[MAX_ELTWISE_INPUTS],
+ const std::vector<EltwiseData>& eltwise_data,
+ const std::vector<element::Type>& exec_precisions_priority);
+
+private:
+ static std::set<std::vector<element::Type>> get_supported_precisions(const Algorithm& algo);
+};
+
+} // namespace intel_cpu
+} // namespace ov
diff --git a/src/plugins/intel_cpu/src/nodes/kernels/x64/jit_uni_eltwise_generic.cpp b/src/plugins/intel_cpu/src/nodes/kernels/x64/jit_uni_eltwise_generic.cpp
new file mode 100644
index 00000000000..9f8080f96b0
--- /dev/null
+++ b/src/plugins/intel_cpu/src/nodes/kernels/x64/jit_uni_eltwise_generic.cpp
@@ -0,0 +1,947 @@
+// Copyright (C) 2025 Intel Corporation
+// SPDX-License-Identifier: Apache-2.0
+//
+
+#include "jit_uni_eltwise_generic.hpp"
+
+#include <utility>
+#include <vector>
+
+#include "emitters/plugin/x64/jit_dnnl_emitters.hpp"
+#include "emitters/plugin/x64/jit_eltwise_emitters.hpp"
+#include "nodes/eltwise.h"
+
+namespace ov {
+namespace intel_cpu {
+namespace x64 {
+
+using namespace Xbyak;
+using namespace dnnl::impl::cpu;
+using namespace dnnl::impl::cpu::x64;
+
+#define GET_OFF(field) offsetof(jit_eltwise_call_args_ptrs, field)
+
+template <dnnl::impl::cpu::x64::cpu_isa_t isa>
+jit_uni_eltwise_generic<isa>::jit_uni_eltwise_generic(const jit_eltwise_params& jep,
+ const std::vector<EltwiseData>& eltwise_data,
+ const std::vector<ov::intel_cpu::Type>& ops_list,
+ const dnnl::post_ops& post_ops)
+ : jit_uni_eltwise_kernel(jep),
+ jit_generator(jit_name()),
+ eltwise_data_(eltwise_data),
+ ops_list_(ops_list),
+ post_ops_(post_ops) {}
+
+template <dnnl::impl::cpu::x64::cpu_isa_t isa>
+void jit_uni_eltwise_generic<isa>::generate() {
+ static const std::vector<element::Type> exec_precisions_priority =
+ {element::u8, element::i8, element::u16, element::i16, element::bf16, element::i32, element::f32};
+ auto const exec_prc = eltwise_precision_helper::get_precision(jep_.inputs_number,
+ jep_.src_prc,
+ eltwise_data_,
+ exec_precisions_priority);
+
+ eltwise_emitter = create_eltwise_emitter(eltwise_data_.front(), exec_prc);
+ for (size_t i = 1; i < eltwise_data_.size(); ++i) {
+ post_op_emitters.push_back(create_eltwise_emitter(eltwise_data_[i], exec_prc));
+ }
+
+ const auto& p = post_ops_.get();
+ for (int i = 0; i < post_ops_.len(); ++i) {
+ if (!p->entry_[i].is_quantization()) {
+ OPENVINO_THROW("Eltwise jitter error. Unsupported post op detected");
+ }
+ quantization_injectors.push_back(std::make_shared<jit_uni_quantization_injector_f32<isa>>(this,
+ p->entry_[i],
+ vmm_d_weights,
+ vmm_d_bias,
+ reg_d_weights,
+ reg_d_bias));
+ }
+
+ if (mayiuse(avx512_core) || mayiuse(avx2_vnni_2)) {
+ auto const mode = jep_.do_output_saturation ? jit_uni_vcvtneps2bf16::conversion_mode::saturation_mode
+ : jit_uni_vcvtneps2bf16::conversion_mode::default_mode;
+ uni_vcvtneps2bf16.reset(new jit_uni_vcvtneps2bf16(this, isa, element::bf16, mode));
+ }
+
+ const auto& jep = jep_;
+
+ this->preamble();
+
+ const int offset_count = jep.input_size - 1;
+
+ // ptrs initializing
+ if (jep.use_runtime_ptrs) {
+ for (size_t i = 0; i < jep.inputs_number; i++) {
+ mov(start_to_offsets, ptr[reg_const_params + GET_OFF(src_offsets) + i * sizeof(size_t)]);
+ mov(get_src_reg(i), ptr[reg_const_params + GET_OFF(src_ptr[0]) + i * sizeof(size_t)]);
+ for (int j = 0; j < offset_count; j++) {
+ mov(reg_tmp_64, ptr[start_to_offsets + j * sizeof(size_t)]);
+ imul(reg_tmp_64, ptr[reg_indexes + j * sizeof(size_t)]);
+ add(get_src_reg(i), reg_tmp_64);
+ }
+ }
+
+ mov(start_to_offsets, ptr[reg_const_params + GET_OFF(dst_offsets)]);
+ mov(reg_dst, ptr[reg_const_params + GET_OFF(dst_ptr)]);
+ for (int j = 0; j < offset_count; j++) {
+ mov(reg_tmp_64, ptr[start_to_offsets + j * sizeof(size_t)]);
+ imul(reg_tmp_64, ptr[reg_indexes + j * sizeof(size_t)]);
+ add(reg_dst, reg_tmp_64);
+ }
+
+ xor_(reg_oc_off, reg_oc_off);
+
+ mov(reg_work_amount, ptr[reg_const_params + GET_OFF(work_amount)]);
+ } else {
+ auto init_ptrs_with_offsets = [this, offset_count](Reg64 pointer, const std::vector<size_t>& offsets) {
+ for (int j = 0; j < offset_count; j++) {
+ if (jep_.dims[j] != 1 && offsets[j] != 0) {
+ mov(reg_tmp_64, offsets[j]);
+ imul(reg_tmp_64, ptr[reg_indexes + j * sizeof(size_t)]);
+ add(pointer, reg_tmp_64);
+ }
+ }
+ };
+
+ for (size_t i = 0; i < jep.inputs_number; i++) {
+ mov(get_src_reg(i), ptr[reg_const_params + GET_OFF(src_ptr[0]) + i * sizeof(size_t)]);
+ init_ptrs_with_offsets(get_src_reg(i), jep.src_offsets[i]);
+ }
+
+ mov(reg_dst, ptr[reg_const_params + GET_OFF(dst_ptr)]);
+ init_ptrs_with_offsets(reg_dst, jep.dst_offsets);
+
+ xor_(reg_oc_off, reg_oc_off);
+ init_ptrs_with_offsets(reg_oc_off, jep.oc_offsets);
+
+ mov(reg_work_amount, jep.work_amount);
+ }
+
+ mov(reg_post_op_ptrs, ptr[reg_const_params + GET_OFF(post_op_data)]);
+
+ Xbyak::Label unroll_loop_label;
+ Xbyak::Label unroll_loop_end_label;
+ Xbyak::Label main_loop_label;
+ Xbyak::Label main_loop_end_label;
+ Xbyak::Label tail_loop_label;
+ Xbyak::Label tail_loop_end_label;
+
+ if (isa == x64::avx512_core) {
+ vpxord(vmm_zero, vmm_zero, vmm_zero);
+ }
+
+ for (size_t i = 0; i < jep.inputs_number; i++) {
+ if (jep.src_size[i] == 1) {
+ load_vector(get_vmm_reg(i), ptr[get_src_reg(i)], jep.src_prc[i], exec_prc, true);
+ }
+ }
+
+ size_t min_src_size = jep.dst_size;
+ for (size_t i = 0; i < jep.inputs_number; i++) {
+ if (jep.src_size[i] != 1) {
+ min_src_size = std::min(min_src_size, jep.src_size[i]);
+ }
+ }
+ if (jep_.oc_size > 1) {
+ min_src_size = std::min(min_src_size, jep_.oc_size);
+ }
+
+ if (min_src_size != jep.dst_size) {
+ bool is_valid_configuration = true;
+ if (jep.dst_size % min_src_size != 0) {
+ is_valid_configuration = false;
+ }
+
+ for (size_t i = 0; i < jep.inputs_number; i++) {
+ if (jep.src_size[i] != 1 && jep.src_size[i] != min_src_size && jep.src_size[i] != jep.dst_size) {
+ is_valid_configuration = false;
+ }
+ }
+
+ if (jep_.oc_size > 1 && jep_.oc_size != min_src_size && jep_.oc_size != jep.dst_size) {
+ is_valid_configuration = false;
+ }
+
+ if (!is_valid_configuration) {
+ OPENVINO_THROW("Eltwise jitter has invalid configuration for Eltwise node");
+ }
+
+ L(unroll_loop_label);
+ {
+ size_t loop_step = min_src_size;
+ size_t vec_step = cpu_isa_traits<isa>::vlen / exec_prc.size();
+
+ cmp(reg_work_amount, loop_step);
+ jl(unroll_loop_end_label, T_NEAR);
+
+ for (size_t j = 0; j < min_src_size / vec_step; j++) {
+ for (size_t i = 0; i < jep.inputs_number; i++) {
+ if (jep.src_size[i] != 1) {
+ load_vector(get_vmm_reg(i),
+ ptr[get_src_reg(i) + j * vec_step * jep.src_prc[i].size()],
+ jep.src_prc[i],
+ exec_prc,
+ false);
+ }
+ }
+
+ compute_eltwise_op();
+
+ apply_post_ops(false, jep_.oc_size > 1 ? j * vec_step * sizeof(float) : 0);
+
+ store_vector(ptr[reg_dst + j * vec_step * jep.dst_prc.size()], vmm_dst, exec_prc, jep.dst_prc);
+ }
+
+ size_t tail_start = min_src_size - min_src_size % vec_step;
+ for (size_t j = tail_start; j < min_src_size; j++) {
+ for (size_t i = 0; i < jep.inputs_number; i++) {
+ if (jep.src_size[i] != 1) {
+ load_scalar(get_xmm_reg(i),
+ ptr[get_src_reg(i) + j * jep.src_prc[i].size()],
+ jep.src_prc[i],
+ exec_prc);
+ }
+ }
+
+ compute_eltwise_op();
+
+ apply_post_ops(true, jep_.oc_size > 1 ? j * sizeof(float) : 0);
+
+ store_scalar(ptr[reg_dst + j * jep.dst_prc.size()],
+ xmm_dst,
+ exec_prc,
+ jep.dst_prc,
+ jep.do_output_saturation);
+ }
+
+ for (size_t i = 0; i < jep.inputs_number; i++) {
+ if (jep.src_size[i] == jep.dst_size) {
+ add(get_src_reg(i), jep.src_prc[i].size() * loop_step);
+ }
+ }
+
+ add(reg_dst, jep.dst_prc.size() * loop_step);
+ sub(reg_work_amount, loop_step);
+ if (jep_.oc_size > 1 && jep_.oc_size != min_src_size) {
+ add(reg_oc_off, loop_step * sizeof(float));
+ }
+
+ jmp(unroll_loop_label, T_NEAR);
+ }
+
+ L(unroll_loop_end_label);
+ }
+
+ if (min_src_size == jep.dst_size) {
+ L(main_loop_label);
+ {
+ size_t loop_step = cpu_isa_traits<isa>::vlen / exec_prc.size();
+
+ cmp(reg_work_amount, loop_step);
+ jl(main_loop_end_label, T_NEAR);
+
+ for (size_t i = 0; i < jep.inputs_number; i++) {
+ if (jep.src_size[i] != 1) {
+ load_vector(get_vmm_reg(i), ptr[get_src_reg(i)], jep.src_prc[i], exec_prc, false);
+ }
+ }
+
+ compute_eltwise_op();
+
+ apply_post_ops(false);
+
+ store_vector(ptr[reg_dst], vmm_dst, exec_prc, jep.dst_prc);
+
+ for (size_t i = 0; i < jep.inputs_number; i++) {
+ if (jep.src_size[i] != 1) {
+ add(get_src_reg(i), jep.src_prc[i].size() * loop_step);
+ }
+ }
+
+ add(reg_dst, jep.dst_prc.size() * loop_step);
+ sub(reg_work_amount, loop_step);
+ if (jep_.oc_size > 1) {
+ add(reg_oc_off, loop_step * sizeof(float));
+ }
+
+ jmp(main_loop_label, T_NEAR);
+ }
+
+ L(main_loop_end_label);
+ }
+
+ L(tail_loop_label);
+ {
+ size_t loop_step = 1;
+
+ cmp(reg_work_amount, loop_step);
+ jl(tail_loop_end_label, T_NEAR);
+
+ for (size_t i = 0; i < jep.inputs_number; i++) {
+ if (jep.src_size[i] != 1) {
+ load_scalar(get_xmm_reg(i), ptr[get_src_reg(i)], jep.src_prc[i], exec_prc);
+ }
+ }
+
+ compute_eltwise_op();
+
+ apply_post_ops(true);
+
+ store_scalar(ptr[reg_dst], xmm_dst, exec_prc, jep.dst_prc, jep.do_output_saturation);
+
+ for (size_t i = 0; i < jep.inputs_number; i++) {
+ if (jep.src_size[i] != 1) {
+ add(get_src_reg(i), jep.src_prc[i].size() * loop_step);
+ }
+ }
+
+ add(reg_dst, jep.dst_prc.size() * loop_step);
+ sub(reg_work_amount, loop_step);
+ if (jep_.oc_size > 1) {
+ add(reg_oc_off, loop_step * sizeof(float));
+ }
+
+ jmp(tail_loop_label, T_NEAR);
+ }
+
+ L(tail_loop_end_label);
+
+ this->postamble();
+
+ if (uni_vcvtneps2bf16) {
+ uni_vcvtneps2bf16->emit_data();
+ }
+
+ eltwise_emitter->emit_data();
+ for (size_t i = 0; i < post_op_emitters.size(); i++) {
+ post_op_emitters[i]->emit_data();
+ }
+}
+
+namespace {
+struct EltwiseEmitterContext {
+ std::shared_ptr<jit_emitter> emitter;
+ jit_generator* host;
+ cpu_isa_t host_isa;
+ const EltwiseData& opData;
+ ov::element::Type exec_prc;
+};
+
+template <typename T>
+struct EltwiseEmitter {
+ void operator()(EltwiseEmitterContext& ctx) {
+ ctx.emitter = std::make_shared<T>(ctx.host, ctx.host_isa, ctx.exec_prc);
+ }
+};
+
+template <>
+struct EltwiseEmitter<jit_dnnl_aux_emitter> {
+ void operator()(EltwiseEmitterContext& ctx) {
+ auto algKind = static_cast<dnnl_alg_kind_t>(ctx.opData.onednnAlgorithm);
+ ctx.emitter = std::make_shared<jit_dnnl_aux_emitter>(ctx.host,
+ ctx.host_isa,
+ algKind,
+ ctx.opData.alpha,
+ ctx.opData.beta,
+ ctx.exec_prc);
+ }
+};
+
+template <>
+struct EltwiseEmitter<jit_power_static_emitter> {
+ void operator()(EltwiseEmitterContext& ctx) {
+ ctx.emitter = std::make_shared<jit_power_static_emitter>(ctx.host,
+ ctx.host_isa,
+ ctx.opData.alpha,
+ ctx.opData.beta,
+ ctx.opData.gamma,
+ ctx.exec_prc);
+ }
+};
+
+template <>
+struct EltwiseEmitter<jit_is_inf_emitter> {
+ void operator()(EltwiseEmitterContext& ctx) {
+ ctx.emitter = std::make_shared<jit_is_inf_emitter>(ctx.host,
+ ctx.host_isa,
+ ctx.exec_prc,
+ ctx.opData.alpha,
+ ctx.opData.beta);
+ }
+};
+} // namespace
+
+template <dnnl::impl::cpu::x64::cpu_isa_t isa>
+std::shared_ptr<jit_emitter> jit_uni_eltwise_generic<isa>::create_eltwise_emitter(const EltwiseData& data,
+ ov::element::Type exec_prec) {
+ EltwiseEmitterContext ctx = {nullptr, this, isa, data, exec_prec};
+
+ OV_SWITCH(intel_cpu,
+ EltwiseEmitter,
+ ctx,
+ data.algo,
+ OV_CASE(Algorithm::EltwiseRelu, jit_dnnl_aux_emitter),
+ OV_CASE(Algorithm::EltwiseGeluErf, jit_dnnl_aux_emitter),
+ OV_CASE(Algorithm::EltwiseGeluTanh, jit_dnnl_aux_emitter),
+ OV_CASE(Algorithm::EltwiseElu, jit_dnnl_aux_emitter),
+ OV_CASE(Algorithm::EltwiseTanh, jit_dnnl_aux_emitter),
+ OV_CASE(Algorithm::EltwiseSigmoid, jit_dnnl_aux_emitter),
+ OV_CASE(Algorithm::EltwiseAbs, jit_dnnl_aux_emitter),
+ OV_CASE(Algorithm::EltwiseSqrt, jit_dnnl_aux_emitter),
+ OV_CASE(Algorithm::EltwiseSoftRelu, jit_dnnl_aux_emitter),
+ OV_CASE(Algorithm::EltwiseClamp, jit_dnnl_aux_emitter),
+ OV_CASE(Algorithm::EltwiseSwish, jit_dnnl_aux_emitter),
+ OV_CASE(Algorithm::EltwiseHswish, jit_dnnl_aux_emitter),
+ OV_CASE(Algorithm::EltwiseMish, jit_dnnl_aux_emitter),
+ OV_CASE(Algorithm::EltwiseHsigmoid, jit_dnnl_aux_emitter),
+ OV_CASE(Algorithm::EltwiseRoundHalfToEven, jit_dnnl_aux_emitter),
+ OV_CASE(Algorithm::EltwiseRoundHalfAwayFromZero, jit_dnnl_aux_emitter),
+ OV_CASE(Algorithm::EltwiseAdd, jit_add_emitter),
+ OV_CASE(Algorithm::EltwiseMulAdd, jit_mul_add_emitter),
+ OV_CASE(Algorithm::EltwiseSubtract, jit_subtract_emitter),
+ OV_CASE(Algorithm::EltwiseMultiply, jit_multiply_emitter),
+ OV_CASE(Algorithm::EltwiseDivide, jit_divide_emitter),
+ OV_CASE(Algorithm::EltwiseFloor, jit_floor_emitter),
+ OV_CASE(Algorithm::EltwiseCeiling, jit_ceiling_emitter),
+ OV_CASE(Algorithm::EltwiseNegative, jit_negative_emitter),
+ OV_CASE(Algorithm::EltwiseFloorMod, jit_floor_mod_emitter),
+ OV_CASE(Algorithm::EltwiseMod, jit_mod_emitter),
+ OV_CASE(Algorithm::EltwiseMaximum, jit_maximum_emitter),
+ OV_CASE(Algorithm::EltwiseMinimum, jit_minimum_emitter),
+ OV_CASE(Algorithm::EltwiseExp, jit_exp_emitter),
+ OV_CASE(Algorithm::EltwiseSquaredDifference, jit_squared_difference_emitter),
+ OV_CASE(Algorithm::EltwisePowerDynamic, jit_power_dynamic_emitter),
+ OV_CASE(Algorithm::EltwiseEqual, jit_equal_emitter),
+ OV_CASE(Algorithm::EltwiseNotEqual, jit_not_equal_emitter),
+ OV_CASE(Algorithm::EltwiseGreater, jit_greater_emitter),
+ OV_CASE(Algorithm::EltwiseGreaterEqual, jit_greater_equal_emitter),
+ OV_CASE(Algorithm::EltwiseLess, jit_less_emitter),
+ OV_CASE(Algorithm::EltwiseLessEqual, jit_less_equal_emitter),
+ OV_CASE(Algorithm::EltwiseLogicalAnd, jit_logical_and_emitter),
+ OV_CASE(Algorithm::EltwiseLogicalOr, jit_logical_or_emitter),
+ OV_CASE(Algorithm::EltwiseLogicalXor, jit_logical_xor_emitter),
+ OV_CASE(Algorithm::EltwiseLogicalNot, jit_logical_not_emitter),
+ OV_CASE(Algorithm::EltwisePowerStatic, jit_power_static_emitter),
+ OV_CASE(Algorithm::EltwisePrelu, jit_prelu_emitter),
+ OV_CASE(Algorithm::EltwiseErf, jit_erf_emitter),
+ OV_CASE(Algorithm::EltwiseSoftSign, jit_soft_sign_emitter),
+ OV_CASE(Algorithm::EltwiseIsFinite, jit_is_finite_emitter),
+ OV_CASE(Algorithm::EltwiseIsInf, jit_is_inf_emitter),
+ OV_CASE(Algorithm::EltwiseIsNaN, jit_is_nan_emitter),
+ OV_CASE(Algorithm::EltwiseSelect, jit_select_emitter),
+ OV_CASE(Algorithm::EltwiseBitwiseAnd, jit_bitwise_and_emitter),
+ OV_CASE(Algorithm::EltwiseBitwiseNot, jit_bitwise_not_emitter),
+ OV_CASE(Algorithm::EltwiseBitwiseOr, jit_bitwise_or_emitter),
+ OV_CASE(Algorithm::EltwiseBitwiseXor, jit_bitwise_xor_emitter));
+
+ if (!ctx.emitter) {
+ OPENVINO_THROW("Unsupported operation type for Eltwise emitter");
+ }
+
+ return ctx.emitter;
+}
+
+template <dnnl::impl::cpu::x64::cpu_isa_t isa>
+void jit_uni_eltwise_generic<isa>::compute_eltwise_op() {
+ std::vector<size_t> in_idxs;
+ std::vector<size_t> aux_idxs;
+ for (size_t i = 0; i < eltwise_emitter->get_inputs_num(); i++) {
+ in_idxs.push_back(get_vmm_reg(i).getIdx());
+ }
+ for (size_t i = 0; i < eltwise_emitter->aux_vecs_count(); i++) {
+ aux_idxs.push_back(get_aux_vmm(i).getIdx());
+ }
+
+ std::vector<size_t> out_idxs;
+ out_idxs.push_back(vmm_dst.getIdx());
+
+ eltwise_emitter->emit_code(in_idxs, out_idxs, aux_idxs);
+}
+
+template <dnnl::impl::cpu::x64::cpu_isa_t isa>
+void jit_uni_eltwise_generic<isa>::apply_post_ops(bool is_scalar, int offset) {
+ int input_idx = eltwise_emitter->get_inputs_num();
+ int eltwise_post_op_idx = 0;
+ int quantization_post_op_idx = 0;
+ for (size_t i = 1; i < ops_list_.size(); i++) {
+ if (ops_list_[i] == ov::intel_cpu::Type::Eltwise) {
+ std::vector<size_t> in_idxs;
+ std::vector<size_t> aux_idxs;
+ in_idxs.push_back(vmm_dst.getIdx());
+ for (size_t j = 1; j < post_op_emitters[eltwise_post_op_idx]->get_inputs_num(); j++) {
+ in_idxs.push_back(get_vmm_reg(input_idx++).getIdx());
+ }
+ for (size_t j = 0; j < post_op_emitters[eltwise_post_op_idx]->aux_vecs_count(); j++) {
+ aux_idxs.push_back(get_aux_vmm(j).getIdx());
+ }
+
+ std::vector<size_t> out_idxs;
+ out_idxs.push_back(vmm_dst.getIdx());
+
+ post_op_emitters[eltwise_post_op_idx]->emit_code(in_idxs, out_idxs, aux_idxs);
+
+ eltwise_post_op_idx++;
+ } else if (ops_list_[i] == ov::intel_cpu::Type::FakeQuantize) {
+ auto& p = post_ops_.get()->entry_[quantization_post_op_idx];
+ bool do_dequantization = p.quantization.alg == dnnl::impl::alg_kind::quantization_quantize_dequantize;
+ bool do_rounding = do_dequantization || jep_.dst_prc == ov::element::f32 || i != ops_list_.size() - 1;
+ int s_idx = vmm_dst.getIdx();
+
+ size_t ptrs_table_off =
+ quantization_post_op_idx * quantization_injectors[quantization_post_op_idx]->memoryStep();
+
+ quantization_injectors[quantization_post_op_idx]->init_crop_ptrs(reg_post_op_ptrs + ptrs_table_off,
+ reg_oc_off);
+ quantization_injectors[quantization_post_op_idx]->compute_crop(s_idx,
+ s_idx + 1,
+ offset,
+ is_scalar,
+ jep_.oc_size == 1);
+
+ quantization_injectors[quantization_post_op_idx]->init_input_scale_shift_ptrs(
+ reg_post_op_ptrs + ptrs_table_off,
+ reg_oc_off);
+ quantization_injectors[quantization_post_op_idx]
+ ->compute_input_scale_shift(s_idx, s_idx + 1, offset, do_rounding, is_scalar, jep_.oc_size == 1);
+
+ quantization_injectors[quantization_post_op_idx]->init_output_scale_shift_ptrs(
+ reg_post_op_ptrs + ptrs_table_off,
+ reg_oc_off);
+ quantization_injectors[quantization_post_op_idx]->compute_output_scale_shift(s_idx,
+ s_idx + 1,
+ offset,
+ is_scalar,
+ jep_.oc_size == 1);
+
+ quantization_post_op_idx++;
+ } else {
+ OPENVINO_THROW("Unexpected: Eltwise jit kernel: unexpected operation type");
+ }
+ }
+}
+
+template <dnnl::impl::cpu::x64::cpu_isa_t isa>
+void jit_uni_eltwise_generic<isa>::load_vector(Vmm vmm_src,
+ const Xbyak::Address& op,
+ ov::element::Type src_prc,
+ ov::element::Type dst_prc,
+ bool broadcast) {
+ Xmm xmm_src = Xmm(vmm_src.getIdx());
+
+ if (src_prc == dst_prc) {
+ if (broadcast) {
+ load_scalar(xmm_src, op, src_prc, dst_prc);
+ uni_vbroadcastss(vmm_src, xmm_src);
+ } else {
+ uni_vmovups(vmm_src, op);
+ }
+ return;
+ }
+
+ if (broadcast) {
+ load_scalar(xmm_src, op, src_prc, dst_prc);
+ uni_vbroadcastss(vmm_src, xmm_src);
+ } else {
+ switch (src_prc) {
+ case ov::element::f32:
+ case ov::element::i32:
+ uni_vmovups(vmm_src, op);
+ break;
+ case ov::element::bf16:
+ vpmovzxwd(vmm_src, op);
+ uni_vpslld(vmm_src, vmm_src, 16);
+ break;
+ case ov::element::f16:
+ vcvtph2ps(vmm_src, op);
+ break;
+ case ov::element::u16:
+ uni_vpmovzxwd(vmm_src, op);
+ break;
+ case ov::element::i16:
+ uni_vpmovsxwd(vmm_src, op);
+ break;
+ case ov::element::i8:
+ uni_vpmovsxbd(vmm_src, op);
+ break;
+ case ov::element::u8:
+ uni_vpmovzxbd(vmm_src, op);
+ break;
+ default:
+ OPENVINO_THROW("unknown src_prc");
+ }
+
+ switch (dst_prc) {
+ case ov::element::f32:
+ if (!src_prc.is_real()) {
+ uni_vcvtdq2ps(vmm_src, vmm_src);
+ }
+ break;
+ case ov::element::i32:
+ if (src_prc.is_real()) {
+ uni_vcvtps2dq(vmm_src, vmm_src);
+ }
+ break;
+ default:
+ OPENVINO_THROW("unknown dst_prc");
+ }
+ }
+}
+
+template <dnnl::impl::cpu::x64::cpu_isa_t isa>
+void jit_uni_eltwise_generic<isa>::load_scalar(Xmm xmm_src,
+ const Xbyak::Address& op,
+ ov::element::Type src_prc,
+ ov::element::Type dst_prc) {
+ if (src_prc == dst_prc) {
+ switch (src_prc.size()) {
+ case 4:
+ uni_vmovss(xmm_src, op);
+ break;
+ case 1:
+ mov(reg_tmp_8, op);
+ movzx(reg_tmp_32, reg_tmp_8);
+ uni_vmovd(xmm_src, reg_tmp_32);
+ break;
+ default:
+ OPENVINO_THROW("unknown prc");
+ }
+ return;
+ }
+
+ switch (src_prc) {
+ case ov::element::f32:
+ case ov::element::i32:
+ uni_vmovss(xmm_src, op);
+ break;
+ case ov::element::bf16:
+ if (isa == x64::avx2_vnni_2) {
+ vbcstnebf162ps(xmm_src, op);
+ } else {
+ uni_vpinsrw(xmm_src, xmm_src, op, 0);
+ uni_vpslld(xmm_src, xmm_src, 16);
+ }
+ break;
+ case ov::element::f16:
+ if (isa == x64::avx2_vnni_2) {
+ vbcstnesh2ps(xmm_src, op);
+ } else {
+ vcvtph2ps(xmm_src, op);
+ }
+ break;
+ case ov::element::i16:
+ uni_vpinsrw(xmm_src, xmm_src, op, 0);
+ uni_vpmovsxwd(xmm_src, op);
+ break;
+ case ov::element::u16:
+ uni_vpinsrw(xmm_src, xmm_src, op, 0);
+ uni_vpmovzxwd(xmm_src, op);
+ break;
+ case ov::element::i8:
+ movsx(reg_tmp_32, op);
+ uni_vmovq(xmm_src, reg_tmp_64);
+ break;
+ case ov::element::u8:
+ movzx(reg_tmp_32, op);
+ uni_vmovq(xmm_src, reg_tmp_64);
+ break;
+ default:
+ OPENVINO_THROW("unknown src_prc");
+ }
+
+ switch (dst_prc) {
+ case ov::element::f32:
+ if (!src_prc.is_real()) {
+ uni_vcvtdq2ps(xmm_src, xmm_src);
+ }
+ break;
+ case ov::element::i32:
+ if (src_prc.is_real()) {
+ uni_vcvtps2dq(xmm_src, xmm_src);
+ }
+ break;
+ default:
+ OPENVINO_THROW("unknown dst_prc");
+ }
+}
+
+template <dnnl::impl::cpu::x64::cpu_isa_t isa>
+void jit_uni_eltwise_generic<isa>::store_vector(const Xbyak::Address& op,
+ Vmm vmm_dst,
+ ov::element::Type src_prc,
+ ov::element::Type dst_prc) {
+ Xmm xmm_dst = Xmm(vmm_dst.getIdx());
+ Ymm ymm_dst = Ymm(vmm_dst.getIdx());
+
+ if (src_prc == dst_prc) {
+ uni_vmovups(op, vmm_dst);
+ return;
+ }
+
+ switch (src_prc) {
+ case ov::element::f32:
+ if (!dst_prc.is_real()) {
+ uni_vcvtps2dq(vmm_dst, vmm_dst);
+ }
+ break;
+ case ov::element::i32:
+ if (dst_prc.is_real()) {
+ uni_vcvtdq2ps(vmm_dst, vmm_dst);
+ }
+ break;
+ default:
+ OPENVINO_THROW("unknown src_prc");
+ }
+
+ switch (dst_prc) {
+ case ov::element::f32:
+ case ov::element::i32:
+ uni_vmovups(op, vmm_dst);
+ break;
+ case ov::element::bf16:
+ if (isa == x64::avx512_core) {
+ uni_vcvtneps2bf16->emit_code({static_cast<size_t>(vmm_dst.getIdx())},
+ {static_cast<size_t>(ymm_dst.getIdx())});
+ vmovdqu16(op, ymm_dst);
+ } else {
+ uni_vcvtneps2bf16->emit_code({static_cast<size_t>(vmm_dst.getIdx())},
+ {static_cast<size_t>(xmm_dst.getIdx())});
+ uni_vmovdqu(op, xmm_dst);
+ }
+ break;
+ case ov::element::f16:
+ vcvtps2ph(op, vmm_dst, 0x4);
+ break;
+ case ov::element::i16:
+ if (isa == x64::avx512_core) {
+ vpmovsdw(op, vmm_dst);
+ } else {
+ uni_vpackssdw(vmm_dst, vmm_dst, vmm_dst);
+ if (isa != x64::sse41) {
+ vpermq(ymm_dst, ymm_dst, 0x08);
+ uni_vmovdqu(op, xmm_dst);
+ } else {
+ movq(op, xmm_dst);
+ }
+ }
+ break;
+ case ov::element::u16:
+ if (isa == x64::avx512_core) {
+ vpmaxsd(vmm_dst, vmm_zero, vmm_dst);
+ vpmovusdw(op, vmm_dst);
+ } else {
+ uni_vpackusdw(vmm_dst, vmm_dst, vmm_dst);
+ if (isa != x64::sse41) {
+ vpermq(ymm_dst, ymm_dst, 0x08);
+ uni_vmovdqu(op, xmm_dst);
+ } else {
+ movq(op, xmm_dst);
+ }
+ }
+ break;
+ case ov::element::i8:
+ if (isa == x64::avx512_core) {
+ vpmovsdb(op, vmm_dst);
+ } else {
+ uni_vpackssdw(vmm_dst, vmm_dst, vmm_dst);
+ if (isa != x64::sse41) {
+ vpermq(ymm_dst, ymm_dst, 0x08);
+ }
+ uni_vpacksswb(vmm_dst, vmm_dst, vmm_dst);
+ if (isa != x64::sse41) {
+ vmovq(op, xmm_dst);
+ } else {
+ movd(op, xmm_dst);
+ }
+ }
+ break;
+ case ov::element::u8:
+ if (isa == x64::avx512_core) {
+ vpmaxsd(vmm_dst, vmm_zero, vmm_dst);
+ vpmovusdb(op, vmm_dst);
+ } else {
+ uni_vpackusdw(vmm_dst, vmm_dst, vmm_dst);
+ if (isa != x64::sse41) {
+ vpermq(ymm_dst, ymm_dst, 0x08);
+ }
+ uni_vpackuswb(vmm_dst, vmm_dst, vmm_dst);
+ if (isa != x64::sse41) {
+ vmovq(op, xmm_dst);
+ } else {
+ movd(op, xmm_dst);
+ }
+ }
+ break;
+ default:
+ OPENVINO_THROW("unknown dst_prc");
+ }
+}
+
+template <dnnl::impl::cpu::x64::cpu_isa_t isa>
+void jit_uni_eltwise_generic<isa>::store_scalar(const Xbyak::Address& op,
+ Xmm xmm_dst,
+ ov::element::Type src_prc,
+ ov::element::Type dst_prc,
+ const bool do_output_saturation) {
+ if (src_prc == dst_prc) {
+ switch (src_prc.size()) {
+ case 4:
+ uni_vmovss(op, xmm_dst);
+ break;
+ case 1:
+ movq(reg_tmp_64, xmm_dst);
+ mov(op, reg_tmp_8);
+ break;
+ default:
+ OPENVINO_THROW("unknown prc");
+ }
+ return;
+ }
+
+ switch (src_prc) {
+ case ov::element::f32:
+ if (!dst_prc.is_real()) {
+ uni_vcvtps2dq(xmm_dst, xmm_dst);
+ }
+ break;
+ case ov::element::i32:
+ if (dst_prc.is_real()) {
+ uni_vcvtdq2ps(xmm_dst, xmm_dst);
+ }
+ break;
+ default:
+ OPENVINO_THROW("unknown src_prc");
+ }
+
+ switch (dst_prc) {
+ case ov::element::f32:
+ case ov::element::i32:
+ uni_vmovss(op, xmm_dst);
+ break;
+ case ov::element::bf16:
+ if (do_output_saturation) {
+ uni_vpsrld(xmm_dst, xmm_dst, 16);
+ } else {
+ uni_vcvtneps2bf16->emit_code({static_cast<size_t>(xmm_dst.getIdx())},
+ {static_cast<size_t>(xmm_dst.getIdx())});
+ }
+ uni_vpextrw(op, xmm_dst, 0x0);
+ break;
+ case ov::element::f16:
+ vcvtps2ph(xmm_dst, xmm_dst, 0x4);
+ movq(reg_tmp_64, xmm_dst);
+ mov(op, reg_tmp_16);
+ break;
+ case ov::element::i16:
+ uni_vpackssdw(xmm_dst, xmm_dst, xmm_dst);
+ movq(reg_tmp_64, xmm_dst);
+ mov(op, reg_tmp_16);
+ break;
+ case ov::element::u16:
+ uni_vpackusdw(xmm_dst, xmm_dst, xmm_dst);
+ movq(reg_tmp_64, xmm_dst);
+ mov(op, reg_tmp_16);
+ break;
+ case ov::element::i8:
+ uni_vpackssdw(xmm_dst, xmm_dst, xmm_dst);
+ uni_vpacksswb(xmm_dst, xmm_dst, xmm_dst);
+ movq(reg_tmp_64, xmm_dst);
+ mov(op, reg_tmp_8);
+ break;
+ case ov::element::u8:
+ uni_vpackusdw(xmm_dst, xmm_dst, xmm_dst);
+ uni_vpackuswb(xmm_dst, xmm_dst, xmm_dst);
+ movq(reg_tmp_64, xmm_dst);
+ mov(op, reg_tmp_8);
+ break;
+ default:
+ OPENVINO_THROW("unknown dst_prc");
+ }
+}
+
+template struct jit_uni_eltwise_generic<cpu_isa_t::sse41>;
+template struct jit_uni_eltwise_generic<cpu_isa_t::avx2>;
+template struct jit_uni_eltwise_generic<cpu_isa_t::avx512_core>;
+
+} // namespace x64
+
+namespace {
+template <typename T>
+struct SupportedPrecisions {
+ void operator()(std::set<std::vector<element::Type>>& precisions) {
+ precisions = T::get_supported_precisions();
+ }
+};
+} // namespace
+
+std::set<std::vector<element::Type>> eltwise_precision_helper::get_supported_precisions(const Algorithm& algo) {
+ std::set<std::vector<element::Type>> precisions;
+
+ OV_SWITCH(intel_cpu,
+ SupportedPrecisions,
+ precisions,
+ algo,
+ OV_CASE(Algorithm::EltwiseRelu, jit_dnnl_aux_emitter),
+ OV_CASE(Algorithm::EltwiseGeluErf, jit_dnnl_aux_emitter),
+ OV_CASE(Algorithm::EltwiseGeluTanh, jit_dnnl_aux_emitter),
+ OV_CASE(Algorithm::EltwiseElu, jit_dnnl_aux_emitter),
+ OV_CASE(Algorithm::EltwiseTanh, jit_dnnl_aux_emitter),
+ OV_CASE(Algorithm::EltwiseSigmoid, jit_dnnl_aux_emitter),
+ OV_CASE(Algorithm::EltwiseAbs, jit_dnnl_aux_emitter),
+ OV_CASE(Algorithm::EltwiseSqrt, jit_dnnl_aux_emitter),
+ OV_CASE(Algorithm::EltwiseSoftRelu, jit_dnnl_aux_emitter),
+ OV_CASE(Algorithm::EltwiseClamp, jit_dnnl_aux_emitter),
+ OV_CASE(Algorithm::EltwiseSwish, jit_dnnl_aux_emitter),
+ OV_CASE(Algorithm::EltwiseHswish, jit_dnnl_aux_emitter),
+ OV_CASE(Algorithm::EltwiseMish, jit_dnnl_aux_emitter),
+ OV_CASE(Algorithm::EltwiseHsigmoid, jit_dnnl_aux_emitter),
+ OV_CASE(Algorithm::EltwiseRoundHalfToEven, jit_dnnl_aux_emitter),
+ OV_CASE(Algorithm::EltwiseRoundHalfAwayFromZero, jit_dnnl_aux_emitter),
+ OV_CASE(Algorithm::EltwiseAdd, jit_add_emitter),
+ OV_CASE(Algorithm::EltwiseMulAdd, jit_mul_add_emitter),
+ OV_CASE(Algorithm::EltwiseSubtract, jit_subtract_emitter),
+ OV_CASE(Algorithm::EltwiseMultiply, jit_multiply_emitter),
+ OV_CASE(Algorithm::EltwiseDivide, jit_divide_emitter),
+ OV_CASE(Algorithm::EltwiseFloor, jit_floor_emitter),
+ OV_CASE(Algorithm::EltwiseCeiling, jit_ceiling_emitter),
+ OV_CASE(Algorithm::EltwiseNegative, jit_negative_emitter),
+ OV_CASE(Algorithm::EltwiseFloorMod, jit_floor_mod_emitter),
+ OV_CASE(Algorithm::EltwiseMod, jit_mod_emitter),
+ OV_CASE(Algorithm::EltwiseMaximum, jit_maximum_emitter),
+ OV_CASE(Algorithm::EltwiseMinimum, jit_minimum_emitter),
+ OV_CASE(Algorithm::EltwiseExp, jit_exp_emitter),
+ OV_CASE(Algorithm::EltwiseSquaredDifference, jit_squared_difference_emitter),
+ OV_CASE(Algorithm::EltwisePowerDynamic, jit_power_dynamic_emitter),
+ OV_CASE(Algorithm::EltwiseEqual, jit_equal_emitter),
+ OV_CASE(Algorithm::EltwiseNotEqual, jit_not_equal_emitter),
+ OV_CASE(Algorithm::EltwiseGreater, jit_greater_emitter),
+ OV_CASE(Algorithm::EltwiseGreaterEqual, jit_greater_equal_emitter),
+ OV_CASE(Algorithm::EltwiseLess, jit_less_emitter),
+ OV_CASE(Algorithm::EltwiseLessEqual, jit_less_equal_emitter),
+ OV_CASE(Algorithm::EltwiseLogicalAnd, jit_logical_and_emitter),
+ OV_CASE(Algorithm::EltwiseLogicalOr, jit_logical_or_emitter),
+ OV_CASE(Algorithm::EltwiseLogicalXor, jit_logical_xor_emitter),
+ OV_CASE(Algorithm::EltwiseLogicalNot, jit_logical_not_emitter),
+ OV_CASE(Algorithm::EltwisePowerStatic, jit_power_static_emitter),
+ OV_CASE(Algorithm::EltwisePrelu, jit_prelu_emitter),
+ OV_CASE(Algorithm::EltwiseErf, jit_erf_emitter),
+ OV_CASE(Algorithm::EltwiseSoftSign, jit_soft_sign_emitter),
+ OV_CASE(Algorithm::EltwiseIsFinite, jit_is_finite_emitter),
+ OV_CASE(Algorithm::EltwiseIsInf, jit_is_inf_emitter),
+ OV_CASE(Algorithm::EltwiseIsNaN, jit_is_nan_emitter),
+ OV_CASE(Algorithm::EltwiseSelect, jit_select_emitter),
+ OV_CASE(Algorithm::EltwiseBitwiseAnd, jit_bitwise_and_emitter),
+ OV_CASE(Algorithm::EltwiseBitwiseNot, jit_bitwise_not_emitter),
+ OV_CASE(Algorithm::EltwiseBitwiseOr, jit_bitwise_or_emitter),
+ OV_CASE(Algorithm::EltwiseBitwiseXor, jit_bitwise_xor_emitter));
+
+ if (precisions.empty()) {
+ OPENVINO_THROW("Unsupported operation type for Eltwise emitter");
+ }
+
+ return precisions;
+}
+
+} // namespace intel_cpu
+} // namespace ov
diff --git a/src/plugins/intel_cpu/src/nodes/kernels/x64/jit_uni_eltwise_generic.hpp b/src/plugins/intel_cpu/src/nodes/kernels/x64/jit_uni_eltwise_generic.hpp
new file mode 100644
index 00000000000..e7cb6066815
--- /dev/null
+++ b/src/plugins/intel_cpu/src/nodes/kernels/x64/jit_uni_eltwise_generic.hpp
@@ -0,0 +1,127 @@
+// Copyright (C) 2025 Intel Corporation
+// SPDX-License-Identifier: Apache-2.0
+//
+
+#pragma once
+
+#include <utility>
+#include <vector>
+
+#include "cpu/x64/cpu_isa_traits.hpp"
+#include "cpu/x64/injectors/jit_uni_quantization_injector.hpp"
+#include "cpu/x64/jit_generator.hpp"
+#include "emitters/plugin/x64/jit_bf16_emitters.hpp"
+#include "emitters/plugin/x64/jit_emitter.hpp"
+#include "nodes/executors/eltwise.hpp"
+#include "nodes/kernels/jit_eltwise_common.hpp"
+#include "onednn/dnnl.h"
+#include "utils/cpu_utils.hpp"
+#include "utils/general_utils.h"
+
+namespace ov {
+namespace intel_cpu {
+namespace x64 {
+
+template <dnnl::impl::cpu::x64::cpu_isa_t isa>
+struct jit_uni_eltwise_generic : public jit_uni_eltwise_kernel, public dnnl::impl::cpu::x64::jit_generator {
+ DECLARE_CPU_JIT_AUX_FUNCTIONS(jit_uni_eltwise_generic)
+
+ jit_uni_eltwise_generic(const jit_eltwise_params& jep,
+ const std::vector<EltwiseData>& eltwise_data,
+ const std::vector<ov::intel_cpu::Type>& ops_list,
+ const dnnl::post_ops& post_ops);
+
+ void create_ker() override {
+ jit_generator::create_kernel();
+ ker_ = (decltype(ker_))jit_ker();
+ }
+
+ void generate() override;
+
+private:
+ using Vmm = typename dnnl::impl::utils::conditional3<isa == dnnl::impl::cpu::x64::sse41,
+ Xbyak::Xmm,
+ isa == dnnl::impl::cpu::x64::avx2,
+ Xbyak::Ymm,
+ Xbyak::Zmm>::type;
+
+ inline Xbyak::Reg64 get_src_reg(int idx) {
+ return Xbyak::Reg64(r8.getIdx() + idx);
+ }
+
+ inline Vmm get_vmm_reg(int idx) {
+ return Vmm(1 + idx);
+ }
+
+ inline Vmm get_aux_vmm(int idx) {
+ return Vmm(10 + idx);
+ }
+
+ inline Xbyak::Xmm get_xmm_reg(int idx) {
+ return Xbyak::Xmm(get_vmm_reg(idx).getIdx());
+ }
+
+ Xbyak::Reg64 reg_post_op_ptrs = rax;
+ Xbyak::Reg64 start_to_offsets = reg_post_op_ptrs; // rax
+ Xbyak::Reg64 reg_dst = rbx;
+ Xbyak::Reg64 reg_work_amount = rdx;
+
+ static constexpr auto abi_param_regs = dnnl::impl::cpu::x64::abi_param_regs;
+ static constexpr auto abi_not_param_reg = dnnl::impl::cpu::x64::abi_not_param_reg;
+ Xbyak::Reg64 reg_oc_off = abi_not_param1;
+ Xbyak::Reg64 reg_const_params = abi_param1;
+ Xbyak::Reg64 reg_indexes = abi_param2; // reg_d_bias
+
+ Xbyak::Reg8 reg_tmp_8 = Xbyak::Reg8(r15.getIdx());
+ Xbyak::Reg16 reg_tmp_16 = Xbyak::Reg16(r15.getIdx());
+ Xbyak::Reg32 reg_tmp_32 = Xbyak::Reg32(r15.getIdx());
+ Xbyak::Reg64 reg_tmp_64 = Xbyak::Reg64(r15.getIdx());
+
+ Xbyak::Reg64 reg_d_weights = rbp;
+ Xbyak::Reg64 reg_d_bias = rsi;
+
+ Vmm vmm_dst = Vmm(9);
+ Xbyak::Xmm xmm_dst = Xbyak::Xmm(9);
+
+ Vmm vmm_d_weights = Vmm(12);
+ Vmm vmm_d_bias = Vmm(13);
+ Vmm vmm_zero = Vmm(15);
+
+ std::shared_ptr<jit_uni_vcvtneps2bf16> uni_vcvtneps2bf16;
+
+ std::shared_ptr<jit_emitter> eltwise_emitter = nullptr;
+ std::vector<std::shared_ptr<jit_emitter>> post_op_emitters = {};
+
+ std::vector<std::shared_ptr<dnnl::impl::cpu::x64::jit_uni_quantization_injector_f32<isa>>> quantization_injectors =
+ {};
+
+ const std::vector<EltwiseData>& eltwise_data_;
+ const std::vector<ov::intel_cpu::Type>& ops_list_;
+ const dnnl::post_ops& post_ops_;
+
+ std::shared_ptr<jit_emitter> create_eltwise_emitter(const EltwiseData& data, ov::element::Type exec_prec);
+
+ void compute_eltwise_op();
+ void apply_post_ops(bool is_scalar, int offset = 0);
+
+ void load_vector(Vmm vmm_src,
+ const Xbyak::Address& op,
+ ov::element::Type src_prc,
+ ov::element::Type dst_prc,
+ bool broadcast);
+ void load_scalar(Xbyak::Xmm xmm_src,
+ const Xbyak::Address& op,
+ ov::element::Type src_prc,
+ ov::element::Type dst_prc);
+
+ void store_vector(const Xbyak::Address& op, Vmm vmm_dst, ov::element::Type src_prc, ov::element::Type dst_prc);
+ void store_scalar(const Xbyak::Address& op,
+ Xbyak::Xmm xmm_dst,
+ ov::element::Type src_prc,
+ ov::element::Type dst_prc,
+ const bool do_output_saturation);
+};
+
+} // namespace x64
+} // namespace intel_cpu
+} // namespace ov
diff --git a/src/plugins/intel_cpu/tests/unit/nodes/eltwise_node_test.cpp b/src/plugins/intel_cpu/tests/unit/nodes/eltwise_node_test.cpp
index 091f9e0d1bc..60b81c38f1e 100644
--- a/src/plugins/intel_cpu/tests/unit/nodes/eltwise_node_test.cpp
+++ b/src/plugins/intel_cpu/tests/unit/nodes/eltwise_node_test.cpp
@@ -10,6 +10,11 @@ using namespace ov::intel_cpu;
class EltwisePrecisionHelperTest : public testing::Test {};
+namespace EltwisePrecisionHelper {
+static const std::vector<ov::element::Type> exec_precisions_priority =
+ {ov::element::u8, ov::element::bf16, ov::element::i32, ov::element::f32};
+} // namespace EltwisePrecisionHelper
+
TEST(EltwisePrecisionHelperTest, get_precision_mixed) {
ov::element::Type src_prc[MAX_ELTWISE_INPUTS];
const size_t inputs_size = 4ull;
@@ -22,7 +27,8 @@ TEST(EltwisePrecisionHelperTest, get_precision_mixed) {
{Algorithm::EltwiseMulAdd}
};
- const auto precision = ov::intel_cpu::node::eltwise_precision_helper::get_precision(inputs_size, src_prc, eltwise_data);
+ const auto precision =
+ ov::intel_cpu::eltwise_precision_helper::get_precision(inputs_size, src_prc, eltwise_data, EltwisePrecisionHelper::exec_precisions_priority);
ASSERT_EQ(ov::element::i32, precision);
}
@@ -38,6 +44,7 @@ TEST(EltwisePrecisionHelperTest, get_precision_single) {
{Algorithm::EltwiseMod}
};
- const auto precision = ov::intel_cpu::node::eltwise_precision_helper::get_precision(inputs_size, src_prc, eltwise_data);
+ const auto precision =
+ ov::intel_cpu::eltwise_precision_helper::get_precision(inputs_size, src_prc, eltwise_data, EltwisePrecisionHelper::exec_precisions_priority);
ASSERT_EQ(ov::element::f32, precision);
}