diff --git a/src/bindings/python/tests_compatibility/__init__.py b/src/bindings/python/tests_compatibility/__init__.py index b6eb6e0b5c7..b5005972496 100644 --- a/src/bindings/python/tests_compatibility/__init__.py +++ b/src/bindings/python/tests_compatibility/__init__.py @@ -85,6 +85,7 @@ xfail_issue_44965 = xfail_test(reason="Expected: RuntimeError: value info has no xfail_issue_47323 = xfail_test(reason="RuntimeError: The plugin does not support FP64") xfail_issue_73538 = xfail_test(reason="OneHot: Unsupported negative indices, " "AssertionError: Mismatched elements.") +skip_bitwise_ui64 = pytest.mark.skip(reason="AssertionError: Not equal to tolerance rtol=0.001, atol=1e-07") xfail_issue_99949 = xfail_test(reason="Bitwise operators are not supported") xfail_issue_99950 = xfail_test(reason="CenterCropPad func is not supported") xfail_issue_99952 = xfail_test(reason="Col2Im operator is not supported") diff --git a/src/bindings/python/tests_compatibility/test_onnx/test_backend.py b/src/bindings/python/tests_compatibility/test_onnx/test_backend.py index c1ad04a6fe4..c1f9a4d7b77 100644 --- a/src/bindings/python/tests_compatibility/test_onnx/test_backend.py +++ b/src/bindings/python/tests_compatibility/test_onnx/test_backend.py @@ -47,6 +47,7 @@ from tests_compatibility import ( xfail_issue_91151, xfail_issue_91490, xfail_issue_101965, + skip_bitwise_ui64, xfail_issue_99949, xfail_issue_99950, xfail_issue_99952, @@ -521,11 +522,12 @@ tests_expected_to_fail = [ "OnnxBackendNodeModelTest.test_reduce_sum_square_keepdims_example_expanded_cpu", "OnnxBackendNodeModelTest.test_reduce_sum_square_keepdims_random_expanded_cpu", ), + ( + skip_bitwise_ui64, + "OnnxBackendNodeModelTest.test_bitwise_and_ui64_bcast_3v1d_cpu", + ), ( xfail_issue_99949, - "OnnxBackendNodeModelTest.test_bitwise_and_i16_3d_cpu", - "OnnxBackendNodeModelTest.test_bitwise_and_i32_2d_cpu", - "OnnxBackendNodeModelTest.test_bitwise_and_ui64_bcast_3v1d_cpu", "OnnxBackendNodeModelTest.test_bitwise_not_2d_cpu", "OnnxBackendNodeModelTest.test_bitwise_not_3d_cpu", "OnnxBackendNodeModelTest.test_bitwise_not_4d_cpu", @@ -535,7 +537,6 @@ tests_expected_to_fail = [ "OnnxBackendNodeModelTest.test_bitwise_xor_ui8_bcast_4v3d_cpu", "OnnxBackendNodeModelTest.test_bitwise_xor_i16_3d_cpu", "OnnxBackendNodeModelTest.test_bitwise_xor_i32_2d_cpu", - "OnnxBackendNodeModelTest.test_bitwise_and_ui8_bcast_4v3d_cpu", "OnnxBackendNodeModelTest.test_bitwise_or_ui8_bcast_4v3d_cpu", "OnnxBackendNodeModelTest.test_bitwise_xor_ui64_bcast_3v1d_cpu", ), diff --git a/src/frontends/onnx/frontend/src/op/bitwise_and.cpp b/src/frontends/onnx/frontend/src/op/bitwise_and.cpp new file mode 100644 index 00000000000..54961812505 --- /dev/null +++ b/src/frontends/onnx/frontend/src/op/bitwise_and.cpp @@ -0,0 +1,24 @@ +// Copyright (C) 2018-2023 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "op/bitwise_and.hpp" +OPENVINO_SUPPRESS_DEPRECATED_START + +#include "default_opset.hpp" + +using namespace ov::op; + +namespace ngraph { +namespace onnx_import { +namespace op { +namespace set_1 { +OutputVector bitwise_and(const Node& node) { + const auto inputs = node.get_ng_inputs(); + OPENVINO_ASSERT(inputs.size() == 2); + return {std::make_shared(inputs[0], inputs[1])}; +} +} // namespace set_1 +} // namespace op +} // namespace onnx_import +} // namespace ngraph diff --git a/src/frontends/onnx/frontend/src/op/bitwise_and.hpp b/src/frontends/onnx/frontend/src/op/bitwise_and.hpp new file mode 100644 index 00000000000..d0f66569c95 --- /dev/null +++ b/src/frontends/onnx/frontend/src/op/bitwise_and.hpp @@ -0,0 +1,25 @@ +// Copyright (C) 2018-2023 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#pragma once + +#include "openvino/core/deprecated.hpp" +OPENVINO_SUPPRESS_DEPRECATED_START + +#include "ngraph/node.hpp" +#include "onnx_import/core/node.hpp" + +namespace ngraph { +namespace onnx_import { +namespace op { +namespace set_1 { +OutputVector bitwise_and(const Node& node); + +} // namespace set_1 +} // namespace op + +} // namespace onnx_import + +} // namespace ngraph +OPENVINO_SUPPRESS_DEPRECATED_END diff --git a/src/frontends/onnx/frontend/src/ops_bridge.cpp b/src/frontends/onnx/frontend/src/ops_bridge.cpp index b26efd10bf0..fefe1879e40 100644 --- a/src/frontends/onnx/frontend/src/ops_bridge.cpp +++ b/src/frontends/onnx/frontend/src/ops_bridge.cpp @@ -29,6 +29,7 @@ #include "op/average_pool.hpp" #include "op/batch_norm.hpp" #include "op/bitshift.hpp" +#include "op/bitwise_and.hpp" #include "op/blackmanwindow.hpp" #include "op/cast.hpp" #include "op/cast_like.hpp" @@ -351,6 +352,7 @@ OperatorsBridge::OperatorsBridge() { REGISTER_OPERATOR("BatchNormalization", 1, batch_norm); REGISTER_OPERATOR("BatchNormalization", 7, batch_norm); REGISTER_OPERATOR("BitShift", 1, bitshift); + REGISTER_OPERATOR("BitwiseAnd", 1, bitwise_and); REGISTER_OPERATOR("BlackmanWindow", 1, blackmanwindow); REGISTER_OPERATOR("Cast", 1, cast); REGISTER_OPERATOR("CastLike", 1, cast_like); diff --git a/src/frontends/onnx/tests/__init__.py b/src/frontends/onnx/tests/__init__.py index 6db6add7b6a..de3cddcfbb9 100644 --- a/src/frontends/onnx/tests/__init__.py +++ b/src/frontends/onnx/tests/__init__.py @@ -52,6 +52,7 @@ xfail_issue_38701 = xfail_test(reason="RuntimeError: unsupported element type: S xfail_issue_38706 = xfail_test(reason="RuntimeError: output_3.0 has zero dimension which is not allowed") xfail_issue_38708 = xfail_test(reason="RuntimeError: While validating ONNX node '': " "Axes input must be constant") +skip_bitwise_ui64 = pytest.mark.skip(reason="AssertionError: Not equal to tolerance rtol=0.001, atol=1e-07") xfail_issue_99949 = xfail_test(reason="Bitwise operators are not supported") xfail_issue_99950 = xfail_test(reason="CenterCropPad func is not supported") xfail_issue_99952 = xfail_test(reason="Col2Im operator is not supported") diff --git a/src/frontends/onnx/tests/models/bitwise_and.prototxt b/src/frontends/onnx/tests/models/bitwise_and.prototxt new file mode 100644 index 00000000000..85d3cbf12b0 --- /dev/null +++ b/src/frontends/onnx/tests/models/bitwise_and.prototxt @@ -0,0 +1,53 @@ +ir_version: 7 +graph { + node { + input: "a" + input: "b" + output: "output" + op_type: "BitwiseAnd" + } + name: "BitwiseAndGraph" + input { + name: "a" + type { + tensor_type { + elem_type: 6 + shape { + dim { + dim_value: 5 + } + } + } + } + } + input { + name: "b" + type { + tensor_type { + elem_type:6 + shape { + dim { + dim_value: 5 + } + } + } + } + } + output { + name: "output" + type { + tensor_type { + elem_type: 6 + shape { + dim { + dim_value: 5 + } + } + } + } + } +} +opset_import { + domain: "" + version: 16 +} \ No newline at end of file diff --git a/src/frontends/onnx/tests/models/bitwise_and_broadcast_condition.prototxt b/src/frontends/onnx/tests/models/bitwise_and_broadcast_condition.prototxt new file mode 100644 index 00000000000..21518c85bbc --- /dev/null +++ b/src/frontends/onnx/tests/models/bitwise_and_broadcast_condition.prototxt @@ -0,0 +1,53 @@ +ir_version: 7 +graph { + node { + input: "a" + input: "b" + output: "output" + op_type: "BitwiseAnd" + } + name: "BitwiseAndGraph" + input { + name: "a" + type { + tensor_type { + elem_type: 6 + shape { + dim { + dim_value: 5 + } + } + } + } + } + input { + name: "b" + type { + tensor_type { + elem_type:6 + shape { + dim { + dim_value: 1 + } + } + } + } + } + output { + name: "output" + type { + tensor_type { + elem_type: 6 + shape { + dim { + dim_value: 5 + } + } + } + } + } +} +opset_import { + domain: "" + version: 16 +} diff --git a/src/frontends/onnx/tests/onnx_import.in.cpp b/src/frontends/onnx/tests/onnx_import.in.cpp index bf4a0e09d46..8e547236163 100644 --- a/src/frontends/onnx/tests/onnx_import.in.cpp +++ b/src/frontends/onnx/tests/onnx_import.in.cpp @@ -6117,3 +6117,25 @@ OPENVINO_TEST(${BACKEND_NAME}, onnx_model_greater_or_equal_float) { test_case.run(); } + +OPENVINO_TEST(${BACKEND_NAME}, onnx_model_bitwise_and) { + auto model = convert_model("bitwise_and.onnx"); + + auto test_case = ov::test::TestCase(model, s_device); + test_case.add_input(Shape{5}, {1, 2, 3, 4, 5}); + test_case.add_input(Shape{5}, {5, 5, 5, 5, 5}); + test_case.add_expected_output(Shape{5}, {1, 0, 1, 4, 5}); + + test_case.run(); +} + +OPENVINO_TEST(${BACKEND_NAME}, onnx_model_bitwise_and_broadcast_condition) { + auto model = convert_model("bitwise_and_broadcast_condition.onnx"); + + auto test_case = ov::test::TestCase(model, s_device); + test_case.add_input(Shape{5}, {1, 2, 3, 4, 5}); + test_case.add_input(Shape{1}, {4}); + test_case.add_expected_output(Shape{5}, {0, 0, 0, 4, 4}); + + test_case.run(); +} diff --git a/src/frontends/onnx/tests/tests_python/test_backend.py b/src/frontends/onnx/tests/tests_python/test_backend.py index 6a9e0fa7896..bf9af6c6532 100644 --- a/src/frontends/onnx/tests/tests_python/test_backend.py +++ b/src/frontends/onnx/tests/tests_python/test_backend.py @@ -46,6 +46,7 @@ from tests import ( xfail_issue_82039, xfail_issue_90649, xfail_issue_91151, + skip_bitwise_ui64, xfail_issue_99949, xfail_issue_99950, xfail_issue_99952, @@ -390,10 +391,11 @@ tests_expected_to_fail = [ "OnnxBackendNodeModelTest.test_castlike_FLOAT_to_BFLOAT16_cpu", ), ( - xfail_issue_99949, - "OnnxBackendNodeModelTest.test_bitwise_and_i16_3d_cpu", - "OnnxBackendNodeModelTest.test_bitwise_and_i32_2d_cpu", + skip_bitwise_ui64, "OnnxBackendNodeModelTest.test_bitwise_and_ui64_bcast_3v1d_cpu", + ), + ( + xfail_issue_99949, "OnnxBackendNodeModelTest.test_bitwise_not_2d_cpu", "OnnxBackendNodeModelTest.test_bitwise_not_3d_cpu", "OnnxBackendNodeModelTest.test_bitwise_not_4d_cpu", @@ -403,7 +405,6 @@ tests_expected_to_fail = [ "OnnxBackendNodeModelTest.test_bitwise_xor_ui8_bcast_4v3d_cpu", "OnnxBackendNodeModelTest.test_bitwise_xor_i16_3d_cpu", "OnnxBackendNodeModelTest.test_bitwise_xor_i32_2d_cpu", - "OnnxBackendNodeModelTest.test_bitwise_and_ui8_bcast_4v3d_cpu", "OnnxBackendNodeModelTest.test_bitwise_or_ui8_bcast_4v3d_cpu", "OnnxBackendNodeModelTest.test_bitwise_xor_ui64_bcast_3v1d_cpu", ),