From f107b7663fa17434d07b6cc249a6645a96192a68 Mon Sep 17 00:00:00 2001 From: Pawel Raasz Date: Mon, 16 Oct 2023 06:16:43 +0200 Subject: [PATCH 01/12] Migrate Split operator to new API (#20263) --- src/core/include/openvino/op/split.hpp | 5 +- .../include/openvino/reference/split.hpp | 17 ++- src/core/reference/src/op/split.cpp | 42 ++++--- src/core/src/op/split.cpp | 110 +++++++++--------- 4 files changed, 97 insertions(+), 77 deletions(-) diff --git a/src/core/include/openvino/op/split.hpp b/src/core/include/openvino/op/split.hpp index 918457c0d84a05..6137f0591cfba1 100644 --- a/src/core/include/openvino/op/split.hpp +++ b/src/core/include/openvino/op/split.hpp @@ -39,9 +39,8 @@ class OPENVINO_API Split : public Op { void set_num_splits(const size_t num_splits) { m_num_splits = num_splits; } - OPENVINO_SUPPRESS_DEPRECATED_START - bool evaluate(const HostTensorVector& outputs, const HostTensorVector& inputs) const override; - OPENVINO_SUPPRESS_DEPRECATED_END + + bool evaluate(TensorVector& outputs, const TensorVector& inputs) const override; bool evaluate_lower(TensorVector& outputs) const override; bool evaluate_upper(TensorVector& outputs) const override; bool has_evaluate() const override; diff --git a/src/core/reference/include/openvino/reference/split.hpp b/src/core/reference/include/openvino/reference/split.hpp index dcbede1883a409..6e3564ed035bb1 100644 --- a/src/core/reference/include/openvino/reference/split.hpp +++ b/src/core/reference/include/openvino/reference/split.hpp @@ -4,17 +4,28 @@ #pragma once -#include +#include -#include "openvino/reference/slice.hpp" +#include "openvino/core/shape.hpp" namespace ov { namespace reference { + +/** + * @brief Reference implementation of Split operator. + * + * @param data Pointer to input data. + * @param data_shape Input data shape. + * @param elem_size Size of single element type. + * @param axis Axis used for split input data. + * @param num_splits Number of splits + * @param out_data Pointer to output data pointers (must have size of num_splits) + */ void split(const char* data, const Shape& data_shape, size_t elem_size, int64_t axis, size_t num_splits, char** out_data); -} +} // namespace reference } // namespace ov diff --git a/src/core/reference/src/op/split.cpp b/src/core/reference/src/op/split.cpp index 6186bdd5af941d..855fc29c4a1be9 100644 --- a/src/core/reference/src/op/split.cpp +++ b/src/core/reference/src/op/split.cpp @@ -6,35 +6,43 @@ #include -#include +#include -using namespace ov; +#include "openvino/core/coordinate.hpp" +#include "openvino/reference/slice.hpp" -void reference::split(const char* data, - const Shape& data_shape, - size_t elem_size, - int64_t axis, - size_t num_splits, - char** out_data) { +namespace ov { +namespace reference { + +void split(const char* data, + const Shape& data_shape, + const size_t elem_size, + const int64_t axis, + const size_t num_splits, + char** out_data) { const size_t part_length = data_shape.at(axis) / num_splits; - Shape output_shape = data_shape; - output_shape.at(axis) = part_length; + auto output_shape = data_shape; + output_shape[axis] = part_length; - std::vector lower_bounds(data_shape.size(), 0); - std::vector upper_bounds = data_shape; - upper_bounds.at(axis) = part_length; + Coordinate lower_bounds(data_shape.size(), 0); + Coordinate upper_bounds = output_shape; + auto& lb_at_axis = lower_bounds[axis]; + auto& ub_at_axis = upper_bounds[axis]; - for (size_t i = 0; i < num_splits; ++i) { + const auto out_last = std::next(out_data, num_splits); + for (auto out_first = out_data; out_first != out_last; ++out_first) { reference::slice(data, - out_data[i], + *out_first, data_shape, lower_bounds, upper_bounds, Strides(lower_bounds.size(), 1), output_shape, elem_size); - lower_bounds.at(axis) += part_length; - upper_bounds.at(axis) += part_length; + lb_at_axis += part_length; + ub_at_axis += part_length; } } +} // namespace reference +} // namespace ov diff --git a/src/core/src/op/split.cpp b/src/core/src/op/split.cpp index dc2ac72b509db7..4c5563e892321c 100644 --- a/src/core/src/op/split.cpp +++ b/src/core/src/op/split.cpp @@ -2,42 +2,46 @@ // SPDX-License-Identifier: Apache-2.0 // -#include "openvino/reference/split.hpp" +#include "openvino/op/split.hpp" #include -#include #include "bound_evaluate.hpp" #include "itt.hpp" -#include "ngraph/attribute_visitor.hpp" -#include "ngraph/builder/split.hpp" -#include "ngraph/op/constant.hpp" -#include "ngraph/op/split.hpp" -#include "ngraph/op/util/op_types.hpp" -#include "ngraph/runtime/host_tensor.hpp" -#include "ngraph/validation_util.hpp" - -using namespace std; -using namespace ngraph; - -op::v1::Split::Split(const Output& data, const Output& axis, const size_t num_splits) +#include "openvino/core/validation_util.hpp" +#include "openvino/reference/split.hpp" +#include "split_shape_inference.hpp" + +namespace ov { +namespace op { + +namespace v1 { +namespace validate { +namespace { +bool axis_type(const element::Type& et) { + return et.is_integral_number(); +} +} // namespace +} // namespace validate + +Split::Split(const Output& data, const Output& axis, const size_t num_splits) : Op({data, axis}), m_num_splits{num_splits} { constructor_validate_and_infer_types(); } -bool ngraph::op::v1::Split::visit_attributes(AttributeVisitor& visitor) { +bool Split::visit_attributes(AttributeVisitor& visitor) { OV_OP_SCOPE(v1_Split_visit_attributes); visitor.on_attribute("num_splits", m_num_splits); return true; } -void op::v1::Split::validate_and_infer_types() { +void Split::validate_and_infer_types() { OV_OP_SCOPE(v1_Split_validate_and_infer_types); const auto& axis_et = get_input_element_type(1); NODE_VALIDATION_CHECK(this, - axis_et.is_integral_number(), + validate::axis_type(axis_et), "Element type of 'axis' input must be integer. Got: ", axis_et); @@ -58,72 +62,70 @@ void op::v1::Split::validate_and_infer_types() { set_input_is_relevant_to_shape(0); } -shared_ptr op::v1::Split::clone_with_new_inputs(const OutputVector& new_args) const { +std::shared_ptr Split::clone_with_new_inputs(const OutputVector& new_args) const { OV_OP_SCOPE(v1_Split_clone_with_new_inputs); check_new_args_count(this, new_args); - return make_shared(new_args.at(0), new_args.at(1), m_num_splits); + return std::make_shared(new_args.at(0), new_args.at(1), m_num_splits); } -OPENVINO_SUPPRESS_DEPRECATED_START -bool op::v1::Split::evaluate(const HostTensorVector& outputs, const HostTensorVector& inputs) const { +bool Split::evaluate(TensorVector& outputs, const TensorVector& inputs) const { OV_OP_SCOPE(v1_Split_evaluate); - OPENVINO_SUPPRESS_DEPRECATED_START - OPENVINO_ASSERT(validate_host_tensor_vector(outputs, m_num_splits) && validate_host_tensor_vector(inputs, 2)); - OPENVINO_SUPPRESS_DEPRECATED_END + OPENVINO_ASSERT(outputs.size() == m_num_splits); - if (has_evaluate()) { + const auto output_shapes = + shape_infer(this, ov::util::get_tensors_partial_shapes(inputs), make_tensor_accessor(inputs)); + const auto& axis_tensor = inputs[1]; + const auto result = validate::axis_type(axis_tensor.get_element_type()); + if (result) { const auto& data_tensor = inputs[0]; - const auto& axis_tensor = inputs[1]; - - const auto input_shapes = - std::vector{data_tensor->get_partial_shape(), axis_tensor->get_partial_shape()}; - - auto output_shapes = shape_infer(this, input_shapes, make_tensor_accessor(inputs)); auto outputs_data = std::vector(m_num_splits); - for (size_t i = 0; i < m_num_splits; ++i) { - outputs[i]->set_shape(output_shapes[i].get_shape()); - outputs_data[i] = outputs[i]->get_data_ptr(); + { + auto outputs_it = outputs.begin(); + auto outputs_data_it = outputs_data.begin(); + for (const auto& p_shape : output_shapes) { + outputs_it->set_shape(p_shape.get_shape()); + *outputs_data_it = static_cast(outputs_it->data()); + ++outputs_it, ++outputs_data_it; + } } - OPENVINO_SUPPRESS_DEPRECATED_START - auto axis = host_tensor_2_vector(axis_tensor)[0]; - axis = normalize_axis(this, axis, data_tensor->get_partial_shape().rank()); - OPENVINO_SUPPRESS_DEPRECATED_END + auto axis = get_tensor_data_as(axis_tensor).front(); + axis = ov::util::normalize(axis, data_tensor.get_shape().size()); - ov::reference::split(data_tensor->get_data_ptr(), - data_tensor->get_shape(), - data_tensor->get_element_type().size(), + ov::reference::split(static_cast(data_tensor.data()), + data_tensor.get_shape(), + data_tensor.get_element_type().size(), axis, m_num_splits, outputs_data.data()); - return true; } - return false; + + return result; } -OPENVINO_SUPPRESS_DEPRECATED_END -bool op::v1::Split::has_evaluate() const { +bool Split::has_evaluate() const { OV_OP_SCOPE(v1_Split_has_evaluate); - return get_input_element_type(1).is_integral_number(); + return validate::axis_type(get_input_element_type(1)); } -bool op::v1::Split::evaluate_lower(ov::TensorVector& output_values) const { +bool Split::evaluate_lower(ov::TensorVector& output_values) const { OV_OP_SCOPE(v1_Split_evaluate_lower); - - return input(1).get_tensor().has_and_set_bound() && default_lower_bound_evaluator(this, output_values); + return get_input_tensor(1).has_and_set_bound() && default_lower_bound_evaluator(this, output_values); } -bool op::v1::Split::evaluate_upper(ov::TensorVector& output_values) const { +bool Split::evaluate_upper(ov::TensorVector& output_values) const { OV_OP_SCOPE(v1_Split_evaluate_upper); - - return input(1).get_tensor().has_and_set_bound() && default_upper_bound_evaluator(this, output_values); + return get_input_tensor(1).has_and_set_bound() && default_upper_bound_evaluator(this, output_values); } -bool op::v1::Split::evaluate_label(TensorLabelVector& output_labels) const { +bool Split::evaluate_label(TensorLabelVector& output_labels) const { OPENVINO_ASSERT(output_labels.size() == get_num_splits()); OPENVINO_SUPPRESS_DEPRECATED_START - return input(1).get_tensor().has_and_set_bound() && default_label_evaluator(this, output_labels); + return get_input_tensor(1).has_and_set_bound() && default_label_evaluator(this, output_labels); OPENVINO_SUPPRESS_DEPRECATED_END } +} // namespace v1 +} // namespace op +} // namespace ov From 893517dd4a3ae6ba2e1f7e5a60a19c63a88d0b39 Mon Sep 17 00:00:00 2001 From: Pawel Raasz Date: Mon, 16 Oct 2023 06:54:38 +0200 Subject: [PATCH 02/12] Migrate LogicalAnd to new API (#20423) --- src/core/include/openvino/op/logical_and.hpp | 5 +- .../include/openvino/reference/and.hpp | 26 +++-- src/core/src/op/logical_and.cpp | 98 +++++++------------ 3 files changed, 51 insertions(+), 78 deletions(-) diff --git a/src/core/include/openvino/op/logical_and.hpp b/src/core/include/openvino/op/logical_and.hpp index 6d55f8f3585e0f..382679d16b78e1 100644 --- a/src/core/include/openvino/op/logical_and.hpp +++ b/src/core/include/openvino/op/logical_and.hpp @@ -35,10 +35,7 @@ class OPENVINO_API LogicalAnd : public util::BinaryElementwiseLogical { const AutoBroadcastSpec& auto_broadcast = AutoBroadcastSpec(AutoBroadcastType::NUMPY)); std::shared_ptr clone_with_new_inputs(const OutputVector& new_args) const override; - bool visit_attributes(AttributeVisitor& visitor) override; - OPENVINO_SUPPRESS_DEPRECATED_START - bool evaluate(const HostTensorVector& outputs, const HostTensorVector& inputs) const override; - OPENVINO_SUPPRESS_DEPRECATED_END + bool evaluate(TensorVector& outputs, const TensorVector& inputs) const override; bool has_evaluate() const override; }; } // namespace v1 diff --git a/src/core/reference/include/openvino/reference/and.hpp b/src/core/reference/include/openvino/reference/and.hpp index 326e4b59d773af..8f43b045d6398c 100644 --- a/src/core/reference/include/openvino/reference/and.hpp +++ b/src/core/reference/include/openvino/reference/and.hpp @@ -4,31 +4,37 @@ #pragma once -#include +#include +#include #include "openvino/core/shape.hpp" -#include "openvino/op/util/attr_types.hpp" #include "openvino/reference/autobroadcast_binop.hpp" namespace ov { namespace reference { -template +template void logical_and(const T* arg0, const T* arg1, T* out, size_t count) { - for (size_t i = 0; i < count; i++) { - out[i] = static_cast(arg0[i] && arg1[i]); - } + std::transform(arg0, std::next(arg0, count), arg1, out, std::logical_and()); } -template +/** + * @brief Reference implementation of binary elementwise LogicalAnd operator. + * + * @param arg0 Pointer to input 0 data. + * @param arg1 Pointer to input 1 data. + * @param out Pointer to output data. + * @param arg_shape0 Input 0 shape. + * @param arg_shape1 Input 1 shape. + * @param broadcast_spec Broadcast specification mode. + */ +template void logical_and(const T* arg0, const T* arg1, T* out, const Shape& arg0_shape, const Shape& arg1_shape, const op::AutoBroadcastSpec& broadcast_spec) { - autobroadcast_binop(arg0, arg1, out, arg0_shape, arg1_shape, broadcast_spec, [](T x, T y) -> T { - return static_cast(x && y); - }); + autobroadcast_binop(arg0, arg1, out, arg0_shape, arg1_shape, broadcast_spec, std::logical_and()); } } // namespace reference } // namespace ov diff --git a/src/core/src/op/logical_and.cpp b/src/core/src/op/logical_and.cpp index d6f451715a564d..fe8bd612ed2d85 100644 --- a/src/core/src/op/logical_and.cpp +++ b/src/core/src/op/logical_and.cpp @@ -2,83 +2,53 @@ // SPDX-License-Identifier: Apache-2.0 // +#include "openvino/op/logical_and.hpp" + #include "itt.hpp" -#include "ngraph/op/and.hpp" -#include "ngraph/runtime/host_tensor.hpp" -#include "ngraph/validation_util.hpp" #include "openvino/reference/and.hpp" +#include "utils.hpp" -using namespace std; -using namespace ngraph; - -op::v1::LogicalAnd::LogicalAnd(const Output& arg0, - const Output& arg1, - const AutoBroadcastSpec& auto_broadcast) +namespace ov { +namespace op { +namespace v1 { +LogicalAnd::LogicalAnd(const Output& arg0, const Output& arg1, const AutoBroadcastSpec& auto_broadcast) : BinaryElementwiseLogical(arg0, arg1, auto_broadcast) { constructor_validate_and_infer_types(); } -bool op::v1::LogicalAnd::visit_attributes(AttributeVisitor& visitor) { - OV_OP_SCOPE(v1_LogicalAnd_visit_attributes); - BinaryElementwiseLogical::visit_attributes(visitor); - return true; -} - -shared_ptr op::v1::LogicalAnd::clone_with_new_inputs(const OutputVector& new_args) const { +std::shared_ptr LogicalAnd::clone_with_new_inputs(const OutputVector& new_args) const { OV_OP_SCOPE(v1_LogicalAnd_clone_with_new_inputs); check_new_args_count(this, new_args); - return make_shared(new_args.at(0), new_args.at(1), this->get_autob()); + return std::make_shared(new_args.at(0), new_args.at(1), get_autob()); } -OPENVINO_SUPPRESS_DEPRECATED_START -namespace logand { -namespace { -template -bool evaluate(const HostTensorPtr& arg0, - const HostTensorPtr& arg1, - const HostTensorPtr& out, - const op::AutoBroadcastSpec& broadcast_spec) { - ov::reference::logical_and(arg0->get_data_ptr(), - arg1->get_data_ptr(), - out->get_data_ptr(), - arg0->get_shape(), - arg1->get_shape(), - broadcast_spec); - return true; -} - -bool evaluate_logand(const HostTensorPtr& arg0, - const HostTensorPtr& arg1, - const HostTensorPtr& out, - const op::AutoBroadcastSpec& broadcast_spec) { - bool rc = true; - out->set_broadcast(broadcast_spec, arg0, arg1); - switch (arg0->get_element_type()) { - OPENVINO_TYPE_CASE(evaluate_logand, boolean, arg0, arg1, out, broadcast_spec); - default: - rc = false; - break; - } - return rc; -} -} // namespace -} // namespace logand - -bool op::v1::LogicalAnd::evaluate(const HostTensorVector& outputs, const HostTensorVector& inputs) const { +bool LogicalAnd::evaluate(TensorVector& outputs, const TensorVector& inputs) const { OV_OP_SCOPE(v1_LogicalAnd_evaluate); - OPENVINO_SUPPRESS_DEPRECATED_START - OPENVINO_ASSERT(validate_host_tensor_vector(outputs, 1) && validate_host_tensor_vector(inputs, 2)); - OPENVINO_SUPPRESS_DEPRECATED_END - return logand::evaluate_logand(inputs[0], inputs[1], outputs[0], get_autob()); + OPENVINO_ASSERT(outputs.size() == 1); + OPENVINO_ASSERT(inputs.size() == 2); + + const auto& shape_0 = inputs[0].get_shape(); + const auto& shape_1 = inputs[1].get_shape(); + outputs[0].set_shape(infer_broadcast_shape(this, shape_0, shape_1)); + + if (inputs[0].get_element_type() == element::boolean) { + using T = fundamental_type_for; + reference::logical_and(inputs[0].data(), + inputs[1].data(), + outputs[0].data(), + shape_0, + shape_1, + get_autob()); + return true; + } else { + return false; + } } -bool op::v1::LogicalAnd::has_evaluate() const { +bool LogicalAnd::has_evaluate() const { OV_OP_SCOPE(v1_LogicalAnd_has_evaluate); - switch (get_input_element_type(0)) { - case ngraph::element::boolean: - return true; - default: - break; - } - return false; + return get_input_element_type(0) == element::boolean; } +} // namespace v1 +} // namespace op +} // namespace ov From fb93638cb2489af8e00b1f8123a814540289777e Mon Sep 17 00:00:00 2001 From: Pawel Raasz Date: Mon, 16 Oct 2023 06:56:24 +0200 Subject: [PATCH 03/12] [core]Migrate LogicalOr to new API (#20421) * Migrate LogicalOr to new API * Remove leftovers --- src/core/include/openvino/op/logical_or.hpp | 4 +- .../include/openvino/reference/or.hpp | 29 +++--- src/core/src/op/logical_or.cpp | 91 +++++++------------ 3 files changed, 53 insertions(+), 71 deletions(-) diff --git a/src/core/include/openvino/op/logical_or.hpp b/src/core/include/openvino/op/logical_or.hpp index 15c00eea04baf3..1dab36217b175a 100644 --- a/src/core/include/openvino/op/logical_or.hpp +++ b/src/core/include/openvino/op/logical_or.hpp @@ -34,9 +34,7 @@ class OPENVINO_API LogicalOr : public util::BinaryElementwiseLogical { std::shared_ptr clone_with_new_inputs(const OutputVector& new_args) const override; - OPENVINO_SUPPRESS_DEPRECATED_START - bool evaluate(const HostTensorVector& outputs, const HostTensorVector& inputs) const override; - OPENVINO_SUPPRESS_DEPRECATED_END + bool evaluate(TensorVector& outputs, const TensorVector& inputs) const override; bool has_evaluate() const override; }; } // namespace v1 diff --git a/src/core/reference/include/openvino/reference/or.hpp b/src/core/reference/include/openvino/reference/or.hpp index 7e821de63e3c03..4b0d760ec41349 100644 --- a/src/core/reference/include/openvino/reference/or.hpp +++ b/src/core/reference/include/openvino/reference/or.hpp @@ -4,31 +4,38 @@ #pragma once -#include +#include +#include #include "openvino/core/shape.hpp" -#include "openvino/op/util/attr_types.hpp" #include "openvino/reference/autobroadcast_binop.hpp" namespace ov { namespace reference { -template -void logical_or(const T* arg0, const T* arg1, T* out, size_t count) { - for (size_t i = 0; i < count; i++) { - out[i] = static_cast(arg0[i] || arg1[i]); - } + +template +void logical_or(const T* arg0, const T* arg1, T* out, const size_t count) { + std::transform(arg0, std::next(arg0, count), arg1, out, std::logical_or()); } -template +/** + * @brief Reference implementation of binary elementwise LogicalOr operator. + * + * @param arg0 Pointer to input 0 data. + * @param arg1 Pointer to input 1 data. + * @param out Pointer to output data. + * @param arg_shape0 Input 0 shape. + * @param arg_shape1 Input 1 shape. + * @param broadcast_spec Broadcast specification mode. + */ +template void logical_or(const T* arg0, const T* arg1, T* out, const Shape& arg0_shape, const Shape& arg1_shape, const op::AutoBroadcastSpec& broadcast_spec) { - autobroadcast_binop(arg0, arg1, out, arg0_shape, arg1_shape, broadcast_spec, [](T x, T y) -> T { - return static_cast(x || y); - }); + autobroadcast_binop(arg0, arg1, out, arg0_shape, arg1_shape, broadcast_spec, std::logical_or()); } } // namespace reference } // namespace ov diff --git a/src/core/src/op/logical_or.cpp b/src/core/src/op/logical_or.cpp index c473e6c12e385f..403089318de314 100644 --- a/src/core/src/op/logical_or.cpp +++ b/src/core/src/op/logical_or.cpp @@ -2,77 +2,54 @@ // SPDX-License-Identifier: Apache-2.0 // +#include "openvino/op/logical_or.hpp" + #include "itt.hpp" -#include "ngraph/op/or.hpp" -#include "ngraph/runtime/host_tensor.hpp" -#include "ngraph/validation_util.hpp" #include "openvino/reference/or.hpp" +#include "utils.hpp" -using namespace std; -using namespace ngraph; +namespace ov { +namespace op { +namespace v1 { -op::v1::LogicalOr::LogicalOr(const Output& arg0, - const Output& arg1, - const AutoBroadcastSpec& auto_broadcast) +LogicalOr::LogicalOr(const Output& arg0, const Output& arg1, const AutoBroadcastSpec& auto_broadcast) : BinaryElementwiseLogical(arg0, arg1, auto_broadcast) { constructor_validate_and_infer_types(); } -shared_ptr op::v1::LogicalOr::clone_with_new_inputs(const OutputVector& new_args) const { +std::shared_ptr LogicalOr::clone_with_new_inputs(const OutputVector& new_args) const { OV_OP_SCOPE(v1_LogicalOr_clone_with_new_inputs); check_new_args_count(this, new_args); - return make_shared(new_args.at(0), new_args.at(1), this->get_autob()); -} - -OPENVINO_SUPPRESS_DEPRECATED_START -namespace logor { -namespace { -template -bool evaluate(const HostTensorPtr& arg0, - const HostTensorPtr& arg1, - const HostTensorPtr& out, - const op::AutoBroadcastSpec& broadcast_spec) { - ov::reference::logical_or(arg0->get_data_ptr(), - arg1->get_data_ptr(), - out->get_data_ptr(), - arg0->get_shape(), - arg1->get_shape(), - broadcast_spec); - return true; -} - -bool evaluate_logor(const HostTensorPtr& arg0, - const HostTensorPtr& arg1, - const HostTensorPtr& out, - const op::AutoBroadcastSpec& broadcast_spec) { - bool rc = true; - out->set_broadcast(broadcast_spec, arg0, arg1); - switch (arg0->get_element_type()) { - OPENVINO_TYPE_CASE(evaluate_logor, boolean, arg0, arg1, out, broadcast_spec); - default: - rc = false; - break; - } - return rc; + return std::make_shared(new_args.at(0), new_args.at(1), get_autob()); } -} // namespace -} // namespace logor -bool op::v1::LogicalOr::evaluate(const HostTensorVector& outputs, const HostTensorVector& inputs) const { +bool LogicalOr::evaluate(TensorVector& outputs, const TensorVector& inputs) const { OV_OP_SCOPE(v1_LogicalOr_evaluate); - OPENVINO_SUPPRESS_DEPRECATED_START - OPENVINO_ASSERT(validate_host_tensor_vector(outputs, 1) && validate_host_tensor_vector(inputs, 2)); - OPENVINO_SUPPRESS_DEPRECATED_END - return logor::evaluate_logor(inputs[0], inputs[1], outputs[0], get_autob()); + OPENVINO_ASSERT(outputs.size() == 1); + OPENVINO_ASSERT(inputs.size() == 2); + + const auto& shape_0 = inputs[0].get_shape(); + const auto& shape_1 = inputs[1].get_shape(); + outputs[0].set_shape(infer_broadcast_shape(this, shape_0, shape_1)); + + if (inputs[0].get_element_type() == element::boolean) { + using T = fundamental_type_for; + reference::logical_or(inputs[0].data(), + inputs[1].data(), + outputs[0].data(), + shape_0, + shape_1, + get_autob()); + return true; + } else { + return false; + } } -bool op::v1::LogicalOr::has_evaluate() const { +bool LogicalOr::has_evaluate() const { OV_OP_SCOPE(v1_LogicalOr_has_evaluate); - switch (get_input_element_type(0)) { - case ngraph::element::boolean: - return true; - default: - break; - } - return false; + return get_input_element_type(0) == element::boolean; } +} // namespace v1 +} // namespace op +} // namespace ov From 00618a429bfb4e1ca3cbca941dfd236338ae765f Mon Sep 17 00:00:00 2001 From: Ilya Lavrenov Date: Mon, 16 Oct 2023 12:54:30 +0400 Subject: [PATCH 04/12] Relocatable OpenVINO Dev package improvements (#20461) --- ...DeveloperPackageConfigRelocatable.cmake.in | 4 +--- src/bindings/python/CMakeLists.txt | 21 ++++++++++--------- thirdparty/dependencies.cmake | 21 +------------------ thirdparty/pugixml | 2 +- 4 files changed, 14 insertions(+), 34 deletions(-) diff --git a/cmake/templates/OpenVINODeveloperPackageConfigRelocatable.cmake.in b/cmake/templates/OpenVINODeveloperPackageConfigRelocatable.cmake.in index ed9826e663e8d9..a4cdb93d387c58 100644 --- a/cmake/templates/OpenVINODeveloperPackageConfigRelocatable.cmake.in +++ b/cmake/templates/OpenVINODeveloperPackageConfigRelocatable.cmake.in @@ -9,9 +9,7 @@ include(CMakeFindDependencyMacro) # Variables to export in plugin's projects set(ov_options "@OV_OPTIONS@") -list(APPEND ov_options CMAKE_CXX_COMPILER_LAUNCHER CMAKE_C_COMPILER_LAUNCHER - CMAKE_CXX_LINKER_LAUNCHER CMAKE_C_LINKER_LAUNCHER - CMAKE_INSTALL_PREFIX CPACK_GENERATOR) +list(APPEND ov_options CPACK_GENERATOR) if(APPLE) list(APPEND ov_options CMAKE_OSX_ARCHITECTURES CMAKE_OSX_DEPLOYMENT_TARGET) diff --git a/src/bindings/python/CMakeLists.txt b/src/bindings/python/CMakeLists.txt index 89d21c8a7c91f4..a2e8945a807776 100644 --- a/src/bindings/python/CMakeLists.txt +++ b/src/bindings/python/CMakeLists.txt @@ -28,6 +28,8 @@ if(NOT DEFINED OpenVINO_SOURCE_DIR) if(NOT EXISTS "${OpenVINO_BINARY_DIR}/cmake_install.cmake") set(OpenVINODeveloperPackage_RELOCATABLE ON) endif() + + set(OpenVINO_SOURCE_DIR "${OpenVINOPython_SOURCE_DIR}/../../../") endif() if(NOT DEFINED OpenVINODeveloperPackage_RELOCATABLE) @@ -154,8 +156,8 @@ endfunction() set(INIT_FILES_RUNTIME "${OpenVINOPython_SOURCE_DIR}/src/openvino/__init__.py" "${OpenVINOPython_SOURCE_DIR}/src/compatibility/openvino/__init__.py" - "${OpenVINOPython_SOURCE_DIR}/../../../tools/ovc/openvino/__init__.py" - "${OpenVINOPython_SOURCE_DIR}/../../../tools/benchmark_tool/openvino/__init__.py") + "${OpenVINO_SOURCE_DIR}/tools/ovc/openvino/__init__.py" + "${OpenVINO_SOURCE_DIR}/tools/benchmark_tool/openvino/__init__.py") ov_check_init_files_alignment("${INIT_FILES_RUNTIME}") @@ -319,15 +321,15 @@ macro(ov_define_setup_py_dependencies) "${CMAKE_CURRENT_SOURCE_DIR}/wheel/setup.py" "${OpenVINOPython_SOURCE_DIR}/requirements.txt" "${OpenVINOPython_SOURCE_DIR}/wheel/readme.txt" - "${OpenVINOPython_SOURCE_DIR}/../../../LICENSE" - "${OpenVINOPython_SOURCE_DIR}/../../../licensing/onednn_third-party-programs.txt" - "${OpenVINOPython_SOURCE_DIR}/../../../licensing/runtime-third-party-programs.txt" - "${OpenVINOPython_SOURCE_DIR}/../../../licensing/tbb_third-party-programs.txt" - "${OpenVINOPython_SOURCE_DIR}/../../../docs/install_guides/pypi-openvino-rt.md") + "${OpenVINO_SOURCE_DIR}/LICENSE" + "${OpenVINO_SOURCE_DIR}/licensing/onednn_third-party-programs.txt" + "${OpenVINO_SOURCE_DIR}/licensing/runtime-third-party-programs.txt" + "${OpenVINO_SOURCE_DIR}/licensing/tbb_third-party-programs.txt" + "${OpenVINO_SOURCE_DIR}/docs/install_guides/pypi-openvino-rt.md") if(wheel_pre_release) list(APPEND ov_setup_py_deps - "${OpenVINOPython_SOURCE_DIR}/../../../docs/install_guides/pre-release-note.md") + "${OpenVINO_SOURCE_DIR}/docs/install_guides/pre-release-note.md") endif() endmacro() @@ -404,9 +406,8 @@ if(ENABLE_TESTS) endif() if(OpenVINODeveloperPackage_FOUND) - # TODO: understand whether it's required # provides a callback function to describe each component in repo - include("${OpenVINOPython_SOURCE_DIR}/../../../cmake/packaging/packaging.cmake") + include("${OpenVINO_SOURCE_DIR}/cmake/packaging/packaging.cmake") ov_cpack(${OV_CPACK_COMPONENTS_ALL}) endif() diff --git a/thirdparty/dependencies.cmake b/thirdparty/dependencies.cmake index 1524378287fdfa..fac4752c318250 100644 --- a/thirdparty/dependencies.cmake +++ b/thirdparty/dependencies.cmake @@ -266,26 +266,7 @@ if(NOT TARGET openvino::pugixml) function(ov_build_pugixml) function(ov_build_pugixml_static) set(BUILD_SHARED_LIBS OFF) - function(install) - cmake_parse_arguments(_install "" "EXPORT" "" ${ARGV}) - if(_install_EXPORT STREQUAL "pugixml-targets") - # does nothing! - # we need to override 'export' command to prevent cmake issue with multiple - # export sets for pugixml-target. Currently, it's installed only by OpenVINO - else() - _install(${ARGV}) - endif() - endfunction() - function(export) - cmake_parse_arguments(_export "" "EXPORT" "" ${ARGV}) - if(_export_EXPORT STREQUAL "pugixml-targets") - # does nothing! - # we need to override 'export' command to prevent cmake issue with multiple - # export sets for pugixml-target. Currently, it's installed only by OpenVINO - else() - _export(${ARGV}) - endif() - endfunction() + set(PUGIXML_INSTALL OFF CACHE BOOL "" FORCE) add_subdirectory(thirdparty/pugixml EXCLUDE_FROM_ALL) endfunction() ov_build_pugixml_static() diff --git a/thirdparty/pugixml b/thirdparty/pugixml index a0e064336317c9..2e357d19a3228c 160000 --- a/thirdparty/pugixml +++ b/thirdparty/pugixml @@ -1 +1 @@ -Subproject commit a0e064336317c9347a91224112af9933598714e9 +Subproject commit 2e357d19a3228c0a301727aac6bea6fecd982d21 From 146ca36f8ffb1d959a2d53f394fa83c90623714f Mon Sep 17 00:00:00 2001 From: Sergey Shlyapnikov Date: Mon, 16 Oct 2023 13:47:57 +0400 Subject: [PATCH 05/12] [GPU] Minor debug improvements: add suffix to shape agnostic kernels names and show batch_hash for impl_types::any (#20275) --- src/plugins/intel_gpu/src/graph/program_node.cpp | 3 ++- .../intel_gpu/src/kernel_selector/kernel_base_opencl.cpp | 4 ++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/plugins/intel_gpu/src/graph/program_node.cpp b/src/plugins/intel_gpu/src/graph/program_node.cpp index 62c11e2f7e8066..f72a38af85589f 100644 --- a/src/plugins/intel_gpu/src/graph/program_node.cpp +++ b/src/plugins/intel_gpu/src/graph/program_node.cpp @@ -208,7 +208,8 @@ std::unique_ptr program_node::desc_to_json() const { #endif impls.push_back(selected_impl->get_kernel_name()); - if (get_preferred_impl_type() == impl_types::ocl) { + auto preferred_impl_type = get_preferred_impl_type(); + if (preferred_impl_type != impl_types::onednn && preferred_impl_type != impl_types::cpu) { json_composite cl_dump_info; cl_dump_info.add("batch_hash", selected_impl->get_kernels_dump_info().first); cl_dump_info.add("kernel_entry", selected_impl->get_kernels_dump_info().second); diff --git a/src/plugins/intel_gpu/src/kernel_selector/kernel_base_opencl.cpp b/src/plugins/intel_gpu/src/kernel_selector/kernel_base_opencl.cpp index d0d052b44c4ed3..b382561afdac34 100644 --- a/src/plugins/intel_gpu/src/kernel_selector/kernel_base_opencl.cpp +++ b/src/plugins/intel_gpu/src/kernel_selector/kernel_base_opencl.cpp @@ -80,6 +80,10 @@ std::string KernelBaseOpenCL::GetEntryPoint(const std::string& templateName, // UniqueID = program_id + processing_index + additional weight/reorder tag kernelID += "_" + params.uniqueID + "_" + std::to_string(partID); + // Add "__sa" suffix for shape agnostic kernels + if (params.is_shape_agnostic) + kernelID += "__sa"; + return kernelID; } From f655d2177d5eda48bffad9c6fbf3b1728872062b Mon Sep 17 00:00:00 2001 From: Sergey Shlyapnikov Date: Mon, 16 Oct 2023 13:52:45 +0400 Subject: [PATCH 06/12] [GPU] Fix scatter_nd_update output paddings handling (#20447) --- .../intel_gpu/src/graph/scatter_nd_update.cpp | 3 +- .../cl_kernels/scatter_nd_update_ref.cl | 5 +- .../scatter_nd_update_kernel_ref.cpp | 7 ++- .../src/kernel_selector/tensor_type.h | 4 ++ .../test_cases/scatter_nd_update_gpu_test.cpp | 61 +++++++++++++++++++ 5 files changed, 77 insertions(+), 3 deletions(-) diff --git a/src/plugins/intel_gpu/src/graph/scatter_nd_update.cpp b/src/plugins/intel_gpu/src/graph/scatter_nd_update.cpp index 40d2b48d8edfaf..0f64b64a0bcad7 100644 --- a/src/plugins/intel_gpu/src/graph/scatter_nd_update.cpp +++ b/src/plugins/intel_gpu/src/graph/scatter_nd_update.cpp @@ -69,8 +69,9 @@ scatter_nd_update_inst::typed_primitive_inst(network& network, scatter_nd_update void scatter_nd_update_inst::on_execute() { auto input1_shape = _impl_params->input_layouts[1].get_partial_shape(); auto input2_shape = _impl_params->input_layouts[2].get_partial_shape(); + auto same_layouts = _impl_params->input_layouts[0] == _impl_params->output_layouts[0]; - if ((ov::shape_size(input1_shape.to_shape()) == 0) || (ov::shape_size(input2_shape.to_shape()) == 0)) + if (same_layouts && ((ov::shape_size(input1_shape.to_shape()) == 0) || (ov::shape_size(input2_shape.to_shape()) == 0))) reuse_input(); } diff --git a/src/plugins/intel_gpu/src/kernel_selector/cl_kernels/scatter_nd_update_ref.cl b/src/plugins/intel_gpu/src/kernel_selector/cl_kernels/scatter_nd_update_ref.cl index 4ec9b665760e34..8c48ad4d4e9979 100644 --- a/src/plugins/intel_gpu/src/kernel_selector/cl_kernels/scatter_nd_update_ref.cl +++ b/src/plugins/intel_gpu/src/kernel_selector/cl_kernels/scatter_nd_update_ref.cl @@ -36,8 +36,10 @@ KERNEL(scatter_nd_update_ref)(OPTIONAL_SHAPE_INFO_ARG const __global INPUT0_TYPE* data, +#ifdef IS_SECOND_ITER const __global INPUT1_TYPE* indices, const __global INPUT2_TYPE* updates, +#endif __global OUTPUT_TYPE* output #if HAS_FUSED_OPS_DECLS , FUSED_OPS_DECLS @@ -56,8 +58,9 @@ KERNEL(scatter_nd_update_ref)(OPTIONAL_SHAPE_INFO_ARG const uint f = dim2 % OUTPUT_FEATURE_NUM; const uint b = dim2 / OUTPUT_FEATURE_NUM; + const uint input_idx = GET_UPDATES_INDEX(INPUT0, ORDER); const uint output_idx = GET_OUTPUT_INDEX(ORDER); - INPUT0_TYPE val = data[output_idx]; + INPUT0_TYPE val = data[input_idx]; #if HAS_FUSED_OPS FUSED_OPS_FIRST_KERNEL; output[output_idx] = TO_OUTPUT_TYPE(FUSED_OPS_RESULT_FIRST_KERNEL); diff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/scatter_update/scatter_nd_update_kernel_ref.cpp b/src/plugins/intel_gpu/src/kernel_selector/kernels/scatter_update/scatter_nd_update_kernel_ref.cpp index 9fbe45f3da02a4..1680d39ca27bb6 100644 --- a/src/plugins/intel_gpu/src/kernel_selector/kernels/scatter_update/scatter_nd_update_kernel_ref.cpp +++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/scatter_update/scatter_nd_update_kernel_ref.cpp @@ -170,6 +170,10 @@ KernelsData ScatterNDUpdateKernelRef::GetKernelsData(const Params& params, const kd.kernels[i].params.workGroups.global = dispatchData.gws; kd.kernels[i].params.workGroups.local = dispatchData.lws; kd.kernels[i].skip_execution = KernelData::SkipKernelExecution(prim_params); + + // Do not skip copy stage if output buffer is not empty or requires modification + if (i == 0 && prim_params.outputs[0].LogicalSize() != 0 && prim_params.outputs[0] != prim_params.inputs[0]) + kd.kernels[i].skip_execution = false; } }; @@ -178,6 +182,7 @@ KernelsData ScatterNDUpdateKernelRef::GetKernelsData(const Params& params, const for (int i = 0; i < 2; i++) { auto dispatchData = SetDefault(newParams, (i == 1)); auto entry_point = GetEntryPoint(kernelName, newParams.layerID, params, options, i); + auto inputs_number = i == 0 ? 1 : 3; if (i == 1) { size_t input0_rank = newParams.inputs[0].LogicalDims().size(); @@ -213,7 +218,7 @@ KernelsData ScatterNDUpdateKernelRef::GetKernelsData(const Params& params, const clKernelData& kernel = kd.kernels[i]; FillCLKernelData(kernel, dispatchData, params.engineInfo, kernelName, jit, entry_point, - "", false, false, 3, GetFusedPrimitiveInputsCount(params), 1, newParams.has_dynamic_tensors()); + "", false, false, inputs_number, GetFusedPrimitiveInputsCount(params), 1, newParams.has_dynamic_tensors()); } return {kd}; diff --git a/src/plugins/intel_gpu/src/kernel_selector/tensor_type.h b/src/plugins/intel_gpu/src/kernel_selector/tensor_type.h index 3d54dfabade1c0..97f087e6f2a051 100644 --- a/src/plugins/intel_gpu/src/kernel_selector/tensor_type.h +++ b/src/plugins/intel_gpu/src/kernel_selector/tensor_type.h @@ -621,6 +621,10 @@ struct TensorBaseT : public TensorBase { return same; } + bool operator!=(const TensorBaseT& t) const { + return !(*this == t); + } + bool SameDims(const TensorBaseT& t) const { bool same = dtype == t.dtype && layout == t.layout && dims.size() == t.dims.size(); if (same) { diff --git a/src/plugins/intel_gpu/tests/unit/test_cases/scatter_nd_update_gpu_test.cpp b/src/plugins/intel_gpu/tests/unit/test_cases/scatter_nd_update_gpu_test.cpp index d905755e789a71..b3f68e0f00b349 100644 --- a/src/plugins/intel_gpu/tests/unit/test_cases/scatter_nd_update_gpu_test.cpp +++ b/src/plugins/intel_gpu/tests/unit/test_cases/scatter_nd_update_gpu_test.cpp @@ -4458,6 +4458,67 @@ TEST(scatter_nd_update_gpu, dynamic) { } } + +TEST(scatter_nd_update_gpu, dynamic_padded_output) { + // Dictionary : 2x1x2x8 + // Indexes : 0x3 + // Updates : 0x8 + // Output : 2x1x2x8 + // Input values in fp32 + // + auto& engine = get_test_engine(); + + auto input1_layout = layout{ ov::PartialShape::dynamic(4), data_types::f32, format::bfyx }; + auto input2_layout = layout{ ov::PartialShape::dynamic(2), data_types::f32, format::bfyx }; + auto input3_layout = layout{ ov::PartialShape::dynamic(2), data_types::f32, format::bfyx }; + + auto input1 = engine.allocate_memory({ { 1, 1, 2, 8 }, data_types::f32, format::bfyx }); // Dictionary + auto input2 = engine.allocate_memory({ { 0, 3 }, data_types::f32, format::bfyx }); // Indexes + auto input3 = engine.allocate_memory({ { 0, 8 }, data_types::f32, format::bfyx }); // Updates + + set_values(input1, { + 0.f, 1.f, 2.f, 3.f, 4.f, 5.f, 6.f, 7.f, + 8.f, 9.f, 10.f, 11.f, 12.f, 13.f, 14.f, 15.f, + }); + + topology topology; + topology.add(input_layout("InputData", input1_layout)); + topology.add(input_layout("InputIndices", input2_layout)); + topology.add(input_layout("InputUpdates", input3_layout)); + topology.add( + scatter_nd_update("scatter_nd_update", input_info("InputData"), input_info("InputIndices"), input_info("InputUpdates"), 2, padding({0, 0, 1, 1})) + ); + + ExecutionConfig config = get_test_default_config(engine); + config.set_property(ov::intel_gpu::allow_new_shape_infer(true)); + network network(engine, topology, config); + + network.set_input_data("InputData", input1); + network.set_input_data("InputIndices", input2); + network.set_input_data("InputUpdates", input3); + + auto inst = network.get_primitive("scatter_nd_update"); + auto impl = inst->get_impl(); + ASSERT_TRUE(impl != nullptr); + ASSERT_TRUE(impl->is_dynamic()); + + auto outputs = network.execute(); + + auto output = outputs.at("scatter_nd_update").get_memory(); + cldnn::mem_lock output_ptr(output, get_test_stream()); + + std::vector expected_results = { + 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, + 0.f, 0.f, 1.f, 2.f, 3.f, 4.f, 5.f, 6.f, 7.f, 0.f, + 0.f, 8.f, 9.f, 10.f, 11.f, 12.f, 13.f, 14.f, 15.f, 0.f, + 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, + }; + + for (size_t i = 0; i < expected_results.size(); ++i) { + ASSERT_EQ(expected_results[i], output_ptr[i]); + } +} + TEST(scatter_nd_update_gpu, dynamic_5d) { tests::random_generator rg(std::string(::testing::UnitTest::GetInstance()->current_test_info()->test_suite_name()) + std::string(::testing::UnitTest::GetInstance()->current_test_info()->name())); From 44ac9099b947af4dfd9c50067036aa558a0643f6 Mon Sep 17 00:00:00 2001 From: Tatiana Savina Date: Mon, 16 Oct 2023 11:53:50 +0200 Subject: [PATCH 07/12] [DOCS] Add openvino-dev deprecation note (#20480) * add deprecation note * address comments --- docs/install_guides/pypi-openvino-dev.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/install_guides/pypi-openvino-dev.md b/docs/install_guides/pypi-openvino-dev.md index 8d53e6488f1602..08a16318b42d92 100644 --- a/docs/install_guides/pypi-openvino-dev.md +++ b/docs/install_guides/pypi-openvino-dev.md @@ -3,6 +3,7 @@ > **NOTE**: This version is pre-release software and has not undergone full release validation or qualification. No support is offered on pre-release software and APIs/behavior are subject to change. It should NOT be incorporated into any production software/solution and instead should be used only for early testing and integration while awaiting a final release version of this software. +> **NOTE**: OpenVINO™ Development Tools package has been deprecated and will be discontinued with 2024.0 release. To learn more, refer to the [OpenVINO Legacy Features and Components page](https://docs.openvino.ai/2023.1/openvino_legacy_features.html). Intel® Distribution of OpenVINO™ toolkit is an open-source toolkit for optimizing and deploying AI inference. It can be used to develop applications and solutions based on deep learning tasks, such as: emulation of human vision, automatic speech recognition, natural language processing, recommendation systems, etc. It provides high-performance and rich deployment options, from edge to cloud. From a00d28aac0efda832209dbaf6794481a1c16005c Mon Sep 17 00:00:00 2001 From: Vladimir Paramuzov Date: Mon, 16 Oct 2023 14:54:32 +0400 Subject: [PATCH 08/12] [GPU] Type traits cleanup (#20455) --- .../include/intel_gpu/runtime/layout.hpp | 116 +++--------------- .../intel_gpu/runtime/shape_predictor.hpp | 2 +- .../graph_optimizer/concat_input_order.cpp | 4 + .../src/graph/impls/cpu/activation.cpp | 3 +- .../src/graph/impls/cpu/detection_output.cpp | 8 +- .../graph/impls/cpu/non_max_suppression.cpp | 32 ++--- .../src/graph/impls/cpu/proposal.cpp | 24 ++-- .../graph/impls/onednn/convolution_onednn.cpp | 4 +- .../intel_gpu/src/graph/primitive_inst.cpp | 2 +- src/plugins/intel_gpu/src/graph/prior_box.cpp | 4 +- .../src/plugin/sync_infer_request.cpp | 5 +- .../intel_gpu/src/runtime/shape_predictor.cpp | 4 +- .../module_tests/shape_predictor_test.cpp | 4 +- .../shape_infer/random_uniform_si_test.cpp | 10 +- .../tests/unit/shape_infer/range_si_test.cpp | 10 +- .../unit/test_cases/permute_gpu_test.cpp | 5 +- 16 files changed, 83 insertions(+), 154 deletions(-) diff --git a/src/plugins/intel_gpu/include/intel_gpu/runtime/layout.hpp b/src/plugins/intel_gpu/include/intel_gpu/runtime/layout.hpp index 3dad0cea4e008b..679f4c51ea6881 100644 --- a/src/plugins/intel_gpu/include/intel_gpu/runtime/layout.hpp +++ b/src/plugins/intel_gpu/include/intel_gpu/runtime/layout.hpp @@ -13,10 +13,10 @@ #include #include #include -#include -#include -#include +#include "openvino/core/partial_shape.hpp" +#include "openvino/core/type/element_type.hpp" +#include "openvino/core/type/element_type_traits.hpp" #include "intel_gpu/graph/serialization/binary_buffer.hpp" #include "intel_gpu/graph/serialization/vector_serializer.hpp" @@ -28,33 +28,9 @@ namespace cldnn { /// @addtogroup cpp_memory Memory description and management /// @{ -constexpr size_t float_type_mask = 0x80; -constexpr size_t uint_type_mask = 0x40; -constexpr size_t bin_type_mask = 0x20; - /// @brief Possible data types could be stored in memory. using data_types = ov::element::Type_t; -/// Converts @ref data_types to C++ type. -template -struct data_type_to_type; -#ifndef DOXYGEN_SHOULD_SKIP_THIS -template <> -struct data_type_to_type { typedef uint32_t type; }; -template <> -struct data_type_to_type { typedef uint8_t type; }; -template <> -struct data_type_to_type { typedef int8_t type; }; -template <> -struct data_type_to_type { typedef int32_t type; }; -template <> -struct data_type_to_type { typedef int64_t type; }; -template <> -struct data_type_to_type { typedef ov::float16 type; }; -template <> -struct data_type_to_type { typedef float type; }; -#endif - /// Helper class to identify key properties for data_types. struct data_type_traits { static size_t size_of(data_types data_type) { @@ -72,52 +48,27 @@ struct data_type_traits { return et.is_quantized() && et.bitwidth() == 8; } - static size_t align_of(data_types data_type) { - switch (data_type) { - case data_types::u1: - return alignof(data_type_to_type::type); - case data_types::i8: - return alignof(data_type_to_type::type); - case data_types::u8: - return alignof(data_type_to_type::type); - case data_types::i32: - return alignof(data_type_to_type::type); - case data_types::i64: - return alignof(data_type_to_type::type); - case data_types::f16: - return alignof(data_type_to_type::type); - case data_types::f32: - return alignof(data_type_to_type::type); - default: - return size_t(1); - } - } - - static std::string name(data_types data_type) { - return ov::element::Type(data_type).get_type_name(); - } + static ov::element::Type max_type(ov::element::Type t1, ov::element::Type t2) { + if (t1 == ov::element::u1) + return t2; - static data_types max_type(data_types dt1, data_types dt2) { - if (dt1 == data_types::u1) - return dt2; + if (t2 == ov::element::u1) + return t1; - if (dt2 == data_types::u1) - return dt1; + if (t1.bitwidth() < t2.bitwidth()) + return t2; - if (size_of(dt1) < size_of(dt2)) - return dt2; + if (t1.bitwidth() > t2.bitwidth()) + return t1; - if (size_of(dt1) > size_of(dt2)) - return dt1; + if (t2.is_real()) + return t2; - if (is_floating_point(dt2)) - return dt2; - - return dt1; + return t1; } - static bool is_quantized(data_types dt) { - return is_i8_u8(dt); + static bool is_quantized(ov::element::Type t) { + return t.is_quantized(); } template @@ -132,7 +83,7 @@ struct data_type_traits { case data_types::i64: return static_cast(std::numeric_limits::max()); case data_types::f16: - return static_cast(65504); + return static_cast(std::numeric_limits::max()); case data_types::f32: return static_cast(std::numeric_limits::max()); default: @@ -152,7 +103,7 @@ struct data_type_traits { case data_types::i64: return static_cast(std::numeric_limits::lowest()); case data_types::f16: - return static_cast(-65504); + return static_cast(std::numeric_limits::lowest()); case data_types::f32: return static_cast(std::numeric_limits::lowest()); default: @@ -170,44 +121,17 @@ inline data_types element_type_to_data_type(ov::element::Type t) { switch (t) { case ov::element::Type_t::i16: case ov::element::Type_t::u16: - case ov::element::Type_t::f32: case ov::element::Type_t::f64: return cldnn::data_types::f32; - case ov::element::Type_t::f16: - return cldnn::data_types::f16; - case ov::element::Type_t::u8: - return cldnn::data_types::u8; - case ov::element::Type_t::i8: - return cldnn::data_types::i8; - case ov::element::Type_t::i32: case ov::element::Type_t::u32: case ov::element::Type_t::u64: return cldnn::data_types::i32; - case ov::element::Type_t::i64: - return cldnn::data_types::i64; case ov::element::Type_t::boolean: return cldnn::data_types::u8; - case ov::element::Type_t::u1: - return cldnn::data_types::u1; - default: - throw std::runtime_error("Can't convert " + t.get_type_name() + " element type"); + default: return t; } } -/// Helper function to get both data_types and format::type in a single, unique value. Useable in 'case' statement. -constexpr auto fuse(data_types dt, cldnn::format::type fmt) -> decltype(static_cast::type>(dt) | - static_cast::type>(fmt)) { - using dt_type = std::underlying_type::type; - using fmt_type = std::underlying_type::type; - using fmt_narrow_type = int16_t; - - return static_cast(fmt) <= std::numeric_limits::max() && - static_cast(dt) <= (std::numeric_limits::max() >> (sizeof(fmt_narrow_type) * 8)) - ? (static_cast(dt) << (sizeof(fmt_narrow_type) * 8)) | - (static_cast(fmt) >= 0 ? static_cast(fmt) : static_cast(-1)) - : throw std::invalid_argument("data_type and/or format values are too big to be fused into single value"); -} - /// @brief Represents data padding information. struct padding { /// @brief Filling value for padding area. diff --git a/src/plugins/intel_gpu/include/intel_gpu/runtime/shape_predictor.hpp b/src/plugins/intel_gpu/include/intel_gpu/runtime/shape_predictor.hpp index 2f2e614c29f2c6..51f09989502a13 100644 --- a/src/plugins/intel_gpu/include/intel_gpu/runtime/shape_predictor.hpp +++ b/src/plugins/intel_gpu/include/intel_gpu/runtime/shape_predictor.hpp @@ -50,7 +50,7 @@ struct ShapePredictor { /// says if shape is successfully predicted and can be preallocated, and the second element is ov::Shape itself. std::pair predict_preallocation_shape(const std::string& id, const ov::Shape& current_shape, - size_t dt_size, + size_t dt_bitwidth, bool can_reuse_buffer); bool can_preallocate(size_t desired_buffer_size); diff --git a/src/plugins/intel_gpu/src/graph/graph_optimizer/concat_input_order.cpp b/src/plugins/intel_gpu/src/graph/graph_optimizer/concat_input_order.cpp index 1f2016e8d6706e..de6d6c62859bd9 100644 --- a/src/plugins/intel_gpu/src/graph/graph_optimizer/concat_input_order.cpp +++ b/src/plugins/intel_gpu/src/graph/graph_optimizer/concat_input_order.cpp @@ -23,6 +23,8 @@ bool can_shuffle_features(program_node& node, stream& stream) { if (node.is_type()) { auto& conv_node = node.as(); auto& wei_node = conv_node.weights(); + if (ov::element::Type(wei_node.get_output_layout().data_type).bitwidth() < 8) + return false; return conv_node.get_groups() == 1 && conv_node.get_deformable_groups() == 1 && !conv_node.get_transposed() && @@ -32,6 +34,8 @@ bool can_shuffle_features(program_node& node, stream& stream) { if (node.is_type()) { auto& fc_node = node.as(); auto& wei_node = fc_node.weights(); + if (ov::element::Type(wei_node.get_output_layout().data_type).bitwidth() < 8) + return false; return wei_node.is_type() && wei_node.is_constant() && !wei_node.is_output(); } diff --git a/src/plugins/intel_gpu/src/graph/impls/cpu/activation.cpp b/src/plugins/intel_gpu/src/graph/impls/cpu/activation.cpp index 57c0f057455ba7..7f1e7abcb9b580 100644 --- a/src/plugins/intel_gpu/src/graph/impls/cpu/activation.cpp +++ b/src/plugins/intel_gpu/src/graph/impls/cpu/activation.cpp @@ -2,6 +2,7 @@ // SPDX-License-Identifier: Apache-2.0 // +#include "openvino/core/type/element_type_traits.hpp" #include "register.hpp" #include "activation_inst.h" #include "implementation_map.hpp" @@ -108,7 +109,7 @@ struct activation_impl : public typed_primitive_impl { input_host_tensors.push_back(make_tensor(params->input_layouts[i], input_mem_ptrs[i]->lock(stream, mem_lock_type::read))); // Most of the evaluate functions expect same data type for all inputs, so we need to convert params from float - typename data_type_to_type
::type param_a = static_cast::type>(additional_params.a); + auto param_a = static_cast::value_type>(additional_params.a); auto input_dt = instance.get_input_layout().data_type; diff --git a/src/plugins/intel_gpu/src/graph/impls/cpu/detection_output.cpp b/src/plugins/intel_gpu/src/graph/impls/cpu/detection_output.cpp index 9e9cd8b1c93389..f15d143e28539c 100644 --- a/src/plugins/intel_gpu/src/graph/impls/cpu/detection_output.cpp +++ b/src/plugins/intel_gpu/src/graph/impls/cpu/detection_output.cpp @@ -839,11 +839,11 @@ struct detection_output_impl : typed_primitive_impl { std::vector>>> scoreIndexPairs; if (instance.location_memory()->get_layout().data_type == data_types::f32) { - prepare_data::type>(stream, instance, bboxes, confidences, scoreIndexPairs); - generate_detections::type>(stream, instance, num_of_images, bboxes, confidences, scoreIndexPairs); + prepare_data::value_type>(stream, instance, bboxes, confidences, scoreIndexPairs); + generate_detections::value_type>(stream, instance, num_of_images, bboxes, confidences, scoreIndexPairs); } else { - prepare_data::type>(stream, instance, bboxes, confidences, scoreIndexPairs); - generate_detections::type>(stream, instance, num_of_images, bboxes, confidences, scoreIndexPairs); + prepare_data::value_type>(stream, instance, bboxes, confidences, scoreIndexPairs); + generate_detections::value_type>(stream, instance, num_of_images, bboxes, confidences, scoreIndexPairs); } ev->set(); diff --git a/src/plugins/intel_gpu/src/graph/impls/cpu/non_max_suppression.cpp b/src/plugins/intel_gpu/src/graph/impls/cpu/non_max_suppression.cpp index 7afca0cb91c91f..cfb05c176c06ca 100644 --- a/src/plugins/intel_gpu/src/graph/impls/cpu/non_max_suppression.cpp +++ b/src/plugins/intel_gpu/src/graph/impls/cpu/non_max_suppression.cpp @@ -149,9 +149,9 @@ vector2D load_boxes(stream& stream, memory::ptr mem, bool center_p auto data_type = mem->get_layout().data_type; switch (data_type) { case cldnn::data_types::f16: - return load_boxes_impl::type>(stream, mem, center_point); + return load_boxes_impl::value_type>(stream, mem, center_point); case cldnn::data_types::f32: - return load_boxes_impl::type>(stream, mem, center_point); + return load_boxes_impl::value_type>(stream, mem, center_point); default: throw std::runtime_error("Non max suppression - unsupported boxes data type"); } @@ -186,9 +186,9 @@ vector3D load_scores(stream& stream, memory::ptr mem) { auto data_type = mem->get_layout().data_type; switch (data_type) { case cldnn::data_types::f16: - return load_scores_impl::type>(stream, mem); + return load_scores_impl::value_type>(stream, mem); case cldnn::data_types::f32: - return load_scores_impl::type>(stream, mem); + return load_scores_impl::value_type>(stream, mem); default: throw std::runtime_error("Non max suppression - unsupported scores data type"); } @@ -207,11 +207,11 @@ T load_scalar(stream& stream, memory::ptr mem) { auto data_type = mem->get_layout().data_type; switch (data_type) { case cldnn::data_types::i32: - return load_scalar_impl::type>(stream, mem); + return load_scalar_impl::value_type>(stream, mem); case cldnn::data_types::f16: - return load_scalar_impl::type>(stream, mem); + return load_scalar_impl::value_type>(stream, mem); case cldnn::data_types::f32: - return load_scalar_impl::type>(stream, mem); + return load_scalar_impl::value_type>(stream, mem); default: throw std::runtime_error("Non max suppression - unsupported data type"); } @@ -244,13 +244,13 @@ void store_result(stream& stream, memory::ptr mem, const std::vectorget_layout().data_type; switch (data_type) { case cldnn::data_types::i32: - store_result_impl::type>(stream, mem, result); + store_result_impl::value_type>(stream, mem, result); break; case cldnn::data_types::f16: - store_result_impl::type>(stream, mem, result); + store_result_impl::value_type>(stream, mem, result); break; case cldnn::data_types::f32: - store_result_impl::type>(stream, mem, result); + store_result_impl::value_type>(stream, mem, result); break; default: throw std::runtime_error("Non max suppression - unsupported output data type"); @@ -261,10 +261,10 @@ void store_first_output(stream& stream, memory::ptr mem, const std::vectorget_layout().data_type; switch (data_type) { case cldnn::data_types::i32: - store_result_impl::type>(stream, mem, result); + store_result_impl::value_type>(stream, mem, result); break; case cldnn::data_types::i64: - store_result_impl::type>(stream, mem, result); + store_result_impl::value_type>(stream, mem, result); break; default: throw std::runtime_error("Non max suppression - unsupported output data type"); @@ -298,10 +298,10 @@ void store_second_output(stream& stream, memory::ptr mem, const std::vectorget_layout().data_type; switch (data_type) { case cldnn::data_types::f16: - store_second_output_impl::type>(stream, mem, result); + store_second_output_impl::value_type>(stream, mem, result); break; case cldnn::data_types::f32: - store_second_output_impl::type>(stream, mem, result); + store_second_output_impl::value_type>(stream, mem, result); break; default: throw std::runtime_error("Non max suppression - unsupported second output data type"); @@ -319,10 +319,10 @@ void store_third_output(stream& stream, memory::ptr mem, const std::vectorget_layout().data_type; switch (data_type) { case cldnn::data_types::i32: - store_third_output_impl::type>(stream, mem, result); + store_third_output_impl::value_type>(stream, mem, result); break; case cldnn::data_types::i64: - store_third_output_impl::type>(stream, mem, result); + store_third_output_impl::value_type>(stream, mem, result); break; default: throw std::runtime_error("Non max suppression - unsupported third output data type"); diff --git a/src/plugins/intel_gpu/src/graph/impls/cpu/proposal.cpp b/src/plugins/intel_gpu/src/graph/impls/cpu/proposal.cpp index 461035c1defd75..2670949f8e9284 100644 --- a/src/plugins/intel_gpu/src/graph/impls/cpu/proposal.cpp +++ b/src/plugins/intel_gpu/src/graph/impls/cpu/proposal.cpp @@ -396,9 +396,9 @@ struct proposal_impl : typed_primitive_impl { auto ev = instance.get_network().get_stream().create_user_event(false); im_info_t im_info; if (instance.dep_memory(proposal_inst::image_info_index).get_layout().data_type == data_types::f16) { - read_image_info::type>(stream, instance, im_info); + read_image_info::value_type>(stream, instance, im_info); } else { - read_image_info::type>(stream, instance, im_info); + read_image_info::value_type>(stream, instance, im_info); } if (instance.dep_memory(proposal_inst::cls_scores_index).get_layout().data_type != @@ -408,26 +408,26 @@ struct proposal_impl : typed_primitive_impl { if (instance.dependencies().size() == 4) { auto proposal_probabilities = instance.dep_memory_ptr(proposal_inst::proposal_probabilities_out); if (instance.dep_memory(proposal_inst::cls_scores_index).get_layout().data_type == data_types::f16) { - mem_lock::type, mem_lock_type::read> proposal_prob_ptr{proposal_probabilities, stream}; - execute::type>(stream, instance, im_info, proposal_prob_ptr.data()); + mem_lock::value_type, mem_lock_type::read> proposal_prob_ptr{proposal_probabilities, stream}; + execute::value_type>(stream, instance, im_info, proposal_prob_ptr.data()); } else { - mem_lock::type, mem_lock_type::read> proposal_prob_ptr{proposal_probabilities, stream}; - execute::type>(stream, instance, im_info, proposal_prob_ptr.data()); + mem_lock::value_type, mem_lock_type::read> proposal_prob_ptr{proposal_probabilities, stream}; + execute::value_type>(stream, instance, im_info, proposal_prob_ptr.data()); } } else if (instance.outputs_memory_count() == 2) { auto proposal_probabilities = instance.output_memory_ptr(1); if (instance.dep_memory(proposal_inst::cls_scores_index).get_layout().data_type == data_types::f16) { - mem_lock::type, mem_lock_type::write> proposal_prob_ptr{proposal_probabilities, stream}; - execute::type>(stream, instance, im_info, proposal_prob_ptr.data()); + mem_lock::value_type, mem_lock_type::write> proposal_prob_ptr{proposal_probabilities, stream}; + execute::value_type>(stream, instance, im_info, proposal_prob_ptr.data()); } else { - mem_lock::type, mem_lock_type::write> proposal_prob_ptr{proposal_probabilities, stream}; - execute::type>(stream, instance, im_info, proposal_prob_ptr.data()); + mem_lock::value_type, mem_lock_type::write> proposal_prob_ptr{proposal_probabilities, stream}; + execute::value_type>(stream, instance, im_info, proposal_prob_ptr.data()); } } else { if (instance.dep_memory(proposal_inst::cls_scores_index).get_layout().data_type == data_types::f16) { - execute::type>(stream, instance, im_info); + execute::value_type>(stream, instance, im_info); } else { - execute::type>(stream, instance, im_info); + execute::value_type>(stream, instance, im_info); } } diff --git a/src/plugins/intel_gpu/src/graph/impls/onednn/convolution_onednn.cpp b/src/plugins/intel_gpu/src/graph/impls/onednn/convolution_onednn.cpp index 075929afa765fb..aa11884b2445bc 100644 --- a/src/plugins/intel_gpu/src/graph/impls/onednn/convolution_onednn.cpp +++ b/src/plugins/intel_gpu/src/graph/impls/onednn/convolution_onednn.cpp @@ -121,9 +121,9 @@ struct convolution_onednn : typed_primitive_onednn_impl { } if (a_zp_dtype == data_types::i8) { - set_activation_zero_points_attr::type>(attrs, a_zp.as(), zero_point_mask); + set_activation_zero_points_attr::value_type>(attrs, a_zp.as(), zero_point_mask); } else { // if (a_zp_dtype == data_types::u8) - set_activation_zero_points_attr::type>(attrs, a_zp.as(), zero_point_mask); + set_activation_zero_points_attr::value_type>(attrs, a_zp.as(), zero_point_mask); } } diff --git a/src/plugins/intel_gpu/src/graph/primitive_inst.cpp b/src/plugins/intel_gpu/src/graph/primitive_inst.cpp index 44b1fec8bb0963..6c1e88de349115 100644 --- a/src/plugins/intel_gpu/src/graph/primitive_inst.cpp +++ b/src/plugins/intel_gpu/src/graph/primitive_inst.cpp @@ -425,7 +425,7 @@ event::ptr primitive_inst::realloc_if_needed() { auto current_shape = actual_layout.get_shape(); auto& sp = get_network().get_shape_predictor(); - auto dt_size = data_type_traits::size_of(actual_layout.data_type); + auto dt_size = ov::element::Type(actual_layout.data_type).bitwidth(); auto prealloc_info = sp.predict_preallocation_shape(id(), current_shape, dt_size, can_reuse_buffer); if (prealloc_info.first && sp.can_preallocate(ov::shape_size(prealloc_info.second) * dt_size)) { auto new_layout = actual_layout; diff --git a/src/plugins/intel_gpu/src/graph/prior_box.cpp b/src/plugins/intel_gpu/src/graph/prior_box.cpp index 899f0db6f2ba4a..571a2c6d92c218 100644 --- a/src/plugins/intel_gpu/src/graph/prior_box.cpp +++ b/src/plugins/intel_gpu/src/graph/prior_box.cpp @@ -401,12 +401,12 @@ void prior_box_node::calc_result() { // perform calculations if (get_output_layout().data_type == data_types::f16) - calculate_prior_box_output::type>(result, + calculate_prior_box_output::value_type>(result, get_program().get_stream(), input().get_output_layout(), *typed_desc()); else - calculate_prior_box_output::type>(result, + calculate_prior_box_output::value_type>(result, get_program().get_stream(), input().get_output_layout(), *typed_desc()); diff --git a/src/plugins/intel_gpu/src/plugin/sync_infer_request.cpp b/src/plugins/intel_gpu/src/plugin/sync_infer_request.cpp index 6e9e8bbf353803..61ac1424c7649e 100644 --- a/src/plugins/intel_gpu/src/plugin/sync_infer_request.cpp +++ b/src/plugins/intel_gpu/src/plugin/sync_infer_request.cpp @@ -167,11 +167,10 @@ bool same_host_mem(cldnn::memory::cptr memory, const uint8_t* host_ptr) { } ov::Shape predict_shape(const std::string& name, const ov::Shape current_shape, ov::element::Type element_type, cldnn::ShapePredictor& shape_predictor) { - auto et_size = cldnn::ceil_div(element_type.bitwidth(), 8); - auto prealloc_info = shape_predictor.predict_preallocation_shape(name, current_shape, et_size, false); + auto prealloc_info = shape_predictor.predict_preallocation_shape(name, current_shape, element_type.bitwidth(), false); const auto& preallocation_shape = prealloc_info.second; auto can_preallocate_buffer = prealloc_info.first && - shape_predictor.can_preallocate(ov::shape_size(preallocation_shape) * et_size); + shape_predictor.can_preallocate(cldnn::ceil_div(ov::shape_size(preallocation_shape) * element_type.bitwidth(), 8)); if (can_preallocate_buffer) { return preallocation_shape; } diff --git a/src/plugins/intel_gpu/src/runtime/shape_predictor.cpp b/src/plugins/intel_gpu/src/runtime/shape_predictor.cpp index 2d398ee89ff1de..1ff00c905bd073 100644 --- a/src/plugins/intel_gpu/src/runtime/shape_predictor.cpp +++ b/src/plugins/intel_gpu/src/runtime/shape_predictor.cpp @@ -58,7 +58,7 @@ bool ShapePredictor::can_preallocate(size_t desired_buffer_size) { std::pair ShapePredictor::predict_preallocation_shape(const std::string& id, const ov::Shape& current_shape, - size_t dt_size, + size_t dt_bitwidth, bool can_reuse_buffer) { add_shape(id, current_shape); @@ -110,7 +110,7 @@ std::pair ShapePredictor::predict_preallocation_shape(const std for (size_t i = 0; i < current_shape.size(); ++i) single_iter_shape.push_back(diffs[0][i] == 0 ? current_shape[i] : 1); - if (ov::shape_size(single_iter_shape) * dt_size > _max_per_iter_size) + if (ceil_div(ov::shape_size(single_iter_shape) * dt_bitwidth, 8) > _max_per_iter_size) can_use_iterations_preallocation = false; } diff --git a/src/plugins/intel_gpu/tests/unit/module_tests/shape_predictor_test.cpp b/src/plugins/intel_gpu/tests/unit/module_tests/shape_predictor_test.cpp index e6c78b4fd8513e..5e5caa91cd7d3f 100644 --- a/src/plugins/intel_gpu/tests/unit/module_tests/shape_predictor_test.cpp +++ b/src/plugins/intel_gpu/tests/unit/module_tests/shape_predictor_test.cpp @@ -25,10 +25,10 @@ TEST_P(shape_predictor_tests, prediction) { ShapePredictor sp(&engine, p.buffers_preallocation_ratio); std::pair result; - const auto dt_size = 4; + const auto dt_bitwidth = ov::element::f32.bitwidth(); for (auto& shape : in_shapes) - result = sp.predict_preallocation_shape("dummy_name", shape, dt_size, p.can_reuse_buffer); + result = sp.predict_preallocation_shape("dummy_name", shape, dt_bitwidth, p.can_reuse_buffer); ASSERT_TRUE(result.first == !expected_predicted_shape.empty()); ASSERT_EQ(result.second, expected_predicted_shape); diff --git a/src/plugins/intel_gpu/tests/unit/shape_infer/random_uniform_si_test.cpp b/src/plugins/intel_gpu/tests/unit/shape_infer/random_uniform_si_test.cpp index 6597351a0c728c..f41cafc9e2d4f9 100644 --- a/src/plugins/intel_gpu/tests/unit/shape_infer/random_uniform_si_test.cpp +++ b/src/plugins/intel_gpu/tests/unit/shape_infer/random_uniform_si_test.cpp @@ -67,19 +67,19 @@ TEST_P(random_uniform_si_test, shape_infer) { set_values(allocated_mem, {ov::float16(val).to_bits()}); break; case data_types::f32: - set_values(allocated_mem, {static_cast::type>(val)}); + set_values(allocated_mem, {static_cast::value_type>(val)}); break; case data_types::i32: - set_values(allocated_mem, {static_cast::type>(val)}); + set_values(allocated_mem, {static_cast::value_type>(val)}); break; case data_types::i64: - set_values(allocated_mem, {static_cast::type>(val)}); + set_values(allocated_mem, {static_cast::value_type>(val)}); break; case data_types::i8: - set_values(allocated_mem, {static_cast::type>(val)}); + set_values(allocated_mem, {static_cast::value_type>(val)}); break; case data_types::u8: - set_values(allocated_mem, {static_cast::type>(val)}); + set_values(allocated_mem, {static_cast::value_type>(val)}); break; default: break; diff --git a/src/plugins/intel_gpu/tests/unit/shape_infer/range_si_test.cpp b/src/plugins/intel_gpu/tests/unit/shape_infer/range_si_test.cpp index 2430d628aa2c42..b079017d5c12e0 100644 --- a/src/plugins/intel_gpu/tests/unit/shape_infer/range_si_test.cpp +++ b/src/plugins/intel_gpu/tests/unit/shape_infer/range_si_test.cpp @@ -66,19 +66,19 @@ TEST_P(range_si_test, shape_infer) { set_values(prim_mem, {ov::float16(p.vals[idx]).to_bits()}); break; case data_types::f32: - set_values(prim_mem, {static_cast::type>(p.vals[idx])}); + set_values(prim_mem, {static_cast::value_type>(p.vals[idx])}); break; case data_types::i32: - set_values(prim_mem, {static_cast::type>(p.vals[idx])}); + set_values(prim_mem, {static_cast::value_type>(p.vals[idx])}); break; case data_types::i64: - set_values(prim_mem, {static_cast::type>(p.vals[idx])}); + set_values(prim_mem, {static_cast::value_type>(p.vals[idx])}); break; case data_types::i8: - set_values(prim_mem, {static_cast::type>(p.vals[idx])}); + set_values(prim_mem, {static_cast::value_type>(p.vals[idx])}); break; case data_types::u8: - set_values(prim_mem, {static_cast::type>(p.vals[idx])}); + set_values(prim_mem, {static_cast::value_type>(p.vals[idx])}); break; default: break; diff --git a/src/plugins/intel_gpu/tests/unit/test_cases/permute_gpu_test.cpp b/src/plugins/intel_gpu/tests/unit/test_cases/permute_gpu_test.cpp index 7be1609c64a9c9..ac22cc773f885a 100644 --- a/src/plugins/intel_gpu/tests/unit/test_cases/permute_gpu_test.cpp +++ b/src/plugins/intel_gpu/tests/unit/test_cases/permute_gpu_test.cpp @@ -2,6 +2,7 @@ // SPDX-License-Identifier: Apache-2.0 // +#include "openvino/core/type/element_type_traits.hpp" #include "test_utils.h" #include "random_generator.hpp" @@ -1924,7 +1925,7 @@ void TiledPermuteTest::run_test(const std::vector& si const std::string & permute_opt, std::vector permute_order, bool is_caching_test) { // convert ov::float16 to ov::float16 - using type_ = typename data_type_to_type::type; + using type_ = typename ov::element_type_traits::value_type; using type = typename std::conditional::value, ov::float16, type_>::type; std::vector internal_sizes(sizes); @@ -2318,7 +2319,7 @@ struct TiledPerformancePermuteTest : TiledPermuteTest { auto& engine = get_test_engine(); // convert ov::float16 to ov::float16 - using type_ = typename data_type_to_type::type; + using type_ = typename ov::element_type_traits::value_type; using type = typename std::conditional::value, ov::float16, type_>::type; std::vector internal_sizes(sizes); From c24d1b4abcc565eef1f87193c364edbfcfcfe047 Mon Sep 17 00:00:00 2001 From: Irina Efode Date: Mon, 16 Oct 2023 15:19:07 +0400 Subject: [PATCH 09/12] [CONFORMANCE][CPU] Add Expected failures for CPU Opset13 OP (#20490) * [CONFORMANCE][CPU] Add Expected failures for CPU Opset13 OP * Update expected_failures_OP.csv * Update expected_failures_OP.csv --- .../skip_configs/CPU/expected_failures_OP.csv | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/tests/test_utils/functional_test_utils/layer_tests_summary/skip_configs/CPU/expected_failures_OP.csv b/src/tests/test_utils/functional_test_utils/layer_tests_summary/skip_configs/CPU/expected_failures_OP.csv index 84d3e26eb35fc2..07f091dd7a222b 100644 --- a/src/tests/test_utils/functional_test_utils/layer_tests_summary/skip_configs/CPU/expected_failures_OP.csv +++ b/src/tests/test_utils/functional_test_utils/layer_tests_summary/skip_configs/CPU/expected_failures_OP.csv @@ -1130,3 +1130,10 @@ conformance_PRelu/ReadIRTest.ImportExport/Op=PRelu.1_Type=f32_IR=20e7e74f55eb5fb conformance_RegionYolo/ReadIRTest.ImportExport/Op=RegionYolo.1_Type=f32_IR=RegionYolo-1_750_Device=CPU_Shape=static_Config=(),5.06332e-06 conformance_Add/ReadIRTest.ImportExport/Op=Add.1_Type=i32_IR=28f23780d4ca0d40671caf79d5cd9223ad8f6dc2fa5ade2521f3d99586eeeb7f_Device=CPU_Shape=static_Config=(),9.72615e-07 conformance_Convolution/ReadIRTest.Inference/Op=Convolution.1_Type=f32_IR=c301804445f273eef62f41f02204711d9d6e571da28c76ab447d7d90983b0032_Device=CPU_Shape=dynamic_Config=(),0.000113281 +conformance/OpImplCheckTest.checkPluginImplementation/Function=BitwiseAnd_opset13_Device=CPU_Config=(),1 +conformance/OpImplCheckTest.checkPluginImplementation/Function=BitwiseOr_opset13_Device=CPU_Config=(),1 +conformance/OpImplCheckTest.checkPluginImplementation/Function=BitwiseNot_opset13_Device=CPU_Config=(),1 +conformance/OpImplCheckTest.checkPluginImplementation/Function=Multinomial_opset13_Device=CPU_Config=(),1 +conformance/OpImplCheckTest.checkPluginImplementation/Function=NMSRotated_opset13_Device=CPU_Config=(),1 +conformance/OpImplCheckTest.checkPluginImplementation/Function=LSTMSequence_opset1_Device=CPU_Config=(),1 +conformance/OpImplCheckTest.checkPluginImplementation/Function=BitwiseXor_opset13_Device=CPU_Config=(),1 From a5b5623ece0d492b4d65a4213402f77904f13f9a Mon Sep 17 00:00:00 2001 From: Siddhant Chauhan Date: Mon, 16 Oct 2023 17:22:30 +0530 Subject: [PATCH 10/12] [TF FE][TF Hub] Support Xlogy operation (#20467) * [TF FE][TF Hub] Support Xlogy operation * fix * fix * fix * fix * Update tests/layer_tests/tensorflow_tests/test_tf_Xlogy.py * Update tests/layer_tests/tensorflow_tests/test_tf_Xlogy.py --------- Co-authored-by: Roman Kazantsev --- src/frontends/tensorflow/src/op_table.cpp | 1 + .../include/common_op_table.hpp | 1 + .../tensorflow_common/src/op/xlogy.cpp | 43 ++++++++++++++++ .../tensorflow_tests/test_tf_Xlogy.py | 49 +++++++++++++++++++ 4 files changed, 94 insertions(+) create mode 100644 src/frontends/tensorflow_common/src/op/xlogy.cpp create mode 100644 tests/layer_tests/tensorflow_tests/test_tf_Xlogy.py diff --git a/src/frontends/tensorflow/src/op_table.cpp b/src/frontends/tensorflow/src/op_table.cpp index fce3af3f0a235b..7c093d7301a640 100644 --- a/src/frontends/tensorflow/src/op_table.cpp +++ b/src/frontends/tensorflow/src/op_table.cpp @@ -286,6 +286,7 @@ const std::map get_supported_ops() { {"While", CreatorFunction(translate_while_op)}, {"Where", CreatorFunction(translate_where_op)}, {"Xdivy", CreatorFunction(translate_x_div_y_op)}, + {"Xlogy", CreatorFunction(translate_xlogy_op)}, {"ZerosLike", CreatorFunction(translate_zeros_like_op)}, // Translators for SavedModel and MetaGraph diff --git a/src/frontends/tensorflow_common/include/common_op_table.hpp b/src/frontends/tensorflow_common/include/common_op_table.hpp index 17a865acfb0e99..9c1f995f25f1e8 100644 --- a/src/frontends/tensorflow_common/include/common_op_table.hpp +++ b/src/frontends/tensorflow_common/include/common_op_table.hpp @@ -149,6 +149,7 @@ OP_CONVERTER(translate_unravel_index_op); OP_CONVERTER(translate_unsorted_segment_sum_op); OP_CONVERTER(translate_where_op); OP_CONVERTER(translate_x_div_y_op); +OP_CONVERTER(translate_xlogy_op); OP_CONVERTER(translate_zeros_like_op); // Translators for internal operations diff --git a/src/frontends/tensorflow_common/src/op/xlogy.cpp b/src/frontends/tensorflow_common/src/op/xlogy.cpp new file mode 100644 index 00000000000000..8b4f9da063a27e --- /dev/null +++ b/src/frontends/tensorflow_common/src/op/xlogy.cpp @@ -0,0 +1,43 @@ +// Copyright (C) 2018-2023 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "common_op_table.hpp" +#include "openvino/op/constant.hpp" +#include "openvino/op/convert_like.hpp" +#include "openvino/op/equal.hpp" +#include "openvino/op/log.hpp" +#include "openvino/op/multiply.hpp" +#include "openvino/op/select.hpp" + +using namespace std; +using namespace ov::opset10; + +namespace ov { +namespace frontend { +namespace tensorflow { +namespace op { +OutputVector translate_xlogy_op(const NodeContext& node) { + default_op_checks(node, 2, {"Xlogy"}); + auto x = node.get_input(0); + auto y = node.get_input(1); + + // prepare auxiliary zero constant of the same type as the input + auto zero = create_same_type_const_scalar(x, 0); + + // compute a mask to identify where x is equal to 0 + auto is_zero = make_shared(x, zero); + + // compute x * log(y) elementwise + auto xlog_y = make_shared(x, make_shared(y)); + + // create the output tensor using Select to handle the x == 0 condition + auto result = make_shared