From f5fe664fb71a7b8a24787476130800d5374b844d Mon Sep 17 00:00:00 2001 From: Mateusz Mikolajczyk Date: Wed, 27 Sep 2023 08:17:53 +0200 Subject: [PATCH 1/5] [Ref][Core][Opset13] Add BitwiseNot operation (#19956) * [Ref][Core][Opset13] Add bitwise_not operation * Fix CI issues + add missing test * improve test * formatting * Requested changes * Remove unused include * Add requested changes * Try to fix test problems * Fix CI * Fix type validation * Add checks in template eval --- src/core/include/openvino/op/bitwise_not.hpp | 30 +++++ src/core/include/openvino/op/ops.hpp | 1 + .../include/openvino/opsets/opset13_tbl.hpp | 1 + .../openvino/reference/bitwise_not.hpp | 36 ++++++ src/core/src/op/bitwise_not.cpp | 33 +++++ src/core/tests/op_version_tbl.hpp | 1 + src/core/tests/opset.cpp | 2 +- src/core/tests/type_prop/bitwise_not.cpp | 85 +++++++++++++ src/core/tests/visitors/op/bitwise_not.cpp | 11 ++ .../template/backend/ops/bitwise_not.cpp | 52 ++++++++ .../template/backend/ops/ops_evaluates.hpp | 4 + .../template/backend/opset_int_tbl.hpp | 2 + src/plugins/template/src/plugin.cpp | 1 + .../tests/functional/op_reference/bitwise.cpp | 17 +++ .../tests/functional/op_reference/bitwise.hpp | 74 +++++++++++ .../functional/op_reference/bitwise_not.cpp | 119 ++++++++++++++++++ .../src/op_impl_check/single_op_graph.cpp | 7 ++ 17 files changed, 475 insertions(+), 1 deletion(-) create mode 100644 src/core/include/openvino/op/bitwise_not.hpp create mode 100644 src/core/reference/include/openvino/reference/bitwise_not.hpp create mode 100644 src/core/src/op/bitwise_not.cpp create mode 100644 src/core/tests/type_prop/bitwise_not.cpp create mode 100644 src/core/tests/visitors/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..8b5c8faa80031b --- /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::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/opset13_tbl.hpp b/src/core/include/openvino/opsets/opset13_tbl.hpp index f8b1709648e860..abe98b4754f6db 100644 --- a/src/core/include/openvino/opsets/opset13_tbl.hpp +++ b/src/core/include/openvino/opsets/opset13_tbl.hpp @@ -209,3 +209,4 @@ _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/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/src/op/bitwise_not.cpp b/src/core/src/op/bitwise_not.cpp new file mode 100644 index 00000000000000..92aeace18ad501 --- /dev/null +++ b/src/core/src/op/bitwise_not.cpp @@ -0,0 +1,33 @@ +// 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" + +namespace ov { +namespace op { +namespace v13 { +BitwiseNot::BitwiseNot(const Output& arg) : op::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); + NODE_VALIDATION_CHECK(this, + 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)); +} + +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/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 e8007d9b74b95b..b0e540171d922c 100644 --- a/src/core/tests/opset.cpp +++ b/src/core/tests/opset.cpp @@ -71,7 +71,7 @@ INSTANTIATE_TEST_SUITE_P(opset, OpsetTestParams{ov::get_opset10, 177}, OpsetTestParams{ov::get_opset11, 177}, OpsetTestParams{ov::get_opset12, 178}, - OpsetTestParams{ov::get_opset13, 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..edfb0693db3abf --- /dev/null +++ b/src/core/tests/type_prop/bitwise_not.cpp @@ -0,0 +1,85 @@ +// Copyright (C) 2018-2023 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "openvino/op/bitwise_not.hpp" + +#include + +#include "common_test_utils/test_assertions.hpp" +#include "common_test_utils/type_prop.hpp" + +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::dynamic(3), PartialShape{2, {0, 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 = 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 integer or boolean.")); +} 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/plugins/template/backend/ops/bitwise_not.cpp b/src/plugins/template/backend/ops/bitwise_not.cpp new file mode 100644 index 00000000000000..91a73fa0dd1c3f --- /dev/null +++ b/src/plugins/template/backend/ops/bitwise_not.cpp @@ -0,0 +1,52 @@ +// 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/bitwise_not.hpp" +#include "utils.hpp" + +using namespace ov; + +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; +} + +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/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()); 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..0e8ff7af32ce1b --- /dev/null +++ b/src/plugins/template/tests/functional/op_reference/bitwise.hpp @@ -0,0 +1,74 @@ +// Copyright (C) 2018-2023 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include + +#include "base_reference_test.hpp" +#include "openvino/op/bitwise_not.hpp" + +using namespace ov; + +namespace reference_tests { +namespace BitwiseOpsRefTestDefinitions { + +enum BitwiseTypes { 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_NOT: { + bitwise_op = std::make_shared(params_vec[0]); + 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..3c79473532eb62 --- /dev/null +++ b/src/plugins/template/tests/functional/op_reference/bitwise_not.cpp @@ -0,0 +1,119 @@ +// Copyright (C) 2018-2023 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "openvino/op/bitwise_not.hpp" + +#include + +#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({{{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( + {{{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( + {{{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({{{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( + {{{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({{{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( + {{{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({{{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()), + ReferenceBitwiseLayerTest::getTestCaseName); + +} // namespace +} // namespace BitwiseOpsRefTestDefinitions +} // namespace reference_tests 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 a5383310174bc9..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 @@ -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::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}, "BitwiseNotGraph"); +} + 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}); From edfb951876ff983629c7ec87b84c49119468d2eb Mon Sep 17 00:00:00 2001 From: Maciej Smyk Date: Wed, 27 Sep 2023 09:32:11 +0200 Subject: [PATCH 2/5] [DOCS] Toctree update for Plugin articles for master (#20061) * toctree update * Update step3_main.md --- docs/IE_PLUGIN_DG/layout.xml | 106 ------------------ .../pipeline/step1_prerequisites.md | 8 ++ .../pipeline/step2_markup.md | 20 ++++ .../pipeline/step3_main.md | 40 ++++++- .../pipeline/step4_cleanup.md | 13 +++ 5 files changed, 77 insertions(+), 110 deletions(-) delete mode 100644 docs/IE_PLUGIN_DG/layout.xml diff --git a/docs/IE_PLUGIN_DG/layout.xml b/docs/IE_PLUGIN_DG/layout.xml deleted file mode 100644 index 03dda0379e060f..00000000000000 --- a/docs/IE_PLUGIN_DG/layout.xml +++ /dev/null @@ -1,106 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/docs/IE_PLUGIN_DG/plugin_transformation_pipeline/low_precision_transformations/pipeline/step1_prerequisites.md b/docs/IE_PLUGIN_DG/plugin_transformation_pipeline/low_precision_transformations/pipeline/step1_prerequisites.md index 38258c24660b4c..c2f2d75cbe125f 100644 --- a/docs/IE_PLUGIN_DG/plugin_transformation_pipeline/low_precision_transformations/pipeline/step1_prerequisites.md +++ b/docs/IE_PLUGIN_DG/plugin_transformation_pipeline/low_precision_transformations/pipeline/step1_prerequisites.md @@ -6,6 +6,14 @@ :description: Learn about optional Prerequisites transformations, that prepare a model before applying other low precision transformations. +.. toctree:: + :maxdepth: 1 + :hidden: + + PullReshapeThroughDequantization + PullTransposeThroughDequantization + LinOpSequenceFusion + Prerequisites transformations are optional. The transformations prepare a model before running other low precision transformations. The transformations do not operate with dequantization operations or update precisions. Prerequisites transformations include: * :doc:`PullReshapeThroughDequantization ` diff --git a/docs/IE_PLUGIN_DG/plugin_transformation_pipeline/low_precision_transformations/pipeline/step2_markup.md b/docs/IE_PLUGIN_DG/plugin_transformation_pipeline/low_precision_transformations/pipeline/step2_markup.md index 426c37c88792a4..661324b6463ea1 100644 --- a/docs/IE_PLUGIN_DG/plugin_transformation_pipeline/low_precision_transformations/pipeline/step2_markup.md +++ b/docs/IE_PLUGIN_DG/plugin_transformation_pipeline/low_precision_transformations/pipeline/step2_markup.md @@ -6,6 +6,26 @@ :description: Learn about markup transformations, which are used to create attributes for input and output ports and operations during runtime. +.. toctree:: + :maxdepth: 1 + :caption: Low Precision Transformations + :hidden: + + MarkupBias + MarkupCanBeQuantized + MarkupPrecisions + MarkupPerTensorQuantization + MarkupAvgPoolPrecisionPreserved + PropagatePrecisions + AlignQuantizationIntervals + AlignQuantizationParameters + + CreateAttribute + CreatePrecisionsDependentAttribute + PropagateThroughPrecisionPreserved + PropagateToInput + UpdateSharedPrecisionPreserved + This step defines the optimal ``FakeQuantize`` decomposition precisions for the best inference performance via operations markup with runtime attribute instances. Attributes are created for input and output ports and operations. Transformations do not change the operation output port precisions. A model markup low precision logic is decomposed and implemented into the following common markup transformations. The order of transformations is important: 1. :doc:`MarkupBias ` diff --git a/docs/IE_PLUGIN_DG/plugin_transformation_pipeline/low_precision_transformations/pipeline/step3_main.md b/docs/IE_PLUGIN_DG/plugin_transformation_pipeline/low_precision_transformations/pipeline/step3_main.md index 700b5d98f4c323..162ba3ebfce1df 100644 --- a/docs/IE_PLUGIN_DG/plugin_transformation_pipeline/low_precision_transformations/pipeline/step3_main.md +++ b/docs/IE_PLUGIN_DG/plugin_transformation_pipeline/low_precision_transformations/pipeline/step3_main.md @@ -7,21 +7,52 @@ precision transformations that handle decomposition and dequantization operations. - -Main transformations are the majority of low precision transformations. Transformations operate with dequantization operations. Main transformations include: - .. toctree:: :maxdepth: 1 :hidden: + AddTransformation + AvgPoolTransformation BatchToSpaceTransformation + ClampTransformation + ConcatTransformation + ConvolutionTransformation + ConvolutionBackpropDataTransformation + DepthToSpaceTransformation + FakeQuantizeDecompositionTransformation + FakeQuantizeTransformation + InterpolateTransformation + GroupConvolutionTransformation + GatherTransformation + MatMulTransformation + MaxPoolTransformation + MultiplyTransformation + MVNTransformation + NormalizeL2Transformation + PadTransformation + PReluTransformation + ReduceMaxTransformation + ReduceMeanTransformation + ReduceMinTransformation + ReduceSumTransformation + ReluTransformation + ReshapeTransformation SpaceToBatchTransformation + SqueezeTransformation + ShuffleChannelsTransformation + SplitTransformation + StridedSliceTransformation + TransposeTransformation + UnsqueezeTransformation + VariadicSplitTransformation + +Main transformations are the majority of low precision transformations. Transformations operate with dequantization operations. Main transformations include: * :doc:`AddTransformation ` * :doc:`AvgPoolTransformation ` * :doc:`BatchToSpaceTransformation ` -* :doc:`ClampTransformation ` +* :doc:`ClampTransformation ` * :doc:`ConcatTransformation ` * :doc:`ConvolutionTransformation ` * :doc:`ConvolutionBackpropDataTransformation ` @@ -36,6 +67,7 @@ Main transformations are the majority of low precision transformations. Transfor * :doc:`MultiplyTransformation ` * :doc:`MVNTransformation ` * :doc:`NormalizeL2Transformation ` +* :doc:`PadTransformation` * :doc:`PReluTransformation ` * :doc:`ReduceMaxTransformation ` * :doc:`ReduceMeanTransformation ` diff --git a/docs/IE_PLUGIN_DG/plugin_transformation_pipeline/low_precision_transformations/pipeline/step4_cleanup.md b/docs/IE_PLUGIN_DG/plugin_transformation_pipeline/low_precision_transformations/pipeline/step4_cleanup.md index fd9a2d638df3d0..53ecc34686d02b 100644 --- a/docs/IE_PLUGIN_DG/plugin_transformation_pipeline/low_precision_transformations/pipeline/step4_cleanup.md +++ b/docs/IE_PLUGIN_DG/plugin_transformation_pipeline/low_precision_transformations/pipeline/step4_cleanup.md @@ -6,6 +6,19 @@ :description: Check the list of transformations used to clean up the resulting model to avoid unhandled dequantization operations. +.. toctree:: + :maxdepth: 1 + :hidden: + + EliminateFakeQuantizeTransformation + FoldConvertTransformation + FoldFakeQuantizeTransformation + FuseConvertTransformation + FuseMultiplyToFakeQuantizeTransformation + FuseSubtractToFakeQuantizeTransformation + MultiplyToGroupConvolutionTransformation + + * :doc:`EliminateFakeQuantizeTransformation ` * :doc:`FoldConvertTransformation ` * :doc:`FoldFakeQuantizeTransformation ` From a6e7bac962584f8e207c47f0e61c1e86e04a75ab Mon Sep 17 00:00:00 2001 From: Ilya Lavrenov Date: Wed, 27 Sep 2023 12:24:20 +0400 Subject: [PATCH 3/5] Added RISC-V Conan build (#20064) --- .github/workflows/linux.yml | 7 +- .github/workflows/linux_arm64.yml | 199 ------------------ .github/workflows/linux_riscv.yml | 188 +++++++++++++++++ cmake/developer_package/add_ie_target.cmake | 2 +- src/cmake/openvino.cmake | 5 + src/core/tests/CMakeLists.txt | 5 + src/inference/src/system_conf.cpp | 3 + src/plugins/auto/tests/unit/CMakeLists.txt | 8 +- .../tests/unit/compile_model_metric_test.cpp | 3 + .../auto/tests/unit/dynamic_output_test.cpp | 1 + .../auto/tests/unit/release_helper_test.cpp | 5 +- .../auto/tests/unit/runtime_fallback_test.cpp | 3 + .../tests/unit/async_infer_request_test.cpp | 1 + .../tests/unit/sync_infer_request_test.cpp | 1 + .../intel_cpu/tests/functional/CMakeLists.txt | 15 +- .../intel_cpu/tests/unit/CMakeLists.txt | 11 +- 16 files changed, 241 insertions(+), 216 deletions(-) delete mode 100644 .github/workflows/linux_arm64.yml create mode 100644 .github/workflows/linux_riscv.yml diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index a00a5b9d0241eb..4321c532311458 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -263,7 +263,12 @@ jobs: /usr/share/openvino/samples/c/build_samples.sh ~/openvino_cpp_samples_build/intel64/Release/hello_query_device python3 /usr/share/openvino/samples/python/hello_query_device/hello_query_device.py - python3 -c 'from openvino import Core; print(Core().available_devices)' + python3 -c 'from openvino import Core; Core().get_property("CPU", "AVAILABLE_DEVICES")' + python3 -c 'from openvino import Core; Core().get_property("GPU", "AVAILABLE_DEVICES")' + python3 -c 'from openvino import Core; Core().get_property("AUTO", "SUPPORTED_METRICS")' + python3 -c 'from openvino import Core; Core().get_property("MULTI", "SUPPORTED_METRICS")' + python3 -c 'from openvino import Core; Core().get_property("HETERO", "SUPPORTED_METRICS")' + python3 -c 'from openvino import Core; Core().get_property("BATCH", "SUPPORTED_METRICS")' python3 -c 'from openvino.frontend import FrontEndManager; assert len(FrontEndManager().get_available_front_ends()) == 6' benchmark_app --help ovc --help diff --git a/.github/workflows/linux_arm64.yml b/.github/workflows/linux_arm64.yml deleted file mode 100644 index 117f4eee1594f2..00000000000000 --- a/.github/workflows/linux_arm64.yml +++ /dev/null @@ -1,199 +0,0 @@ -name: Linux ARM64 with Conan (Ubuntu 20.04, Python 3.11) -on: - schedule: - # run daily at 00:00 - - cron: '0 0 * * *' - workflow_dispatch: -# pull_request: -# paths-ignore: -# - '**/docs/**' -# - 'docs/**' -# - '**/**.md' -# - '**.md' -# - '**/layer_tests_summary/**' -# - '**/conformance/**' -# push: -# paths-ignore: -# - '**/docs/**' -# - 'docs/**' -# - '**/**.md' -# - '**.md' -# - '**/layer_tests_summary/**' -# - '**/conformance/**' -# branches: -# - master - -concurrency: - group: ${{ github.head_ref || github.run_id }}-linux-arm64 - cancel-in-progress: true - -jobs: - Build: - # TODO: remove. Temporary measure to prevent the workflow from scheduling on forks. - if: ${{ github.repository_owner == 'openvinotoolkit' }} - defaults: - run: - shell: bash - runs-on: ubuntu-20.04-8-cores - env: - CMAKE_BUILD_TYPE: 'Release' - CMAKE_GENERATOR: 'Ninja' - CMAKE_CXX_COMPILER_LAUNCHER: ccache - CMAKE_C_COMPILER_LAUNCHER: ccache - BUILD_TYPE: Release - OPENVINO_REPO: ${{ github.workspace }}/openvino - BUILD_DIR: ${{ github.workspace }}/build - INSTALL_DIR: ${{ github.workspace }}/install - OV_TEMP: ${{ github.workspace }}/openvino_temp - steps: - - name: Clone OpenVINO - uses: actions/checkout@v4 - with: - path: 'openvino' - - - name: Init submodules for non Conan dependencies - run: | - pushd ${{ env.OPENVINO_REPO }} - git submodule update --init -- ${{ env.OPENVINO_REPO }}/src/plugins - git submodule update --init -- ${{ env.OPENVINO_REPO }}/thirdparty/gtest - git submodule update --init -- ${{ env.OPENVINO_REPO }}/thirdparty/open_model_zoo - popd - - - name: Setup Python 3.11 - uses: actions/setup-python@v4 - with: - python-version: '3.11' - - # - # Dependencies - # - - - name: Install build dependencies - run: | - sudo -E apt update - # install dependencies needed to build CPU plugin for ARM - sudo -E apt --assume-yes install scons gcc-10-aarch64-linux-gnu g++-10-aarch64-linux-gnu - # generic dependencies - sudo -E apt --assume-yes install cmake ccache ninja-build unzip fdupes - - - name: Install python dependencies - run: | - python3 -m pip install --upgrade pip - python3 -m pip install -r ${{ env.OPENVINO_REPO }}/src/bindings/python/requirements.txt - python3 -m pip install -r ${{ env.OPENVINO_REPO }}/src/bindings/python/wheel/requirements-dev.txt - python3 -m pip install -r ${{ env.OPENVINO_REPO }}/src/bindings/python/src/compatibility/openvino/requirements-dev.txt - - - name: Install arm64 libraries - run: | - echo deb [arch=amd64] http://archive.ubuntu.com/ubuntu/ focal main restricted > arm64-sources.list - echo deb [arch=amd64] http://archive.ubuntu.com/ubuntu/ focal-updates main restricted >> arm64-sources.list - echo deb [arch=amd64] http://archive.ubuntu.com/ubuntu/ focal universe >> arm64-sources.list - echo deb [arch=amd64] http://archive.ubuntu.com/ubuntu/ focal-updates universe >> arm64-sources.list - echo deb [arch=amd64] http://archive.ubuntu.com/ubuntu/ focal multiverse >> arm64-sources.list - echo deb [arch=amd64] http://archive.ubuntu.com/ubuntu/ focal-updates multiverse >> arm64-sources.list - echo deb [arch=amd64] http://archive.ubuntu.com/ubuntu/ focal-backports main restricted universe multiverse >> arm64-sources.list - echo deb [arch=amd64] http://security.ubuntu.com/ubuntu/ focal-security main restricted >> arm64-sources.list - echo deb [arch=amd64] http://security.ubuntu.com/ubuntu/ focal-security universe >> arm64-sources.list - echo deb [arch=amd64] http://security.ubuntu.com/ubuntu/ focal-security multiverse >> arm64-sources.list - echo deb [arch=arm64] http://ports.ubuntu.com/ubuntu-ports/ focal main >> arm64-sources.list - echo deb [arch=arm64] http://ports.ubuntu.com/ubuntu-ports/ focal universe >> arm64-sources.list - echo deb [arch=arm64] http://ports.ubuntu.com/ubuntu-ports/ focal-updates main >> arm64-sources.list - echo deb [arch=arm64] http://ports.ubuntu.com/ubuntu-ports/ focal-security main >> arm64-sources.list - sudo mv arm64-sources.list /etc/apt/sources.list.d/ - sudo -E dpkg --add-architecture arm64 - sudo -E apt-get update -o Dir::Etc::sourcelist=/etc/apt/sources.list.d/arm64-sources.list - sudo -E apt-get install -y --no-install-recommends libpython3-dev:arm64 - - - name: Setup ccache - uses: hendrikmuhs/ccache-action@v1.2 - with: - max-size: "2000M" - # Should save cache only if run in the master branch of the base repo - # github.ref_name is 'ref/PR_#' in case of the PR, and 'branch_name' when executed on push - save: ${{ github.ref_name == 'master' && 'true' || 'false' }} - verbose: 2 - key: ${{ github.job }}-linux-arm64 - restore-keys: | - ${{ github.job }}-linux-arm64 - - - name: Install conan and dependencies - run: | - - # create build directory - mkdir -p ${{ env.BUILD_DIR }} - - python3 -m pip install conan - # install build profile compilers - sudo -E apt --assume-yes install gcc g++ - # generate build profile - conan profile detect - # generate host profile for linux_arm64 - echo "include(default)" > ${{ env.BUILD_DIR }}/linux_arm64 - echo "[buildenv]" >> ${{ env.BUILD_DIR }}/linux_arm64 - echo "CC=aarch64-linux-gnu-gcc-10" >> ${{ env.BUILD_DIR }}/linux_arm64 - echo "CXX=aarch64-linux-gnu-g++-10" >> ${{ env.BUILD_DIR }}/linux_arm64 - # install OpenVINO dependencies - conan install ${{ env.OPENVINO_REPO }}/conanfile.txt \ - -pr:h ${{ env.BUILD_DIR }}/linux_arm64 \ - -s:h arch=armv8 \ - -of ${{ env.BUILD_DIR }}/dependencies \ - -b missing - - # - # Build - # - - - name: Get number of CPU cores - uses: SimenB/github-actions-cpu-cores@v2 - id: cpu-cores - - - name: CMake configure - run: | - source ${{ env.BUILD_DIR }}/dependencies/conanbuild.sh - cmake \ - -G Ninja \ - -DCMAKE_VERBOSE_MAKEFILE=ON \ - -DBUILD_SHARED_LIBS=OFF \ - -DCMAKE_COMPILE_WARNING_AS_ERROR=OFF \ - -DENABLE_CPPLINT=ON \ - -DENABLE_INTEL_GPU=ON \ - -DENABLE_PYTHON=ON \ - -DENABLE_WHEEL=ON \ - -DPYBIND11_PYTHONLIBS_OVERWRITE=OFF \ - -DPYTHON_MODULE_EXTENSION=$(aarch64-linux-gnu-python3-config --extension-suffix) \ - -DPython3_INCLUDE_DIR=$(python3 -c "import sysconfig; print(sysconfig.get_path('include'))") \ - -DENABLE_TESTS=ON \ - -DENABLE_SYSTEM_TBB=ON \ - -DENABLE_SYSTEM_PROTOBUF=ON \ - -DENABLE_SYSTEM_SNAPPY=ON \ - -DENABLE_SYSTEM_PUGIXML=ON \ - -DCMAKE_TOOLCHAIN_FILE=${{ env.BUILD_DIR }}/dependencies/conan_toolchain.cmake \ - -DCMAKE_CXX_COMPILER_LAUNCHER=ccache \ - -DCMAKE_C_COMPILER_LAUNCHER=ccache \ - -DARM_COMPUTE_SCONS_JOBS=${{ steps.cpu-cores.outputs.count }} \ - -DCMAKE_INSTALL_PREFIX=${{ env.INSTALL_DIR }} \ - -DCMAKE_BUILD_TYPE=${{ env.BUILD_TYPE }} \ - -DENABLE_PYTHON_PACKAGING=ON \ - -S ${{ env.OPENVINO_REPO }} \ - -B ${{ env.BUILD_DIR }} - source ${{ env.BUILD_DIR }}/dependencies/deactivate_conanbuild.sh - - - name: Clean ccache stats - run: ccache --zero-stats --show-config - - - name: Build OpenVINO Runtime - run: cmake --build ${{ env.BUILD_DIR }} --parallel ${{ steps.cpu-cores.outputs.count }} --config ${{ env.BUILD_TYPE }} - - - name: Show ccache stats - run: ccache --show-stats - - - name: Install OpenVINO Runtime - run: cmake --build ${{ env.BUILD_DIR }} --parallel ${{ steps.cpu-cores.outputs.count }} --config ${{ env.BUILD_TYPE }} --target install - - - name: Build OpenVINO C++ samples - run: | - source ${{ env.BUILD_DIR }}/dependencies/conanbuild.sh - ${{ env.INSTALL_DIR }}/samples/cpp/build_samples.sh - source ${{ env.BUILD_DIR }}/dependencies/deactivate_conanbuild.sh - env: - CMAKE_TOOLCHAIN_FILE: ${{ env.BUILD_DIR }}/dependencies/conan_toolchain.cmake diff --git a/.github/workflows/linux_riscv.yml b/.github/workflows/linux_riscv.yml new file mode 100644 index 00000000000000..4593974d54475a --- /dev/null +++ b/.github/workflows/linux_riscv.yml @@ -0,0 +1,188 @@ +name: Linux RISC-V with Conan (Ubuntu 22.04, Python 3.10) +on: + schedule: + # at 00:00 on Wednesday and Saturday + - cron: '0 0 * * 3,6' + workflow_dispatch: + pull_request: + paths-ignore: + - '**/docs/**' + - 'docs/**' + - '**/**.md' + - '**.md' + - '**/layer_tests_summary/**' + - '**/conformance/**' + push: + paths-ignore: + - '**/docs/**' + - 'docs/**' + - '**/**.md' + - '**.md' + - '**/layer_tests_summary/**' + - '**/conformance/**' + branches: + - master + - 'releases/**' + +concurrency: + # github.ref is not unique in post-commit + group: ${{ github.event_name == 'push' && github.run_id || github.ref }}-linux-riscv + cancel-in-progress: true + +jobs: + Build: + defaults: + run: + shell: bash + runs-on: aks-linux-16-cores + container: + image: ubuntu:22.04 + volumes: + - /mount/caches:/mount/caches + env: + CMAKE_BUILD_TYPE: 'Release' + CMAKE_GENERATOR: 'Ninja' + CMAKE_CXX_COMPILER_LAUNCHER: ccache + CMAKE_C_COMPILER_LAUNCHER: ccache + OPENVINO_REPO: /__w/openvino/openvino/openvino + OPENVINO_BUILD_DIR: /__w/openvino/openvino/openvino_build + INSTALL_DIR: /__w/openvino/openvino/openvino_install + CONAN_USER_HOME: /mount/caches/ccache/ubuntu22_riscv64_Release/.conan + CCACHE_DIR: /mount/caches/ccache/ubuntu22_riscv64_Release + CCACHE_TEMPDIR: /__w/openvino/openvino/ccache_temp + CCACHE_MAXSIZE: 50G + steps: + - name: Install git + run: apt-get update && apt-get install --assume-yes --no-install-recommends git ca-certificates + + - name: Clone OpenVINO + uses: actions/checkout@v4 + with: + path: 'openvino' + + - name: Init submodules for non-Conan dependencies + run: | + pushd ${OPENVINO_REPO} + git submodule update --init -- ${OPENVINO_REPO}/src/plugins/intel_cpu + git submodule update --init -- ${OPENVINO_REPO}/thirdparty/gtest + git submodule update --init -- ${OPENVINO_REPO}/thirdparty/open_model_zoo + popd + + # + # Dependencies + # + + - name: Install build dependencies + run: | + # create build directory + mkdir -p ${OPENVINO_BUILD_DIR} + + # install compilers to build OpenVINO for RISC-V 64 + apt --assume-yes install gcc-riscv64-linux-gnu g++-riscv64-linux-gnu + apt --assume-yes install gcc g++ python3-pip python3-venv python3-dev + # generic dependencies + apt --assume-yes install cmake ccache ninja-build fdupes patchelf + + python3 -m venv ${OPENVINO_BUILD_DIR}/env + source ${OPENVINO_BUILD_DIR}/env/bin/activate + python3 -m pip install -r ${OPENVINO_REPO}/src/bindings/python/requirements.txt + python3 -m pip install -r ${OPENVINO_REPO}/src/bindings/python/wheel/requirements-dev.txt + python3 -m pip install -r ${OPENVINO_REPO}/src/bindings/python/src/compatibility/openvino/requirements-dev.txt + python3 -m pip install conan + + - name: Install RISC-V native debian packages + run: | + echo deb [arch=amd64] http://archive.ubuntu.com/ubuntu/ jammy main restricted > riscv64-sources.list + echo deb [arch=amd64] http://archive.ubuntu.com/ubuntu/ jammy-updates main restricted >> riscv64-sources.list + echo deb [arch=amd64] http://archive.ubuntu.com/ubuntu/ jammy universe >> riscv64-sources.list + echo deb [arch=amd64] http://archive.ubuntu.com/ubuntu/ jammy-updates universe >> riscv64-sources.list + echo deb [arch=amd64] http://archive.ubuntu.com/ubuntu/ jammy multiverse >> riscv64-sources.list + echo deb [arch=amd64] http://archive.ubuntu.com/ubuntu/ jammy-updates multiverse >> riscv64-sources.list + echo deb [arch=amd64] http://archive.ubuntu.com/ubuntu/ jammy-backports main restricted universe multiverse >> riscv64-sources.list + echo deb [arch=amd64] http://security.ubuntu.com/ubuntu/ jammy-security main restricted >> riscv64-sources.list + echo deb [arch=amd64] http://security.ubuntu.com/ubuntu/ jammy-security universe >> riscv64-sources.list + echo deb [arch=amd64] http://security.ubuntu.com/ubuntu/ jammy-security multiverse >> riscv64-sources.list + echo deb [arch=riscv64] http://ports.ubuntu.com/ubuntu-ports/ jammy main >> riscv64-sources.list + echo deb [arch=riscv64] http://ports.ubuntu.com/ubuntu-ports/ jammy universe >> riscv64-sources.list + echo deb [arch=riscv64] http://ports.ubuntu.com/ubuntu-ports/ jammy-updates main >> riscv64-sources.list + echo deb [arch=riscv64] http://ports.ubuntu.com/ubuntu-ports/ jammy-security main >> riscv64-sources.list + mv riscv64-sources.list /etc/apt/sources.list.d/ + dpkg --add-architecture riscv64 + apt-get update -o Dir::Etc::sourcelist=/etc/apt/sources.list.d/riscv64-sources.list + apt-get install -y --no-install-recommends libpython3-dev:riscv64 + + - name: Create conan_toolchain.cmake file + run: | + source ${OPENVINO_BUILD_DIR}/env/bin/activate + # generate build profile + conan profile detect + # patch settings.yml to contain riscv64 architecture + sed -i 's/sparcv9/riscv64/g' ~/.conan2/settings.yml + # generate host profile for linux_riscv64 + echo "include(default)" > ${OPENVINO_BUILD_DIR}/linux_riscv64 + echo "[buildenv]" >> ${OPENVINO_BUILD_DIR}/linux_riscv64 + echo "CC=riscv64-linux-gnu-gcc" >> ${OPENVINO_BUILD_DIR}/linux_riscv64 + echo "CXX=riscv64-linux-gnu-g++" >> ${OPENVINO_BUILD_DIR}/linux_riscv64 + # install OpenVINO dependencies + conan install ${OPENVINO_REPO}/conanfile.txt \ + -pr:h ${OPENVINO_BUILD_DIR}/linux_riscv64 \ + -s:h arch=riscv64 \ + -s:h build_type=${CMAKE_BUILD_TYPE} \ + -o:h onetbb/*:tbbbind=False \ + -of ${OPENVINO_BUILD_DIR}/dependencies \ + -b missing + + # + # Build + # + + - name: CMake - Configure + run: | + source ${OPENVINO_BUILD_DIR}/env/bin/activate + source ${OPENVINO_BUILD_DIR}/dependencies/conanbuild.sh + cmake \ + -G 'Ninja' \ + -DENABLE_CPPLINT=OFF \ + -DENABLE_INTEL_GPU=ON \ + -DENABLE_PYTHON=ON \ + -DENABLE_WHEEL=ON \ + -DPYTHON_MODULE_EXTENSION=$(riscv64-linux-gnu-python3-config --extension-suffix) \ + -DPython3_INCLUDE_DIR=$(python3 -c "import sysconfig; print(sysconfig.get_path('include'))") \ + -DPYBIND11_PYTHON_EXECUTABLE_LAST=${OPENVINO_BUILD_DIR}/env/bin/python3.10 \ + -DENABLE_TESTS=ON \ + -DTHREADING=SEQ \ + -DENABLE_PYTHON_PACKAGING=ON \ + -DENABLE_SYSTEM_TBB=ON \ + -DENABLE_SYSTEM_PROTOBUF=ON \ + -DENABLE_SYSTEM_SNAPPY=ON \ + -DENABLE_SYSTEM_PUGIXML=ON \ + -DBUILD_SHARED_LIBS=OFF \ + -DCMAKE_CXX_FLAGS="-Wno-deprecated-declarations" \ + -DCMAKE_C_FLAGS="-Wno-deprecated-declarations" \ + -DCMAKE_VERBOSE_MAKEFILE=ON \ + -DCMAKE_COMPILE_WARNING_AS_ERROR=OFF \ + -DCMAKE_TOOLCHAIN_FILE=${OPENVINO_BUILD_DIR}/dependencies/conan_toolchain.cmake \ + -DCMAKE_CXX_COMPILER_LAUNCHER=ccache \ + -DCMAKE_C_COMPILER_LAUNCHER=ccache \ + -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} \ + -DCMAKE_INSTALL_PREFIX=${INSTALL_DIR} \ + -S ${OPENVINO_REPO} \ + -B ${OPENVINO_BUILD_DIR} + source ${OPENVINO_BUILD_DIR}/dependencies/deactivate_conanbuild.sh + + - name: Cmake - Build + run: cmake --build ${OPENVINO_BUILD_DIR} --parallel + + - name: Show ccache stats + run: ccache --show-stats + + - name: Cmake - Install + run: cmake --build ${OPENVINO_BUILD_DIR} --parallel --target install + + - name: Build OpenVINO C++ samples + run: | + source ${OPENVINO_BUILD_DIR}/dependencies/conanbuild.sh + ${INSTALL_DIR}/samples/cpp/build_samples.sh + source ${OPENVINO_BUILD_DIR}/dependencies/deactivate_conanbuild.sh + env: + CMAKE_TOOLCHAIN_FILE: ${{ env.OPENVINO_BUILD_DIR }}/dependencies/conan_toolchain.cmake diff --git a/cmake/developer_package/add_ie_target.cmake b/cmake/developer_package/add_ie_target.cmake index b52e8b15dcf515..7d62b1f604cd9a 100644 --- a/cmake/developer_package/add_ie_target.cmake +++ b/cmake/developer_package/add_ie_target.cmake @@ -75,7 +75,7 @@ function(addIeTarget) file(GLOB_RECURSE sources ${sourceSearch}) # remove unnecessary directories - foreach(excludedDir ${ARG_EXCLUDED_SOURCE_PATHS}) + foreach(excludedDir IN LISTS ARG_EXCLUDED_SOURCE_PATHS) list(FILTER includes EXCLUDE REGEX "${excludedDir}.*") list(FILTER sources EXCLUDE REGEX "${excludedDir}.*") endforeach() diff --git a/src/cmake/openvino.cmake b/src/cmake/openvino.cmake index 302c263b024e7e..d187c007c75d2d 100644 --- a/src/cmake/openvino.cmake +++ b/src/cmake/openvino.cmake @@ -64,6 +64,11 @@ if(WIN32) set_target_properties(${TARGET_NAME} PROPERTIES COMPILE_PDB_NAME ${TARGET_NAME}) endif() +if(RISCV64) + # for std::atomic_bool + target_link_libraries(${TARGET_NAME} PRIVATE atomic) +endif() + ov_set_threading_interface_for(${TARGET_NAME}) ov_mark_target_as_cc(${TARGET_NAME}) diff --git a/src/core/tests/CMakeLists.txt b/src/core/tests/CMakeLists.txt index b5298b9e5eea3c..f8fb34acb349ae 100644 --- a/src/core/tests/CMakeLists.txt +++ b/src/core/tests/CMakeLists.txt @@ -65,6 +65,11 @@ target_compile_definitions(${TARGET_NAME} FRONTEND_LIB_SUFFIX="${FRONTEND_NAME_SUFFIX}${IE_BUILD_POSTFIX}${CMAKE_SHARED_LIBRARY_SUFFIX}" ) +if(RISCV64) + # for std::atomic_bool + target_link_libraries(${TARGET_NAME} PRIVATE atomic) +endif() + add_dependencies(${TARGET_NAME} ${UNIT_TESTS_DEPENDENCIES}) if (ENABLE_OV_ONNX_FRONTEND) diff --git a/src/inference/src/system_conf.cpp b/src/inference/src/system_conf.cpp index 72437e758b7695..b4fded633ffdb0 100644 --- a/src/inference/src/system_conf.cpp +++ b/src/inference/src/system_conf.cpp @@ -103,6 +103,9 @@ bool with_cpu_x86_avx() { bool with_cpu_x86_avx2() { return false; } +bool with_cpu_x86_avx2_vnni() { + return false; +} bool with_cpu_x86_avx512f() { return false; } diff --git a/src/plugins/auto/tests/unit/CMakeLists.txt b/src/plugins/auto/tests/unit/CMakeLists.txt index e4b392c8146a76..5088ce0d400f49 100644 --- a/src/plugins/auto/tests/unit/CMakeLists.txt +++ b/src/plugins/auto/tests/unit/CMakeLists.txt @@ -10,9 +10,13 @@ add_definitions(-DMULTIUNITTEST) ov_add_test_target( NAME ${TARGET_NAME} ROOT ${CMAKE_CURRENT_SOURCE_DIR} - ADDITIONAL_SOURCE_DIRS ${OpenVINO_SOURCE_DIR}/src/plugins/auto/src ${OpenVINO_SOURCE_DIR}/src/plugins/auto/src/utils + ADDITIONAL_SOURCE_DIRS + ${OpenVINO_SOURCE_DIR}/src/plugins/auto/src + ${OpenVINO_SOURCE_DIR}/src/plugins/auto/src/utils INCLUDES - ${OpenVINO_SOURCE_DIR}/src/plugins/auto ${CMAKE_CURRENT_SOURCE_DIR} ${OpenVINO_SOURCE_DIR}/src/plugins/auto/src + ${OpenVINO_SOURCE_DIR}/src/plugins/auto + ${CMAKE_CURRENT_SOURCE_DIR} + ${OpenVINO_SOURCE_DIR}/src/plugins/auto/src LINK_LIBRARIES ngraphFunctions unit_test_utils diff --git a/src/plugins/auto/tests/unit/compile_model_metric_test.cpp b/src/plugins/auto/tests/unit/compile_model_metric_test.cpp index 05161963605675..698c7deb03d990 100644 --- a/src/plugins/auto/tests/unit/compile_model_metric_test.cpp +++ b/src/plugins/auto/tests/unit/compile_model_metric_test.cpp @@ -1,6 +1,9 @@ // Copyright (C) 2018-2023 Intel Corporation // SPDX-License-Identifier: Apache-2.0 // + +#include + #include "include/auto_unit_test.hpp" #include "openvino/runtime/properties.hpp" diff --git a/src/plugins/auto/tests/unit/dynamic_output_test.cpp b/src/plugins/auto/tests/unit/dynamic_output_test.cpp index bac2334e00aa1b..0ff5c35c116d1d 100644 --- a/src/plugins/auto/tests/unit/dynamic_output_test.cpp +++ b/src/plugins/auto/tests/unit/dynamic_output_test.cpp @@ -5,6 +5,7 @@ #include #include #include "include/auto_unit_test.hpp" + using DynamicOutputConfigParams = std::tuple< ov::Any, // priority device list ov::Any // expected device to run inference on diff --git a/src/plugins/auto/tests/unit/release_helper_test.cpp b/src/plugins/auto/tests/unit/release_helper_test.cpp index 0ffd6e4d801aed..c90139bdd8f244 100644 --- a/src/plugins/auto/tests/unit/release_helper_test.cpp +++ b/src/plugins/auto/tests/unit/release_helper_test.cpp @@ -2,10 +2,11 @@ // SPDX-License-Identifier: Apache-2.0 // -#include -#include "include/auto_unit_test.hpp" #include +#include "common_test_utils/test_constants.hpp" +#include "include/auto_unit_test.hpp" + using Config = std::map; using namespace ov::mock_auto_plugin; diff --git a/src/plugins/auto/tests/unit/runtime_fallback_test.cpp b/src/plugins/auto/tests/unit/runtime_fallback_test.cpp index c344938fd95075..12158884c3fd64 100644 --- a/src/plugins/auto/tests/unit/runtime_fallback_test.cpp +++ b/src/plugins/auto/tests/unit/runtime_fallback_test.cpp @@ -1,6 +1,9 @@ // Copyright (C) 2018-2023 Intel Corporation // SPDX-License-Identifier: Apache-2.0 // + +#include + #include "include/auto_unit_test.hpp" #include "openvino/runtime/threading/immediate_executor.hpp" #include "openvino/runtime/auto/properties.hpp" diff --git a/src/plugins/auto_batch/tests/unit/async_infer_request_test.cpp b/src/plugins/auto_batch/tests/unit/async_infer_request_test.cpp index 48f7a92b98d0cd..2ff0b39f9c5d49 100644 --- a/src/plugins/auto_batch/tests/unit/async_infer_request_test.cpp +++ b/src/plugins/auto_batch/tests/unit/async_infer_request_test.cpp @@ -2,6 +2,7 @@ // SPDX-License-Identifier: Apache-2.0 // +#include #include #include diff --git a/src/plugins/auto_batch/tests/unit/sync_infer_request_test.cpp b/src/plugins/auto_batch/tests/unit/sync_infer_request_test.cpp index 95713fea538a8f..6cdef3fb0bf172 100644 --- a/src/plugins/auto_batch/tests/unit/sync_infer_request_test.cpp +++ b/src/plugins/auto_batch/tests/unit/sync_infer_request_test.cpp @@ -2,6 +2,7 @@ // SPDX-License-Identifier: Apache-2.0 // +#include #include #include diff --git a/src/plugins/intel_cpu/tests/functional/CMakeLists.txt b/src/plugins/intel_cpu/tests/functional/CMakeLists.txt index f79ca57304524c..f0127f0bb71099 100644 --- a/src/plugins/intel_cpu/tests/functional/CMakeLists.txt +++ b/src/plugins/intel_cpu/tests/functional/CMakeLists.txt @@ -19,14 +19,11 @@ else() set(EXCLUDED_SOURCE_PATHS ${CMAKE_CURRENT_SOURCE_DIR}/extension ${CMAKE_CURRENT_SOURCE_DIR}/shared_tests_instances/onnx) endif() -if(X86_64) +if(NOT (ARM OR AARCH64)) list(APPEND EXCLUDED_SOURCE_PATHS - ${CMAKE_CURRENT_SOURCE_DIR}/single_layer_tests/instances/arm - ${CMAKE_CURRENT_SOURCE_DIR}/subgraph_tests/src/arm) + ${CMAKE_CURRENT_SOURCE_DIR}/single_layer_tests/instances/arm + ${CMAKE_CURRENT_SOURCE_DIR}/subgraph_tests/src/arm) else() - list(APPEND EXCLUDED_SOURCE_PATHS - ${CMAKE_CURRENT_SOURCE_DIR}/single_layer_tests/instances/x64 - ${CMAKE_CURRENT_SOURCE_DIR}/subgraph_tests/src/x64) # temporary disable all custom tests for ARM list(APPEND EXCLUDED_SOURCE_PATHS ${CMAKE_CURRENT_SOURCE_DIR}/single_layer_tests @@ -41,6 +38,12 @@ else() set(TMP_EXPLICITLY_ENABLED_TESTS "${TMP_LIST_OF_EXPLICITLY_ENABLED_TESTS}") endif() +if(NOT X86_64) + list(APPEND EXCLUDED_SOURCE_PATHS + ${CMAKE_CURRENT_SOURCE_DIR}/single_layer_tests/instances/x64 + ${CMAKE_CURRENT_SOURCE_DIR}/subgraph_tests/src/x64) +endif() + addIeTargetTest( NAME ${TARGET_NAME} ROOT ${CMAKE_CURRENT_SOURCE_DIR} diff --git a/src/plugins/intel_cpu/tests/unit/CMakeLists.txt b/src/plugins/intel_cpu/tests/unit/CMakeLists.txt index eed1959c799fb3..6c986d2d8c79f4 100644 --- a/src/plugins/intel_cpu/tests/unit/CMakeLists.txt +++ b/src/plugins/intel_cpu/tests/unit/CMakeLists.txt @@ -12,11 +12,13 @@ if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") ov_add_compiler_flags(/wd5051) endif() -if (X86_64) - set(EXCLUDED_SOURCE_PATHS_FOR_UNIT_TEST +if(NOT (ARM OR AARCH64)) + list(APPEND EXCLUDED_SOURCE_PATHS_FOR_UNIT_TEST ${CMAKE_CURRENT_SOURCE_DIR}/ngraph_transformations/arm) -else() - set(EXCLUDED_SOURCE_PATHS_FOR_UNIT_TEST +endif() + +if(NOT X86_64) + list(APPEND EXCLUDED_SOURCE_PATHS_FOR_UNIT_TEST ${CMAKE_CURRENT_SOURCE_DIR}/jit_kernel_test.cpp ${CMAKE_CURRENT_SOURCE_DIR}/registers_pool.cpp ${CMAKE_CURRENT_SOURCE_DIR}/ngraph_transformations/x64 @@ -25,7 +27,6 @@ else() endif() if (NOT ENABLE_MLAS_FOR_CPU) - set(MLAS_LIBRARY "") list(APPEND EXCLUDED_SOURCE_PATHS_FOR_UNIT_TEST ${CMAKE_CURRENT_SOURCE_DIR}/gemm_api_test.cpp) else() set(MLAS_LIBRARY "mlas") From 5079c50bb8fb300d0ee63822b3a70109ab7497a8 Mon Sep 17 00:00:00 2001 From: Sonder <55493212+AndSonder@users.noreply.github.com> Date: Wed, 27 Sep 2023 16:26:17 +0800 Subject: [PATCH 4/5] Update the regular syntax in cmakelist (#20066) --- src/bindings/python/src/pyopenvino/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bindings/python/src/pyopenvino/CMakeLists.txt b/src/bindings/python/src/pyopenvino/CMakeLists.txt index 977a970e8095f2..5d5aeeb40021ac 100644 --- a/src/bindings/python/src/pyopenvino/CMakeLists.txt +++ b/src/bindings/python/src/pyopenvino/CMakeLists.txt @@ -60,7 +60,7 @@ endif() # create target file(GLOB_RECURSE SOURCES core/*.cpp graph/*.cpp frontend/*.cpp utils/*.cpp pyopenvino.cpp) -list(FILTER SOURCES EXCLUDE REGEX frontend/onnx|tensorflow|paddle|pytorch/* ) +list(FILTER SOURCES EXCLUDE REGEX ".*(frontend/(onnx|tensorflow|paddle|pytorch))/*") pybind11_add_module(${PROJECT_NAME} MODULE NO_EXTRAS ${SOURCES}) From b5f4087f66d3415d510f9fcc91f0b552c251f81b Mon Sep 17 00:00:00 2001 From: Andrei Beleiu Date: Wed, 27 Sep 2023 12:06:06 +0300 Subject: [PATCH 5/5] [transformations][WeightsDequantizeToFakeQuantize] Extend pattern matching (#19772) * [transformations] WeightsDequantizeToFakeQuantize: Extend pattern matching with the case when both Subtract inputs are Convert * [transformations] WeightsDequantizeToFakeQuantize: Added new tests to cover the extention added to pattern match * Fix review comments --- .../weights_dequantize_to_fake_quantize.cpp | 24 ++++++--- .../weights_dequantize_to_fake_quantize.cpp | 52 +++++++++++++++---- 2 files changed, 59 insertions(+), 17 deletions(-) diff --git a/src/common/transformations/src/transformations/common_optimizations/weights_dequantize_to_fake_quantize.cpp b/src/common/transformations/src/transformations/common_optimizations/weights_dequantize_to_fake_quantize.cpp index 7a4e0ebaa62e47..582d48917f5bd6 100644 --- a/src/common/transformations/src/transformations/common_optimizations/weights_dequantize_to_fake_quantize.cpp +++ b/src/common/transformations/src/transformations/common_optimizations/weights_dequantize_to_fake_quantize.cpp @@ -21,10 +21,13 @@ ov::pass::WeightsDequantizeToFakeQuantize::WeightsDequantizeToFakeQuantize() { const auto weights = ov::pass::pattern::wrap_type(pattern::type_matches(element::i8)); const auto convert = ov::pass::pattern::wrap_type({weights}); + const auto sub_c_integer = ov::pass::pattern::wrap_type(pattern::type_matches(element::i8)); + const auto convert_sub_c_integer = ov::pass::pattern::wrap_type({sub_c_integer}); + const auto sub_integer = ov::pass::pattern::wrap_type({convert, convert_sub_c_integer}); const auto sub_c = ov::pass::pattern::wrap_type(); const auto sub = ov::pass::pattern::wrap_type({convert, sub_c}); - - const auto sub_or_convert = std::make_shared(OutputVector{convert, sub}); + const auto sub_or_sub_integer = std::make_shared(OutputVector{sub_integer, sub}); + const auto sub_or_convert = std::make_shared(OutputVector{convert, sub_or_sub_integer}); const auto mul_c = ov::pass::pattern::wrap_type(); const auto mul = ov::pass::pattern::wrap_type({sub_or_convert, mul_c}); @@ -32,7 +35,6 @@ ov::pass::WeightsDequantizeToFakeQuantize::WeightsDequantizeToFakeQuantize() { ov::matcher_pass_callback callback; callback = [=](ov::pass::pattern::Matcher& m) { const auto& pattern_map = m.get_pattern_map(); - const auto& weights_node = ov::as_type_ptr(pattern_map.at(weights)); const auto& convert_node = pattern_map.at(convert); const auto& multiply_node = pattern_map.at(mul); @@ -48,10 +50,18 @@ ov::pass::WeightsDequantizeToFakeQuantize::WeightsDequantizeToFakeQuantize() { const auto& input_low = ov::op::v0::Constant::create(convert_node->get_element_type(), {}, {in_low}); const auto& input_high = ov::op::v0::Constant::create(convert_node->get_element_type(), {}, {in_high}); - - auto& zero_point = pattern_map.count(sub_c) - ? pattern_map.at(sub_c) - : ov::op::v0::Constant::create(convert_node->get_element_type(), {}, {0}); + std::shared_ptr zero_point; + if (pattern_map.count(sub_c)) { + const auto& sub_c_node = ov::as_type_ptr(pattern_map.at(sub_c)); + zero_point = sub_c_node; + } else if (pattern_map.count(sub_c_integer)) { + const auto& sub_c_integer_node = ov::as_type_ptr(pattern_map.at(sub_c_integer)); + zero_point = ov::op::v0::Constant::create(convert_node->get_element_type(), + sub_c_integer_node->get_output_shape(0), + sub_c_integer_node->get_vector()); + } else { + zero_point = ov::op::v0::Constant::create(convert_node->get_element_type(), {}, {0}); + } const auto& output_low = op::util::eltwise_fold( op::util::eltwise_fold(input_low, zero_point), diff --git a/src/common/transformations/tests/common_optimizations/weights_dequantize_to_fake_quantize.cpp b/src/common/transformations/tests/common_optimizations/weights_dequantize_to_fake_quantize.cpp index 5ef8239896fdf5..bac86a3b9676aa 100644 --- a/src/common/transformations/tests/common_optimizations/weights_dequantize_to_fake_quantize.cpp +++ b/src/common/transformations/tests/common_optimizations/weights_dequantize_to_fake_quantize.cpp @@ -18,9 +18,20 @@ using namespace ov; using namespace testing; +enum class ZPType { INT8_T, FLOAT }; + +union FloatInt8Union { + FloatInt8Union(int8_t val) : int8_val{val} {} + FloatInt8Union(float val) : float_val{val} {} + int8_t int8_val; + float float_val; +}; + struct FQ_as_Mul_Sub_dequantize { int8_t min_int, max_int; - float zp, scale; + ZPType zp_type; + FloatInt8Union zp; + float scale; float o_low, o_high; size_t levels; }; @@ -40,15 +51,28 @@ class TranslateNewWeightFormatToOldOne auto i_weights = std::make_shared(element::i8, Shape{weights.size()}, weights); auto f_weights = std::make_shared(i_weights, float_element_type); - - auto zp = std::make_shared(float_element_type, Shape{}, std::vector{test_case.zp}); - auto subtract_zp = std::make_shared(f_weights, zp); + std::shared_ptr subtract_zp; + float zp; + if (test_case.zp_type == ZPType::FLOAT) { + auto f_zp = std::make_shared(float_element_type, + Shape{}, + std::vector{test_case.zp.float_val}); + subtract_zp = std::make_shared(f_weights, f_zp); + zp = test_case.zp.float_val; + } else { + auto i_zp = std::make_shared(element::i8, + Shape{}, + std::vector{test_case.zp.int8_val}); + auto f_zp = std::make_shared(i_zp, float_element_type); + subtract_zp = std::make_shared(f_weights, f_zp); + zp = test_case.zp.int8_val; + } auto scale = std::make_shared(float_element_type, Shape{}, std::vector{test_case.scale}); NodeVector output; - if (test_case.zp == 0) + if (zp == 0) output.push_back(std::make_shared(f_weights, scale)); else output.push_back(std::make_shared(subtract_zp, scale)); @@ -97,11 +121,19 @@ TEST_P(TranslateNewWeightFormatToOldOne, ReshapeMatMul) { ASSERT_TRUE(res.valid) << res.message; } +// clang-format off INSTANTIATE_TEST_SUITE_P( NGraph, TranslateNewWeightFormatToOldOne, - testing::Combine(testing::Values(FQ_as_Mul_Sub_dequantize{-128, 127, 1, 2, (-128 - 1) * 2, (127 - 1) * 2, 256}, - FQ_as_Mul_Sub_dequantize{-127, 127, 1, 2, (-127 - 1) * 2, (127 - 1) * 2, 255}, - FQ_as_Mul_Sub_dequantize{-128, 127, 0, 2, (-128 - 0) * 2, (127 - 0) * 2, 256}, - FQ_as_Mul_Sub_dequantize{-127, 127, 0, 2, (-127 - 0) * 2, (127 - 0) * 2, 255}), - testing::Values(element::f32, element::f16))); + testing::Combine( + testing::Values( + FQ_as_Mul_Sub_dequantize{-128, 127, ZPType::FLOAT, 1.0f, 2, (-128 - 1) * 2, (127 - 1) * 2, 256}, + FQ_as_Mul_Sub_dequantize{-127, 127, ZPType::FLOAT, 1.0f, 2, (-127 - 1) * 2, (127 - 1) * 2, 255}, + FQ_as_Mul_Sub_dequantize{-128, 127, ZPType::FLOAT, 0.0f, 2, (-128 - 0) * 2, (127 - 0) * 2, 256}, + FQ_as_Mul_Sub_dequantize{-127, 127, ZPType::FLOAT, 0.0f, 2, (-127 - 0) * 2, (127 - 0) * 2, 255}, + FQ_as_Mul_Sub_dequantize{-128, 127, ZPType::INT8_T, (int8_t)1, 2, (-128 - 1) * 2, (127 - 1) * 2, 256}, + FQ_as_Mul_Sub_dequantize{-127, 127, ZPType::INT8_T, (int8_t)1, 2, (-127 - 1) * 2, (127 - 1) * 2, 255}, + FQ_as_Mul_Sub_dequantize{-128, 127, ZPType::INT8_T, (int8_t)0, 2, (-128 - 0) * 2, (127 - 0) * 2, 256}, + FQ_as_Mul_Sub_dequantize{-127, 127, ZPType::INT8_T, (int8_t)0, 2, (-127 - 0) * 2, (127 - 0) * 2, 255}), + testing::Values(element::f32, element::f16))); +// clang-format on