From fe5147668fd0d161384abcd4867d936484eca7d1 Mon Sep 17 00:00:00 2001 From: Mateusz Date: Tue, 19 Sep 2023 14:01:18 +0000 Subject: [PATCH 01/11] [Ref][Core][Opset13] Add bitwise_not operation --- src/core/include/openvino/op/bitwise_not.hpp | 30 +++ src/core/include/openvino/op/ops.hpp | 1 + src/core/include/openvino/opsets/opset.hpp | 5 + src/core/include/openvino/opsets/opset13.hpp | 15 ++ .../include/openvino/opsets/opset13_tbl.hpp | 212 ++++++++++++++++++ .../include/openvino/reference/not.hpp | 8 + src/core/src/op/bitwise_not.cpp | 35 +++ src/core/src/opsets/opset.cpp | 11 + .../template/backend/ops/bitwise_not.cpp | 51 +++++ .../template/backend/ops/ops_evaluates.hpp | 4 + .../template/backend/opset_int_tbl.hpp | 2 + .../tests/functional/op_reference/bitwise.cpp | 17 ++ .../tests/functional/op_reference/bitwise.hpp | 94 ++++++++ .../functional/op_reference/bitwise_not.cpp | 64 ++++++ 14 files changed, 549 insertions(+) create mode 100644 src/core/include/openvino/op/bitwise_not.hpp create mode 100644 src/core/include/openvino/opsets/opset13.hpp create mode 100644 src/core/include/openvino/opsets/opset13_tbl.hpp create mode 100644 src/core/src/op/bitwise_not.cpp create mode 100644 src/plugins/template/backend/ops/bitwise_not.cpp create mode 100644 src/plugins/template/tests/functional/op_reference/bitwise.cpp create mode 100644 src/plugins/template/tests/functional/op_reference/bitwise.hpp create mode 100644 src/plugins/template/tests/functional/op_reference/bitwise_not.cpp diff --git a/src/core/include/openvino/op/bitwise_not.hpp b/src/core/include/openvino/op/bitwise_not.hpp new file mode 100644 index 00000000000000..8b259022c3430f --- /dev/null +++ b/src/core/include/openvino/op/bitwise_not.hpp @@ -0,0 +1,30 @@ +// Copyright (C) 2018-2023 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#pragma once + +#include "openvino/op/op.hpp" + +namespace ov { +namespace op { +namespace v13 { +/// \brief Elementwise bitwise negation operation. +/// \ingroup ov_ops_cpp_api +class OPENVINO_API BitwiseNot : public Op { +public: + OPENVINO_OP("BitwiseNot", "opset13", op::Op); + /// \brief Constructs a bitwise negation operation. + BitwiseNot() = default; + /// \brief Constructs a bitwise negation operation. + /// + /// \param arg Node that produces the input tensor. + BitwiseNot(const Output& arg); + + void validate_and_infer_types() override; + + std::shared_ptr clone_with_new_inputs(const OutputVector& new_args) const override; +}; +} // namespace v13 +} // namespace op +} // namespace ov diff --git a/src/core/include/openvino/op/ops.hpp b/src/core/include/openvino/op/ops.hpp index 05eaa7e5d430ea..fe48372636c95f 100644 --- a/src/core/include/openvino/op/ops.hpp +++ b/src/core/include/openvino/op/ops.hpp @@ -21,6 +21,7 @@ #include "openvino/op/batch_norm.hpp" #include "openvino/op/batch_to_space.hpp" #include "openvino/op/binary_convolution.hpp" +#include "openvino/op/bitwise_not.hpp" #include "openvino/op/broadcast.hpp" #include "openvino/op/bucketize.hpp" #include "openvino/op/ceiling.hpp" diff --git a/src/core/include/openvino/opsets/opset.hpp b/src/core/include/openvino/opsets/opset.hpp index 0e487e95a0fe09..e9d483f27eeaa2 100644 --- a/src/core/include/openvino/opsets/opset.hpp +++ b/src/core/include/openvino/opsets/opset.hpp @@ -179,6 +179,11 @@ const OPENVINO_API OpSet& get_opset11(); * @ingroup ov_opset_cpp_api */ const OPENVINO_API OpSet& get_opset12(); +/** + * @brief Returns opset13 + * @ingroup ov_opset_cpp_api + */ +const OPENVINO_API OpSet& get_opset13(); /** * @brief Returns map of available opsets * @ingroup ov_opset_cpp_api diff --git a/src/core/include/openvino/opsets/opset13.hpp b/src/core/include/openvino/opsets/opset13.hpp new file mode 100644 index 00000000000000..a97cefba5967cd --- /dev/null +++ b/src/core/include/openvino/opsets/opset13.hpp @@ -0,0 +1,15 @@ +// Copyright (C) 2018-2023 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#pragma once + +#include "openvino/op/ops.hpp" + +namespace ov { +namespace opset13 { +#define _OPENVINO_OP_REG(a, b) using b::a; +#include "openvino/opsets/opset13_tbl.hpp" +#undef _OPENVINO_OP_REG +} // namespace opset13 +} // namespace ov diff --git a/src/core/include/openvino/opsets/opset13_tbl.hpp b/src/core/include/openvino/opsets/opset13_tbl.hpp new file mode 100644 index 00000000000000..abe98b4754f6db --- /dev/null +++ b/src/core/include/openvino/opsets/opset13_tbl.hpp @@ -0,0 +1,212 @@ +// Copyright (C) 2018-2023 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#ifndef _OPENVINO_OP_REG +# warning "_OPENVINO_OP_REG not defined" +# define _OPENVINO_OP_REG(x, y) +#endif + +_OPENVINO_OP_REG(Abs, ov::op::v0) +_OPENVINO_OP_REG(Acos, ov::op::v0) +_OPENVINO_OP_REG(Add, ov::op::v1) +_OPENVINO_OP_REG(Asin, ov::op::v0) +_OPENVINO_OP_REG(Atan, ov::op::v0) +_OPENVINO_OP_REG(AvgPool, ov::op::v1) +_OPENVINO_OP_REG(BatchNormInference, ov::op::v5) +_OPENVINO_OP_REG(BinaryConvolution, ov::op::v1) +_OPENVINO_OP_REG(Broadcast, ov::op::v3) +_OPENVINO_OP_REG(Bucketize, ov::op::v3) +_OPENVINO_OP_REG(CTCGreedyDecoder, ov::op::v0) +_OPENVINO_OP_REG(Ceiling, ov::op::v0) +_OPENVINO_OP_REG(Clamp, ov::op::v0) +_OPENVINO_OP_REG(Concat, ov::op::v0) +_OPENVINO_OP_REG(Constant, ov::op::v0) +_OPENVINO_OP_REG(Convert, ov::op::v0) +_OPENVINO_OP_REG(ConvertLike, ov::op::v1) +_OPENVINO_OP_REG(Convolution, ov::op::v1) +_OPENVINO_OP_REG(ConvolutionBackpropData, ov::op::v1) +_OPENVINO_OP_REG(Cos, ov::op::v0) +_OPENVINO_OP_REG(Cosh, ov::op::v0) +_OPENVINO_OP_REG(CumSum, ov::op::v0) +_OPENVINO_OP_REG(DeformablePSROIPooling, ov::op::v1) +_OPENVINO_OP_REG(DepthToSpace, ov::op::v0) +_OPENVINO_OP_REG(Divide, ov::op::v1) +_OPENVINO_OP_REG(Elu, ov::op::v0) +_OPENVINO_OP_REG(Erf, ov::op::v0) +_OPENVINO_OP_REG(Equal, ov::op::v1) +_OPENVINO_OP_REG(Exp, ov::op::v0) +_OPENVINO_OP_REG(ExtractImagePatches, ov::op::v3) +_OPENVINO_OP_REG(FakeQuantize, ov::op::v0) +_OPENVINO_OP_REG(Floor, ov::op::v0) +_OPENVINO_OP_REG(FloorMod, ov::op::v1) +_OPENVINO_OP_REG(GatherTree, ov::op::v1) +_OPENVINO_OP_REG(Greater, ov::op::v1) +_OPENVINO_OP_REG(GreaterEqual, ov::op::v1) +_OPENVINO_OP_REG(GridSample, ov::op::v9) +_OPENVINO_OP_REG(GroupConvolution, ov::op::v1) +_OPENVINO_OP_REG(GroupConvolutionBackpropData, ov::op::v1) +_OPENVINO_OP_REG(GRN, ov::op::v0) +_OPENVINO_OP_REG(HardSigmoid, ov::op::v0) +_OPENVINO_OP_REG(Less, ov::op::v1) +_OPENVINO_OP_REG(LessEqual, ov::op::v1) +_OPENVINO_OP_REG(Log, ov::op::v0) +_OPENVINO_OP_REG(LogicalAnd, ov::op::v1) +_OPENVINO_OP_REG(LogicalNot, ov::op::v1) +_OPENVINO_OP_REG(LogicalOr, ov::op::v1) +_OPENVINO_OP_REG(LogicalXor, ov::op::v1) +_OPENVINO_OP_REG(LRN, ov::op::v0) +_OPENVINO_OP_REG(LSTMCell, ov::op::v4) +_OPENVINO_OP_REG(MatMul, ov::op::v0) +_OPENVINO_OP_REG(Maximum, ov::op::v1) +_OPENVINO_OP_REG(Minimum, ov::op::v1) +_OPENVINO_OP_REG(Mod, ov::op::v1) +_OPENVINO_OP_REG(Multiply, ov::op::v1) +_OPENVINO_OP_REG(Negative, ov::op::v0) +_OPENVINO_OP_REG(NormalizeL2, ov::op::v0) +_OPENVINO_OP_REG(NotEqual, ov::op::v1) +_OPENVINO_OP_REG(OneHot, ov::op::v1) +_OPENVINO_OP_REG(PRelu, ov::op::v0) +_OPENVINO_OP_REG(PSROIPooling, ov::op::v0) +_OPENVINO_OP_REG(Parameter, ov::op::v0) +_OPENVINO_OP_REG(Power, ov::op::v1) +_OPENVINO_OP_REG(PriorBoxClustered, ov::op::v0) +_OPENVINO_OP_REG(Proposal, ov::op::v4) +_OPENVINO_OP_REG(Range, ov::op::v4) +_OPENVINO_OP_REG(Relu, ov::op::v0) +_OPENVINO_OP_REG(ReduceMax, ov::op::v1) +_OPENVINO_OP_REG(ReduceLogicalAnd, ov::op::v1) +_OPENVINO_OP_REG(ReduceLogicalOr, ov::op::v1) +_OPENVINO_OP_REG(ReduceMean, ov::op::v1) +_OPENVINO_OP_REG(ReduceMin, ov::op::v1) +_OPENVINO_OP_REG(ReduceProd, ov::op::v1) +_OPENVINO_OP_REG(ReduceSum, ov::op::v1) +_OPENVINO_OP_REG(RegionYolo, ov::op::v0) +_OPENVINO_OP_REG(ReorgYolo, ov::op::v0) +_OPENVINO_OP_REG(Reshape, ov::op::v1) +_OPENVINO_OP_REG(Result, ov::op::v0) +_OPENVINO_OP_REG(ReverseSequence, ov::op::v0) +_OPENVINO_OP_REG(ROIPooling, ov::op::v0) +_OPENVINO_OP_REG(ScatterNDUpdate, ov::op::v3) +_OPENVINO_OP_REG(Select, ov::op::v1) +_OPENVINO_OP_REG(Selu, ov::op::v0) +_OPENVINO_OP_REG(Sign, ov::op::v0) +_OPENVINO_OP_REG(Sigmoid, ov::op::v0) +_OPENVINO_OP_REG(Sin, ov::op::v0) +_OPENVINO_OP_REG(Sinh, ov::op::v0) +_OPENVINO_OP_REG(Sqrt, ov::op::v0) +_OPENVINO_OP_REG(SpaceToDepth, ov::op::v0) +_OPENVINO_OP_REG(Split, ov::op::v1) +_OPENVINO_OP_REG(SquaredDifference, ov::op::v0) +_OPENVINO_OP_REG(Squeeze, ov::op::v0) +_OPENVINO_OP_REG(StridedSlice, ov::op::v1) +_OPENVINO_OP_REG(Subtract, ov::op::v1) +_OPENVINO_OP_REG(Tan, ov::op::v0) +_OPENVINO_OP_REG(Tanh, ov::op::v0) +_OPENVINO_OP_REG(TensorIterator, ov::op::v0) +_OPENVINO_OP_REG(Tile, ov::op::v0) +_OPENVINO_OP_REG(Transpose, ov::op::v1) +_OPENVINO_OP_REG(Unsqueeze, ov::op::v0) +_OPENVINO_OP_REG(VariadicSplit, ov::op::v1) + +// New operations added in opset2 +_OPENVINO_OP_REG(BatchToSpace, ov::op::v1) +_OPENVINO_OP_REG(SpaceToBatch, ov::op::v1) + +// New operations added in opset3 +_OPENVINO_OP_REG(EmbeddingBagPackedSum, ov::op::v3) +_OPENVINO_OP_REG(EmbeddingSegmentsSum, ov::op::v3) +_OPENVINO_OP_REG(EmbeddingBagOffsetsSum, ov::op::v3) +_OPENVINO_OP_REG(GRUCell, ov::op::v3) +_OPENVINO_OP_REG(NonZero, ov::op::v3) +_OPENVINO_OP_REG(RNNCell, ov::op::v0) +_OPENVINO_OP_REG(ScatterUpdate, ov::op::v3) +_OPENVINO_OP_REG(ShuffleChannels, ov::op::v0) +_OPENVINO_OP_REG(ShapeOf, ov::op::v3) + +// New operations added in opset4 +_OPENVINO_OP_REG(Acosh, ov::op::v3) +_OPENVINO_OP_REG(Asinh, ov::op::v3) +_OPENVINO_OP_REG(Atanh, ov::op::v3) +_OPENVINO_OP_REG(CTCLoss, ov::op::v4) +_OPENVINO_OP_REG(HSwish, ov::op::v4) +_OPENVINO_OP_REG(Mish, ov::op::v4) +_OPENVINO_OP_REG(ReduceL1, ov::op::v4) +_OPENVINO_OP_REG(ReduceL2, ov::op::v4) +_OPENVINO_OP_REG(SoftPlus, ov::op::v4) +_OPENVINO_OP_REG(Swish, ov::op::v4) + +// New operations added in opset5 +_OPENVINO_OP_REG(GRUSequence, ov::op::v5) +_OPENVINO_OP_REG(HSigmoid, ov::op::v5) +_OPENVINO_OP_REG(LogSoftmax, ov::op::v5) +_OPENVINO_OP_REG(Loop, ov::op::v5) +_OPENVINO_OP_REG(LSTMSequence, ov::op::v5) +_OPENVINO_OP_REG(RNNSequence, ov::op::v5) +_OPENVINO_OP_REG(Round, ov::op::v5) + +// New operations added in opset6 +_OPENVINO_OP_REG(CTCGreedyDecoderSeqLen, ov::op::v6) +_OPENVINO_OP_REG(ExperimentalDetectronDetectionOutput, ov::op::v6) +_OPENVINO_OP_REG(ExperimentalDetectronGenerateProposalsSingleImage, ov::op::v6) +_OPENVINO_OP_REG(ExperimentalDetectronPriorGridGenerator, ov::op::v6) +_OPENVINO_OP_REG(ExperimentalDetectronROIFeatureExtractor, ov::op::v6) +_OPENVINO_OP_REG(ExperimentalDetectronTopKROIs, ov::op::v6) +_OPENVINO_OP_REG(GatherElements, ov::op::v6) +_OPENVINO_OP_REG(MVN, ov::op::v6) +_OPENVINO_OP_REG(Assign, ov::op::v6) // new version +_OPENVINO_OP_REG(ReadValue, ov::op::v6) // new version + +// New operations added in opset7 +_OPENVINO_OP_REG(DFT, ov::op::v7) +_OPENVINO_OP_REG(Einsum, ov::op::v7) +_OPENVINO_OP_REG(Gelu, ov::op::v7) +_OPENVINO_OP_REG(IDFT, ov::op::v7) +_OPENVINO_OP_REG(Roll, ov::op::v7) + +// New operations added in opset8 +_OPENVINO_OP_REG(Gather, ov::op::v8) +_OPENVINO_OP_REG(GatherND, ov::op::v8) +_OPENVINO_OP_REG(AdaptiveAvgPool, ov::op::v8) +_OPENVINO_OP_REG(AdaptiveMaxPool, ov::op::v8) +_OPENVINO_OP_REG(DeformableConvolution, ov::op::v8) +_OPENVINO_OP_REG(DetectionOutput, ov::op::v8) +_OPENVINO_OP_REG(I420toBGR, ov::op::v8) +_OPENVINO_OP_REG(I420toRGB, ov::op::v8) +_OPENVINO_OP_REG(MatrixNms, ov::op::v8) +_OPENVINO_OP_REG(MaxPool, ov::op::v8) +_OPENVINO_OP_REG(NV12toBGR, ov::op::v8) +_OPENVINO_OP_REG(NV12toRGB, ov::op::v8) +_OPENVINO_OP_REG(RandomUniform, ov::op::v8) +_OPENVINO_OP_REG(Slice, ov::op::v8) +_OPENVINO_OP_REG(Softmax, ov::op::v8) +_OPENVINO_OP_REG(If, ov::op::v8) +_OPENVINO_OP_REG(PriorBox, ov::op::v8) + +// New operations added in opset9 +_OPENVINO_OP_REG(IRDFT, ov::op::v9) +_OPENVINO_OP_REG(RDFT, ov::op::v9) +_OPENVINO_OP_REG(Eye, ov::op::v9) +_OPENVINO_OP_REG(NonMaxSuppression, ov::op::v9) +_OPENVINO_OP_REG(ROIAlign, ov::op::v9) +_OPENVINO_OP_REG(SoftSign, ov::op::v9) +_OPENVINO_OP_REG(GenerateProposals, ov::op::v9) +_OPENVINO_OP_REG(MulticlassNms, ov::op::v9) + +// New operations added in opset10 +_OPENVINO_OP_REG(IsFinite, ov::op::v10) +_OPENVINO_OP_REG(IsInf, ov::op::v10) +_OPENVINO_OP_REG(IsNaN, ov::op::v10) +_OPENVINO_OP_REG(Unique, ov::op::v10) + +// New operations added in opset11 +_OPENVINO_OP_REG(Interpolate, ov::op::v11) +_OPENVINO_OP_REG(TopK, ov::op::v11) + +// New operations added in opset12 +_OPENVINO_OP_REG(GroupNormalization, ov::op::v12) +_OPENVINO_OP_REG(Pad, ov::op::v12) +_OPENVINO_OP_REG(ScatterElementsUpdate, ov::op::v12) + +// New operations added in opset13 +_OPENVINO_OP_REG(BitwiseNot, ov::op::v13) diff --git a/src/core/reference/include/openvino/reference/not.hpp b/src/core/reference/include/openvino/reference/not.hpp index e0444a8eb73a2a..90af51b8ad527d 100644 --- a/src/core/reference/include/openvino/reference/not.hpp +++ b/src/core/reference/include/openvino/reference/not.hpp @@ -4,6 +4,7 @@ #pragma once +#include #include namespace ov { @@ -14,5 +15,12 @@ void logical_not(const T* arg, T* out, size_t count) { out[i] = static_cast(!(arg[i])); } } + +template +void bitwise_not(const T* arg, T* out, size_t count) { + std::transform(arg, std::next(arg, count), out, [](T x) -> T { + return static_cast(~x); + }); +} } // namespace reference } // namespace ov diff --git a/src/core/src/op/bitwise_not.cpp b/src/core/src/op/bitwise_not.cpp new file mode 100644 index 00000000000000..03d19bc7ba92e2 --- /dev/null +++ b/src/core/src/op/bitwise_not.cpp @@ -0,0 +1,35 @@ +// Copyright (C) 2018-2023 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// +#include "openvino/op/bitwise_not.hpp" + +#include "itt.hpp" +#include "openvino/core/validation_util.hpp" +#include "openvino/op/op.hpp" +#include "openvino/reference/not.hpp" + +namespace ov { +namespace op { +namespace v13 { +BitwiseNot::BitwiseNot(const Output& arg) : Op({arg}) { + constructor_validate_and_infer_types(); +} +void BitwiseNot::validate_and_infer_types() { + OV_OP_SCOPE(v13_BitwiseNot_validate_and_infer_types); + const auto& element_type = get_input_element_type(0); + const auto& arg_pshape = get_input_partial_shape(0); + NODE_VALIDATION_CHECK(this, + element_type.is_dynamic() || element_type.is_integral() || element_type == element::boolean, + "The element type of the input tensor must be integral or boolean."); + set_output_type(0, element_type, arg_pshape); +} + +std::shared_ptr BitwiseNot::clone_with_new_inputs(const OutputVector& new_args) const { + OV_OP_SCOPE(v13_BitwiseNot_clone_with_new_inputs); + check_new_args_count(this, new_args); + return std::make_shared(new_args.at(0)); +} + +} // namespace v13 +} // namespace op +} // namespace ov diff --git a/src/core/src/opsets/opset.cpp b/src/core/src/opsets/opset.cpp index 041503a973c61a..1407e8403e3f8c 100644 --- a/src/core/src/opsets/opset.cpp +++ b/src/core/src/opsets/opset.cpp @@ -220,6 +220,17 @@ const ov::OpSet& ov::get_opset12() { return opset; } +const ov::OpSet& ov::get_opset13() { + static OpSet opset; + static std::once_flag flag; + std::call_once(flag, [&]() { +#define _OPENVINO_OP_REG(NAME, NAMESPACE) opset.insert(); +#include "openvino/opsets/opset13_tbl.hpp" +#undef _OPENVINO_OP_REG + }); + return opset; +} + const ngraph::OpSet& ngraph::get_opset1() { static OpSet opset(ov::get_opset1()); return opset; diff --git a/src/plugins/template/backend/ops/bitwise_not.cpp b/src/plugins/template/backend/ops/bitwise_not.cpp new file mode 100644 index 00000000000000..44374936f02538 --- /dev/null +++ b/src/plugins/template/backend/ops/bitwise_not.cpp @@ -0,0 +1,51 @@ +// Copyright (C) 2018-2023 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "openvino/op/bitwise_not.hpp" + +#include "evaluate_node.hpp" +#include "openvino/reference/not.hpp" + +using namespace ov; + +template +bool evaluate(const std::shared_ptr& node, + ov::TensorVector& outputs, + const ov::TensorVector& inputs) { + using ET = typename ov::element_type_traits::value_type; + if (T == element::Type_t::boolean) { + ov::reference::logical_not(inputs[0].data(), outputs[0].data(), shape_size(inputs[0].get_shape())); + } else { + ov::reference::bitwise_not(inputs[0].data(), outputs[0].data(), shape_size(inputs[0].get_shape())); + } + return true; +} + +template <> +bool evaluate_node(std::shared_ptr node, + ov::TensorVector& outputs, + const ov::TensorVector& inputs) { + switch (node->get_input_element_type(0)) { + case element::boolean: + return evaluate(as_type_ptr(node), outputs, inputs); + case element::u8: + return evaluate(as_type_ptr(node), outputs, inputs); + case element::i8: + return evaluate(as_type_ptr(node), outputs, inputs); + case element::u16: + return evaluate(as_type_ptr(node), outputs, inputs); + case element::i16: + return evaluate(as_type_ptr(node), outputs, inputs); + case element::u32: + return evaluate(as_type_ptr(node), outputs, inputs); + case element::i32: + return evaluate(as_type_ptr(node), outputs, inputs); + case element::u64: + return evaluate(as_type_ptr(node), outputs, inputs); + case element::i64: + return evaluate(as_type_ptr(node), outputs, inputs); + default: + OPENVINO_THROW("Unhandled data type ", node->get_element_type().get_type_name(), "in evaluate_node()"); + } +} diff --git a/src/plugins/template/backend/ops/ops_evaluates.hpp b/src/plugins/template/backend/ops/ops_evaluates.hpp index c3a316bea50aa5..bc0918ae3dde9c 100644 --- a/src/plugins/template/backend/ops/ops_evaluates.hpp +++ b/src/plugins/template/backend/ops/ops_evaluates.hpp @@ -445,6 +445,10 @@ extern template bool evaluate_node(std::shared_ ov::TensorVector& outputs, const ov::TensorVector& inputs); +extern template bool evaluate_node(std::shared_ptr node, + ov::TensorVector& outputs, + const ov::TensorVector& inputs); + extern template bool evaluate_node(std::shared_ptr node, ov::TensorVector& outputs, const ov::TensorVector& inputs); diff --git a/src/plugins/template/backend/opset_int_tbl.hpp b/src/plugins/template/backend/opset_int_tbl.hpp index c94db72de7728f..b4435c87a47f5b 100644 --- a/src/plugins/template/backend/opset_int_tbl.hpp +++ b/src/plugins/template/backend/opset_int_tbl.hpp @@ -150,5 +150,7 @@ _OPENVINO_OP_REG(Interpolate, op::v11) _OPENVINO_OP_REG(GroupNormalization, ov::op::v12) +_OPENVINO_OP_REG(BitwiseNot, ov::op::v13) + _OPENVINO_OP_REG(AUGRUCell, ov::op::internal) _OPENVINO_OP_REG(AUGRUSequence, ov::op::internal) diff --git a/src/plugins/template/tests/functional/op_reference/bitwise.cpp b/src/plugins/template/tests/functional/op_reference/bitwise.cpp new file mode 100644 index 00000000000000..a3f490fbd869c9 --- /dev/null +++ b/src/plugins/template/tests/functional/op_reference/bitwise.cpp @@ -0,0 +1,17 @@ +// Copyright (C) 2018-2023 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "bitwise.hpp" + +namespace reference_tests { +namespace BitwiseOpsRefTestDefinitions { +namespace { + +TEST_P(ReferenceBitwiseLayerTest, BitwiseWithHardcodedRefs) { + Exec(); +} + +} // namespace +} // namespace BitwiseOpsRefTestDefinitions +} // namespace reference_tests diff --git a/src/plugins/template/tests/functional/op_reference/bitwise.hpp b/src/plugins/template/tests/functional/op_reference/bitwise.hpp new file mode 100644 index 00000000000000..bd989578bbcdd2 --- /dev/null +++ b/src/plugins/template/tests/functional/op_reference/bitwise.hpp @@ -0,0 +1,94 @@ +// Copyright (C) 2018-2023 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include + +#include "base_reference_test.hpp" + +// #include "openvino/op/bitwise_and.hpp" +#include "openvino/op/bitwise_not.hpp" +// #include "openvino/op/bitwise_or.hpp" +// #include "openvino/op/bitwise_xor.hpp" + +using namespace ov; + +namespace reference_tests { +namespace BitwiseOpsRefTestDefinitions { + +enum BitwiseTypes { + // BITWISE_AND, + // BITWISE_OR, + // BITWISE_XOR, + BITWISE_NOT +}; + +struct RefBitwiseParams { + BitwiseTypes opType; + std::vector inputs; + reference_tests::Tensor expected; +}; + +struct Builder : ParamsBuilder { + REFERENCE_TESTS_ADD_SET_PARAM(Builder, opType); + REFERENCE_TESTS_ADD_SET_PARAM(Builder, inputs); + REFERENCE_TESTS_ADD_SET_PARAM(Builder, expected); +}; + +class ReferenceBitwiseLayerTest : public testing::TestWithParam, public CommonReferenceTest { +public: + void SetUp() override { + const auto& params = GetParam(); + function = CreateFunction(params.opType, params.inputs); + for (auto& input : params.inputs) { + inputData.push_back(input.data); + } + refOutData = {params.expected.data}; + } + static std::string getTestCaseName(const testing::TestParamInfo& obj) { + const auto& param = obj.param; + std::ostringstream result; + result << "BitwiseType=" << param.opType << "_"; + for (size_t i =0; i< param.inputs.size(); i++) { + const auto input = param.inputs[i]; + result << "inpt_shape" << i << "=" << input.shape << "_"; + result << "inpt_type" << i << "=" << input.type << "_"; + } + result << "oType=" << param.expected.type; + return result.str(); + } + +private: + static std::shared_ptr CreateFunction(BitwiseTypes op_type, const std::vector& inputs) { + ov::ParameterVector params_vec; + for (auto& input : inputs) { + params_vec.push_back(std::make_shared(input.type, input.shape)); + } + + std::shared_ptr bitwise_op; + switch (op_type) { + // case BitwiseTypes::BITWISE_AND: { + // bitwise_op = std::make_shared(params_vec[0], params_vec[1]); + // break; + // } + case BitwiseTypes::BITWISE_NOT: { + bitwise_op = std::make_shared(params_vec[0]); + break; + } + // case BitwiseTypes::BITWISE_OR: { + // bitwise_op = std::make_shared(params_vec[0], params_vec[1]); + // break; + // } + // case BitwiseTypes::BITWISE_XOR: { + // bitwise_op = std::make_shared(params_vec[0], params_vec[1]); + // break; + // } + default: { + throw std::runtime_error("Incorrect type of Bitwise operation"); + } + } + return std::make_shared(ov::NodeVector {bitwise_op}, ov::ParameterVector {params_vec}); + } +}; +} // namespace BitwiseOpsRefTestDefinitions +} // namespace reference_tests diff --git a/src/plugins/template/tests/functional/op_reference/bitwise_not.cpp b/src/plugins/template/tests/functional/op_reference/bitwise_not.cpp new file mode 100644 index 00000000000000..9bb930474f0021 --- /dev/null +++ b/src/plugins/template/tests/functional/op_reference/bitwise_not.cpp @@ -0,0 +1,64 @@ +// Copyright (C) 2018-2023 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include + +#include "openvino/op/bitwise_not.hpp" +#include "bitwise.hpp" + +using namespace ov; + +namespace reference_tests { +namespace BitwiseOpsRefTestDefinitions { +namespace { + +std::vector generateBitwiseParams() { + std::vector bitwiseParams { + Builder {} + .opType(BitwiseTypes::BITWISE_NOT) + .inputs({{{2, 2}, element::boolean, std::vector {true, false, true, false}}}) + .expected({{2, 2}, element::boolean, std::vector {false, true, false, true}}), + Builder {} + .opType(BitwiseTypes::BITWISE_NOT) + .inputs({{{7}, element::i8, std::vector {127, -128, 0, 63, -64, 6, -7}}}) + .expected({{7}, element::i8, std::vector {-128, 127, -1, -64, 63, -7, 6}}), + Builder {} + .opType(BitwiseTypes::BITWISE_NOT) + .inputs({{{7}, element::u8, std::vector {255, 0, 127, 255, 127, 134, 120}}}) + .expected({{7}, element::u8, std::vector {0, 255, 128, 0, 128, 121, 135}}), + Builder {} + .opType(BitwiseTypes::BITWISE_NOT) + .inputs({{{7}, element::i16, std::vector {32767, -32768, 0, 16383, -16384, 6, -7}}}) + .expected({{7}, element::i16, std::vector {-32768, 32767, -1, -16384, 16383, -7, 6}}), + Builder {} + .opType(BitwiseTypes::BITWISE_NOT) + .inputs({{{7}, element::u16, std::vector {65535, 0, 32767, 65535, 32767, 32774, 32760}}}) + .expected({{7}, element::u16, std::vector {0, 65535, 32768, 0, 32768, 32761, 32775}}), + Builder {} + .opType(BitwiseTypes::BITWISE_NOT) + .inputs({{{7}, element::i32, std::vector {2147483647, -2147483648, 0, 1073741823, -1073741824, 6, -7}}}) + .expected({{7}, element::i32, std::vector {-2147483648, 2147483647, -1, -1073741824, 1073741823, -7, 6}}), + Builder {} + .opType(BitwiseTypes::BITWISE_NOT) + .inputs({{{7}, element::u32, std::vector {4294967295, 0, 2147483647, 4294967295, 2147483647, 2147483654, 2147483640}}}) + .expected({{7}, element::u32, std::vector {0, 4294967295, 2147483648, 0, 2147483648, 2147483641, 2147483655}}), + Builder {} + .opType(BitwiseTypes::BITWISE_NOT) + .inputs({{{7}, element::i64, std::vector {9223372036854775807, -9223372036854775808, 0, 4611686018427387904, -4611686018427387904, 6, -7}}}) + .expected({{7}, element::i64, std::vector {-9223372036854775808, 9223372036854775807, -1, -4611686018427387905, 4611686018427387903, -7, 6}}), + Builder {} + .opType(BitwiseTypes::BITWISE_NOT) + .inputs({{{3}, element::u64, std::vector {std::numeric_limits::max(), std::numeric_limits::min(), 5}}}) + .expected({{3}, element::u64, std::vector {std::numeric_limits::min(), std::numeric_limits::max(), std::numeric_limits::max()-5}}), + }; + return bitwiseParams; +} + + +INSTANTIATE_TEST_SUITE_P(smoke_BitwiseNot_With_Hardcoded_Refs, ReferenceBitwiseLayerTest, ::testing::ValuesIn(generateBitwiseParams()), + ReferenceBitwiseLayerTest::getTestCaseName); + +} // namespace +} // namespace BitwiseOpsRefTestDefinitions +} // namespace reference_tests From 8e2146e9f9f9fe2faa5154c4f2e2ed778ebb552f Mon Sep 17 00:00:00 2001 From: Mateusz Date: Wed, 20 Sep 2023 10:11:19 +0000 Subject: [PATCH 02/11] Fix CI issues + add missing test --- .../functional/op_reference/bitwise_not.cpp | 32 +++++++++---------- .../src/op_impl_check/single_op_graph.cpp | 8 +++++ 2 files changed, 24 insertions(+), 16 deletions(-) diff --git a/src/plugins/template/tests/functional/op_reference/bitwise_not.cpp b/src/plugins/template/tests/functional/op_reference/bitwise_not.cpp index 9bb930474f0021..08c1ae1f2ab358 100644 --- a/src/plugins/template/tests/functional/op_reference/bitwise_not.cpp +++ b/src/plugins/template/tests/functional/op_reference/bitwise_not.cpp @@ -21,36 +21,36 @@ std::vector generateBitwiseParams() { .expected({{2, 2}, element::boolean, std::vector {false, true, false, true}}), Builder {} .opType(BitwiseTypes::BITWISE_NOT) - .inputs({{{7}, element::i8, std::vector {127, -128, 0, 63, -64, 6, -7}}}) - .expected({{7}, element::i8, std::vector {-128, 127, -1, -64, 63, -7, 6}}), + .inputs({{{2}, element::i8, std::vector {std::numeric_limits::max(), std::numeric_limits::min()}}}) + .expected({{2}, element::i8, std::vector {std::numeric_limits::min(), std::numeric_limits::max()}}), Builder {} .opType(BitwiseTypes::BITWISE_NOT) - .inputs({{{7}, element::u8, std::vector {255, 0, 127, 255, 127, 134, 120}}}) - .expected({{7}, element::u8, std::vector {0, 255, 128, 0, 128, 121, 135}}), + .inputs({{{2}, element::u8, std::vector {std::numeric_limits::max(), std::numeric_limits::min()}}}) + .expected({{2}, element::u8, std::vector {std::numeric_limits::min(), std::numeric_limits::max()}}), Builder {} .opType(BitwiseTypes::BITWISE_NOT) - .inputs({{{7}, element::i16, std::vector {32767, -32768, 0, 16383, -16384, 6, -7}}}) - .expected({{7}, element::i16, std::vector {-32768, 32767, -1, -16384, 16383, -7, 6}}), + .inputs({{{2}, element::i16, std::vector {std::numeric_limits::max(), std::numeric_limits::min()}}}) + .expected({{2}, element::i16, std::vector {std::numeric_limits::min(), std::numeric_limits::max()}}), Builder {} .opType(BitwiseTypes::BITWISE_NOT) - .inputs({{{7}, element::u16, std::vector {65535, 0, 32767, 65535, 32767, 32774, 32760}}}) - .expected({{7}, element::u16, std::vector {0, 65535, 32768, 0, 32768, 32761, 32775}}), + .inputs({{{2}, element::u16, std::vector {std::numeric_limits::max(), std::numeric_limits::min()}}}) + .expected({{2}, element::u16, std::vector {std::numeric_limits::min(), std::numeric_limits::max()}}), Builder {} .opType(BitwiseTypes::BITWISE_NOT) - .inputs({{{7}, element::i32, std::vector {2147483647, -2147483648, 0, 1073741823, -1073741824, 6, -7}}}) - .expected({{7}, element::i32, std::vector {-2147483648, 2147483647, -1, -1073741824, 1073741823, -7, 6}}), + .inputs({{{2}, element::i32, std::vector {std::numeric_limits::max(), std::numeric_limits::min()}}}) + .expected({{2}, element::i32, std::vector {std::numeric_limits::min(), std::numeric_limits::max()}}), Builder {} .opType(BitwiseTypes::BITWISE_NOT) - .inputs({{{7}, element::u32, std::vector {4294967295, 0, 2147483647, 4294967295, 2147483647, 2147483654, 2147483640}}}) - .expected({{7}, element::u32, std::vector {0, 4294967295, 2147483648, 0, 2147483648, 2147483641, 2147483655}}), + .inputs({{{2}, element::u32, std::vector {std::numeric_limits::max(), std::numeric_limits::min()}}}) + .expected({{2}, element::u32, std::vector {std::numeric_limits::min(), std::numeric_limits::max()}}), Builder {} .opType(BitwiseTypes::BITWISE_NOT) - .inputs({{{7}, element::i64, std::vector {9223372036854775807, -9223372036854775808, 0, 4611686018427387904, -4611686018427387904, 6, -7}}}) - .expected({{7}, element::i64, std::vector {-9223372036854775808, 9223372036854775807, -1, -4611686018427387905, 4611686018427387903, -7, 6}}), + .inputs({{{2}, element::i64, std::vector {std::numeric_limits::max(), std::numeric_limits::min()}}}) + .expected({{2}, element::i64, std::vector {std::numeric_limits::min(), std::numeric_limits::max()}}), Builder {} .opType(BitwiseTypes::BITWISE_NOT) - .inputs({{{3}, element::u64, std::vector {std::numeric_limits::max(), std::numeric_limits::min(), 5}}}) - .expected({{3}, element::u64, std::vector {std::numeric_limits::min(), std::numeric_limits::max(), std::numeric_limits::max()-5}}), + .inputs({{{2}, element::u64, std::vector {std::numeric_limits::max(), std::numeric_limits::min()}}}) + .expected({{2}, element::u64, std::vector {std::numeric_limits::min(), std::numeric_limits::max()}}), }; return bitwiseParams; } diff --git a/src/tests/functional/plugin/conformance/test_runner/op_conformance_runner/src/op_impl_check/single_op_graph.cpp b/src/tests/functional/plugin/conformance/test_runner/op_conformance_runner/src/op_impl_check/single_op_graph.cpp index 7dad25bbab8efb..f51843dac733e6 100644 --- a/src/tests/functional/plugin/conformance/test_runner/op_conformance_runner/src/op_impl_check/single_op_graph.cpp +++ b/src/tests/functional/plugin/conformance/test_runner/op_conformance_runner/src/op_impl_check/single_op_graph.cpp @@ -1242,6 +1242,13 @@ std::shared_ptr generate(const std::shared_ptr &n return std::make_shared(results, ov::ParameterVector{param}, "is_nan_graph"); } +std::shared_ptr generate(const std::shared_ptr &node) { + const auto param = std::make_shared(ov::element::i32, ov::PartialShape{1, 2}); + auto bitwise = std::make_shared(param); + ov::ResultVector results{std::make_shared(bitwise)}; + return std::make_shared(results, ov::ParameterVector{param}, "bitwise_not_graph"); +} + std::shared_ptr generateArithmeticReductionKeepDims(const std::shared_ptr &node) { const auto data = std::make_shared(ov::element::f32, ov::PartialShape{3, 3}); const auto axes = ov::op::v0::Constant::create(ov::element::i32, {1}, {1}); @@ -2003,6 +2010,7 @@ OpGenerator getOpGeneratorMap() { #include "openvino/opsets/opset10_tbl.hpp" #include "openvino/opsets/opset11_tbl.hpp" #include "openvino/opsets/opset12_tbl.hpp" +#include "openvino/opsets/opset13_tbl.hpp" #undef _OPENVINO_OP_REG }; return opGeneratorMap; From 5358c47a1424bee42b30ae7ca83d5062e4af5aab Mon Sep 17 00:00:00 2001 From: Mateusz Date: Wed, 20 Sep 2023 12:22:39 +0000 Subject: [PATCH 03/11] improve test --- .../functional/op_reference/bitwise_not.cpp | 119 +++++++++++++----- 1 file changed, 87 insertions(+), 32 deletions(-) diff --git a/src/plugins/template/tests/functional/op_reference/bitwise_not.cpp b/src/plugins/template/tests/functional/op_reference/bitwise_not.cpp index 08c1ae1f2ab358..3c79473532eb62 100644 --- a/src/plugins/template/tests/functional/op_reference/bitwise_not.cpp +++ b/src/plugins/template/tests/functional/op_reference/bitwise_not.cpp @@ -2,9 +2,10 @@ // SPDX-License-Identifier: Apache-2.0 // +#include "openvino/op/bitwise_not.hpp" + #include -#include "openvino/op/bitwise_not.hpp" #include "bitwise.hpp" using namespace ov; @@ -14,49 +15,103 @@ namespace BitwiseOpsRefTestDefinitions { namespace { std::vector generateBitwiseParams() { - std::vector bitwiseParams { - Builder {} + std::vector bitwiseParams{ + Builder{} .opType(BitwiseTypes::BITWISE_NOT) - .inputs({{{2, 2}, element::boolean, std::vector {true, false, true, false}}}) - .expected({{2, 2}, element::boolean, std::vector {false, true, false, true}}), - Builder {} + .inputs({{{2, 2}, element::boolean, std::vector{true, false, true, false}}}) + .expected({{2, 2}, element::boolean, std::vector{false, true, false, true}}), + Builder{} .opType(BitwiseTypes::BITWISE_NOT) - .inputs({{{2}, element::i8, std::vector {std::numeric_limits::max(), std::numeric_limits::min()}}}) - .expected({{2}, element::i8, std::vector {std::numeric_limits::min(), std::numeric_limits::max()}}), - Builder {} + .inputs({{{3}, + element::i8, + std::vector{std::numeric_limits::max(), std::numeric_limits::min(), -7}}}) + .expected({{3}, + element::i8, + std::vector{std::numeric_limits::min(), std::numeric_limits::max(), 6}}), + Builder{} .opType(BitwiseTypes::BITWISE_NOT) - .inputs({{{2}, element::u8, std::vector {std::numeric_limits::max(), std::numeric_limits::min()}}}) - .expected({{2}, element::u8, std::vector {std::numeric_limits::min(), std::numeric_limits::max()}}), - Builder {} + .inputs( + {{{3}, + element::u8, + std::vector{std::numeric_limits::max(), std::numeric_limits::min(), 7}}}) + .expected({{3}, + element::u8, + std::vector{std::numeric_limits::min(), + std::numeric_limits::max(), + std::numeric_limits::max() - 7}}), + Builder{} .opType(BitwiseTypes::BITWISE_NOT) - .inputs({{{2}, element::i16, std::vector {std::numeric_limits::max(), std::numeric_limits::min()}}}) - .expected({{2}, element::i16, std::vector {std::numeric_limits::min(), std::numeric_limits::max()}}), - Builder {} + .inputs( + {{{3}, + element::i16, + std::vector{std::numeric_limits::max(), std::numeric_limits::min(), -7}}}) + .expected( + {{3}, + element::i16, + std::vector{std::numeric_limits::min(), std::numeric_limits::max(), 6}}), + Builder{} .opType(BitwiseTypes::BITWISE_NOT) - .inputs({{{2}, element::u16, std::vector {std::numeric_limits::max(), std::numeric_limits::min()}}}) - .expected({{2}, element::u16, std::vector {std::numeric_limits::min(), std::numeric_limits::max()}}), - Builder {} + .inputs({{{3}, + element::u16, + std::vector{std::numeric_limits::max(), + std::numeric_limits::min(), + 7}}}) + .expected({{3}, + element::u16, + std::vector{std::numeric_limits::min(), + std::numeric_limits::max(), + std::numeric_limits::max() - 7}}), + Builder{} .opType(BitwiseTypes::BITWISE_NOT) - .inputs({{{2}, element::i32, std::vector {std::numeric_limits::max(), std::numeric_limits::min()}}}) - .expected({{2}, element::i32, std::vector {std::numeric_limits::min(), std::numeric_limits::max()}}), - Builder {} + .inputs( + {{{3}, + element::i32, + std::vector{std::numeric_limits::max(), std::numeric_limits::min(), -7}}}) + .expected( + {{3}, + element::i32, + std::vector{std::numeric_limits::min(), std::numeric_limits::max(), 6}}), + Builder{} .opType(BitwiseTypes::BITWISE_NOT) - .inputs({{{2}, element::u32, std::vector {std::numeric_limits::max(), std::numeric_limits::min()}}}) - .expected({{2}, element::u32, std::vector {std::numeric_limits::min(), std::numeric_limits::max()}}), - Builder {} + .inputs({{{3}, + element::u32, + std::vector{std::numeric_limits::max(), + std::numeric_limits::min(), + 7}}}) + .expected({{3}, + element::u32, + std::vector{std::numeric_limits::min(), + std::numeric_limits::max(), + std::numeric_limits::max() - 7}}), + Builder{} .opType(BitwiseTypes::BITWISE_NOT) - .inputs({{{2}, element::i64, std::vector {std::numeric_limits::max(), std::numeric_limits::min()}}}) - .expected({{2}, element::i64, std::vector {std::numeric_limits::min(), std::numeric_limits::max()}}), - Builder {} + .inputs( + {{{3}, + element::i64, + std::vector{std::numeric_limits::max(), std::numeric_limits::min(), -7}}}) + .expected( + {{3}, + element::i64, + std::vector{std::numeric_limits::min(), std::numeric_limits::max(), 6}}), + Builder{} .opType(BitwiseTypes::BITWISE_NOT) - .inputs({{{2}, element::u64, std::vector {std::numeric_limits::max(), std::numeric_limits::min()}}}) - .expected({{2}, element::u64, std::vector {std::numeric_limits::min(), std::numeric_limits::max()}}), - }; + .inputs({{{3}, + element::u64, + std::vector{std::numeric_limits::max(), + std::numeric_limits::min(), + 7}}}) + .expected({{3}, + element::u64, + std::vector{std::numeric_limits::min(), + std::numeric_limits::max(), + std::numeric_limits::max() - 7}}), + }; return bitwiseParams; } - -INSTANTIATE_TEST_SUITE_P(smoke_BitwiseNot_With_Hardcoded_Refs, ReferenceBitwiseLayerTest, ::testing::ValuesIn(generateBitwiseParams()), +INSTANTIATE_TEST_SUITE_P(smoke_BitwiseNot_With_Hardcoded_Refs, + ReferenceBitwiseLayerTest, + ::testing::ValuesIn(generateBitwiseParams()), ReferenceBitwiseLayerTest::getTestCaseName); } // namespace From 5b86c3369eb1fc812bb781ebbd3542e8ae267375 Mon Sep 17 00:00:00 2001 From: Mateusz Date: Wed, 20 Sep 2023 12:44:43 +0000 Subject: [PATCH 04/11] formatting --- .../template/tests/functional/op_reference/bitwise.hpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/plugins/template/tests/functional/op_reference/bitwise.hpp b/src/plugins/template/tests/functional/op_reference/bitwise.hpp index bd989578bbcdd2..4d1b448e7b0199 100644 --- a/src/plugins/template/tests/functional/op_reference/bitwise.hpp +++ b/src/plugins/template/tests/functional/op_reference/bitwise.hpp @@ -49,7 +49,7 @@ class ReferenceBitwiseLayerTest : public testing::TestWithParam CreateFunction(BitwiseTypes op_type, const std::vector& inputs) { + static std::shared_ptr CreateFunction(BitwiseTypes op_type, + const std::vector& inputs) { ov::ParameterVector params_vec; for (auto& input : inputs) { params_vec.push_back(std::make_shared(input.type, input.shape)); @@ -86,8 +87,8 @@ class ReferenceBitwiseLayerTest : public testing::TestWithParam(ov::NodeVector {bitwise_op}, ov::ParameterVector {params_vec}); + } + return std::make_shared(ov::NodeVector{bitwise_op}, ov::ParameterVector{params_vec}); } }; } // namespace BitwiseOpsRefTestDefinitions From 6f9cc239d07b998e5c80133a9a2f4cb07b66e72c Mon Sep 17 00:00:00 2001 From: Mateusz Date: Fri, 22 Sep 2023 09:36:04 +0000 Subject: [PATCH 05/11] Requested changes --- src/core/include/openvino/op/bitwise_not.hpp | 3 +- .../openvino/reference/bitwise_not.hpp | 36 ++++++++ .../include/openvino/reference/not.hpp | 8 -- src/core/src/op/bitwise_not.cpp | 5 +- src/core/tests/op.cpp | 1 + src/core/tests/op_version_tbl.hpp | 1 + src/core/tests/opset.cpp | 4 +- src/core/tests/type_prop/bitwise_not.cpp | 92 +++++++++++++++++++ src/core/tests/visitors/op/bitwise_not.cpp | 11 +++ .../openvino/frontend/extension/op.hpp | 2 +- .../template/backend/ops/bitwise_not.cpp | 12 +-- .../tests/functional/op_reference/bitwise.hpp | 23 +---- 12 files changed, 154 insertions(+), 44 deletions(-) create mode 100644 src/core/reference/include/openvino/reference/bitwise_not.hpp create mode 100644 src/core/tests/type_prop/bitwise_not.cpp create mode 100644 src/core/tests/visitors/op/bitwise_not.cpp diff --git a/src/core/include/openvino/op/bitwise_not.hpp b/src/core/include/openvino/op/bitwise_not.hpp index 8b259022c3430f..f7de5224ca35de 100644 --- a/src/core/include/openvino/op/bitwise_not.hpp +++ b/src/core/include/openvino/op/bitwise_not.hpp @@ -5,13 +5,14 @@ #pragma once #include "openvino/op/op.hpp" +#include "openvino/op/util/unary_elementwise_arithmetic.hpp" namespace ov { namespace op { namespace v13 { /// \brief Elementwise bitwise negation operation. /// \ingroup ov_ops_cpp_api -class OPENVINO_API BitwiseNot : public Op { +class OPENVINO_API BitwiseNot : public util::UnaryElementwiseArithmetic { public: OPENVINO_OP("BitwiseNot", "opset13", op::Op); /// \brief Constructs a bitwise negation operation. diff --git a/src/core/reference/include/openvino/reference/bitwise_not.hpp b/src/core/reference/include/openvino/reference/bitwise_not.hpp new file mode 100644 index 00000000000000..da0cd9095c3f9b --- /dev/null +++ b/src/core/reference/include/openvino/reference/bitwise_not.hpp @@ -0,0 +1,36 @@ +// Copyright (C) 2018-2023 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#pragma once + +#include +#include + +namespace ov { +namespace reference { +namespace func { +// Check for char datatype used by ov::element::boolean +template ::type, char>::value>::type* = nullptr> +T bitwise_not(const T in) { + return static_cast(!in); +} + +template ::type, char>::value>::type* = nullptr> +T bitwise_not(const T in) { + return static_cast(~in); +} +} // namespace func +/** + * @brief Reference implementation of BitwiseNot operator. + * + * @param in Input pointer to data. + * @param out Output pointer to results. + * @param count Number of elements in input buffer. + */ +template +void bitwise_not(const T* in, T* out, size_t count) { + std::transform(in, std::next(in, count), out, &func::bitwise_not); +} +} // namespace reference +} // namespace ov diff --git a/src/core/reference/include/openvino/reference/not.hpp b/src/core/reference/include/openvino/reference/not.hpp index 90af51b8ad527d..e0444a8eb73a2a 100644 --- a/src/core/reference/include/openvino/reference/not.hpp +++ b/src/core/reference/include/openvino/reference/not.hpp @@ -4,7 +4,6 @@ #pragma once -#include #include namespace ov { @@ -15,12 +14,5 @@ void logical_not(const T* arg, T* out, size_t count) { out[i] = static_cast(!(arg[i])); } } - -template -void bitwise_not(const T* arg, T* out, size_t count) { - std::transform(arg, std::next(arg, count), out, [](T x) -> T { - return static_cast(~x); - }); -} } // namespace reference } // namespace ov diff --git a/src/core/src/op/bitwise_not.cpp b/src/core/src/op/bitwise_not.cpp index 03d19bc7ba92e2..6e7f44604bea4c 100644 --- a/src/core/src/op/bitwise_not.cpp +++ b/src/core/src/op/bitwise_not.cpp @@ -11,17 +11,16 @@ namespace ov { namespace op { namespace v13 { -BitwiseNot::BitwiseNot(const Output& arg) : Op({arg}) { +BitwiseNot::BitwiseNot(const Output& arg) : util::UnaryElementwiseArithmetic({arg}) { constructor_validate_and_infer_types(); } void BitwiseNot::validate_and_infer_types() { OV_OP_SCOPE(v13_BitwiseNot_validate_and_infer_types); const auto& element_type = get_input_element_type(0); - const auto& arg_pshape = get_input_partial_shape(0); NODE_VALIDATION_CHECK(this, element_type.is_dynamic() || element_type.is_integral() || element_type == element::boolean, "The element type of the input tensor must be integral or boolean."); - set_output_type(0, element_type, arg_pshape); + set_output_type(0, element_type, get_input_partial_shape(0)); } std::shared_ptr BitwiseNot::clone_with_new_inputs(const OutputVector& new_args) const { diff --git a/src/core/tests/op.cpp b/src/core/tests/op.cpp index 20f6d919c89464..b249c0698bf1db 100644 --- a/src/core/tests/op.cpp +++ b/src/core/tests/op.cpp @@ -64,4 +64,5 @@ TEST(op, opset_multi_thread) { doTest(ov::get_opset10); doTest(ov::get_opset11); doTest(ov::get_opset12); + doTest(ov::get_opset13); } diff --git a/src/core/tests/op_version_tbl.hpp b/src/core/tests/op_version_tbl.hpp index 358a6ef416297f..bf2fc789b12635 100644 --- a/src/core/tests/op_version_tbl.hpp +++ b/src/core/tests/op_version_tbl.hpp @@ -26,6 +26,7 @@ _OPENVINO_OP_REG(AvgPool, ov::op::v1) _OPENVINO_OP_REG(BatchNormInference, ov::op::v0) _OPENVINO_OP_REG(BatchToSpace, ov::op::v1) _OPENVINO_OP_REG(BinaryConvolution, ov::op::v1) +_OPENVINO_OP_REG(BitwiseNot, ov::op::v13) _OPENVINO_OP_REG(Broadcast, ov::op::v1) _OPENVINO_OP_REG(Broadcast, ov::op::v3) _OPENVINO_OP_REG(Bucketize, ov::op::v3) diff --git a/src/core/tests/opset.cpp b/src/core/tests/opset.cpp index cafea943c8321b..b0e540171d922c 100644 --- a/src/core/tests/opset.cpp +++ b/src/core/tests/opset.cpp @@ -11,6 +11,7 @@ #include "openvino/opsets/opset10.hpp" #include "openvino/opsets/opset11.hpp" #include "openvino/opsets/opset12.hpp" +#include "openvino/opsets/opset13.hpp" #include "openvino/opsets/opset2.hpp" #include "openvino/opsets/opset3.hpp" #include "openvino/opsets/opset4.hpp" @@ -69,7 +70,8 @@ INSTANTIATE_TEST_SUITE_P(opset, OpsetTestParams{ov::get_opset9, 173}, OpsetTestParams{ov::get_opset10, 177}, OpsetTestParams{ov::get_opset11, 177}, - OpsetTestParams{ov::get_opset12, 178}), + OpsetTestParams{ov::get_opset12, 178}, + OpsetTestParams{ov::get_opset13, 179}), OpsetTestNameGenerator{}); class MyOpOld : public ov::op::Op { diff --git a/src/core/tests/type_prop/bitwise_not.cpp b/src/core/tests/type_prop/bitwise_not.cpp new file mode 100644 index 00000000000000..b371bdfd254f23 --- /dev/null +++ b/src/core/tests/type_prop/bitwise_not.cpp @@ -0,0 +1,92 @@ +// Copyright (C) 2018-2023 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "openvino/op/bitwise_not.hpp" + +#include + +#include "common_test_utils/type_prop.hpp" + +using namespace std; +using namespace ov; +using namespace testing; + +using BitwiseNotTestParam = std::tuple; + +namespace { +using namespace ov::element; +constexpr size_t exp_num_of_outputs = 1; + +const auto types = Values(boolean, i8, i16, i32, i64, u8, u16, u32, u64); + +const auto static_shapes = Values(PartialShape{0}, PartialShape{1}, PartialShape{2, 3, 7, 8}); +const auto dynamic_shapes = Values(PartialShape{Dimension::dynamic(), Dimension::dynamic(), Dimension::dynamic()}, + PartialShape{2, {-1, 5}, {4, -1}, -1, {3, 8}}, + PartialShape::dynamic()); +} // namespace + +class BitwiseNotTest : public TypePropOpTest, public WithParamInterface { +protected: + void SetUp() override { + std::tie(exp_type, exp_shape) = GetParam(); + } + + element::Type exp_type; + PartialShape exp_shape; +}; + +INSTANTIATE_TEST_SUITE_P(type_prop_static_shape, + BitwiseNotTest, + Combine(types, static_shapes), + PrintToStringParamName()); +INSTANTIATE_TEST_SUITE_P(type_prop_dynamic_shape, + BitwiseNotTest, + Combine(types, dynamic_shapes), + PrintToStringParamName()); + +TEST_P(BitwiseNotTest, propagate_dimensions) { + const auto input = std::make_shared(exp_type, exp_shape); + const auto op = make_op(input); + + EXPECT_EQ(op->get_element_type(), exp_type); + EXPECT_EQ(op->get_output_size(), exp_num_of_outputs); + EXPECT_EQ(op->get_output_partial_shape(0), exp_shape); +} + +TEST_P(BitwiseNotTest, propagate_labels) { + if (exp_shape.rank().is_static()) { + set_shape_labels(exp_shape, 10); + } + const auto exp_labels = get_shape_labels(exp_shape); + + const auto input = std::make_shared(exp_type, exp_shape); + const auto op = make_op(input); + + EXPECT_EQ(get_shape_labels(op->get_output_partial_shape(0)), exp_labels); +} + +TEST_P(BitwiseNotTest, default_ctor) { + const auto op = make_op(); + const auto input = std::make_shared(exp_type, exp_shape); + + op->set_argument(0, input); + op->validate_and_infer_types(); + + EXPECT_EQ(op->get_element_type(), exp_type); + EXPECT_EQ(op->get_output_size(), exp_num_of_outputs); + EXPECT_EQ(op->get_output_partial_shape(0), exp_shape); +} + +TEST(BitwiseNotTest, invalid_element_type) { + auto data = make_shared(ov::element::f32, ov::Shape{2, 2}); + + try { + auto bitwise = std::make_shared(data); + FAIL() << "Invalid floating-point element type for input not detected"; + } catch (const ov::NodeValidationFailure& error) { + EXPECT_HAS_SUBSTRING(error.what(), "The element type of the input tensor must be integral or boolean."); + } catch (...) { + FAIL() << "Numeric element type node validation check failed for unexpected reason"; + } +} diff --git a/src/core/tests/visitors/op/bitwise_not.cpp b/src/core/tests/visitors/op/bitwise_not.cpp new file mode 100644 index 00000000000000..ef874eb8fd2295 --- /dev/null +++ b/src/core/tests/visitors/op/bitwise_not.cpp @@ -0,0 +1,11 @@ +// Copyright (C) 2018-2023 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "openvino/op/bitwise_not.hpp" + +#include "unary_ops.hpp" + +using Type = ::testing::Types>; + +INSTANTIATE_TYPED_TEST_SUITE_P(visitor_without_attribute, UnaryOperatorVisitor, Type, UnaryOperatorTypeName); diff --git a/src/frontends/common/include/openvino/frontend/extension/op.hpp b/src/frontends/common/include/openvino/frontend/extension/op.hpp index 916426f77056b1..0bb7b76fe54817 100644 --- a/src/frontends/common/include/openvino/frontend/extension/op.hpp +++ b/src/frontends/common/include/openvino/frontend/extension/op.hpp @@ -25,7 +25,7 @@ inline const ov::OpSet& get_opset_by_name(const std::string& opset_name) { if (opsets.find(opset_name) != opsets.end()) return opsets.at(opset_name)(); if (opset_name.empty() || opset_name == "latest") { - return ov::get_opset12(); + return ov::get_opset13(); } else { FRONT_END_GENERAL_CHECK(false, "Unsupported opset name: ", opset_name); } diff --git a/src/plugins/template/backend/ops/bitwise_not.cpp b/src/plugins/template/backend/ops/bitwise_not.cpp index 44374936f02538..928228fa49cb49 100644 --- a/src/plugins/template/backend/ops/bitwise_not.cpp +++ b/src/plugins/template/backend/ops/bitwise_not.cpp @@ -5,20 +5,16 @@ #include "openvino/op/bitwise_not.hpp" #include "evaluate_node.hpp" -#include "openvino/reference/not.hpp" +#include "openvino/reference/bitwise_not.hpp" using namespace ov; -template +template bool evaluate(const std::shared_ptr& node, ov::TensorVector& outputs, const ov::TensorVector& inputs) { - using ET = typename ov::element_type_traits::value_type; - if (T == element::Type_t::boolean) { - ov::reference::logical_not(inputs[0].data(), outputs[0].data(), shape_size(inputs[0].get_shape())); - } else { - ov::reference::bitwise_not(inputs[0].data(), outputs[0].data(), shape_size(inputs[0].get_shape())); - } + using T = typename ov::element_type_traits::value_type; + ov::reference::bitwise_not(inputs[0].data(), outputs[0].data(), shape_size(inputs[0].get_shape())); return true; } diff --git a/src/plugins/template/tests/functional/op_reference/bitwise.hpp b/src/plugins/template/tests/functional/op_reference/bitwise.hpp index 4d1b448e7b0199..0e8ff7af32ce1b 100644 --- a/src/plugins/template/tests/functional/op_reference/bitwise.hpp +++ b/src/plugins/template/tests/functional/op_reference/bitwise.hpp @@ -5,23 +5,14 @@ #include #include "base_reference_test.hpp" - -// #include "openvino/op/bitwise_and.hpp" #include "openvino/op/bitwise_not.hpp" -// #include "openvino/op/bitwise_or.hpp" -// #include "openvino/op/bitwise_xor.hpp" using namespace ov; namespace reference_tests { namespace BitwiseOpsRefTestDefinitions { -enum BitwiseTypes { - // BITWISE_AND, - // BITWISE_OR, - // BITWISE_XOR, - BITWISE_NOT -}; +enum BitwiseTypes { BITWISE_NOT }; struct RefBitwiseParams { BitwiseTypes opType; @@ -68,22 +59,10 @@ class ReferenceBitwiseLayerTest : public testing::TestWithParam bitwise_op; switch (op_type) { - // case BitwiseTypes::BITWISE_AND: { - // bitwise_op = std::make_shared(params_vec[0], params_vec[1]); - // break; - // } case BitwiseTypes::BITWISE_NOT: { bitwise_op = std::make_shared(params_vec[0]); break; } - // case BitwiseTypes::BITWISE_OR: { - // bitwise_op = std::make_shared(params_vec[0], params_vec[1]); - // break; - // } - // case BitwiseTypes::BITWISE_XOR: { - // bitwise_op = std::make_shared(params_vec[0], params_vec[1]); - // break; - // } default: { throw std::runtime_error("Incorrect type of Bitwise operation"); } From 59fff80d8b7d3db22d5960f0c8559ce88231534a Mon Sep 17 00:00:00 2001 From: Mateusz Mikolajczyk Date: Fri, 22 Sep 2023 13:39:33 +0200 Subject: [PATCH 06/11] Remove unused include --- src/core/src/op/bitwise_not.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/core/src/op/bitwise_not.cpp b/src/core/src/op/bitwise_not.cpp index 6e7f44604bea4c..2a3c4aa0d21e59 100644 --- a/src/core/src/op/bitwise_not.cpp +++ b/src/core/src/op/bitwise_not.cpp @@ -6,7 +6,6 @@ #include "itt.hpp" #include "openvino/core/validation_util.hpp" #include "openvino/op/op.hpp" -#include "openvino/reference/not.hpp" namespace ov { namespace op { From 45860383d4fea10d1f28777c13232bbc2a68411f Mon Sep 17 00:00:00 2001 From: Mateusz Date: Mon, 25 Sep 2023 09:31:38 +0000 Subject: [PATCH 07/11] Add requested changes --- src/core/tests/type_prop/bitwise_not.cpp | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/src/core/tests/type_prop/bitwise_not.cpp b/src/core/tests/type_prop/bitwise_not.cpp index b371bdfd254f23..b891a9fa0631f9 100644 --- a/src/core/tests/type_prop/bitwise_not.cpp +++ b/src/core/tests/type_prop/bitwise_not.cpp @@ -6,9 +6,9 @@ #include +#include "common_test_utils/test_assertions.hpp" #include "common_test_utils/type_prop.hpp" -using namespace std; using namespace ov; using namespace testing; @@ -21,9 +21,8 @@ constexpr size_t exp_num_of_outputs = 1; const auto types = Values(boolean, i8, i16, i32, i64, u8, u16, u32, u64); const auto static_shapes = Values(PartialShape{0}, PartialShape{1}, PartialShape{2, 3, 7, 8}); -const auto dynamic_shapes = Values(PartialShape{Dimension::dynamic(), Dimension::dynamic(), Dimension::dynamic()}, - PartialShape{2, {-1, 5}, {4, -1}, -1, {3, 8}}, - PartialShape::dynamic()); +const auto dynamic_shapes = + Values(PartialShape::dynamic(3), PartialShape{2, {0, 5}, {4, -1}, -1, {3, 8}}, PartialShape::dynamic()); } // namespace class BitwiseNotTest : public TypePropOpTest, public WithParamInterface { @@ -79,14 +78,8 @@ TEST_P(BitwiseNotTest, default_ctor) { } TEST(BitwiseNotTest, invalid_element_type) { - auto data = make_shared(ov::element::f32, ov::Shape{2, 2}); - - try { - auto bitwise = std::make_shared(data); - FAIL() << "Invalid floating-point element type for input not detected"; - } catch (const ov::NodeValidationFailure& error) { - EXPECT_HAS_SUBSTRING(error.what(), "The element type of the input tensor must be integral or boolean."); - } catch (...) { - FAIL() << "Numeric element type node validation check failed for unexpected reason"; - } + auto data = std::make_shared(ov::element::f32, ov::Shape{2, 2}); + OV_EXPECT_THROW(std::ignore = std::make_shared(data), + ov::NodeValidationFailure, + HasSubstr("The element type of the input tensor must be integral or boolean.")); } From 75139d0cf526fa23f5777a838ce45e4d8ccb7855 Mon Sep 17 00:00:00 2001 From: Mateusz Date: Mon, 25 Sep 2023 14:03:24 +0000 Subject: [PATCH 08/11] Try to fix test problems --- src/core/include/openvino/op/bitwise_not.hpp | 2 +- src/core/src/op/bitwise_not.cpp | 2 +- .../src/op_impl_check/single_op_graph.cpp | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/core/include/openvino/op/bitwise_not.hpp b/src/core/include/openvino/op/bitwise_not.hpp index f7de5224ca35de..4e3f0e6cca358c 100644 --- a/src/core/include/openvino/op/bitwise_not.hpp +++ b/src/core/include/openvino/op/bitwise_not.hpp @@ -12,7 +12,7 @@ namespace op { namespace v13 { /// \brief Elementwise bitwise negation operation. /// \ingroup ov_ops_cpp_api -class OPENVINO_API BitwiseNot : public util::UnaryElementwiseArithmetic { +class OPENVINO_API BitwiseNot : public op::Op { public: OPENVINO_OP("BitwiseNot", "opset13", op::Op); /// \brief Constructs a bitwise negation operation. diff --git a/src/core/src/op/bitwise_not.cpp b/src/core/src/op/bitwise_not.cpp index 2a3c4aa0d21e59..93053365a98320 100644 --- a/src/core/src/op/bitwise_not.cpp +++ b/src/core/src/op/bitwise_not.cpp @@ -10,7 +10,7 @@ namespace ov { namespace op { namespace v13 { -BitwiseNot::BitwiseNot(const Output& arg) : util::UnaryElementwiseArithmetic({arg}) { +BitwiseNot::BitwiseNot(const Output& arg) : op::Op({arg}) { constructor_validate_and_infer_types(); } void BitwiseNot::validate_and_infer_types() { diff --git a/src/tests/functional/plugin/conformance/test_runner/op_conformance_runner/src/op_impl_check/single_op_graph.cpp b/src/tests/functional/plugin/conformance/test_runner/op_conformance_runner/src/op_impl_check/single_op_graph.cpp index f51843dac733e6..cd3f69e6e5f7aa 100644 --- a/src/tests/functional/plugin/conformance/test_runner/op_conformance_runner/src/op_impl_check/single_op_graph.cpp +++ b/src/tests/functional/plugin/conformance/test_runner/op_conformance_runner/src/op_impl_check/single_op_graph.cpp @@ -1243,10 +1243,10 @@ std::shared_ptr generate(const std::shared_ptr &n } std::shared_ptr generate(const std::shared_ptr &node) { - const auto param = std::make_shared(ov::element::i32, ov::PartialShape{1, 2}); + const auto param = std::make_shared(ov::element::i64, ov::PartialShape{1, 2}); auto bitwise = std::make_shared(param); ov::ResultVector results{std::make_shared(bitwise)}; - return std::make_shared(results, ov::ParameterVector{param}, "bitwise_not_graph"); + return std::make_shared(results, ov::ParameterVector{param}, "BitwiseNotGraph"); } std::shared_ptr generateArithmeticReductionKeepDims(const std::shared_ptr &node) { From 0f69f0c71c7f8d52dcd788994490bc383a865eb5 Mon Sep 17 00:00:00 2001 From: Mateusz Date: Mon, 25 Sep 2023 15:00:18 +0000 Subject: [PATCH 09/11] Fix CI --- src/core/include/openvino/op/bitwise_not.hpp | 1 - src/plugins/template/src/plugin.cpp | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/include/openvino/op/bitwise_not.hpp b/src/core/include/openvino/op/bitwise_not.hpp index 4e3f0e6cca358c..8b5c8faa80031b 100644 --- a/src/core/include/openvino/op/bitwise_not.hpp +++ b/src/core/include/openvino/op/bitwise_not.hpp @@ -5,7 +5,6 @@ #pragma once #include "openvino/op/op.hpp" -#include "openvino/op/util/unary_elementwise_arithmetic.hpp" namespace ov { namespace op { diff --git a/src/plugins/template/src/plugin.cpp b/src/plugins/template/src/plugin.cpp index 918bfbfb9b0fe0..fde640e7f016d5 100644 --- a/src/plugins/template/src/plugin.cpp +++ b/src/plugins/template/src/plugin.cpp @@ -194,6 +194,7 @@ ov::SupportedOpsMap ov::template_plugin::Plugin::query_model(const std::shared_p #include "openvino/opsets/opset10_tbl.hpp" #include "openvino/opsets/opset11_tbl.hpp" #include "openvino/opsets/opset12_tbl.hpp" +#include "openvino/opsets/opset13_tbl.hpp" // clang-format on #undef _OPENVINO_OP_REG return op_super_set.contains_type(node->get_type_info()); From 5094b974c41e6753907ab8150e210b59ccfbbcf8 Mon Sep 17 00:00:00 2001 From: Mateusz Date: Tue, 26 Sep 2023 13:35:09 +0000 Subject: [PATCH 10/11] Fix type validation --- src/core/src/op/bitwise_not.cpp | 4 ++-- src/core/tests/type_prop/bitwise_not.cpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/core/src/op/bitwise_not.cpp b/src/core/src/op/bitwise_not.cpp index 93053365a98320..92aeace18ad501 100644 --- a/src/core/src/op/bitwise_not.cpp +++ b/src/core/src/op/bitwise_not.cpp @@ -17,8 +17,8 @@ void BitwiseNot::validate_and_infer_types() { OV_OP_SCOPE(v13_BitwiseNot_validate_and_infer_types); const auto& element_type = get_input_element_type(0); NODE_VALIDATION_CHECK(this, - element_type.is_dynamic() || element_type.is_integral() || element_type == element::boolean, - "The element type of the input tensor must be integral or boolean."); + element_type.is_dynamic() || element_type.is_integral(), + "The element type of the input tensor must be integer or boolean."); set_output_type(0, element_type, get_input_partial_shape(0)); } diff --git a/src/core/tests/type_prop/bitwise_not.cpp b/src/core/tests/type_prop/bitwise_not.cpp index b891a9fa0631f9..edfb0693db3abf 100644 --- a/src/core/tests/type_prop/bitwise_not.cpp +++ b/src/core/tests/type_prop/bitwise_not.cpp @@ -81,5 +81,5 @@ TEST(BitwiseNotTest, invalid_element_type) { auto data = std::make_shared(ov::element::f32, ov::Shape{2, 2}); OV_EXPECT_THROW(std::ignore = std::make_shared(data), ov::NodeValidationFailure, - HasSubstr("The element type of the input tensor must be integral or boolean.")); + HasSubstr("The element type of the input tensor must be integer or boolean.")); } From 626cb6a13184dfbd127838e67af7f4d742e1af61 Mon Sep 17 00:00:00 2001 From: Mateusz Date: Tue, 26 Sep 2023 13:44:29 +0000 Subject: [PATCH 11/11] Add checks in template eval --- src/plugins/template/backend/ops/bitwise_not.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/plugins/template/backend/ops/bitwise_not.cpp b/src/plugins/template/backend/ops/bitwise_not.cpp index 928228fa49cb49..91a73fa0dd1c3f 100644 --- a/src/plugins/template/backend/ops/bitwise_not.cpp +++ b/src/plugins/template/backend/ops/bitwise_not.cpp @@ -6,6 +6,7 @@ #include "evaluate_node.hpp" #include "openvino/reference/bitwise_not.hpp" +#include "utils.hpp" using namespace ov; @@ -13,6 +14,10 @@ template bool evaluate(const std::shared_ptr& node, ov::TensorVector& outputs, const ov::TensorVector& inputs) { + OPENVINO_ASSERT(inputs.size() == 1); + OPENVINO_ASSERT(outputs.size() == 1); + outputs[0].set_shape(inputs[0].get_shape()); + using T = typename ov::element_type_traits::value_type; ov::reference::bitwise_not(inputs[0].data(), outputs[0].data(), shape_size(inputs[0].get_shape())); return true;