diff --git a/src/plugins/intel_cpu/src/emitters/x64/jit_eltwise_emitters.cpp b/src/plugins/intel_cpu/src/emitters/x64/jit_eltwise_emitters.cpp index d6ccd2de563227..fd3f5c9f37a6a7 100644 --- a/src/plugins/intel_cpu/src/emitters/x64/jit_eltwise_emitters.cpp +++ b/src/plugins/intel_cpu/src/emitters/x64/jit_eltwise_emitters.cpp @@ -2243,5 +2243,191 @@ void jit_select_emitter::emit_isa(const std::vector &in_vec_idxs, const h->vblendmps(vmm_dst | k_mask, vmm_src1, vmm_src0); } } + +/// BITWISE_AND /// +jit_bitwise_and_emitter::jit_bitwise_and_emitter(x64::jit_generator* host, x64::cpu_isa_t host_isa, const std::shared_ptr& node, Precision exec_prc) + : jit_emitter(host, host_isa, exec_prc) {} + +jit_bitwise_and_emitter::jit_bitwise_and_emitter(x64::jit_generator* host, x64::cpu_isa_t host_isa, Precision exec_prc) + : jit_emitter(host, host_isa, exec_prc) {} + +size_t jit_bitwise_and_emitter::get_inputs_num() const { return 2; } + +std::set> jit_bitwise_and_emitter::get_supported_precisions(const std::shared_ptr& node) { + return { + {element::i8, element::i8}, + {element::i16, element::i16}, + {element::i32, element::i32}, + {element::u8, element::u8}, + {element::u16, element::u16} + }; +} + +void jit_bitwise_and_emitter::emit_impl(const std::vector& in_vec_idxs, const std::vector& out_vec_idxs) const { + if (host_isa_ == x64::sse41) { + emit_isa(in_vec_idxs, out_vec_idxs); + } else if (host_isa_ == x64::avx2) { + emit_isa(in_vec_idxs, out_vec_idxs); + } else if (host_isa_ == x64::avx512_core) { + emit_isa(in_vec_idxs, out_vec_idxs); + } else { + OPENVINO_ASSERT(!"unsupported isa"); + } +} + +template +void jit_bitwise_and_emitter::emit_isa(const std::vector& in_vec_idxs, const std::vector& out_vec_idxs) const { + using Vmm = typename conditional3::type; + Vmm vmm_src0 = Vmm(in_vec_idxs[0]); + Vmm vmm_src1 = Vmm(in_vec_idxs[1]); + Vmm vmm_dst = Vmm(out_vec_idxs[0]); + + h->uni_vandps(vmm_dst, vmm_src0, vmm_src1); +} + +/// BITWISE_NOT /// +jit_bitwise_not_emitter::jit_bitwise_not_emitter(x64::jit_generator* host, x64::cpu_isa_t host_isa, const std::shared_ptr& node, Precision exec_prc) + : jit_emitter(host, host_isa, exec_prc) { + prepare_table(); +} + +jit_bitwise_not_emitter::jit_bitwise_not_emitter(x64::jit_generator* host, x64::cpu_isa_t host_isa, Precision exec_prc) + : jit_emitter(host, host_isa, exec_prc) { + prepare_table(); +} + +size_t jit_bitwise_not_emitter::get_inputs_num() const { return 1; } + +std::set> jit_bitwise_not_emitter::get_supported_precisions(const std::shared_ptr& node) { + return { + {element::i8, element::i8}, + {element::i16, element::i16}, + {element::i32, element::i32}, + {element::u8, element::u8}, + {element::u16, element::u16} + }; +} + +size_t jit_bitwise_not_emitter::aux_vecs_count() const { return 1; } + +void jit_bitwise_not_emitter::emit_impl(const std::vector& in_vec_idxs, const std::vector& out_vec_idxs) const { + if (host_isa_ == x64::sse41) { + emit_isa(in_vec_idxs, out_vec_idxs); + } else if (host_isa_ == x64::avx2) { + emit_isa(in_vec_idxs, out_vec_idxs); + } else if (host_isa_ == x64::avx512_core) { + emit_isa(in_vec_idxs, out_vec_idxs); + } else { + OPENVINO_ASSERT(!"unsupported isa"); + } +} + +template +void jit_bitwise_not_emitter::emit_isa(const std::vector& in_vec_idxs, const std::vector& out_vec_idxs) const { + using Vmm = typename conditional3::type; + Vmm vmm_src = Vmm(in_vec_idxs[0]); + Vmm vmm_dst = Vmm(out_vec_idxs[0]); + Vmm vmm_aux = Vmm(aux_vec_idxs[0]); + + if (isa == x64::sse41) { + std::cout << "jit_bitwise_not_emitter::emit_isa: x64::sse41" << std::endl; + if (vmm_dst.getIdx() != vmm_src.getIdx()) { + h->uni_vmovups(vmm_dst, vmm_src); + } + h->andnps(vmm_dst, table_val("all_bits")); + } else if ((host_isa_ == x64::avx2) || (host_isa_ == x64::avx512_core)) { + std::cout << "jit_bitwise_not_emitter::emit_isa: x64::avx2 or x64::avx512_core" << std::endl; + h->vandnps(vmm_dst, vmm_src, table_val("all_bits")); + } else { + OPENVINO_ASSERT(!"unsupported isa"); + } +} + +void jit_bitwise_not_emitter::register_table_entries() { + push_arg_entry_of("all_bits", 0xFFFFFFFF, true); +} + +/// BITWISE_OR /// +jit_bitwise_or_emitter::jit_bitwise_or_emitter(x64::jit_generator* host, x64::cpu_isa_t host_isa, const std::shared_ptr& node, Precision exec_prc) + : jit_emitter(host, host_isa, exec_prc) {} + +jit_bitwise_or_emitter::jit_bitwise_or_emitter(x64::jit_generator* host, x64::cpu_isa_t host_isa, Precision exec_prc) + : jit_emitter(host, host_isa, exec_prc) {} + +size_t jit_bitwise_or_emitter::get_inputs_num() const { return 2; } + +std::set> jit_bitwise_or_emitter::get_supported_precisions(const std::shared_ptr& node) { + return { + {element::i8, element::i8}, + {element::i16, element::i16}, + {element::i32, element::i32}, + {element::u8, element::u8}, + {element::u16, element::u16} + }; +} + +void jit_bitwise_or_emitter::emit_impl(const std::vector& in_vec_idxs, const std::vector& out_vec_idxs) const { + if (host_isa_ == x64::sse41) { + emit_isa(in_vec_idxs, out_vec_idxs); + } else if (host_isa_ == x64::avx2) { + emit_isa(in_vec_idxs, out_vec_idxs); + } else if (host_isa_ == x64::avx512_core) { + emit_isa(in_vec_idxs, out_vec_idxs); + } else { + OPENVINO_ASSERT(!"unsupported isa"); + } +} + +template +void jit_bitwise_or_emitter::emit_isa(const std::vector& in_vec_idxs, const std::vector& out_vec_idxs) const { + using Vmm = typename conditional3::type; + Vmm vmm_src0 = Vmm(in_vec_idxs[0]); + Vmm vmm_src1 = Vmm(in_vec_idxs[1]); + Vmm vmm_dst = Vmm(out_vec_idxs[0]); + + h->uni_vorps(vmm_dst, vmm_src0, vmm_src1); +} + +/// BITWISE_XOR /// +jit_bitwise_xor_emitter::jit_bitwise_xor_emitter(x64::jit_generator* host, x64::cpu_isa_t host_isa, const std::shared_ptr& node, Precision exec_prc) + : jit_emitter(host, host_isa, exec_prc) {} + +jit_bitwise_xor_emitter::jit_bitwise_xor_emitter(x64::jit_generator* host, x64::cpu_isa_t host_isa, Precision exec_prc) + : jit_emitter(host, host_isa, exec_prc) {} + +size_t jit_bitwise_xor_emitter::get_inputs_num() const { return 2; } + +std::set> jit_bitwise_xor_emitter::get_supported_precisions(const std::shared_ptr& node) { + return { + {element::i8, element::i8}, + {element::i16, element::i16}, + {element::i32, element::i32}, + {element::u8, element::u8}, + {element::u16, element::u16} + }; +} + +void jit_bitwise_xor_emitter::emit_impl(const std::vector& in_vec_idxs, const std::vector& out_vec_idxs) const { + if (host_isa_ == x64::sse41) { + emit_isa(in_vec_idxs, out_vec_idxs); + } else if (host_isa_ == x64::avx2) { + emit_isa(in_vec_idxs, out_vec_idxs); + } else if (host_isa_ == x64::avx512_core) { + emit_isa(in_vec_idxs, out_vec_idxs); + } else { + OPENVINO_ASSERT(!"unsupported isa"); + } +} + +template +void jit_bitwise_xor_emitter::emit_isa(const std::vector& in_vec_idxs, const std::vector& out_vec_idxs) const { + using Vmm = typename conditional3::type; + Vmm vmm_src0 = Vmm(in_vec_idxs[0]); + Vmm vmm_src1 = Vmm(in_vec_idxs[1]); + Vmm vmm_dst = Vmm(out_vec_idxs[0]); + + h->uni_vxorps(vmm_dst, vmm_src0, vmm_src1); +} + } // namespace intel_cpu } // namespace ov diff --git a/src/plugins/intel_cpu/src/emitters/x64/jit_eltwise_emitters.hpp b/src/plugins/intel_cpu/src/emitters/x64/jit_eltwise_emitters.hpp index e624b0f95294c0..f1d4c4aaffe760 100644 --- a/src/plugins/intel_cpu/src/emitters/x64/jit_eltwise_emitters.hpp +++ b/src/plugins/intel_cpu/src/emitters/x64/jit_eltwise_emitters.hpp @@ -669,5 +669,76 @@ class jit_select_emitter : public jit_emitter { template void emit_isa(const std::vector &in_vec_idxs, const std::vector &out_vec_idxs) const; }; + +class jit_bitwise_and_emitter : public jit_emitter { +public: + jit_bitwise_and_emitter(dnnl::impl::cpu::x64::jit_generator* host, dnnl::impl::cpu::x64::cpu_isa_t host_isa, + InferenceEngine::Precision exec_prc = InferenceEngine::Precision::FP32); + jit_bitwise_and_emitter(dnnl::impl::cpu::x64::jit_generator* host, dnnl::impl::cpu::x64::cpu_isa_t host_isa, const std::shared_ptr& n, + InferenceEngine::Precision exec_prc = InferenceEngine::Precision::FP32); + + size_t get_inputs_num() const override; + static std::set> get_supported_precisions(const std::shared_ptr& node = nullptr); + +private: + void emit_impl(const std::vector& in_vec_idxs, const std::vector& out_vec_idxs) const override; + + template + void emit_isa(const std::vector& in_vec_idxs, const std::vector& out_vec_idxs) const; +}; + +class jit_bitwise_not_emitter : public jit_emitter { +public: + jit_bitwise_not_emitter(dnnl::impl::cpu::x64::jit_generator* host, dnnl::impl::cpu::x64::cpu_isa_t host_isa, + InferenceEngine::Precision exec_prc = InferenceEngine::Precision::FP32); + jit_bitwise_not_emitter(dnnl::impl::cpu::x64::jit_generator* host, dnnl::impl::cpu::x64::cpu_isa_t host_isa, const std::shared_ptr& n, + InferenceEngine::Precision exec_prc = InferenceEngine::Precision::FP32); + + size_t get_inputs_num() const override; + static std::set> get_supported_precisions(const std::shared_ptr& node = nullptr); + size_t aux_vecs_count() const override; + +private: + void emit_impl(const std::vector& in_vec_idxs, const std::vector& out_vec_idxs) const override; + + template + void emit_isa(const std::vector& in_vec_idxs, const std::vector& out_vec_idxs) const; + void register_table_entries() override; +}; + +class jit_bitwise_or_emitter : public jit_emitter { +public: + jit_bitwise_or_emitter(dnnl::impl::cpu::x64::jit_generator* host, dnnl::impl::cpu::x64::cpu_isa_t host_isa, + InferenceEngine::Precision exec_prc = InferenceEngine::Precision::FP32); + jit_bitwise_or_emitter(dnnl::impl::cpu::x64::jit_generator* host, dnnl::impl::cpu::x64::cpu_isa_t host_isa, const std::shared_ptr& n, + InferenceEngine::Precision exec_prc = InferenceEngine::Precision::FP32); + + size_t get_inputs_num() const override; + static std::set> get_supported_precisions(const std::shared_ptr& node = nullptr); + +private: + void emit_impl(const std::vector& in_vec_idxs, const std::vector& out_vec_idxs) const override; + + template + void emit_isa(const std::vector& in_vec_idxs, const std::vector& out_vec_idxs) const; +}; + +class jit_bitwise_xor_emitter : public jit_emitter { +public: + jit_bitwise_xor_emitter(dnnl::impl::cpu::x64::jit_generator* host, dnnl::impl::cpu::x64::cpu_isa_t host_isa, + InferenceEngine::Precision exec_prc = InferenceEngine::Precision::FP32); + jit_bitwise_xor_emitter(dnnl::impl::cpu::x64::jit_generator* host, dnnl::impl::cpu::x64::cpu_isa_t host_isa, const std::shared_ptr& n, + InferenceEngine::Precision exec_prc = InferenceEngine::Precision::FP32); + + size_t get_inputs_num() const override; + static std::set> get_supported_precisions(const std::shared_ptr& node = nullptr); + +private: + void emit_impl(const std::vector& in_vec_idxs, const std::vector& out_vec_idxs) const override; + + template + void emit_isa(const std::vector& in_vec_idxs, const std::vector& out_vec_idxs) const; +}; + } // namespace intel_cpu } // namespace ov diff --git a/src/plugins/intel_cpu/src/nodes/eltwise.cpp b/src/plugins/intel_cpu/src/nodes/eltwise.cpp index aae4f68bd14234..b4817913deb618 100644 --- a/src/plugins/intel_cpu/src/nodes/eltwise.cpp +++ b/src/plugins/intel_cpu/src/nodes/eltwise.cpp @@ -139,6 +139,14 @@ static void set_intersection(const std::set>& precisi InferenceEngine::Precision eltwise_precision_helper::get_precision(const size_t inputs_number, const InferenceEngine::Precision(&src_prc)[MAX_ELTWISE_INPUTS], const std::vector& eltwise_data) { + if (one_of(eltwise_data[0].algo, + Algorithm::EltwiseBitwiseAnd, + Algorithm::EltwiseBitwiseNot, + Algorithm::EltwiseBitwiseOr, + Algorithm::EltwiseBitwiseXor)) { + return InferenceEngine::Precision::I32; + } + Precision exec_prc = Precision::UNSPECIFIED; std::set> supported_precision_intersection = get_supported_precisions(eltwise_data.front().algo); @@ -249,7 +257,11 @@ std::set> eltwise_precision_helper::get_supported_pre 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::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()) IE_THROW() << "Unsupported operation type for Eltwise emitter"; @@ -623,7 +635,11 @@ struct jit_uni_eltwise_generic : public jit_uni_eltwise_kernel, public jit_gener 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::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) IE_THROW() << "Unsupported operation type for Eltwise emitter"; @@ -1792,7 +1808,7 @@ class EltwiseRefExecutor : public EltwiseRefBaseExecutor { break; case Algorithm::EltwiseIsNaN: *dst_ptr_f = std::isnan(src_f[0]); break; case Algorithm::EltwiseSelect: *dst_ptr_f = src_f[0] ? src_f[1] : src_f[2]; break; - default: IE_THROW() << "Unsupported operation type for Eltwise executor"; + default: OPENVINO_THROW("Unsupported operation type for Eltwise executor"); } } }); @@ -1849,7 +1865,7 @@ class BitwiseRefExecutor : public EltwiseRefBaseExecutor { *dst_ptr_f = src_f[0] ^ src_f[1]; break; } - default: IE_THROW() << "Unsupported operation type for Eltwise executor"; + default: OPENVINO_THROW("Unsupported operation type for Eltwise executor"); } } }); @@ -2076,7 +2092,7 @@ void Eltwise::initSupportedPrimitiveDescriptors() { // if dim rank is greater than the maximum possible, we should use the reference execution bool canUseOptimizedImpl = mayiuse(x64::sse41) && getInputShapeAtPort(0).getRank() <= MAX_ELTWISE_DIM_RANK; // TODO: Add EltwiseLog algorithm support for JIT implementation - canUseOptimizedImpl &= !(one_of(getAlgorithm(), Algorithm::EltwiseLog) || isBitwise(getAlgorithm())); + canUseOptimizedImpl &= !one_of(getAlgorithm(), Algorithm::EltwiseLog); bool canUseOptimizedShapeAgnosticImpl = isDynamicNode() && canUseOptimizedImpl; @@ -2845,19 +2861,8 @@ bool Eltwise::canFuse(const NodePtr& node) const { if (!mayiuse(x64::sse41) || getInputShapeAtPort(0).getRank() > MAX_ELTWISE_DIM_RANK) return false; - // TODO: supported only via reference executor - if (one_of(getAlgorithm(), - Algorithm::EltwiseLog, - Algorithm::EltwiseBitwiseAnd, - Algorithm::EltwiseBitwiseNot, - Algorithm::EltwiseBitwiseOr, - Algorithm::EltwiseBitwiseXor) || - one_of(node->getAlgorithm(), - Algorithm::EltwiseLog, - Algorithm::EltwiseBitwiseAnd, - Algorithm::EltwiseBitwiseNot, - Algorithm::EltwiseBitwiseOr, - Algorithm::EltwiseBitwiseXor)) + // TODO: EltwiseLog is supported only via reference executor + if (getAlgorithm() == Algorithm::EltwiseLog || node->getAlgorithm() == Algorithm::EltwiseLog) return false; bool isIntegerNode = isIntegerComputeSupported(this); diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/instances/arm/eltwise.cpp b/src/plugins/intel_cpu/tests/functional/single_layer_tests/instances/arm/eltwise.cpp new file mode 100644 index 00000000000000..a0b7a2a08c1355 --- /dev/null +++ b/src/plugins/intel_cpu/tests/functional/single_layer_tests/instances/arm/eltwise.cpp @@ -0,0 +1,109 @@ +// Copyright (C) 2023 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "single_layer_tests/classes/eltwise.hpp" +#include "shared_test_classes/single_layer/eltwise.hpp" +#include "test_utils/cpu_test_utils.hpp" +#include "test_utils/fusing_test_utils.hpp" + +using namespace InferenceEngine; +using namespace CPUTestUtils; +using namespace ngraph::helpers; +using namespace ov::test; + +namespace CPULayerTestsDefinitions { +namespace Eltwise { +namespace { +static const std::vector bitwise_in_shapes_4D = { + { + {1, -1, -1, -1}, + { + {1, 3, 4, 4}, + {1, 3, 1, 1}, + {1, 1, 1, 1} + } + }, + {{1, 3, 4, 4}, {{1, 3, 4, 4}}} +}; + +const auto params_4D_bitwise = ::testing::Combine( + ::testing::Combine( + ::testing::Values(bitwise_in_shapes_4D), + ::testing::ValuesIn({ + ngraph::helpers::EltwiseTypes::BITWISE_AND, + ngraph::helpers::EltwiseTypes::BITWISE_OR, + ngraph::helpers::EltwiseTypes::BITWISE_XOR + }), + ::testing::ValuesIn(secondaryInputTypes()), + ::testing::ValuesIn({ ov::test::utils::OpType::VECTOR }), + ::testing::ValuesIn({ ov::element::Type_t::i8, ov::element::Type_t::u8, ov::element::Type_t::i32 }), + ::testing::Values(ov::element::Type_t::undefined), + ::testing::Values(ov::element::Type_t::undefined), + ::testing::Values(ov::test::utils::DEVICE_CPU), + ::testing::Values(ov::AnyMap())), + ::testing::Values(CPUSpecificParams({ nhwc, nhwc }, { nhwc }, {}, "ref")), + ::testing::Values(emptyFusingSpec), + ::testing::Values(false)); + +INSTANTIATE_TEST_SUITE_P(smoke_CompareWithRefs_4D_Bitwise, EltwiseLayerCPUTest, params_4D_bitwise, EltwiseLayerCPUTest::getTestCaseName); + +const auto params_4D_bitwise_i16 = ::testing::Combine( + ::testing::Combine( + ::testing::Values(bitwise_in_shapes_4D), + ::testing::ValuesIn({ + ngraph::helpers::EltwiseTypes::BITWISE_AND, + ngraph::helpers::EltwiseTypes::BITWISE_OR, + ngraph::helpers::EltwiseTypes::BITWISE_XOR + }), + ::testing::ValuesIn(secondaryInputTypes()), + ::testing::ValuesIn({ ov::test::utils::OpType::VECTOR }), + ::testing::ValuesIn({ ov::element::Type_t::i16, ov::element::Type_t::u16 }), + ::testing::Values(ov::element::Type_t::undefined), + ::testing::Values(ov::element::Type_t::undefined), + ::testing::Values(ov::test::utils::DEVICE_CPU), + ::testing::Values(ov::AnyMap())), + ::testing::Values(CPUSpecificParams({ nhwc, nhwc }, { nhwc }, {}, "ref_I32$/")), + ::testing::Values(emptyFusingSpec), + ::testing::Values(false)); + +INSTANTIATE_TEST_SUITE_P(smoke_CompareWithRefs_4D_Bitwise_i16, EltwiseLayerCPUTest, params_4D_bitwise_i16, EltwiseLayerCPUTest::getTestCaseName); + + +const auto params_4D_bitwise_NOT = ::testing::Combine( + ::testing::Combine( + ::testing::Values(bitwise_in_shapes_4D), + ::testing::ValuesIn({ ngraph::helpers::EltwiseTypes::BITWISE_NOT }), + ::testing::ValuesIn({ ngraph::helpers::InputLayerType::NONE }), + ::testing::ValuesIn({ ov::test::utils::OpType::VECTOR }), + ::testing::ValuesIn({ ov::element::Type_t::i8, /*ov::element::Type_t::u8,*/ ov::element::Type_t::i32}), + ::testing::Values(ov::element::Type_t::undefined), + ::testing::Values(ov::element::Type_t::undefined), + ::testing::Values(ov::test::utils::DEVICE_CPU), + ::testing::Values(ov::AnyMap())), + ::testing::Values(CPUSpecificParams({ nhwc }, { nhwc }, {}, "ref")), + ::testing::Values(emptyFusingSpec), + ::testing::Values(false)); + +INSTANTIATE_TEST_SUITE_P(smoke_CompareWithRefs_4D_Bitwise_NOT, EltwiseLayerCPUTest, params_4D_bitwise_NOT, EltwiseLayerCPUTest::getTestCaseName); + +const auto params_4D_bitwise_NOT_i16 = ::testing::Combine( + ::testing::Combine( + ::testing::Values(bitwise_in_shapes_4D), + ::testing::ValuesIn({ ngraph::helpers::EltwiseTypes::BITWISE_NOT }), + ::testing::ValuesIn({ ngraph::helpers::InputLayerType::NONE }), + ::testing::ValuesIn({ ov::test::utils::OpType::VECTOR }), + ::testing::ValuesIn({ ov::element::Type_t::i16, ov::element::Type_t::u16 }), + ::testing::Values(ov::element::Type_t::undefined), + ::testing::Values(ov::element::Type_t::undefined), + ::testing::Values(ov::test::utils::DEVICE_CPU), + ::testing::Values(ov::AnyMap())), + ::testing::Values(CPUSpecificParams({ nhwc }, { nhwc }, {}, "ref_I32$/")), + ::testing::Values(emptyFusingSpec), + ::testing::Values(false)); + +INSTANTIATE_TEST_SUITE_P(smoke_CompareWithRefs_4D_Bitwise_NOT_i16, EltwiseLayerCPUTest, params_4D_bitwise_NOT, EltwiseLayerCPUTest::getTestCaseName); + +} // namespace +} // namespace Eltwise +} // namespace CPULayerTestsDefinitions diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/instances/common/eltwise.cpp b/src/plugins/intel_cpu/tests/functional/single_layer_tests/instances/common/eltwise.cpp index 7bc76746861444..bf61d07e289d25 100644 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/instances/common/eltwise.cpp +++ b/src/plugins/intel_cpu/tests/functional/single_layer_tests/instances/common/eltwise.cpp @@ -219,94 +219,5 @@ const auto params_5D_dyn_param = ::testing::Combine( INSTANTIATE_TEST_SUITE_P(smoke_CompareWithRefs_5D_MemOrder_dyn_param, EltwiseLayerCPUTest, params_5D_dyn_param, EltwiseLayerCPUTest::getTestCaseName); -static const std::vector bitwise_in_shapes_4D = { - { - {1, -1, -1, -1}, - { - {1, 3, 4, 4}, - {1, 3, 1, 1}, - {1, 1, 1, 1} - } - }, - {{1, 3, 4, 4}, {{1, 3, 4, 4}}} -}; - -const auto params_4D_bitwise = ::testing::Combine( - ::testing::Combine( - ::testing::Values(bitwise_in_shapes_4D), - ::testing::ValuesIn({ - ngraph::helpers::EltwiseTypes::BITWISE_AND, - ngraph::helpers::EltwiseTypes::BITWISE_OR, - ngraph::helpers::EltwiseTypes::BITWISE_XOR - }), - ::testing::ValuesIn(secondaryInputTypes()), - ::testing::ValuesIn({ ov::test::utils::OpType::VECTOR }), - ::testing::ValuesIn({ ov::element::Type_t::i8, ov::element::Type_t::u8, ov::element::Type_t::i32 }), - ::testing::Values(ov::element::Type_t::undefined), - ::testing::Values(ov::element::Type_t::undefined), - ::testing::Values(ov::test::utils::DEVICE_CPU), - ::testing::Values(ov::AnyMap())), - ::testing::Values(CPUSpecificParams({ nhwc, nhwc }, { nhwc }, {}, "ref")), - ::testing::Values(emptyFusingSpec), - ::testing::Values(false)); - -INSTANTIATE_TEST_SUITE_P(smoke_CompareWithRefs_4D_Bitwise, EltwiseLayerCPUTest, params_4D_bitwise, EltwiseLayerCPUTest::getTestCaseName); - -const auto params_4D_bitwise_i16 = ::testing::Combine( - ::testing::Combine( - ::testing::Values(bitwise_in_shapes_4D), - ::testing::ValuesIn({ - ngraph::helpers::EltwiseTypes::BITWISE_AND, - ngraph::helpers::EltwiseTypes::BITWISE_OR, - ngraph::helpers::EltwiseTypes::BITWISE_XOR - }), - ::testing::ValuesIn(secondaryInputTypes()), - ::testing::ValuesIn({ ov::test::utils::OpType::VECTOR }), - ::testing::ValuesIn({ ov::element::Type_t::i16, ov::element::Type_t::u16 }), - ::testing::Values(ov::element::Type_t::undefined), - ::testing::Values(ov::element::Type_t::undefined), - ::testing::Values(ov::test::utils::DEVICE_CPU), - ::testing::Values(ov::AnyMap())), - ::testing::Values(CPUSpecificParams({ nhwc, nhwc }, { nhwc }, {}, "ref_I32$/")), - ::testing::Values(emptyFusingSpec), - ::testing::Values(false)); - -INSTANTIATE_TEST_SUITE_P(smoke_CompareWithRefs_4D_Bitwise_i16, EltwiseLayerCPUTest, params_4D_bitwise_i16, EltwiseLayerCPUTest::getTestCaseName); - - -const auto params_4D_bitwise_NOT = ::testing::Combine( - ::testing::Combine( - ::testing::Values(bitwise_in_shapes_4D), - ::testing::ValuesIn({ ngraph::helpers::EltwiseTypes::BITWISE_NOT }), - ::testing::ValuesIn({ ngraph::helpers::InputLayerType::CONSTANT }), - ::testing::ValuesIn({ ov::test::utils::OpType::VECTOR }), - ::testing::ValuesIn({ ov::element::Type_t::i8, ov::element::Type_t::u8, ov::element::Type_t::i32 }), - ::testing::Values(ov::element::Type_t::undefined), - ::testing::Values(ov::element::Type_t::undefined), - ::testing::Values(ov::test::utils::DEVICE_CPU), - ::testing::Values(ov::AnyMap())), - ::testing::Values(CPUSpecificParams({ nhwc }, { nhwc }, {}, "ref")), - ::testing::Values(emptyFusingSpec), - ::testing::Values(false)); - -INSTANTIATE_TEST_SUITE_P(smoke_CompareWithRefs_4D_Bitwise_NOT, EltwiseLayerCPUTest, params_4D_bitwise_NOT, EltwiseLayerCPUTest::getTestCaseName); - -const auto params_4D_bitwise_NOT_i16 = ::testing::Combine( - ::testing::Combine( - ::testing::Values(bitwise_in_shapes_4D), - ::testing::ValuesIn({ ngraph::helpers::EltwiseTypes::BITWISE_NOT }), - ::testing::ValuesIn({ ngraph::helpers::InputLayerType::CONSTANT }), - ::testing::ValuesIn({ ov::test::utils::OpType::VECTOR }), - ::testing::ValuesIn({ ov::element::Type_t::i16, ov::element::Type_t::u16 }), - ::testing::Values(ov::element::Type_t::undefined), - ::testing::Values(ov::element::Type_t::undefined), - ::testing::Values(ov::test::utils::DEVICE_CPU), - ::testing::Values(ov::AnyMap())), - ::testing::Values(CPUSpecificParams({ nhwc }, { nhwc }, {}, "ref_I32$/")), - ::testing::Values(emptyFusingSpec), - ::testing::Values(false)); - -INSTANTIATE_TEST_SUITE_P(smoke_CompareWithRefs_4D_Bitwise_NOT_i16, EltwiseLayerCPUTest, params_4D_bitwise_NOT, EltwiseLayerCPUTest::getTestCaseName); - } // namespace Eltwise } // namespace CPULayerTestsDefinitions diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/instances/x64/eltwise.cpp b/src/plugins/intel_cpu/tests/functional/single_layer_tests/instances/x64/eltwise.cpp index 5196736a3c9b3f..d3f7df3087be8e 100644 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/instances/x64/eltwise.cpp +++ b/src/plugins/intel_cpu/tests/functional/single_layer_tests/instances/x64/eltwise.cpp @@ -581,6 +581,96 @@ const auto params_5D_dyn_param_Blocked_Blocked = ::testing::Combine( INSTANTIATE_TEST_SUITE_P(smoke_CompareWithRefs_5D_MemOrder_dyn_param_Blocked_Blocked, EltwiseLayerCPUTest, params_5D_dyn_param_Blocked_Blocked, EltwiseLayerCPUTest::getTestCaseName); + +static const std::vector bitwise_in_shapes_4D = { + { + {1, -1, -1, -1}, + { + {1, 3, 4, 4}, + {1, 3, 1, 1}, + {1, 1, 1, 1} + } + }, + {{1, 3, 4, 4}, {{1, 3, 4, 4}}} +}; + +const auto params_4D_bitwise = ::testing::Combine( + ::testing::Combine( + ::testing::Values(bitwise_in_shapes_4D), + ::testing::ValuesIn({ + ngraph::helpers::EltwiseTypes::BITWISE_AND, + ngraph::helpers::EltwiseTypes::BITWISE_OR, + ngraph::helpers::EltwiseTypes::BITWISE_XOR + }), + ::testing::ValuesIn(secondaryInputTypes()), + ::testing::ValuesIn({ ov::test::utils::OpType::VECTOR }), + ::testing::ValuesIn({ ov::element::Type_t::i8, ov::element::Type_t::u8, ov::element::Type_t::i32 }), + ::testing::Values(ov::element::Type_t::undefined), + ::testing::Values(ov::element::Type_t::undefined), + ::testing::Values(ov::test::utils::DEVICE_CPU), + ::testing::Values(ov::AnyMap())), + ::testing::Values(CPUSpecificParams({ nhwc, nhwc }, { nhwc }, {}, {})), + ::testing::Values(emptyFusingSpec), + ::testing::Values(false)); + +INSTANTIATE_TEST_SUITE_P(smoke_CompareWithRefs_4D_Bitwise, EltwiseLayerCPUTest, params_4D_bitwise, EltwiseLayerCPUTest::getTestCaseName); + +const auto params_4D_bitwise_i16 = ::testing::Combine( + ::testing::Combine( + ::testing::Values(bitwise_in_shapes_4D), + ::testing::ValuesIn({ + ngraph::helpers::EltwiseTypes::BITWISE_AND, + ngraph::helpers::EltwiseTypes::BITWISE_OR, + ngraph::helpers::EltwiseTypes::BITWISE_XOR + }), + ::testing::ValuesIn(secondaryInputTypes()), + ::testing::ValuesIn({ ov::test::utils::OpType::VECTOR }), + ::testing::ValuesIn({ ov::element::Type_t::i16, ov::element::Type_t::u16 }), + ::testing::Values(ov::element::Type_t::undefined), + ::testing::Values(ov::element::Type_t::undefined), + ::testing::Values(ov::test::utils::DEVICE_CPU), + ::testing::Values(ov::AnyMap())), + ::testing::Values(CPUSpecificParams({ nhwc, nhwc }, { nhwc }, {}, "*_I32")), + ::testing::Values(emptyFusingSpec), + ::testing::Values(false)); + +INSTANTIATE_TEST_SUITE_P(smoke_CompareWithRefs_4D_Bitwise_i16, EltwiseLayerCPUTest, params_4D_bitwise_i16, EltwiseLayerCPUTest::getTestCaseName); + + +const auto params_4D_bitwise_NOT = ::testing::Combine( + ::testing::Combine( + ::testing::Values(bitwise_in_shapes_4D), + ::testing::ValuesIn({ ngraph::helpers::EltwiseTypes::BITWISE_NOT }), + ::testing::ValuesIn({ ngraph::helpers::InputLayerType::NONE }), + ::testing::ValuesIn({ ov::test::utils::OpType::VECTOR }), + ::testing::ValuesIn({ ov::element::Type_t::i8, /*ov::element::Type_t::u8,*/ ov::element::Type_t::i32}), + ::testing::Values(ov::element::Type_t::undefined), + ::testing::Values(ov::element::Type_t::undefined), + ::testing::Values(ov::test::utils::DEVICE_CPU), + ::testing::Values(ov::AnyMap())), + ::testing::Values(CPUSpecificParams({ nhwc }, { nhwc }, {}, {})), + ::testing::Values(emptyFusingSpec), + ::testing::Values(false)); + +INSTANTIATE_TEST_SUITE_P(smoke_CompareWithRefs_4D_Bitwise_NOT, EltwiseLayerCPUTest, params_4D_bitwise_NOT, EltwiseLayerCPUTest::getTestCaseName); + +const auto params_4D_bitwise_NOT_i16 = ::testing::Combine( + ::testing::Combine( + ::testing::Values(bitwise_in_shapes_4D), + ::testing::ValuesIn({ ngraph::helpers::EltwiseTypes::BITWISE_NOT }), + ::testing::ValuesIn({ ngraph::helpers::InputLayerType::NONE }), + ::testing::ValuesIn({ ov::test::utils::OpType::VECTOR }), + ::testing::ValuesIn({ ov::element::Type_t::i16, ov::element::Type_t::u16 }), + ::testing::Values(ov::element::Type_t::undefined), + ::testing::Values(ov::element::Type_t::undefined), + ::testing::Values(ov::test::utils::DEVICE_CPU), + ::testing::Values(ov::AnyMap())), + ::testing::Values(CPUSpecificParams({ nhwc }, { nhwc }, {}, "*_I32")), + ::testing::Values(emptyFusingSpec), + ::testing::Values(false)); + +INSTANTIATE_TEST_SUITE_P(smoke_CompareWithRefs_4D_Bitwise_NOT_i16, EltwiseLayerCPUTest, params_4D_bitwise_NOT, EltwiseLayerCPUTest::getTestCaseName); + } // namespace } // namespace Eltwise } // namespace CPULayerTestsDefinitions \ No newline at end of file diff --git a/src/plugins/intel_cpu/tests/functional/test_utils/cpu_test_utils.cpp b/src/plugins/intel_cpu/tests/functional/test_utils/cpu_test_utils.cpp index ced8d4a2d3cdd9..eb2472dfcc9b6e 100644 --- a/src/plugins/intel_cpu/tests/functional/test_utils/cpu_test_utils.cpp +++ b/src/plugins/intel_cpu/tests/functional/test_utils/cpu_test_utils.cpp @@ -359,14 +359,16 @@ void CPUTestsBase::updateSelectedType(const std::string& primitiveType, const ov selectedType = primitiveType; } + if (selectedType.find("*") != std::string::npos) { + selectedType = primitiveType + "_" + selectedType; + return; + } + if (selectedType.find("$/") != std::string::npos) { - // like as regex selectedType = selectedType.substr(0, selectedType.find("$/")); return; } - selectedType.push_back('_'); - auto getExecType = [&](){ // inference_precision affects only floating point type networks if (!netType.is_real()) { @@ -391,6 +393,7 @@ void CPUTestsBase::updateSelectedType(const std::string& primitiveType, const ov }; const auto execType = getExecType(); + selectedType.push_back('_'); selectedType += InferenceEngine::details::convertPrecision(execType).name(); }