OpenVINO™ is an open source toolkit for optimizing and deploying AI inference
C++ aicomputer-visiondeep-learningdeploy-aidiffusion-modelsgenerative-aigood-first-issueinferencellm-inferencenatural-language-processingnlpopenvinooptimize-aiperformance-boostrecommendation-systemspeech-recognitionstable-diffusiontransformersyolo
[Op] Add BitwiseRightShift and BitwiseLeftShift to OV and enable related TF ops (#25857)
Katarzyna Mitrusd3fe9ff55df7
diff --git a/src/core/include/openvino/op/bitwise_left_shift.hpp b/src/core/include/openvino/op/bitwise_left_shift.hppnew file mode 100644index 00000000000..02f64b0d0bb--- /dev/null+++ b/src/core/include/openvino/op/bitwise_left_shift.hpp@@ -0,0 +1,43 @@+// Copyright (C) 2018-2024 Intel Corporation+// SPDX-License-Identifier: Apache-2.0+//++#pragma once++#include "openvino/op/op.hpp"+#include "openvino/op/util/binary_elementwise_bitwise.hpp"++namespace ov {+namespace op {+namespace v15 {+/// \brief Elementwise bitwise BitwiseLeftShift operation.+/// \ingroup ov_ops_cpp_api+class OPENVINO_API BitwiseLeftShift : public util::BinaryElementwiseBitwise {+public:+ OPENVINO_OP("BitwiseLeftShift", "opset15", util::BinaryElementwiseBitwise);+ /// \brief Constructs a bitwise BitwiseLeftShift operation.+ BitwiseLeftShift() = default;+ /// \brief Constructs a bitwise BitwiseLeftShift operation.+ ///+ /// \param arg0 Node with data to be shifted.+ /// `[d0, ...]`+ /// \param arg1 Node with number of shifts.+ /// `[d0, ...]`+ /// \param auto_broadcast Auto broadcast specification. Default is Numpy-style+ /// implicit broadcasting.+ ///+ /// Output `[d0, ...]`+ ///+ BitwiseLeftShift(const Output<Node>& arg0,+ const Output<Node>& arg1,+ const AutoBroadcastSpec& auto_broadcast = AutoBroadcastSpec(AutoBroadcastType::NUMPY));++ void validate_and_infer_types() override;+ std::shared_ptr<Node> clone_with_new_inputs(const OutputVector& new_args) const override;++ bool evaluate(TensorVector& outputs, const TensorVector& inputs) const override;+ bool has_evaluate() const override;+};+} // namespace v15+} // namespace op+} // namespace ovdiff --git a/src/core/include/openvino/op/bitwise_right_shift.hpp b/src/core/include/openvino/op/bitwise_right_shift.hppnew file mode 100644index 00000000000..ba7ef9b3f34--- /dev/null+++ b/src/core/include/openvino/op/bitwise_right_shift.hpp@@ -0,0 +1,43 @@+// Copyright (C) 2018-2024 Intel Corporation+// SPDX-License-Identifier: Apache-2.0+//++#pragma once++#include "openvino/op/op.hpp"+#include "openvino/op/util/binary_elementwise_bitwise.hpp"++namespace ov {+namespace op {+namespace v15 {+/// \brief Elementwise bitwise BitwiseRightShift operation.+/// \ingroup ov_ops_cpp_api+class OPENVINO_API BitwiseRightShift : public util::BinaryElementwiseBitwise {+public:+ OPENVINO_OP("BitwiseRightShift", "opset15", util::BinaryElementwiseBitwise);+ /// \brief Constructs a bitwise BitwiseRightShift operation.+ BitwiseRightShift() = default;+ /// \brief Constructs a bitwise BitwiseRightShift operation.+ ///+ /// \param arg0 Node with data to be shifted.+ /// `[d0, ...]`+ /// \param arg1 Node with number of shifts.+ /// `[d0, ...]`+ /// \param auto_broadcast Auto broadcast specification. Default is Numpy-style+ /// implicit broadcasting.+ ///+ /// Output `[d0, ...]`+ ///+ BitwiseRightShift(const Output<Node>& arg0,+ const Output<Node>& arg1,+ const AutoBroadcastSpec& auto_broadcast = AutoBroadcastSpec(AutoBroadcastType::NUMPY));++ void validate_and_infer_types() override;+ std::shared_ptr<Node> clone_with_new_inputs(const OutputVector& new_args) const override;++ bool evaluate(TensorVector& outputs, const TensorVector& inputs) const override;+ bool has_evaluate() const override;+};+} // namespace v15+} // namespace op+} // namespace ovdiff --git a/src/core/include/openvino/op/ops.hpp b/src/core/include/openvino/op/ops.hppindex 749069e5bbf..224aa8b3ce2 100644--- a/src/core/include/openvino/op/ops.hpp+++ b/src/core/include/openvino/op/ops.hpp@@ -22,8 +22,10 @@#include "openvino/op/batch_to_space.hpp"#include "openvino/op/binary_convolution.hpp"#include "openvino/op/bitwise_and.hpp"+#include "openvino/op/bitwise_left_shift.hpp"#include "openvino/op/bitwise_not.hpp"#include "openvino/op/bitwise_or.hpp"+#include "openvino/op/bitwise_right_shift.hpp"#include "openvino/op/bitwise_xor.hpp"#include "openvino/op/broadcast.hpp"#include "openvino/op/bucketize.hpp"diff --git a/src/core/include/openvino/opsets/opset15_tbl.hpp b/src/core/include/openvino/opsets/opset15_tbl.hppindex 50c8603cf20..4d85571d5b6 100644--- a/src/core/include/openvino/opsets/opset15_tbl.hpp+++ b/src/core/include/openvino/opsets/opset15_tbl.hpp@@ -18,3 +18,5 @@ _OPENVINO_OP_REG(ScatterNDUpdate, ov::op::v15)_OPENVINO_OP_REG(EmbeddingBagPacked, ov::op::v15)_OPENVINO_OP_REG(EmbeddingBagOffsets, ov::op::v15)_OPENVINO_OP_REG(Col2Im, ov::op::v15)+_OPENVINO_OP_REG(BitwiseLeftShift, ov::op::v15)+_OPENVINO_OP_REG(BitwiseRightShift, ov::op::v15)diff --git a/src/core/reference/include/openvino/reference/bitwise_left_shift.hpp b/src/core/reference/include/openvino/reference/bitwise_left_shift.hppnew file mode 100644index 00000000000..9a8fa7d3aff--- /dev/null+++ b/src/core/reference/include/openvino/reference/bitwise_left_shift.hpp@@ -0,0 +1,41 @@+// Copyleft (C) 2018-2024 Intel Corporation+// SPDX-License-Identifier: Apache-2.0+//++#pragma once++#include <algorithm>+#include <cstddef>++#include "openvino/reference/autobroadcast_binop.hpp"++namespace ov {+namespace reference {+namespace func {+template <class T>+constexpr T bit_shift_left(const T a, const T b) {+ return a << b;+}+} // namespace func++/**+ * @brief Reference implementation of binary elementwise bitwise left shift operator.+ *+ * @param arg0 Pointer to input 0 data.+ * @param arg1 Pointer to input 1 data.+ * @param out Pointer to output data.+ * @param arg_shape0 Input 0 shape.+ * @param arg_shape1 Input 1 shape.+ * @param broadcast_spec Broadcast specification mode.+ */+template <class T>+void bitwise_left_shift(const T* arg0,+ const T* arg1,+ T* out,+ const Shape& arg0_shape,+ const Shape& arg1_shape,+ const op::AutoBroadcastSpec& broadcast_spec = op::AutoBroadcastType::NUMPY) {+ autobroadcast_binop(arg0, arg1, out, arg0_shape, arg1_shape, broadcast_spec, func::bit_shift_left<T>);+}+} // namespace reference+} // namespace ovdiff --git a/src/core/reference/include/openvino/reference/bitwise_right_shift.hpp b/src/core/reference/include/openvino/reference/bitwise_right_shift.hppnew file mode 100644index 00000000000..3b5d383abf1--- /dev/null+++ b/src/core/reference/include/openvino/reference/bitwise_right_shift.hpp@@ -0,0 +1,41 @@+// Copyright (C) 2018-2024 Intel Corporation+// SPDX-License-Identifier: Apache-2.0+//++#pragma once++#include <algorithm>+#include <cstddef>++#include "openvino/reference/autobroadcast_binop.hpp"++namespace ov {+namespace reference {+namespace func {+template <class T>+constexpr T bit_shift_right(const T a, const T b) {+ return a >> b;+}+} // namespace func++/**+ * @brief Reference implementation of binary elementwise bitwise right shift operator.+ *+ * @param arg0 Pointer to input 0 data.+ * @param arg1 Pointer to input 1 data.+ * @param out Pointer to output data.+ * @param arg_shape0 Input 0 shape.+ * @param arg_shape1 Input 1 shape.+ * @param broadcast_spec Broadcast specification mode.+ */+template <class T>+void bitwise_right_shift(const T* arg0,+ const T* arg1,+ T* out,+ const Shape& arg0_shape,+ const Shape& arg1_shape,+ const op::AutoBroadcastSpec& broadcast_spec = op::AutoBroadcastType::NUMPY) {+ autobroadcast_binop(arg0, arg1, out, arg0_shape, arg1_shape, broadcast_spec, func::bit_shift_right<T>);+}+} // namespace reference+} // namespace ovdiff --git a/src/core/src/op/bitwise_left_shift.cpp b/src/core/src/op/bitwise_left_shift.cppnew file mode 100644index 00000000000..840a85d7bff--- /dev/null+++ b/src/core/src/op/bitwise_left_shift.cpp@@ -0,0 +1,95 @@+// Copyright (C) 2018-2024 Intel Corporation+// SPDX-License-Identifier: Apache-2.0+//++#include "openvino/op/bitwise_left_shift.hpp"++#include "itt.hpp"+#include "openvino/op/op.hpp"+#include "openvino/op/util/elementwise_args.hpp"+#include "openvino/reference/bitwise_left_shift.hpp"+#include "utils.hpp"++namespace ov {+namespace op {+namespace v15 {+namespace left_shift {+struct Evaluate : ov::element::NoAction<bool> {+ using ov::element::NoAction<bool>::visit;++ template <element::Type_t ET>+ static result_type visit(const Tensor& in0,+ const Tensor& in1,+ Tensor& out,+ const Shape& arg0_shape,+ const Shape& arg1_shape,+ const op::AutoBroadcastSpec& broadcast_spec) {+ using T = typename element_type_traits<ET>::value_type;+ reference::bitwise_left_shift(in0.data<const T>(),+ in1.data<const T>(),+ out.data<T>(),+ arg0_shape,+ arg1_shape,+ broadcast_spec);+ return true;+ }+};+} // namespace left_shift++BitwiseLeftShift::BitwiseLeftShift(const Output<Node>& arg0,+ const Output<Node>& arg1,+ const AutoBroadcastSpec& auto_broadcast)+ : BinaryElementwiseBitwise(arg0, arg1, auto_broadcast) {+ constructor_validate_and_infer_types();+}++std::shared_ptr<Node> BitwiseLeftShift::clone_with_new_inputs(const OutputVector& new_args) const {+ OV_OP_SCOPE(v15_BitwiseLeftShift_clone_with_new_inputs);+ check_new_args_count(this, new_args);+ return std::make_shared<BitwiseLeftShift>(new_args[0], new_args[1], get_autob());+}++void BitwiseLeftShift::validate_and_infer_types() {+ OV_OP_SCOPE(v15_BitwiseLeftShift_validate_and_infer_types);+ auto args_et_pshape = op::util::validate_and_infer_elementwise_args(this);+ const auto& args_et = std::get<0>(args_et_pshape);+ const auto& args_pshape = std::get<1>(args_et_pshape);++ NODE_VALIDATION_CHECK(this,+ args_et.is_dynamic() || args_et.is_integral_number(),+ "The element type of the input tensor must be integer number.");++ set_output_type(0, args_et, args_pshape);+}++bool BitwiseLeftShift::evaluate(TensorVector& outputs, const TensorVector& inputs) const {+ OV_OP_SCOPE(v15_BitwiseLeftShift_evaluate);+ OPENVINO_ASSERT(outputs.size() == 1);++ outputs[0].set_shape(infer_broadcast_shape(this, inputs));++ using namespace ov::element;+ return IF_TYPE_OF(v15_BitwiseLeftShift_evaluate,+ OV_PP_ET_LIST(i32),+ left_shift::Evaluate,+ inputs[0].get_element_type(),+ inputs[0],+ inputs[1],+ outputs[0],+ inputs[0].get_shape(),+ inputs[1].get_shape(),+ get_autob());+}++bool BitwiseLeftShift::has_evaluate() const {+ OV_OP_SCOPE(v15_BitwiseLeftShift_has_evaluate);+ switch (get_input_element_type(0)) {+ case element::i32:+ return true;+ default:+ return false;+ }+}+} // namespace v15+} // namespace op+} // namespace ovdiff --git a/src/core/src/op/bitwise_right_shift.cpp b/src/core/src/op/bitwise_right_shift.cppnew file mode 100644index 00000000000..5490361d754--- /dev/null+++ b/src/core/src/op/bitwise_right_shift.cpp@@ -0,0 +1,92 @@+// Copyright (C) 2018-2024 Intel Corporation+// SPDX-License-Identifier: Apache-2.0+//+#include "openvino/op/bitwise_right_shift.hpp"++#include "itt.hpp"+#include "openvino/op/op.hpp"+#include "openvino/op/util/elementwise_args.hpp"+#include "openvino/reference/bitwise_right_shift.hpp"+#include "utils.hpp"++namespace ov {+namespace op {+namespace v15 {+namespace right_shift {+struct Evaluate : ov::element::NoAction<bool> {+ using ov::element::NoAction<bool>::visit;++ template <element::Type_t ET>+ static result_type visit(const Tensor& in0,+ const Tensor& in1,+ Tensor& out,+ const Shape& arg0_shape,+ const Shape& arg1_shape,+ const op::AutoBroadcastSpec& broadcast_spec) {+ using T = typename element_type_traits<ET>::value_type;+ reference::bitwise_right_shift(in0.data<const T>(),+ in1.data<const T>(),+ out.data<T>(),+ arg0_shape,+ arg1_shape,+ broadcast_spec);+ return true;+ }+};+} // namespace right_shift++BitwiseRightShift::BitwiseRightShift(const Output<Node>& arg0,+ const Output<Node>& arg1,+ const AutoBroadcastSpec& auto_broadcast)+ : BinaryElementwiseBitwise(arg0, arg1, auto_broadcast) {+ constructor_validate_and_infer_types();+}++std::shared_ptr<Node> BitwiseRightShift::clone_with_new_inputs(const OutputVector& new_args) const {+ OV_OP_SCOPE(v15_BitwiseRightShift_clone_with_new_inputs);+ check_new_args_count(this, new_args);+ return std::make_shared<BitwiseRightShift>(new_args[0], new_args[1], get_autob());+}++bool BitwiseRightShift::evaluate(TensorVector& outputs, const TensorVector& inputs) const {+ OV_OP_SCOPE(v15_BitwiseRightShift_evaluate);+ OPENVINO_ASSERT(outputs.size() == 1);+ outputs[0].set_shape(infer_broadcast_shape(this, inputs));+ using namespace ov::element;+ return IF_TYPE_OF(v15_BitwiseRightShift_evaluate,+ OV_PP_ET_LIST(i32),+ right_shift::Evaluate,+ inputs[0].get_element_type(),+ inputs[0],+ inputs[1],+ outputs[0],+ inputs[0].get_shape(),+ inputs[1].get_shape(),+ get_autob());+}++void BitwiseRightShift::validate_and_infer_types() {+ OV_OP_SCOPE(v15_BitwiseRightShift_validate_and_infer_types);+ auto args_et_pshape = op::util::validate_and_infer_elementwise_args(this);+ const auto& args_et = std::get<0>(args_et_pshape);+ const auto& args_pshape = std::get<1>(args_et_pshape);++ NODE_VALIDATION_CHECK(this,+ args_et.is_dynamic() || args_et.is_integral_number(),+ "The element type of the input tensor must be integer number.");++ set_output_type(0, args_et, args_pshape);+}++bool BitwiseRightShift::has_evaluate() const {+ OV_OP_SCOPE(v15_BitwiseRightShift_has_evaluate);+ switch (get_input_element_type(0)) {+ case element::i32:+ return true;+ default:+ return false;+ }+}+} // namespace v15+} // namespace op+} // namespace ovdiff --git a/src/core/tests/op_version_tbl.hpp b/src/core/tests/op_version_tbl.hppindex d1440e1ec05..8ebccc2181f 100644--- a/src/core/tests/op_version_tbl.hpp+++ b/src/core/tests/op_version_tbl.hpp@@ -28,8 +28,10 @@ _OPENVINO_OP_REG(BatchNormInference, ov::op::v0)_OPENVINO_OP_REG(BatchToSpace, ov::op::v1)_OPENVINO_OP_REG(BinaryConvolution, ov::op::v1)_OPENVINO_OP_REG(BitwiseAnd, ov::op::v13)+_OPENVINO_OP_REG(BitwiseLeftShift, ov::op::v15)_OPENVINO_OP_REG(BitwiseNot, ov::op::v13)_OPENVINO_OP_REG(BitwiseOr, ov::op::v13)+_OPENVINO_OP_REG(BitwiseRightShift, ov::op::v15)_OPENVINO_OP_REG(BitwiseXor, ov::op::v13)_OPENVINO_OP_REG(Broadcast, ov::op::v1)_OPENVINO_OP_REG(Broadcast, ov::op::v3)diff --git a/src/core/tests/opset.cpp b/src/core/tests/opset.cppindex c63b4759287..3692ad5823f 100644--- a/src/core/tests/opset.cpp+++ b/src/core/tests/opset.cpp@@ -75,7 +75,7 @@ INSTANTIATE_TEST_SUITE_P(opset,OpsetTestParams{ov::get_opset12, 178},OpsetTestParams{ov::get_opset13, 186},OpsetTestParams{ov::get_opset14, 188},- OpsetTestParams{ov::get_opset15, 8}),+ OpsetTestParams{ov::get_opset15, 10}),OpsetTestNameGenerator{});class MyOpOld : public ov::op::Op {diff --git a/src/core/tests/type_prop/bitwise_and.cpp b/src/core/tests/type_prop/bitwise_and.cppindex 935d20c2e93..a2b9efbd9b9 100644--- a/src/core/tests/type_prop/bitwise_and.cpp+++ b/src/core/tests/type_prop/bitwise_and.cpp@@ -9,3 +9,4 @@using Type = ::testing::Types<ov::op::v13::BitwiseAnd>;INSTANTIATE_TYPED_TEST_SUITE_P(type_prop_bitwise_and, BitwiseOperator, Type);+INSTANTIATE_TYPED_TEST_SUITE_P(type_prop_bitwise_and, BitwiseOperatorBoolean, Type);diff --git a/src/core/tests/type_prop/bitwise_left_shift.cpp b/src/core/tests/type_prop/bitwise_left_shift.cppnew file mode 100644index 00000000000..e0ca7f222ae--- /dev/null+++ b/src/core/tests/type_prop/bitwise_left_shift.cpp@@ -0,0 +1,12 @@+// Copyright (C) 2018-2024 Intel Corporation+// SPDX-License-Identifier: Apache-2.0+//++#include "openvino/op/bitwise_left_shift.hpp"++#include "bitwise_ops.hpp"++using OpType = ::testing::Types<ov::op::v15::BitwiseLeftShift>;++INSTANTIATE_TYPED_TEST_SUITE_P(type_prop_bitwise_left_shift, BitwiseOperator, OpType);+INSTANTIATE_TYPED_TEST_SUITE_P(type_prop_bitwise_left_shift, BitwiseOperatorNotBoolean, OpType);diff --git a/src/core/tests/type_prop/bitwise_ops.hpp b/src/core/tests/type_prop/bitwise_ops.hppindex 63a5237ded6..cbdc31ed781 100644--- a/src/core/tests/type_prop/bitwise_ops.hpp+++ b/src/core/tests/type_prop/bitwise_ops.hpp@@ -43,30 +43,6 @@ TYPED_TEST_P(BitwiseOperator, default_constructor_integer) {EXPECT_EQ(op->get_output_partial_shape(0), (PartialShape{-1, 4, 5, 6, {5, 8}, {5, 6}}));}-TYPED_TEST_P(BitwiseOperator, default_constructor_boolean) {- auto lhs = std::make_shared<Parameter>(element::boolean, PartialShape{-1, 4, 1, 6, {1, 6}, {2, 6}});- auto rhs = std::make_shared<Parameter>(element::boolean, PartialShape{-1, 1, 5, 6, {5, 8}, {5, 8}});-- const auto op = this->make_op();-- op->set_argument(0, lhs);- op->set_argument(1, rhs);-- auto autob = op::AutoBroadcastSpec(op::AutoBroadcastType::NONE);- op->set_autob(autob);- EXPECT_EQ(op->get_autob(), op::AutoBroadcastType::NONE);- ASSERT_THROW(op->validate_and_infer_types(), NodeValidationFailure);-- autob = op::AutoBroadcastSpec(op::AutoBroadcastType::NUMPY);- op->set_autob(autob);- EXPECT_EQ(op->get_autob(), op::AutoBroadcastType::NUMPY);-- op->validate_and_infer_types();-- EXPECT_EQ(op->get_element_type(), element::boolean);- EXPECT_EQ(op->get_output_partial_shape(0), (PartialShape{-1, 4, 5, 6, {5, 8}, {5, 6}}));-}-TYPED_TEST_P(BitwiseOperator, shape_inference_2D) {auto lhs = std::make_shared<Parameter>(element::i32, Shape{2, 2});auto rhs = std::make_shared<Parameter>(element::i32, Shape{2, 2});@@ -271,7 +247,7 @@ TYPED_TEST_P(BitwiseOperator, incompatible_element_types_f32) {OV_EXPECT_THROW(std::ignore = this->make_op(lhs, rhs),NodeValidationFailure,- HasSubstr("The element type of the input tensor must be integer or boolean."));+ HasSubstr("The element type of the input tensor must be integer"));}TYPED_TEST_P(BitwiseOperator, shape_inference_1D_x_1D_incompatible) {@@ -901,7 +877,6 @@ TYPED_TEST_P(BitwiseOperator, symbols_equal_dynamic_shape_broadcast_none) {REGISTER_TYPED_TEST_SUITE_P(BitwiseOperator,default_constructor_integer,- default_constructor_boolean,// Static shapesshape_inference_2D,@@ -956,3 +931,57 @@ REGISTER_TYPED_TEST_SUITE_P(BitwiseOperator,symbols_equal_static_shape_broadcast_none,symbols_different_dynamic_shape_broadcast_none,symbols_equal_dynamic_shape_broadcast_none);++template <class TOp>+class BitwiseOperatorBoolean : public BitwiseOperator<TOp> {};+TYPED_TEST_SUITE_P(BitwiseOperatorBoolean);++TYPED_TEST_P(BitwiseOperatorBoolean, default_constructor_boolean) {+ auto lhs = std::make_shared<Parameter>(element::boolean, PartialShape{-1, 4, 1, 6, {1, 6}, {2, 6}});+ auto rhs = std::make_shared<Parameter>(element::boolean, PartialShape{-1, 1, 5, 6, {5, 8}, {5, 8}});++ const auto op = this->make_op();++ op->set_argument(0, lhs);+ op->set_argument(1, rhs);++ auto autob = op::AutoBroadcastSpec(op::AutoBroadcastType::NONE);+ op->set_autob(autob);+ EXPECT_EQ(op->get_autob(), op::AutoBroadcastType::NONE);+ ASSERT_THROW(op->validate_and_infer_types(), NodeValidationFailure);++ autob = op::AutoBroadcastSpec(op::AutoBroadcastType::NUMPY);+ op->set_autob(autob);+ EXPECT_EQ(op->get_autob(), op::AutoBroadcastType::NUMPY);++ op->validate_and_infer_types();++ EXPECT_EQ(op->get_element_type(), element::boolean);+ EXPECT_EQ(op->get_output_partial_shape(0), (PartialShape{-1, 4, 5, 6, {5, 8}, {5, 6}}));+}++TYPED_TEST_P(BitwiseOperatorBoolean, incompatible_element_types_f32) {+ auto lhs = std::make_shared<Parameter>(element::f32, Shape{2, 2, 3, 3});+ auto rhs = std::make_shared<Parameter>(element::f32, Shape{2, 2, 3, 3});++ OV_EXPECT_THROW(std::ignore = this->make_op(lhs, rhs),+ NodeValidationFailure,+ HasSubstr("The element type of the input tensor must be integer or boolean."));+}++REGISTER_TYPED_TEST_SUITE_P(BitwiseOperatorBoolean, default_constructor_boolean, incompatible_element_types_f32);++template <class TOp>+class BitwiseOperatorNotBoolean : public BitwiseOperator<TOp> {};+TYPED_TEST_SUITE_P(BitwiseOperatorNotBoolean);++TYPED_TEST_P(BitwiseOperatorNotBoolean, incompatible_element_types_boolean) {+ auto lhs = std::make_shared<Parameter>(element::boolean, Shape{2, 2, 3, 3});+ auto rhs = std::make_shared<Parameter>(element::boolean, Shape{2, 2, 3, 3});++ OV_EXPECT_THROW(std::ignore = this->make_op(lhs, rhs),+ NodeValidationFailure,+ HasSubstr("The element type of the input tensor must be integer number"));+}++REGISTER_TYPED_TEST_SUITE_P(BitwiseOperatorNotBoolean, incompatible_element_types_boolean);diff --git a/src/core/tests/type_prop/bitwise_or.cpp b/src/core/tests/type_prop/bitwise_or.cppindex b89e8fa79a3..908bb809904 100644--- a/src/core/tests/type_prop/bitwise_or.cpp+++ b/src/core/tests/type_prop/bitwise_or.cpp@@ -9,3 +9,4 @@using Type = ::testing::Types<ov::op::v13::BitwiseOr>;INSTANTIATE_TYPED_TEST_SUITE_P(type_prop_bitwise_or, BitwiseOperator, Type);+INSTANTIATE_TYPED_TEST_SUITE_P(type_prop_bitwise_or, BitwiseOperatorBoolean, Type);diff --git a/src/core/tests/type_prop/bitwise_right_shift.cpp b/src/core/tests/type_prop/bitwise_right_shift.cppnew file mode 100644index 00000000000..b406cfd1dd7--- /dev/null+++ b/src/core/tests/type_prop/bitwise_right_shift.cpp@@ -0,0 +1,12 @@+// Copyright (C) 2018-2024 Intel Corporation+// SPDX-License-Identifier: Apache-2.0+//++#include "openvino/op/bitwise_right_shift.hpp"++#include "bitwise_ops.hpp"++using OpType = ::testing::Types<ov::op::v15::BitwiseRightShift>;++INSTANTIATE_TYPED_TEST_SUITE_P(type_prop_bitwise_right_shift, BitwiseOperator, OpType);+INSTANTIATE_TYPED_TEST_SUITE_P(type_prop_bitwise_right_shift, BitwiseOperatorNotBoolean, OpType);diff --git a/src/core/tests/type_prop/bitwise_xor.cpp b/src/core/tests/type_prop/bitwise_xor.cppindex 8c689b7fb56..a6ed0f65349 100644--- a/src/core/tests/type_prop/bitwise_xor.cpp+++ b/src/core/tests/type_prop/bitwise_xor.cpp@@ -9,3 +9,4 @@using Type = ::testing::Types<ov::op::v13::BitwiseXor>;INSTANTIATE_TYPED_TEST_SUITE_P(type_prop_bitwise_xor, BitwiseOperator, Type);+INSTANTIATE_TYPED_TEST_SUITE_P(type_prop_bitwise_xor, BitwiseOperatorBoolean, Type);diff --git a/src/core/tests/visitors/op/bitwise_left_shift.cpp b/src/core/tests/visitors/op/bitwise_left_shift.cppnew file mode 100644index 00000000000..74d23569230--- /dev/null+++ b/src/core/tests/visitors/op/bitwise_left_shift.cpp@@ -0,0 +1,11 @@+// Copyright (C) 2018-2024 Intel Corporation+// SPDX-License-Identifier: Apache-2.0+//++#include "openvino/op/bitwise_left_shift.hpp"++#include "binary_ops.hpp"++using Type = ::testing::Types<BinaryOperatorType<ov::op::v15::BitwiseLeftShift, ov::element::i32>>;++INSTANTIATE_TYPED_TEST_SUITE_P(visitor_with_auto_broadcast, BinaryOperatorVisitor, Type, BinaryOperatorTypeName);diff --git a/src/core/tests/visitors/op/bitwise_rigth_shift.cpp b/src/core/tests/visitors/op/bitwise_rigth_shift.cppnew file mode 100644index 00000000000..4fd397af9e4--- /dev/null+++ b/src/core/tests/visitors/op/bitwise_rigth_shift.cpp@@ -0,0 +1,10 @@+// Copyright (C) 2018-2024 Intel Corporation+// SPDX-License-Identifier: Apache-2.0+//++#include "binary_ops.hpp"+#include "openvino/op/bitwise_right_shift.hpp"++using Type = ::testing::Types<BinaryOperatorType<ov::op::v15::BitwiseRightShift, ov::element::i32>>;++INSTANTIATE_TYPED_TEST_SUITE_P(visitor_with_auto_broadcast, BinaryOperatorVisitor, Type, BinaryOperatorTypeName);diff --git a/src/frontends/tensorflow/docs/supported_ops.md b/src/frontends/tensorflow/docs/supported_ops.mdindex 014becd0d62..ed1307c3b26 100644--- a/src/frontends/tensorflow/docs/supported_ops.md+++ b/src/frontends/tensorflow/docs/supported_ops.md@@ -561,7 +561,7 @@ A "supported operation" is one that TensorFlow Frontend can convert to the OpenV| LeakyRelu | YES | || LeakyReluGrad | NO | || LearnedUnigramCandidateSampler | NO | |-| LeftShift | NO | |+| LeftShift | YES | || LegacyParallelInterleaveDatasetV2 | NO | || Less | YES | || LessEqual | YES | |@@ -987,7 +987,7 @@ A "supported operation" is one that TensorFlow Frontend can convert to the OpenV| ReverseSequence | YES | || ReverseV2 | YES | || RewriteDataset | NO | |-| RightShift | NO | |+| RightShift | YES | || Rint | YES | || RngReadAndSkip | NO | || RngSkip | NO | |diff --git a/src/frontends/tensorflow/src/op_table.cpp b/src/frontends/tensorflow/src/op_table.cppindex ea0e4bd2643..69fba3d2453 100644--- a/src/frontends/tensorflow/src/op_table.cpp+++ b/src/frontends/tensorflow/src/op_table.cpp@@ -14,8 +14,10 @@#include "openvino/op/atan.hpp"#include "openvino/op/atanh.hpp"#include "openvino/op/bitwise_and.hpp"+#include "openvino/op/bitwise_left_shift.hpp"#include "openvino/op/bitwise_not.hpp"#include "openvino/op/bitwise_or.hpp"+#include "openvino/op/bitwise_right_shift.hpp"#include "openvino/op/bitwise_xor.hpp"#include "openvino/op/ceiling.hpp"#include "openvino/op/cos.hpp"@@ -173,6 +175,8 @@ const std::map<std::string, CreatorFunction> get_supported_ops() {{"BitwiseAnd", CreatorFunction(translate_binary_op<v13::BitwiseAnd>)},{"BitwiseOr", CreatorFunction(translate_binary_op<v13::BitwiseOr>)},{"BitwiseXor", CreatorFunction(translate_binary_op<v13::BitwiseXor>)},+ {"RightShift", CreatorFunction(translate_binary_op<v15::BitwiseRightShift>)},+ {"LeftShift", CreatorFunction(translate_binary_op<v15::BitwiseLeftShift>)},{"Div", CreatorFunction(translate_div_op)},{"Equal", CreatorFunction(translate_binary_op<v1::Equal>)},{"FloorMod", CreatorFunction(translate_binary_op<v1::FloorMod>)},diff --git a/src/frontends/tensorflow_common/src/op/binary_op.cpp b/src/frontends/tensorflow_common/src/op/binary_op.cppindex 05ef9a2a907..c3e390e9435 100644--- a/src/frontends/tensorflow_common/src/op/binary_op.cpp+++ b/src/frontends/tensorflow_common/src/op/binary_op.cpp@@ -6,7 +6,9 @@#include "helper_ops/complex_type_mark.hpp"#include "openvino/op/add.hpp"#include "openvino/op/bitwise_and.hpp"+#include "openvino/op/bitwise_left_shift.hpp"#include "openvino/op/bitwise_or.hpp"+#include "openvino/op/bitwise_right_shift.hpp"#include "openvino/op/bitwise_xor.hpp"#include "openvino/op/ceiling.hpp"#include "openvino/op/concat.hpp"@@ -173,6 +175,8 @@ template OutputVector translate_binary_op<v1::Add>(const NodeContext& node);template OutputVector translate_binary_op<v13::BitwiseAnd>(const NodeContext& node);template OutputVector translate_binary_op<v13::BitwiseOr>(const NodeContext& node);template OutputVector translate_binary_op<v13::BitwiseXor>(const NodeContext& node);+template OutputVector translate_binary_op<v15::BitwiseRightShift>(const NodeContext& node);+template OutputVector translate_binary_op<v15::BitwiseLeftShift>(const NodeContext& node);template OutputVector translate_binary_op<v1::Equal>(const NodeContext& node);template OutputVector translate_binary_op<v1::FloorMod>(const NodeContext& node);template OutputVector translate_binary_op<v1::Greater>(const NodeContext& node);diff --git a/src/plugins/template/backend/ops/bitwise_left_shift.cpp b/src/plugins/template/backend/ops/bitwise_left_shift.cppnew file mode 100644index 00000000000..7423cf537d1--- /dev/null+++ b/src/plugins/template/backend/ops/bitwise_left_shift.cpp@@ -0,0 +1,54 @@+// Copyright (C) 2018-2024 Intel Corporation+// SPDX-License-Identifier: Apache-2.0+//++#include "openvino/op/bitwise_left_shift.hpp"++#include "evaluate_node.hpp"+#include "openvino/reference/bitwise_left_shift.hpp"+#include "utils.hpp"++using namespace ov;++template <element::Type_t ET>+bool evaluate(const std::shared_ptr<ov::op::v15::BitwiseLeftShift>& node,+ ov::TensorVector& outputs,+ const ov::TensorVector& inputs) {+ OPENVINO_ASSERT(outputs.size() == 1);++ outputs[0].set_shape(infer_broadcast_shape(node.get(), inputs));+ using T = typename ov::element_type_traits<ET>::value_type;+ ov::reference::bitwise_left_shift(inputs[0].data<const T>(),+ inputs[1].data<const T>(),+ outputs[0].data<T>(),+ inputs[0].get_shape(),+ inputs[1].get_shape(),+ node->get_autob());+ return true;+}++template <>+bool evaluate_node<op::v15::BitwiseLeftShift>(std::shared_ptr<ov::Node> node,+ ov::TensorVector& outputs,+ const ov::TensorVector& inputs) {+ switch (node->get_input_element_type(0)) {+ case element::u8:+ return evaluate<element::u8>(as_type_ptr<op::v15::BitwiseLeftShift>(node), outputs, inputs);+ case element::i8:+ return evaluate<element::i8>(as_type_ptr<op::v15::BitwiseLeftShift>(node), outputs, inputs);+ case element::u16:+ return evaluate<element::u16>(as_type_ptr<op::v15::BitwiseLeftShift>(node), outputs, inputs);+ case element::i16:+ return evaluate<element::i16>(as_type_ptr<op::v15::BitwiseLeftShift>(node), outputs, inputs);+ case element::u32:+ return evaluate<element::u32>(as_type_ptr<op::v15::BitwiseLeftShift>(node), outputs, inputs);+ case element::i32:+ return evaluate<element::i32>(as_type_ptr<op::v15::BitwiseLeftShift>(node), outputs, inputs);+ case element::u64:+ return evaluate<element::u64>(as_type_ptr<op::v15::BitwiseLeftShift>(node), outputs, inputs);+ case element::i64:+ return evaluate<element::i64>(as_type_ptr<op::v15::BitwiseLeftShift>(node), outputs, inputs);+ default:+ OPENVINO_THROW("Unhandled data type ", node->get_element_type().get_type_name(), "in evaluate_node()");+ }+}diff --git a/src/plugins/template/backend/ops/bitwise_right_shift.cpp b/src/plugins/template/backend/ops/bitwise_right_shift.cppnew file mode 100644index 00000000000..0bba63049f1--- /dev/null+++ b/src/plugins/template/backend/ops/bitwise_right_shift.cpp@@ -0,0 +1,54 @@+// Copyright (C) 2018-2024 Intel Corporation+// SPDX-License-Identifier: Apache-2.0+//++#include "openvino/op/bitwise_right_shift.hpp"++#include "evaluate_node.hpp"+#include "openvino/reference/bitwise_right_shift.hpp"+#include "utils.hpp"++using namespace ov;++template <element::Type_t ET>+bool evaluate(const std::shared_ptr<ov::op::v15::BitwiseRightShift>& node,+ ov::TensorVector& outputs,+ const ov::TensorVector& inputs) {+ OPENVINO_ASSERT(outputs.size() == 1);++ outputs[0].set_shape(infer_broadcast_shape(node.get(), inputs));+ using T = typename ov::element_type_traits<ET>::value_type;+ ov::reference::bitwise_right_shift(inputs[0].data<const T>(),+ inputs[1].data<const T>(),+ outputs[0].data<T>(),+ inputs[0].get_shape(),+ inputs[1].get_shape(),+ node->get_autob());+ return true;+}++template <>+bool evaluate_node<op::v15::BitwiseRightShift>(std::shared_ptr<ov::Node> node,+ ov::TensorVector& outputs,+ const ov::TensorVector& inputs) {+ switch (node->get_input_element_type(0)) {+ case element::u8:+ return evaluate<element::u8>(as_type_ptr<op::v15::BitwiseRightShift>(node), outputs, inputs);+ case element::i8:+ return evaluate<element::i8>(as_type_ptr<op::v15::BitwiseRightShift>(node), outputs, inputs);+ case element::u16:+ return evaluate<element::u16>(as_type_ptr<op::v15::BitwiseRightShift>(node), outputs, inputs);+ case element::i16:+ return evaluate<element::i16>(as_type_ptr<op::v15::BitwiseRightShift>(node), outputs, inputs);+ case element::u32:+ return evaluate<element::u32>(as_type_ptr<op::v15::BitwiseRightShift>(node), outputs, inputs);+ case element::i32:+ return evaluate<element::i32>(as_type_ptr<op::v15::BitwiseRightShift>(node), outputs, inputs);+ case element::u64:+ return evaluate<element::u64>(as_type_ptr<op::v15::BitwiseRightShift>(node), outputs, inputs);+ case element::i64:+ return evaluate<element::i64>(as_type_ptr<op::v15::BitwiseRightShift>(node), outputs, inputs);+ default:+ OPENVINO_THROW("Unhandled data type ", node->get_element_type().get_type_name(), "in evaluate_node()");+ }+}diff --git a/src/plugins/template/backend/ops/ops_evaluates.hpp b/src/plugins/template/backend/ops/ops_evaluates.hppindex 65b5a136b70..9bcd0d94b60 100644--- a/src/plugins/template/backend/ops/ops_evaluates.hpp+++ b/src/plugins/template/backend/ops/ops_evaluates.hpp@@ -489,6 +489,14 @@ extern template bool evaluate_node<ov::op::v13::BitwiseXor>(std::shared_ptr<ov::ov::TensorVector& outputs,const ov::TensorVector& inputs);+extern template bool evaluate_node<ov::op::v15::BitwiseLeftShift>(std::shared_ptr<ov::Node> node,+ ov::TensorVector& outputs,+ const ov::TensorVector& inputs);++extern template bool evaluate_node<ov::op::v15::BitwiseRightShift>(std::shared_ptr<ov::Node> node,+ ov::TensorVector& outputs,+ const ov::TensorVector& inputs);+extern template bool evaluate_node<ov::op::v13::NMSRotated>(std::shared_ptr<ov::Node> node,ov::TensorVector& outputs,const ov::TensorVector& inputs);diff --git a/src/plugins/template/backend/opset_int_tbl.hpp b/src/plugins/template/backend/opset_int_tbl.hppindex f050d8e99ec..cce47e15111 100644--- a/src/plugins/template/backend/opset_int_tbl.hpp+++ b/src/plugins/template/backend/opset_int_tbl.hpp@@ -169,6 +169,8 @@ _OPENVINO_OP_REG(ROIAlignRotated, ov::op::v15)_OPENVINO_OP_REG(EmbeddingBagOffsets, op::v15)_OPENVINO_OP_REG(EmbeddingBagPacked, op::v15)_OPENVINO_OP_REG(Col2Im, ov::op::v15)+_OPENVINO_OP_REG(BitwiseLeftShift, ov::op::v15)+_OPENVINO_OP_REG(BitwiseRightShift, ov::op::v15)_OPENVINO_OP_REG(AUGRUCell, ov::op::internal)_OPENVINO_OP_REG(AUGRUSequence, ov::op::internal)diff --git a/src/plugins/template/tests/functional/op_reference/bitwise.hpp b/src/plugins/template/tests/functional/op_reference/bitwise.hppindex 949bdc5a8a4..8b8eebc3543 100644--- a/src/plugins/template/tests/functional/op_reference/bitwise.hpp+++ b/src/plugins/template/tests/functional/op_reference/bitwise.hpp@@ -6,8 +6,10 @@#include "base_reference_test.hpp"#include "openvino/op/bitwise_and.hpp"+#include "openvino/op/bitwise_left_shift.hpp"#include "openvino/op/bitwise_not.hpp"#include "openvino/op/bitwise_or.hpp"+#include "openvino/op/bitwise_right_shift.hpp"#include "openvino/op/bitwise_xor.hpp"using namespace ov;@@ -15,7 +17,7 @@ using namespace ov;namespace reference_tests {namespace BitwiseOpsRefTestDefinitions {-enum BitwiseTypes { BITWISE_AND, BITWISE_NOT, BITWISE_OR, BITWISE_XOR };+enum BitwiseTypes { BITWISE_AND, BITWISE_NOT, BITWISE_OR, BITWISE_XOR, BITWISE_RIGHT_SHIFT, BITWISE_LEFT_SHIFT };struct RefBitwiseParams {BitwiseTypes opType;@@ -78,6 +80,14 @@ private:bitwise_op = std::make_shared<ov::op::v13::BitwiseXor>(params_vec[0], params_vec[1]);break;}+ case BitwiseTypes::BITWISE_RIGHT_SHIFT: {+ bitwise_op = std::make_shared<ov::op::v15::BitwiseRightShift>(params_vec[0], params_vec[1]);+ break;+ }+ case BitwiseTypes::BITWISE_LEFT_SHIFT: {+ bitwise_op = std::make_shared<ov::op::v15::BitwiseLeftShift>(params_vec[0], params_vec[1]);+ break;+ }}EXPECT_TRUE(bitwise_op) << "Incorrect type of Bitwise operation";return std::make_shared<ov::Model>(ov::NodeVector{bitwise_op}, ov::ParameterVector{params_vec});diff --git a/src/plugins/template/tests/functional/op_reference/bitwise_left_shift.cpp b/src/plugins/template/tests/functional/op_reference/bitwise_left_shift.cppnew file mode 100644index 00000000000..7ca19e4b1f1--- /dev/null+++ b/src/plugins/template/tests/functional/op_reference/bitwise_left_shift.cpp@@ -0,0 +1,165 @@+// Copyright (C) 2018-2024 Intel Corporation+// SPDX-License-Identifier: Apache-2.0+//++#include "openvino/op/bitwise_left_shift.hpp"++#include <gtest/gtest.h>++#include <limits>++#include "bitwise.hpp"++using namespace ov;++namespace reference_tests {+namespace BitwiseOpsRefTestDefinitions {+namespace {++// Off clang format to avoid long single column vectors++// clang-format off+std::vector<RefBitwiseParams> generateBitwiseParams() {+ constexpr int32_t min_int32 = std::numeric_limits<int32_t>::min();+ std::vector<RefBitwiseParams> bitwiseParams{+ Builder{}+ .opType(BitwiseTypes::BITWISE_LEFT_SHIFT)+ .inputs({{{10}, element::i32, std::vector<int32_t>{0, 0, 1, -1, 3, -3, 2, -2, 64, -64}},+ {{1}, element::i32, std::vector<int32_t>{1}}})+ .expected({{10}, element::i32, std::vector<int32_t>{0, 0, 2, -2, 6, -6, 4, -4, 128, -128}}),+ Builder{}+ .opType(BitwiseTypes::BITWISE_LEFT_SHIFT)+ .inputs({{{2, 5}, element::i32, std::vector<int32_t>{0, 0, 1, -1, 3, -3, 2, -2, 64, -64}},+ {{1, 1}, element::i32, std::vector<int32_t>{1}}})+ .expected({{2, 5}, element::i32, std::vector<int32_t>{0, 0, 2, -2, 6, -6, 4, -4, 128, -128}}),+ Builder{}+ .opType(BitwiseTypes::BITWISE_LEFT_SHIFT)+ .inputs({{{2, 5}, element::i32, std::vector<int32_t>{0, 0, 1, -1, 3, -3, 2, -2, 64, -64}},+ {{2, 1}, element::i32, std::vector<int32_t>{1, 2}}})+ .expected({{2, 5}, element::i32, std::vector<int32_t>{0, 0, 2, -2, 6, -12, 8, -8, 256, -256}}),+ Builder{}+ .opType(BitwiseTypes::BITWISE_LEFT_SHIFT)+ .inputs({{{10}, element::i8, std::vector<int8_t>{0, 0, 1, -1, 3, -3, 2, -2, 64, -64}},+ {{1}, element::i8, std::vector<int8_t>{1}}})+ .expected({{10}, element::i8, std::vector<int8_t>{0, 0, 2, -2, 6, -6, 4, -4, -128, -128}}),+ Builder{}+ .opType(BitwiseTypes::BITWISE_LEFT_SHIFT)+ .inputs({{{2, 5}, element::i64, std::vector<int64_t>{0, 0, 1, -1, 3, -3, 2, -2, 64, -64}},+ {{6, 1, 1}, element::i64, std::vector<int64_t>{0, 1, 2, 3, 8, 31}}})+ .expected({{6, 2, 5},+ element::i64,+ std::vector<int64_t>{0, 0, 1, -1, 3,+ -3, 2, -2, 64, -64,+ 0, 0, 2, -2, 6,+ -6, 4, -4, 128, -128,+ 0, 0, 4, -4, 12,+ -12, 8, -8, 256, -256,+ 0, 0, 8, -8, 24,+ -24, 16, -16, 512, -512,+ 0, 0, 256, -256, 768,+ -768, 512, -512, 16384, -16384,+ 0, 0, 2147483648L, min_int32, 6442450944L,+ -6442450944L, 4294967296L, -4294967296L, 137438953472L, -137438953472L}}),+ Builder{}+ .opType(BitwiseTypes::BITWISE_LEFT_SHIFT)+ .inputs({{{2, 5}, element::i32, std::vector<int32_t>{0, 0, 1, -1, 3, -3, 2, -2, 64, -64}},+ {{6, 1, 1}, element::i32, std::vector<int32_t>{0, 1, 2, 3, 8, 31}}})+ .expected(+ {{6, 2, 5},+ element::i32,+ std::vector<int32_t>{+ 0, 0, 1, -1, 3, -3, 2, -2, 64, -64, 0, 0,+ 2, -2, 6, -6, 4, -4, 128, -128, 0, 0, 4, -4,+ 12, -12, 8, -8, 256, -256, 0, 0, 8, -8, 24, -24,+ 16, -16, 512, -512, 0, 0, 256, -256, 768, -768, 512, -512,+ 16384, -16384, 0, 0, min_int32, min_int32, min_int32, min_int32, 0, 0, 0, 0}}),+ Builder{}+ .opType(BitwiseTypes::BITWISE_LEFT_SHIFT)+ .inputs({{{2, 5}, element::i16, std::vector<int16_t>{0, 0, 1, -1, 3, -3, 2, -2, 64, -64}},+ {{6, 1, 1}, element::i16, std::vector<int16_t>{0, 1, 2, 3, 8, 15}}})+ .expected({{6, 2, 5},+ element::i16,+ std::vector<int16_t>{+ 0, 0, 1, -1, 3, -3, 2, -2, 64, -64, 0, 0, 2, -2, 6,+ -6, 4, -4, 128, -128, 0, 0, 4, -4, 12, -12, 8, -8, 256, -256,+ 0, 0, 8, -8, 24, -24, 16, -16, 512, -512, 0, 0, 256, -256, 768,+ -768, 512, -512, 16384, -16384, 0, 0, -32768, -32768, -32768, -32768, 0, 0, 0, 0}}),+ Builder{}+ .opType(BitwiseTypes::BITWISE_LEFT_SHIFT)+ .inputs({{{2, 5}, element::i8, std::vector<int8_t>{0, 0, 1, -1, 3, -3, 2, -2, 64, -64}},+ {{6, 1, 1}, element::i8, std::vector<int8_t>{0, 1, 2, 3, 4, 7}}})+ .expected({{6, 2, 5},+ element::i8,+ std::vector<int8_t>{0, 0, 1, -1, 3, -3, 2, -2, 64, -64, 0, 0, 2, -2, 6,+ -6, 4, -4, -128, -128, 0, 0, 4, -4, 12, -12, 8, -8, 0, 0,+ 0, 0, 8, -8, 24, -24, 16, -16, 0, 0, 0, 0, 16, -16, 48,+ -48, 32, -32, 0, 0, 0, 0, -128, -128, -128, -128, 0, 0, 0, 0}}),+ Builder{}+ .opType(BitwiseTypes::BITWISE_LEFT_SHIFT)+ .inputs({{{2, 6}, element::u8, std::vector<uint8_t>{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 51, 64}},+ {{6, 1, 1}, element::u8, std::vector<uint8_t>{0, 1, 2, 3, 4, 7}}})+ .expected({{6, 2, 6},+ element::u8,+ std::vector<uint8_t>{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 51, 64, 0, 2, 4,+ 6, 8, 10, 12, 14, 16, 18, 102, 128, 0, 4, 8, 12, 16, 20,+ 24, 28, 32, 36, 204, 0, 0, 8, 16, 24, 32, 40, 48, 56, 64,+ 72, 152, 0, 0, 16, 32, 48, 64, 80, 96, 112, 128, 144, 48, 0,+ 0, 128, 0, 128, 0, 128, 0, 128, 0, 128, 128, 0}}),+ Builder{}+ .opType(BitwiseTypes::BITWISE_LEFT_SHIFT)+ .inputs({{{2, 6}, element::u16, std::vector<uint16_t>{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 51, 64}},+ {{6, 1, 1}, element::u16, std::vector<uint16_t>{0, 1, 2, 3, 4, 7}}})+ .expected(+ {{6, 2, 6},+ element::u16,+ std::vector<uint16_t>{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 51, 64, 0, 2, 4,+ 6, 8, 10, 12, 14, 16, 18, 102, 128, 0, 4, 8, 12, 16, 20,+ 24, 28, 32, 36, 204, 256, 0, 8, 16, 24, 32, 40, 48, 56, 64,+ 72, 408, 512, 0, 16, 32, 48, 64, 80, 96, 112, 128, 144, 816, 1024,+ 0, 128, 256, 384, 512, 640, 768, 896, 1024, 1152, 6528, 8192}}),++ Builder{}+ .opType(BitwiseTypes::BITWISE_LEFT_SHIFT)+ .inputs({{{2, 6}, element::u32, std::vector<uint32_t>{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 51, 64}},+ {{6, 1, 1}, element::u32, std::vector<uint32_t>{0, 1, 2, 3, 4, 7}}})+ .expected(+ {{6, 2, 6},+ element::u32,+ std::vector<uint32_t>{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 51, 64, 0, 2, 4,+ 6, 8, 10, 12, 14, 16, 18, 102, 128, 0, 4, 8, 12, 16, 20,+ 24, 28, 32, 36, 204, 256, 0, 8, 16, 24, 32, 40, 48, 56, 64,+ 72, 408, 512, 0, 16, 32, 48, 64, 80, 96, 112, 128, 144, 816, 1024,+ 0, 128, 256, 384, 512, 640, 768, 896, 1024, 1152, 6528, 8192}}),+ Builder{}+ .opType(BitwiseTypes::BITWISE_LEFT_SHIFT)+ .inputs({{{2, 6}, element::u64, std::vector<uint64_t>{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 51, 64}},+ {{6, 1, 1}, element::u64, std::vector<uint64_t>{0, 1, 2, 3, 8, 63}}})+ .expected({{6, 2, 6},+ element::u64,+ std::vector<uint64_t>{+ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 51, 64, 0, 2, 4, 6,+ 8, 10, 12, 14, 16, 18, 102, 128, 0, 4, 8, 12, 16, 20, 24, 28,+ 32, 36, 204, 256, 0, 8, 16, 24, 32, 40, 48, 56, 64, 72, 408, 512,+ 0, 256, 512, 768, 1024, 1280, 1536, 1792, 2048, 2304, 13056, 16384, 0, 9223372036854775808ul,+ 0, 9223372036854775808ul, 0, 9223372036854775808ul, 0, 9223372036854775808ul, 0, 9223372036854775808ul,+ 9223372036854775808ul, 0}}),++ //// Note: Negative shift, Implementation defined or undefined behavior+ // Builder{}+ // .opType(BitwiseTypes::BITWISE_LEFT_SHIFT)+ // .inputs({{{1, 10}, element::i32, std::vector<int32_t>{0, 0, 1, -1, 3, -3, 2, -2, 64, -64}},+ // {{1}, element::i32, std::vector<int32_t>{-1}}})+ // .expected({{1, 10}, element::i32, std::vector<int32_t>{0, 0, 0, 0, 0, 0, 0, 0, 0, 0}}),+ };+ return bitwiseParams;+}+// clang-format on++INSTANTIATE_TEST_SUITE_P(smoke_BitwiseLeftShift_With_Hardcoded_Refs,+ ReferenceBitwiseLayerTest,+ ::testing::ValuesIn(generateBitwiseParams()),+ ReferenceBitwiseLayerTest::getTestCaseName);++} // namespace+} // namespace BitwiseOpsRefTestDefinitions+} // namespace reference_testsdiff --git a/src/plugins/template/tests/functional/op_reference/bitwise_right_shift.cpp b/src/plugins/template/tests/functional/op_reference/bitwise_right_shift.cppnew file mode 100644index 00000000000..623c6f25d73--- /dev/null+++ b/src/plugins/template/tests/functional/op_reference/bitwise_right_shift.cpp@@ -0,0 +1,130 @@+// Copyright (C) 2018-2024 Intel Corporation+// SPDX-License-Identifier: Apache-2.0+//++#include "openvino/op/bitwise_right_shift.hpp"++#include <gtest/gtest.h>++#include "bitwise.hpp"++using namespace ov;++namespace reference_tests {+namespace BitwiseOpsRefTestDefinitions {+namespace {++std::vector<RefBitwiseParams> generateBitwiseParams() {+ std::vector<RefBitwiseParams> bitwiseParams{+ Builder{}+ .opType(BitwiseTypes::BITWISE_RIGHT_SHIFT)+ .inputs({{{10}, element::i32, std::vector<int32_t>{0, 0, 1, -1, 3, -3, 2, -2, 64, -64}},+ {{1}, element::i32, std::vector<int32_t>{1}}})+ .expected({{10}, element::i32, std::vector<int32_t>{0, 0, 0, -1, 1, -2, 1, -1, 32, -32}}),+ Builder{}+ .opType(BitwiseTypes::BITWISE_RIGHT_SHIFT)+ .inputs({{{5, 2}, element::i32, std::vector<int32_t>{0, 0, 1, -1, 3, -3, 2, -2, 64, -64}},+ {{1, 1}, element::i32, std::vector<int32_t>{1}}})+ .expected({{5, 2}, element::i32, std::vector<int32_t>{0, 0, 0, -1, 1, -2, 1, -1, 32, -32}}),+ Builder{}+ .opType(BitwiseTypes::BITWISE_RIGHT_SHIFT)+ .inputs({{{2, 5}, element::i32, std::vector<int32_t>{0, 0, 1, -1, 3, -3, 2, -2, 64, -64}},+ {{2, 1}, element::i32, std::vector<int32_t>{1, 2}}})+ .expected({{2, 5}, element::i32, std::vector<int32_t>{0, 0, 0, -1, 1, -1, 0, -1, 16, -16}}),+ Builder{}+ .opType(BitwiseTypes::BITWISE_RIGHT_SHIFT)+ .inputs({{{10}, element::i8, std::vector<int8_t>{0, 0, 1, -1, 3, -3, 2, -2, 64, -64}},+ {{1}, element::i8, std::vector<int8_t>{1}}})+ .expected({{10}, element::i8, std::vector<int8_t>{0, 0, 0, -1, 1, -2, 1, -1, 32, -32}}),+ Builder{}+ .opType(BitwiseTypes::BITWISE_RIGHT_SHIFT)+ .inputs({{{2, 5}, element::i64, std::vector<int64_t>{0, 0, 1, -1, 3, -3, 2, -2, 64, -64}},+ {{6, 1, 1}, element::i64, std::vector<int64_t>{0, 1, 2, 3, 8, 31}}})+ .expected({{6, 2, 5},+ element::i64,+ std::vector<int64_t>{0, 0, 1, -1, 3, -3, 2, -2, 64, -64, 0, 0, 0, -1, 1, -2, 1, -1, 32, -32,+ 0, 0, 0, -1, 0, -1, 0, -1, 16, -16, 0, 0, 0, -1, 0, -1, 0, -1, 8, -8,+ 0, 0, 0, -1, 0, -1, 0, -1, 0, -1, 0, 0, 0, -1, 0, -1, 0, -1, 0, -1}}),+ Builder{}+ .opType(BitwiseTypes::BITWISE_RIGHT_SHIFT)+ .inputs({{{2, 5}, element::i32, std::vector<int32_t>{0, 0, 1, -1, 3, -3, 2, -2, 64, -64}},+ {{6, 1, 1}, element::i32, std::vector<int32_t>{0, 1, 2, 3, 8, 31}}})+ .expected({{6, 2, 5},+ element::i32,+ std::vector<int32_t>{0, 0, 1, -1, 3, -3, 2, -2, 64, -64, 0, 0, 0, -1, 1, -2, 1, -1, 32, -32,+ 0, 0, 0, -1, 0, -1, 0, -1, 16, -16, 0, 0, 0, -1, 0, -1, 0, -1, 8, -8,+ 0, 0, 0, -1, 0, -1, 0, -1, 0, -1, 0, 0, 0, -1, 0, -1, 0, -1, 0, -1}}),+ Builder{}+ .opType(BitwiseTypes::BITWISE_RIGHT_SHIFT)+ .inputs({{{2, 5}, element::i16, std::vector<int16_t>{0, 0, 1, -1, 3, -3, 2, -2, 64, -64}},+ {{6, 1, 1}, element::i16, std::vector<int16_t>{0, 1, 2, 3, 8, 16}}})+ .expected({{6, 2, 5},+ element::i16,+ std::vector<int16_t>{0, 0, 1, -1, 3, -3, 2, -2, 64, -64, 0, 0, 0, -1, 1, -2, 1, -1, 32, -32,+ 0, 0, 0, -1, 0, -1, 0, -1, 16, -16, 0, 0, 0, -1, 0, -1, 0, -1, 8, -8,+ 0, 0, 0, -1, 0, -1, 0, -1, 0, -1, 0, 0, 0, -1, 0, -1, 0, -1, 0, -1}}),++ Builder{}+ .opType(BitwiseTypes::BITWISE_RIGHT_SHIFT)+ .inputs({{{2, 5}, element::i8, std::vector<int8_t>{0, 0, 1, -1, 3, -3, 2, -2, 64, -64}},+ {{6, 1, 1}, element::i8, std::vector<int8_t>{0, 1, 2, 3, 4, 7}}})+ .expected({{6, 2, 5},+ element::i8,+ std::vector<int8_t>{0, 0, 1, -1, 3, -3, 2, -2, 64, -64, 0, 0, 0, -1, 1, -2, 1, -1, 32, -32,+ 0, 0, 0, -1, 0, -1, 0, -1, 16, -16, 0, 0, 0, -1, 0, -1, 0, -1, 8, -8,+ 0, 0, 0, -1, 0, -1, 0, -1, 4, -4, 0, 0, 0, -1, 0, -1, 0, -1, 0, -1}}),+ Builder{}+ .opType(BitwiseTypes::BITWISE_RIGHT_SHIFT)+ .inputs({{{2, 6}, element::u8, std::vector<uint8_t>{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 51, 64}},+ {{6, 1, 1}, element::u8, std::vector<uint8_t>{0, 1, 2, 3, 4, 7}}})+ .expected({{6, 2, 6}, element::u8, std::vector<uint8_t>{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 51, 64, 0, 0, 1,+ 1, 2, 2, 3, 3, 4, 4, 25, 32, 0, 0, 0, 0, 1, 1,+ 1, 1, 2, 2, 12, 16, 0, 0, 0, 0, 0, 0, 0, 0, 1,+ 1, 6, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 4,+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}}),+ Builder{}+ .opType(BitwiseTypes::BITWISE_RIGHT_SHIFT)+ .inputs({{{2, 6}, element::u16, std::vector<uint16_t>{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 51, 64}},+ {{6, 1, 1}, element::u16, std::vector<uint16_t>{0, 1, 2, 3, 4, 7}}})+ .expected({{6, 2, 6}, element::u16, std::vector<uint16_t>{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 51, 64, 0, 0, 1,+ 1, 2, 2, 3, 3, 4, 4, 25, 32, 0, 0, 0, 0, 1, 1,+ 1, 1, 2, 2, 12, 16, 0, 0, 0, 0, 0, 0, 0, 0, 1,+ 1, 6, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 4,+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}}),+ Builder{}+ .opType(BitwiseTypes::BITWISE_RIGHT_SHIFT)+ .inputs({{{2, 6}, element::u32, std::vector<uint32_t>{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 51, 64}},+ {{6, 1, 1}, element::u32, std::vector<uint32_t>{0, 1, 2, 3, 4, 7}}})+ .expected({{6, 2, 6}, element::u32, std::vector<uint32_t>{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 51, 64, 0, 0, 1,+ 1, 2, 2, 3, 3, 4, 4, 25, 32, 0, 0, 0, 0, 1, 1,+ 1, 1, 2, 2, 12, 16, 0, 0, 0, 0, 0, 0, 0, 0, 1,+ 1, 6, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 4,+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}}),+ Builder{}+ .opType(BitwiseTypes::BITWISE_RIGHT_SHIFT)+ .inputs({{{2, 6}, element::u64, std::vector<uint64_t>{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 51, 64}},+ {{6, 1, 1}, element::u64, std::vector<uint64_t>{0, 1, 2, 3, 8, 63}}})+ .expected({{6, 2, 6}, element::u64, std::vector<uint64_t>{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 51, 64, 0, 0, 1,+ 1, 2, 2, 3, 3, 4, 4, 25, 32, 0, 0, 0, 0, 1, 1,+ 1, 1, 2, 2, 12, 16, 0, 0, 0, 0, 0, 0, 0, 0, 1,+ 1, 6, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}}),++ //// Note: Negative shift, Implementation defined or undefined behavior+ // Builder{}+ // .opType(BitwiseTypes::BITWISE_RIGHT_SHIFT)+ // .inputs({{{1, 10}, element::i32, std::vector<int32_t>{0, 0, 1, -1, 3, -3, 2, -2, 64, -64}},+ // {{1}, element::i32, std::vector<int32_t>{-1}}})+ // .expected({{1, 10}, element::i32, std::vector<int32_t>{0, 0, 0, -1, 0, -1, 0, -1, 0, -1}}),+ };+ return bitwiseParams;+}++INSTANTIATE_TEST_SUITE_P(smoke_BitwiseRightShift_With_Hardcoded_Refs,+ ReferenceBitwiseLayerTest,+ ::testing::ValuesIn(generateBitwiseParams()),+ ReferenceBitwiseLayerTest::getTestCaseName);++} // namespace+} // namespace BitwiseOpsRefTestDefinitions+} // namespace reference_testsdiff --git a/src/tests/functional/plugin/conformance/test_runner/op_conformance_runner/src/op_impl_check/single_op_graph.cpp b/src/tests/functional/plugin/conformance/test_runner/op_conformance_runner/src/op_impl_check/single_op_graph.cppindex 98c3d234914..73595dfd1dc 100644--- a/src/tests/functional/plugin/conformance/test_runner/op_conformance_runner/src/op_impl_check/single_op_graph.cpp+++ b/src/tests/functional/plugin/conformance/test_runner/op_conformance_runner/src/op_impl_check/single_op_graph.cpp@@ -1571,6 +1571,10 @@ std::shared_ptr<ov::Model> generateBinaryEltwiseBitwise(const std::shared_ptr<oveltwise = std::make_shared<ov::op::v13::BitwiseOr>(params[0], params[1]);} else if (ov::is_type<ov::op::v13::BitwiseXor>(node)) {eltwise = std::make_shared<ov::op::v13::BitwiseXor>(params[0], params[1]);+ } else if (ov::is_type<ov::op::v15::BitwiseLeftShift>(node)) {+ eltwise = std::make_shared<ov::op::v15::BitwiseLeftShift>(params[0], params[1]);+ } else if (ov::is_type<ov::op::v15::BitwiseRightShift>(node)) {+ eltwise = std::make_shared<ov::op::v15::BitwiseRightShift>(params[0], params[1]);} else {return nullptr;}diff --git a/tests/layer_tests/tensorflow_tests/test_tf_BitwiseShift.py b/tests/layer_tests/tensorflow_tests/test_tf_BitwiseShift.pynew file mode 100644index 00000000000..1f4aee82965--- /dev/null+++ b/tests/layer_tests/tensorflow_tests/test_tf_BitwiseShift.py@@ -0,0 +1,77 @@+# Copyright (C) 2018-2024 Intel Corporation+# SPDX-License-Identifier: Apache-2.0++import numpy as np+import platform+import pytest+import tensorflow as tf+from common.tf_layer_test_class import CommonTFLayerTest++rng = np.random.default_rng(21097)++op_type_to_tf = {+ 'LeftShift': tf.raw_ops.RightShift,+ 'RightShift': tf.raw_ops.RightShift,+}+++def generate_input(in_shape, in_type, is_rhs=False):+ # Note: Type conversion to i32 in CPU, can lead to mismatch for values out of i32 range+ if is_rhs:+ return rng.integers(0, np.iinfo(in_type).bits/2, in_shape).astype(in_type)+ if np.issubdtype(in_type, np.signedinteger):+ return rng.integers(-100, 100, in_shape).astype(in_type)+ return rng.integers(0, 200, in_shape).astype(in_type)+++class TestBitwise(CommonTFLayerTest):+ def _prepare_input(self, inputs_info):+ inputs_data = {}++ assert 'x:0' in inputs_info, "Test error: inputs_info must contain `x`"+ x_shape = inputs_info['x:0']+ inputs_data['x:0'] = generate_input(x_shape, self.input_type)+ if not self.is_y_const:+ assert 'y:0' in inputs_info, "Test error: inputs_info must contain `y`"+ y_shape = inputs_info['y:0']+ inputs_data['y:0'] = generate_input(y_shape, self.input_type, True)+ return inputs_data++ def create_bitwise_net(self, x_shape, y_shape, is_y_const, input_type, op_type):+ self.is_y_const = is_y_const+ self.input_type = input_type+ tf.compat.v1.reset_default_graph()+ # Create the graph and model+ with tf.compat.v1.Session() as sess:+ x = tf.compat.v1.placeholder(input_type, x_shape, 'x')+ if is_y_const:+ constant_value = generate_input(y_shape, input_type, True)+ y = tf.constant(constant_value, dtype=input_type)+ else:+ y = tf.compat.v1.placeholder(input_type, y_shape, 'y')+ op_type_to_tf[op_type](x=x, y=y, name=op_type)++ tf.compat.v1.global_variables_initializer()+ tf_net = sess.graph_def++ ref_net = None++ return tf_net, ref_net++ @pytest.mark.parametrize('x_shape', [[4], [3, 4], [1, 2, 3, 4]])+ @pytest.mark.parametrize('y_shape', [[1], [4], [2, 3, 4]])+ @pytest.mark.parametrize('is_y_const', [True, False])+ # Element types supported by evaluate, to be updated with further enablement+ @pytest.mark.parametrize('input_type', [np.int32])+ @pytest.mark.parametrize("op_type", ['RightShift', 'LeftShift'])+ @pytest.mark.precommit+ @pytest.mark.nightly+ def test_bitwise(self, x_shape, y_shape, is_y_const, input_type, op_type, ie_device, precision, ir_version,+ temp_dir, use_legacy_frontend):+ if ie_device == 'GPU':+ pytest.skip("148540: Bitwise ops are not supported on GPU")+ if use_legacy_frontend:+ pytest.skip("BitwiseShift ops are supported only by new TF FE")+ self._test(*self.create_bitwise_net(x_shape=x_shape, y_shape=y_shape, is_y_const=is_y_const,+ input_type=input_type, op_type=op_type),+ ie_device, precision, ir_version, temp_dir=temp_dir, use_legacy_frontend=use_legacy_frontend)