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

* Create bitwise_or.hpp
* Update ops_bridge.cpp
* Added protobuf(.prototxt) files via upload.
* Update onnx_import.in.cpp
* Update test_backend.py
* Skip "test_bitwise_or_ui64_bcast_3v1d_cpu"
This commit is contained in:
rghvsh
2023-12-21 13:57:28 +05:30
committed by GitHub
parent 0709a35cb0
commit 1a0f0ccd2a
8 changed files with 182 additions and 9 deletions

View File

@@ -549,20 +549,17 @@ tests_expected_to_fail = [
),
(
skip_bitwise_ui64,
"OnnxBackendNodeModelTest.test_bitwise_and_ui64_bcast_3v1d_cpu",
"OnnxBackendNodeModelTest.test_bitwise_and_ui64_bcast_3v1d_cpu",
"OnnxBackendNodeModelTest.test_bitwise_or_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",
"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",
),
(

View File

@@ -0,0 +1,24 @@
// Copyright (C) 2018-2023 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
//
#include "op/bitwise_or.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_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

View File

@@ -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

View File

@@ -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"
@@ -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);

View File

@@ -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
}

View File

@@ -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
}

View File

@@ -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();
}

View File

@@ -412,19 +412,16 @@ tests_expected_to_fail = [
(
skip_bitwise_ui64,
"OnnxBackendNodeModelTest.test_bitwise_and_ui64_bcast_3v1d_cpu",
"OnnxBackendNodeModelTest.test_bitwise_or_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",
"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",
),
(