[ONNX] Extend ONNX Frontend with BitwiseAnd-18 operator (#21585)

This commit is contained in:
rghvsh 2023-12-19 11:24:55 +05:30 committed by GitHub
parent 63b23a1ebb
commit a4e8f9d98c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 191 additions and 8 deletions

View File

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

View File

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

View File

@ -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<v13::BitwiseAnd>(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_and(const Node& node);
} // namespace set_1
} // namespace op
} // namespace onnx_import
} // namespace ngraph
OPENVINO_SUPPRESS_DEPRECATED_END

View File

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

View File

@ -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 '<Node(Slice): y>': "
"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")

View File

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

View File

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

View File

@ -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<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}, {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<int>(Shape{5}, {1, 2, 3, 4, 5});
test_case.add_input<int>(Shape{1}, {4});
test_case.add_expected_output<int>(Shape{5}, {0, 0, 0, 4, 4});
test_case.run();
}

View File

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