Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ONNX] Extend ONNX Frontend with BitwiseOr-18 operator #21755

Merged
merged 14 commits into from
Dec 21, 2023
Original file line number Diff line number Diff line change
Expand Up @@ -531,13 +531,9 @@ def expect_fail(test_case_path, xfail): # type: (str) -> None
"OnnxBackendNodeModelTest.test_bitwise_not_2d_cpu",
"OnnxBackendNodeModelTest.test_bitwise_not_3d_cpu",
"OnnxBackendNodeModelTest.test_bitwise_not_4d_cpu",
"OnnxBackendNodeModelTest.test_bitwise_or_i16_4d_cpu",
"OnnxBackendNodeModelTest.test_bitwise_or_i32_2d_cpu",
"OnnxBackendNodeModelTest.test_bitwise_or_ui64_bcast_3v1d_cpu",
"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_or_ui8_bcast_4v3d_cpu",
"OnnxBackendNodeModelTest.test_bitwise_xor_ui64_bcast_3v1d_cpu",
),
(
Expand Down
24 changes: 24 additions & 0 deletions src/frontends/onnx/frontend/src/op/bitwise_or.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// Copyright (C) 2018-2023 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
//

#include "op/bitwise_or.hpp"

Check warning on line 5 in src/frontends/onnx/frontend/src/op/bitwise_or.cpp

View workflow job for this annotation

GitHub Actions / clang-format

[reviewdog-suggester] reported by reviewdog 🐶 Raw Output: src/frontends/onnx/frontend/src/op/bitwise_or.cpp:5:-#include "op/bitwise_or.hpp" src/frontends/onnx/frontend/src/op/bitwise_or.cpp:5:+#include "op/bitwise_or.hpp"
rghvsh marked this conversation as resolved.
Show resolved Hide resolved
OPENVINO_SUPPRESS_DEPRECATED_START

#include "default_opset.hpp"

using namespace ov::op;

namespace ngraph {
namespace onnx_import {
namespace op {
namespace set_1 {
OutputVector bitwise_or(const Node& node) {
const auto inputs = node.get_ng_inputs();
OPENVINO_ASSERT(inputs.size() == 2);
return {std::make_shared<v13::BitwiseOr>(inputs[0], inputs[1])};
}
} // namespace set_1
} // namespace op
} // namespace onnx_import
} // namespace ngraph
25 changes: 25 additions & 0 deletions src/frontends/onnx/frontend/src/op/bitwise_or.hpp
Original file line number Diff line number Diff line change
@@ -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_or(const Node& node);

} // namespace set_1
} // namespace op

} // namespace onnx_import

} // namespace ngraph
OPENVINO_SUPPRESS_DEPRECATED_END
2 changes: 2 additions & 0 deletions src/frontends/onnx/frontend/src/ops_bridge.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#include "op/batch_norm.hpp"
#include "op/bitshift.hpp"
#include "op/bitwise_and.hpp"
#include "op/bitwise_or.hpp"
#include "op/blackmanwindow.hpp"
#include "op/cast.hpp"
#include "op/cast_like.hpp"
Expand Down Expand Up @@ -353,6 +354,7 @@ OperatorsBridge::OperatorsBridge() {
REGISTER_OPERATOR("BatchNormalization", 7, batch_norm);
REGISTER_OPERATOR("BitShift", 1, bitshift);
REGISTER_OPERATOR("BitwiseAnd", 1, bitwise_and);
REGISTER_OPERATOR("BitwiseOr", 1, bitwise_or);
REGISTER_OPERATOR("BlackmanWindow", 1, blackmanwindow);
REGISTER_OPERATOR("Cast", 1, cast);
REGISTER_OPERATOR("CastLike", 1, cast_like);
Expand Down
53 changes: 53 additions & 0 deletions src/frontends/onnx/tests/models/bitwise_or.prototxt
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
ir_version: 7
graph {
node {
input: "a"
input: "b"
output: "output"
op_type: "BitwiseOr"
}
name: "BitwiseOrGraph"
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
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
ir_version: 7
graph {
node {
input: "a"
input: "b"
output: "output"
op_type: "BitwiseOr"
}
name: "BitwiseOrGraph"
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
}
22 changes: 22 additions & 0 deletions src/frontends/onnx/tests/onnx_import.in.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6139,3 +6139,25 @@ OPENVINO_TEST(${BACKEND_NAME}, onnx_model_bitwise_and_broadcast_condition) {

test_case.run();
}

OPENVINO_TEST(${BACKEND_NAME}, onnx_model_bitwise_or) {
auto model = convert_model("bitwise_or.onnx");

auto test_case = ov::test::TestCase(model, s_device);
test_case.add_input<int>(Shape{5}, {1, 2, 3, 4, 5});
test_case.add_input<int>(Shape{5}, {5, 5, 5, 5, 5});
test_case.add_expected_output<int>(Shape{5}, {5, 7, 7, 5, 5});

test_case.run();
}

OPENVINO_TEST(${BACKEND_NAME}, onnx_model_bitwise_or_broadcast_condition) {
auto model = convert_model("bitwise_or_broadcast_condition.onnx");

auto test_case = ov::test::TestCase(model, s_device);
test_case.add_input<int>(Shape{5}, {1, 2, 3, 4, 5});
test_case.add_input<int>(Shape{1}, {4});
test_case.add_expected_output<int>(Shape{5}, {5, 6, 7, 4, 5});

test_case.run();
}
4 changes: 0 additions & 4 deletions src/frontends/onnx/tests/tests_python/test_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -399,13 +399,9 @@ def expect_fail(test_case_path, xfail): # type: (str) -> None
"OnnxBackendNodeModelTest.test_bitwise_not_2d_cpu",
"OnnxBackendNodeModelTest.test_bitwise_not_3d_cpu",
"OnnxBackendNodeModelTest.test_bitwise_not_4d_cpu",
"OnnxBackendNodeModelTest.test_bitwise_or_i16_4d_cpu",
"OnnxBackendNodeModelTest.test_bitwise_or_i32_2d_cpu",
"OnnxBackendNodeModelTest.test_bitwise_or_ui64_bcast_3v1d_cpu",
"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_or_ui8_bcast_4v3d_cpu",
"OnnxBackendNodeModelTest.test_bitwise_xor_ui64_bcast_3v1d_cpu",
),
(
Expand Down
Loading