-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Ref][Core][Opset13] BitwiseAnd, BitwiseOr and BitwiseXor core shell …
…and reference (#20058) * Add Bitwise binary core and refs * Add draft for tests * Formatting, build issues and tests * Fix tests * Add reference tests * Apply requested changes * Add requested changes * Rename * uncomment test * Update src/tests/functional/plugin/conformance/test_runner/op_conformance_runner/src/op_impl_check/single_op_graph.cpp Co-authored-by: Tomasz Jankowski <[email protected]> * change reference --------- Co-authored-by: Tomasz Jankowski <[email protected]>
- Loading branch information
1 parent
0ee0b4d
commit 7926302
Showing
34 changed files
with
2,801 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// Copyright (C) 2018-2023 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 v13 { | ||
/// \brief Elementwise bitwise AND operation. | ||
/// \ingroup ov_ops_cpp_api | ||
class OPENVINO_API BitwiseAnd : public util::BinaryElementwiseBitwise { | ||
public: | ||
OPENVINO_OP("BitwiseAnd", "opset13", util::BinaryElementwiseBitwise); | ||
/// \brief Constructs a bitwise AND operation. | ||
BitwiseAnd() = default; | ||
/// \brief Constructs a bitwise AND operation. | ||
/// | ||
/// \param arg0 Output that produces the first input tensor.<br> | ||
/// `[d0, ...]` | ||
/// \param arg1 Output that produces the second input tensor.<br> | ||
/// `[d0, ...]` | ||
/// \param auto_broadcast Auto broadcast specification. Default is Numpy-style | ||
/// implicit broadcasting. | ||
/// | ||
/// Output `[d0, ...]` | ||
/// | ||
BitwiseAnd(const Output<Node>& arg0, | ||
const Output<Node>& arg1, | ||
const AutoBroadcastSpec& auto_broadcast = AutoBroadcastSpec(AutoBroadcastType::NUMPY)); | ||
|
||
std::shared_ptr<Node> clone_with_new_inputs(const OutputVector& new_args) const override; | ||
}; | ||
} // namespace v13 | ||
} // namespace op | ||
} // namespace ov |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// Copyright (C) 2018-2023 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 v13 { | ||
/// \brief Elementwise bitwise OR operation. | ||
/// \ingroup ov_ops_cpp_api | ||
class OPENVINO_API BitwiseOr : public util::BinaryElementwiseBitwise { | ||
public: | ||
OPENVINO_OP("BitwiseOr", "opset13", util::BinaryElementwiseBitwise); | ||
/// \brief Constructs a bitwise OR operation. | ||
BitwiseOr() = default; | ||
/// \brief Constructs a bitwise OR operation. | ||
/// | ||
/// \param arg0 Output that produces the first input tensor.<br> | ||
/// `[d0, ...]` | ||
/// \param arg1 Output that produces the second input tensor.<br> | ||
/// `[d0, ...]` | ||
/// \param auto_broadcast Auto broadcast specification. Default is Numpy-style | ||
/// implicit broadcasting. | ||
/// | ||
/// Output `[d0, ...]` | ||
/// | ||
BitwiseOr(const Output<Node>& arg0, | ||
const Output<Node>& arg1, | ||
const AutoBroadcastSpec& auto_broadcast = AutoBroadcastSpec(AutoBroadcastType::NUMPY)); | ||
|
||
std::shared_ptr<Node> clone_with_new_inputs(const OutputVector& new_args) const override; | ||
}; | ||
} // namespace v13 | ||
} // namespace op | ||
} // namespace ov |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// Copyright (C) 2018-2023 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 v13 { | ||
/// \brief Elementwise bitwise XOR operation. | ||
/// \ingroup ov_ops_cpp_api | ||
class OPENVINO_API BitwiseXor : public util::BinaryElementwiseBitwise { | ||
public: | ||
OPENVINO_OP("BitwiseXor", "opset13", util::BinaryElementwiseBitwise); | ||
/// \brief Constructs a bitwise XOR operation. | ||
BitwiseXor() = default; | ||
/// \brief Constructs a bitwise XOR operation. | ||
/// | ||
/// \param arg0 Output that produces the first input tensor.<br> | ||
/// `[d0, ...]` | ||
/// \param arg1 Output that produces the second input tensor.<br> | ||
/// `[d0, ...]` | ||
/// \param auto_broadcast Auto broadcast specification. Default is Numpy-style | ||
/// implicit broadcasting. | ||
/// | ||
/// Output `[d0, ...]` | ||
/// | ||
BitwiseXor(const Output<Node>& arg0, | ||
const Output<Node>& arg1, | ||
const AutoBroadcastSpec& auto_broadcast = AutoBroadcastSpec(AutoBroadcastType::NUMPY)); | ||
|
||
std::shared_ptr<Node> clone_with_new_inputs(const OutputVector& new_args) const override; | ||
}; | ||
} // namespace v13 | ||
} // namespace op | ||
} // namespace ov |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
src/core/include/openvino/op/util/binary_elementwise_bitwise.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
// Copyright (C) 2018-2023 Intel Corporation | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// | ||
|
||
#pragma once | ||
|
||
#include "openvino/op/op.hpp" | ||
|
||
namespace ov { | ||
namespace op { | ||
namespace util { | ||
class OPENVINO_API BinaryElementwiseBitwise : public Op { | ||
protected: | ||
BinaryElementwiseBitwise(); | ||
|
||
/// \brief Constructs a binary elementwise bitwise operation. | ||
/// | ||
/// \param arg0 Output that produces the first input tensor. | ||
/// \param arg1 Output that produces the second input tensor. | ||
/// \param auto_broadcast Auto broadcast specification. Default is Numpy-style | ||
/// implicit broadcasting. | ||
BinaryElementwiseBitwise(const Output<Node>& arg0, | ||
const Output<Node>& arg1, | ||
const AutoBroadcastSpec& autob = AutoBroadcastSpec()); | ||
|
||
public: | ||
OPENVINO_OP("BinaryElementwiseBitwise", "util"); | ||
|
||
void validate_and_infer_types() override; | ||
|
||
virtual const AutoBroadcastSpec& get_autob() const override; | ||
|
||
void set_autob(const AutoBroadcastSpec& autob); | ||
bool visit_attributes(AttributeVisitor& visitor) override; | ||
|
||
private: | ||
AutoBroadcastSpec m_autob = AutoBroadcastType::NUMPY; | ||
}; | ||
} // namespace util | ||
} // namespace op | ||
} // namespace ov |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
src/core/reference/include/openvino/reference/bitwise_and.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
// Copyright (C) 2018-2023 Intel Corporation | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// | ||
|
||
#pragma once | ||
|
||
#include <algorithm> | ||
#include <cstddef> | ||
|
||
#include "openvino/reference/autobroadcast_binop.hpp" | ||
|
||
namespace ov { | ||
namespace reference { | ||
/** | ||
* @brief Reference implementation of binary elementwise bitwise AND 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, typename std::enable_if<std::is_same<typename std::decay<T>::type, char>::value>::type* = nullptr> | ||
// Check for char datatype used by ov::element::boolean | ||
void bitwise_and(const T* arg0, | ||
const T* arg1, | ||
T* out, | ||
const Shape& arg0_shape, | ||
const Shape& arg1_shape, | ||
const op::AutoBroadcastSpec& broadcast_spec) { | ||
autobroadcast_binop(arg0, arg1, out, arg0_shape, arg1_shape, broadcast_spec, std::bit_and<bool>()); | ||
} | ||
/** | ||
* @brief Reference implementation of binary elementwise bitwise AND 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, typename std::enable_if<!std::is_same<typename std::decay<T>::type, char>::value>::type* = nullptr> | ||
void bitwise_and(const T* arg0, | ||
const T* arg1, | ||
T* out, | ||
const Shape& arg0_shape, | ||
const Shape& arg1_shape, | ||
const op::AutoBroadcastSpec& broadcast_spec) { | ||
autobroadcast_binop(arg0, arg1, out, arg0_shape, arg1_shape, broadcast_spec, std::bit_and<T>()); | ||
} | ||
} // namespace reference | ||
} // namespace ov |
54 changes: 54 additions & 0 deletions
54
src/core/reference/include/openvino/reference/bitwise_or.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
// Copyright (C) 2018-2023 Intel Corporation | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// | ||
|
||
#pragma once | ||
|
||
#include <algorithm> | ||
#include <cstddef> | ||
|
||
#include "openvino/reference/autobroadcast_binop.hpp" | ||
|
||
namespace ov { | ||
namespace reference { | ||
/** | ||
* @brief Reference implementation of binary elementwise bitwise OR 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, typename std::enable_if<std::is_same<typename std::decay<T>::type, char>::value>::type* = nullptr> | ||
// Check for char datatype used by ov::element::boolean | ||
void bitwise_or(const T* arg0, | ||
const T* arg1, | ||
T* out, | ||
const Shape& arg0_shape, | ||
const Shape& arg1_shape, | ||
const op::AutoBroadcastSpec& broadcast_spec) { | ||
autobroadcast_binop(arg0, arg1, out, arg0_shape, arg1_shape, broadcast_spec, std::bit_or<bool>()); | ||
} | ||
/** | ||
* @brief Reference implementation of binary elementwise bitwise OR 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, typename std::enable_if<!std::is_same<typename std::decay<T>::type, char>::value>::type* = nullptr> | ||
void bitwise_or(const T* arg0, | ||
const T* arg1, | ||
T* out, | ||
const Shape& arg0_shape, | ||
const Shape& arg1_shape, | ||
const op::AutoBroadcastSpec& broadcast_spec) { | ||
autobroadcast_binop(arg0, arg1, out, arg0_shape, arg1_shape, broadcast_spec, std::bit_or<T>()); | ||
} | ||
} // namespace reference | ||
} // namespace ov |
54 changes: 54 additions & 0 deletions
54
src/core/reference/include/openvino/reference/bitwise_xor.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
// Copyright (C) 2018-2023 Intel Corporation | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// | ||
|
||
#pragma once | ||
|
||
#include <algorithm> | ||
#include <cstddef> | ||
|
||
#include "openvino/reference/autobroadcast_binop.hpp" | ||
|
||
namespace ov { | ||
namespace reference { | ||
/** | ||
* @brief Reference implementation of binary elementwise bitwise XOR 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, typename std::enable_if<std::is_same<typename std::decay<T>::type, char>::value>::type* = nullptr> | ||
// Check for char datatype used by ov::element::boolean | ||
void bitwise_xor(const T* arg0, | ||
const T* arg1, | ||
T* out, | ||
const Shape& arg0_shape, | ||
const Shape& arg1_shape, | ||
const op::AutoBroadcastSpec& broadcast_spec) { | ||
autobroadcast_binop(arg0, arg1, out, arg0_shape, arg1_shape, broadcast_spec, std::bit_xor<bool>()); | ||
} | ||
/** | ||
* @brief Reference implementation of binary elementwise bitwise XOR 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, typename std::enable_if<!std::is_same<typename std::decay<T>::type, char>::value>::type* = nullptr> | ||
void bitwise_xor(const T* arg0, | ||
const T* arg1, | ||
T* out, | ||
const Shape& arg0_shape, | ||
const Shape& arg1_shape, | ||
const op::AutoBroadcastSpec& broadcast_spec) { | ||
autobroadcast_binop(arg0, arg1, out, arg0_shape, arg1_shape, broadcast_spec, std::bit_xor<T>()); | ||
} | ||
} // namespace reference | ||
} // namespace ov |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
// | ||
#include "openvino/op/bitwise_and.hpp" | ||
|
||
#include "itt.hpp" | ||
#include "openvino/op/op.hpp" | ||
|
||
namespace ov { | ||
namespace op { | ||
namespace v13 { | ||
BitwiseAnd::BitwiseAnd(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> BitwiseAnd::clone_with_new_inputs(const OutputVector& new_args) const { | ||
OV_OP_SCOPE(v13_BitwiseAnd_clone_with_new_inputs); | ||
check_new_args_count(this, new_args); | ||
return std::make_shared<BitwiseAnd>(new_args[0], new_args[1], get_autob()); | ||
} | ||
|
||
} // namespace v13 | ||
} // namespace op | ||
} // namespace ov |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.