From a00d28aac0efda832209dbaf6794481a1c16005c Mon Sep 17 00:00:00 2001 From: Vladimir Paramuzov Date: Mon, 16 Oct 2023 14:54:32 +0400 Subject: [PATCH 1/3] [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 2/3] [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 3/3] [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