diff --git a/src/core/dev_api/validation_util.hpp b/src/core/dev_api/validation_util.hpp index 82f1f193c5277a..57430f5cef35ca 100644 --- a/src/core/dev_api/validation_util.hpp +++ b/src/core/dev_api/validation_util.hpp @@ -63,29 +63,6 @@ Tensor make_tensor_of_max_value(const element::Type_t et); /// \return Tensor with minimum value. Tensor make_tensor_of_min_value(const element::Type_t et); -/// \brief Apply auto padding to padding_above and padding_below inputs -/// if all needed informations are known. -/// -/// \param image_shape The shape of input image. -/// \param filter_shape The shape of filter input. -/// \param filter_strides The strides of applied padding. -/// \param filter_dilations The dilations of applied padding. -/// \param pad_type The type of padding. Auto padding is applied only -/// for SAME_UPPER and SAME_LOWER mode. -/// \param padding_above The beginning of padding shape. -/// \param end The beginning of padding shape. -/// -/// \return true if auto padding was applied successfully (all needed informations such as -/// spatial dims are known), false otherwise. -OPENVINO_DEPRECATED("This function is deprecated and will be removed.") -OPENVINO_API bool try_apply_auto_padding(const PartialShape& image_shape, - const Shape& filter_shape, - const Strides& filter_strides, - const Strides& filter_dilations, - const op::PadType pad_type, - CoordinateDiff& padding_above, - CoordinateDiff& padding_below); - /// @brief Get the tensors shapes as ov::PartialShape. /// /// @param tensors Input tensors vector to get their shapes. @@ -107,29 +84,6 @@ OPENVINO_API std::vector get_node_input_partial_shapes(const ov::N /// \return True if rank compatible to any of others, otherwise false. OPENVINO_API bool is_rank_compatible_any_of(const Rank& r, std::initializer_list others); -/// \brief Infers the output batch shape for convolution forward propagation. -/// -/// \return Infered output shape. -OPENVINO_DEPRECATED("This function is deprecated and will be removed.") -OPENVINO_API PartialShape infer_convolution_forward(const Node* node, - const PartialShape& data_batch_shape, - const Strides& data_dilation, - const CoordinateDiff& data_padding_below, - const CoordinateDiff& data_padding_above, - const PartialShape& filters_shape, - const Strides& filter_strides, - const Strides& filter_dilation); - -/// \brief Infers image paddings. -OPENVINO_DEPRECATED("This function is deprecated and will be removed.") -OPENVINO_API void infer_auto_padding(const Shape& image_shape, - const Shape& filter_shape, - const Strides& filter_strides, - const Strides& filter_dilations, - const op::PadType pad_type, - CoordinateDiff& padding_above, - CoordinateDiff& padding_below); - /// \brief Evaluates lower and upper value estimations for the output tensor. Estimation would be represented as partial /// shape object using Dimension(min, max) for each element. /// diff --git a/src/core/include/ngraph/validation_util.hpp b/src/core/include/ngraph/validation_util.hpp index 3535911b1eb9bb..09d485791b99b7 100644 --- a/src/core/include/ngraph/validation_util.hpp +++ b/src/core/include/ngraph/validation_util.hpp @@ -25,8 +25,6 @@ namespace ngraph { using ov::evaluate_as_partial_shape; using ov::get_constant_from_source; using ov::has_no_labels; -using ov::infer_auto_padding; -using ov::infer_convolution_forward; using ov::normalize_axes; using ov::normalize_axis; using ov::op::v0::Constant; @@ -63,29 +61,6 @@ void validate_conv_params_spatial_dimensions(const Node* node, CoordinateDiff& pads_begin, CoordinateDiff& pads_end); -/// \brief Validates input shape ranks and infers convolution forward output shape. -/// -/// \param[in] node Node with convolution operation. -/// \param[in] data_batch_pshape Partial shape of data batch input. -/// \param[in] filters_pshape Partial shape of filters input. -/// \param[in] auto_pad Type of padding. -/// \param strides Strides. -/// \param dilations Dilations. -/// \param pads_begin Pads begin. -/// \param pads_end Pads end. -/// -/// \return Partial shape of the output. -NGRAPH_API_DEPRECATED -PartialShape validate_and_infer_convolution_forward_output_shape(const Node* node, - const Rank& result_ps_rank, - const PartialShape& data_batch_pshape, - const PartialShape& filters_pshape, - const op::PadType auto_pad, - Strides& strides, - Strides& dilations, - CoordinateDiff& pads_begin, - CoordinateDiff& pads_end); - NGRAPH_API_DEPRECATED NGRAPH_API PartialShape infer_batched_pooling_forward(const Node* node, @@ -122,30 +97,6 @@ std::tuple infer_batch_norm_forward(c const PartialShape& gamma_shape, const PartialShape& beta_shape); -/// \brief Apply auto padding to padding_above and padding_below inputs -/// if all needed informations are known. -/// -/// \param image_shape The shape of input image. -/// \param filter_shape The shape of filter input. -/// \param filter_strides The strides of applied padding. -/// \param filter_dilations The dilations of applied padding. -/// \param pad_type The type of padding. Auto padding is applied only -/// for SAME_UPPER and SAME_LOWER mode. -/// \param padding_above The beginning of padding shape. -/// \param end The beginning of padding shape. -/// -/// \return true if auto padding was applied successfully (all needed informations such as -/// spatial dims are known), false otherwise. -NGRAPH_API_DEPRECATED -NGRAPH_API -bool try_apply_auto_padding(const PartialShape& image_shape, - const Shape& filter_shape, - const Strides& filter_strides, - const Strides& filter_dilations, - const op::PadType pad_type, - CoordinateDiff& padding_above, - CoordinateDiff& padding_below); - NGRAPH_API_DEPRECATED NGRAPH_API PartialShape infer_slice_shape(const Node* node, diff --git a/src/core/include/openvino/core/validation_util.hpp b/src/core/include/openvino/core/validation_util.hpp index 4316bdbebc549d..51ef5facdb4b21 100644 --- a/src/core/include/openvino/core/validation_util.hpp +++ b/src/core/include/openvino/core/validation_util.hpp @@ -11,27 +11,6 @@ namespace ov { -OPENVINO_DEPRECATED("This function is deprecated and will be moved to dev api in 2024.0 release.") -OPENVINO_API -PartialShape infer_convolution_forward(const Node* node, - const PartialShape& data_batch_shape, - const Strides& data_dilation, - const CoordinateDiff& data_padding_below, - const CoordinateDiff& data_padding_above, - const PartialShape& filters_shape, - const Strides& filter_strides, - const Strides& filter_dilation); - -OPENVINO_DEPRECATED("This function is deprecated and will be moved to dev api in 2024.0 release.") -OPENVINO_API -void infer_auto_padding(const Shape& image_shape, - const Shape& filter_shape, - const Strides& filter_strides, - const Strides& filter_dilations, - const op::PadType pad_type, - CoordinateDiff& padding_above, - CoordinateDiff& padding_below); - /// \brief Handle out of range axis. /// /// \param[in] node The node with requested axis. diff --git a/src/core/src/validation_util.cpp b/src/core/src/validation_util.cpp index a4597f7aac6a76..23256da00e3c5b 100644 --- a/src/core/src/validation_util.cpp +++ b/src/core/src/validation_util.cpp @@ -230,72 +230,6 @@ void validate_conv_params_spatial_dimensions(const Node* node, "Pads should be defined for all and only spatial features."); } -PartialShape validate_and_infer_convolution_forward_output_shape(const Node* node, - const Rank& result_ps_rank, - const PartialShape& data_batch_pshape, - const PartialShape& filters_pshape, - const op::PadType auto_pad, - Strides& strides, - Strides& dilations, - CoordinateDiff& pads_begin, - CoordinateDiff& pads_end) { - PartialShape result_shape = PartialShape::dynamic(); - if (result_ps_rank.is_static()) { - const auto num_spatial_dims = result_ps_rank.get_length() - 2; - validate_conv_params_spatial_dimensions(node, - num_spatial_dims, - auto_pad, - strides, - dilations, - pads_begin, - pads_end); - - result_shape = PartialShape::dynamic(result_ps_rank); - if (data_batch_pshape.rank().is_static()) { - result_shape[0] = data_batch_pshape[0]; // batch size - } - if (filters_pshape.rank().is_static()) { - result_shape[1] = filters_pshape[0]; // filter channel size - } - if (auto_pad == op::PadType::SAME_UPPER || auto_pad == op::PadType::SAME_LOWER) { - bool auto_padding_applied = false; - if (filters_pshape.rank().is_static() && filters_pshape.rank().get_length() > 2) { - pads_begin.clear(); - pads_end.clear(); - - const PartialShape filter_spatial_shape = [filters_pshape]() { - std::vector filter_dims{filters_pshape}; - filter_dims.erase(filter_dims.begin(), - filter_dims.begin() + 2); // Remove {C_OUT, C_IN} - return PartialShape{filter_dims}; - }(); - - if (filter_spatial_shape.is_static()) { - auto_padding_applied = try_apply_auto_padding(data_batch_pshape, - filter_spatial_shape.to_shape(), - strides, - dilations, - auto_pad, - pads_end, - pads_begin); - } - } - if (!auto_padding_applied) { - return result_shape; - } - } - result_shape = infer_convolution_forward(node, - data_batch_pshape, - Strides(num_spatial_dims, 1), // dummy data dilations - pads_begin, - pads_end, - filters_pshape, - strides, - dilations); - } - return result_shape; -} - // // Infers the output batch shape and element type for batched pooling fprop. // @@ -520,22 +454,6 @@ std::tuple infer_batch_norm_forward(c {{gamma_element_type, gamma_shape, "gamma"}, {beta_element_type, beta_shape, "beta"}}); } -bool try_apply_auto_padding(const PartialShape& image_shape, - const Shape& filter_shape, - const Strides& filter_strides, - const Strides& filter_dilations, - const op::PadType pad_type, - CoordinateDiff& padding_above, - CoordinateDiff& padding_below) { - return ov::util::try_apply_auto_padding(image_shape, - filter_shape, - filter_strides, - filter_dilations, - pad_type, - padding_above, - padding_below); -} - PartialShape infer_slice_shape(const Node* node, const PartialShape& input_shape, const std::vector& begin, @@ -930,22 +848,6 @@ std::shared_ptr get_constant_lowest_of_type(element::Type_t t) } } // namespace ngraph -void ov::infer_auto_padding(const Shape& image_shape, - const Shape& filter_shape, - const Strides& filter_strides, - const Strides& filter_dilations, - const op::PadType pad_type, - CoordinateDiff& padding_above, - CoordinateDiff& padding_below) { - ov::util::infer_auto_padding(image_shape, - filter_shape, - filter_strides, - filter_dilations, - pad_type, - padding_above, - padding_below); -} - namespace { const auto normalize_axis_to = [](const int64_t& tensor_rank) { return [&tensor_rank](int64_t& axis) { @@ -1070,27 +972,6 @@ std::shared_ptr ov::util::constantfold_subgraph(const Outp return ov::as_type_ptr(outputs[subgraph_sink.get_index()].get_node_shared_ptr()); } -// -// Infers the output batch shape for convolution fprop. -// -ov::PartialShape ov::infer_convolution_forward(const Node* node, - const PartialShape& data_batch_shape, - const Strides& data_dilation, - const CoordinateDiff& data_padding_below, - const CoordinateDiff& data_padding_above, - const PartialShape& filters_shape, - const Strides& filter_strides, - const Strides& filter_dilation) { - return ov::util::infer_convolution_forward(node, - data_batch_shape, - data_dilation, - data_padding_below, - data_padding_above, - filters_shape, - filter_strides, - filter_dilation); -} - namespace ov { namespace util { using ov::op::v0::Constant; @@ -1213,178 +1094,6 @@ bool is_rank_compatible_any_of(const Rank& r, std::initializer_list others }); } -PartialShape infer_convolution_forward(const Node* node, - const PartialShape& data_batch_shape, - const Strides& data_dilation, - const CoordinateDiff& data_padding_below, - const CoordinateDiff& data_padding_above, - const PartialShape& filters_shape, - const Strides& filter_strides, - const Strides& filter_dilation) { - Rank data_batch_filters_rank{Rank::dynamic()}; - - NODE_VALIDATION_CHECK(node, - Rank::merge(data_batch_filters_rank, data_batch_shape.rank(), filters_shape.rank()), - "Data batch and filters rank do not match (data batch shape: ", - data_batch_shape, - ", filters shape: ", - filters_shape, - ")."); - - NODE_VALIDATION_CHECK(node, - data_batch_filters_rank.is_dynamic() || data_batch_filters_rank.get_length() >= 3, - "Data batch and filters must have rank of at least 3 (one batch axis, ", - "one input-channel axis, and at least one spatial dimension) ", - "(data batch shape: ", - data_batch_shape, - ", filters shape: ", - filters_shape, - ")."); - - Rank spatial_rank{Rank::dynamic()}; - NODE_VALIDATION_CHECK(node, - Rank::merge(spatial_rank, spatial_rank, data_batch_filters_rank - 2) && - Rank::merge(spatial_rank, spatial_rank, data_dilation.size()) && - Rank::merge(spatial_rank, spatial_rank, data_padding_below.size()) && - Rank::merge(spatial_rank, spatial_rank, data_padding_above.size()) && - Rank::merge(spatial_rank, spatial_rank, filter_strides.size()) && - Rank::merge(spatial_rank, spatial_rank, filter_dilation.size()), - "Ranks for data item shape/filters shape (data batch has shape ", - data_batch_shape, - ", so data item rank is ", - (data_batch_shape.rank() - 2), - " and filters have shape ", - filters_shape, - ", so filters spatial rank is ", - (filters_shape.rank() - 2), - "), data dilation (", - data_dilation, - "), padding below (", - data_padding_below, - "), padding above (", - data_padding_above, - "), filter strides (", - filter_strides, - "), and filter dilation (", - filter_dilation, - ") do not match."); - - Dimension batch_size = (data_batch_shape.rank().is_static() ? data_batch_shape[0] : Dimension::dynamic()); - Dimension data_channel_count = (data_batch_shape.rank().is_static() ? data_batch_shape[1] : Dimension::dynamic()); - PartialShape data_spatial_shape(PartialShape::dynamic(spatial_rank)); - - Dimension filter_output_channel_count = - (filters_shape.rank().is_static() ? filters_shape[0] : Dimension::dynamic()); - Dimension filter_input_channel_count = (filters_shape.rank().is_static() ? filters_shape[1] : Dimension::dynamic()); - PartialShape filter_spatial_shape(PartialShape::dynamic(spatial_rank)); - - // - // Note: spatial_rank is definitely static at this point. - // - - for (int64_t i = 0; i < spatial_rank.get_length(); i++) { - if (data_batch_shape.rank().is_static()) { - data_spatial_shape[i] = data_batch_shape[i + 2]; - } - - if (filters_shape.rank().is_static()) { - filter_spatial_shape[i] = filters_shape[i + 2]; - } - } - - NODE_VALIDATION_CHECK(node, batch_size.is_dynamic() || batch_size.get_length() > 0, "Batch size is zero."); - - Dimension merged_channel_count; - - NODE_VALIDATION_CHECK(node, - Dimension::merge(merged_channel_count, data_channel_count, filter_input_channel_count), - "Data batch channel count (", - data_channel_count, - ") does not match filter input ", - "channel count (", - filter_input_channel_count, - ")."); - - NODE_VALIDATION_CHECK(node, - merged_channel_count.is_dynamic() || merged_channel_count.get_length() > 0, - "Data batch channel count and/or filter input channel count is zero."); - - NODE_VALIDATION_CHECK(node, - filter_output_channel_count.is_dynamic() || filter_output_channel_count.get_length() > 0, - "Filter output channel count is zero."); - - PartialShape data_output_shape = ngraph::infer_windowed_reduction_output_shape(node, - data_spatial_shape, - data_dilation, - data_padding_below, - data_padding_above, - filter_spatial_shape, - filter_strides, - filter_dilation, - true); - - PartialShape batch_output_shape(PartialShape::dynamic(spatial_rank + 2)); - batch_output_shape[0] = batch_size; - batch_output_shape[1] = filter_output_channel_count; - - for (int64_t i = 0; i < spatial_rank.get_length(); i++) { - batch_output_shape[i + 2] = data_output_shape[i]; - } - - return batch_output_shape; -} - -bool try_apply_auto_padding(const PartialShape& image_shape, - const Shape& filter_shape, - const Strides& filter_strides, - const Strides& filter_dilations, - const op::PadType pad_type, - CoordinateDiff& padding_above, - CoordinateDiff& padding_below) { - OPENVINO_ASSERT(pad_type == op::PadType::SAME_UPPER || pad_type == op::PadType::SAME_LOWER); - - if (image_shape.rank().is_dynamic()) { - return false; - } - const auto image_dims = static_cast>(image_shape); - for (size_t i = 0; i < static_cast(filter_shape.size()); i++) { - if (image_dims[i + 2].is_static()) { - auto image_size = static_cast(image_dims[i + 2].get_length()); - int64_t filter_size = (static_cast(filter_shape[i]) - 1) * filter_dilations[i] + 1; - auto filter_stride = static_cast(filter_strides[i]); - auto output_size = (image_size + filter_stride - 1) / filter_stride; - - auto padding_needed = std::max(int64_t(0), (output_size - 1) * filter_stride + filter_size - image_size); - auto padding_lhs = padding_needed / 2; - auto padding_rhs = padding_needed - padding_lhs; - padding_below.push_back(pad_type == op::PadType::SAME_UPPER ? padding_lhs : padding_rhs); - padding_above.push_back(pad_type == op::PadType::SAME_UPPER ? padding_rhs : padding_lhs); - } else { - padding_below.push_back(0); - padding_above.push_back(0); - } - } - return true; -} - -void infer_auto_padding(const Shape& image_shape, - const Shape& filter_shape, - const Strides& filter_strides, - const Strides& filter_dilations, - const op::PadType pad_type, - CoordinateDiff& padding_above, - CoordinateDiff& padding_below) { - const auto image_dims = std::vector(std::begin(image_shape), std::end(image_shape)); - // because image_shape is fully known result of try_apply_infer_auto_padding is ignored - try_apply_auto_padding(image_dims, - filter_shape, - filter_strides, - filter_dilations, - pad_type, - padding_above, - padding_below); -} - bool evaluate_as_partial_shape(const Output& output, PartialShape& pshape) { Tensor lb, ub; std::tie(lb, ub) = evaluate_both_bounds(output); diff --git a/src/frontends/onnx/frontend/src/utils/convpool.cpp b/src/frontends/onnx/frontend/src/utils/convpool.cpp index f789eb58ecf4fa..d78d403c098bd7 100644 --- a/src/frontends/onnx/frontend/src/utils/convpool.cpp +++ b/src/frontends/onnx/frontend/src/utils/convpool.cpp @@ -142,13 +142,25 @@ void calculate_auto_pads(const Shape& data_shape, CoordinateDiff& padding_below, CoordinateDiff& padding_above) { if (pad_type == ov::op::PadType::SAME_UPPER || pad_type == ov::op::PadType::SAME_LOWER) { - padding_below.clear(); - padding_above.clear(); - // Extract kernel shape - remove (N,C) channels - Shape kernel_shape(std::next(std::begin(filter_shape), 2), std::end(filter_shape)); - OPENVINO_SUPPRESS_DEPRECATED_START - ov::infer_auto_padding(data_shape, kernel_shape, strides, dilations, pad_type, padding_above, padding_below); - OPENVINO_SUPPRESS_DEPRECATED_END + const auto num_spatial = strides.size(); + padding_below.resize(num_spatial); + padding_above.resize(num_spatial); + auto data_dim = data_shape.cend() - num_spatial; + auto filter_dim = filter_shape.cend() - num_spatial; + + const auto padding_swap = pad_type == ov::op::PadType::SAME_UPPER; + auto&& pad_b = padding_swap ? padding_below.begin() : padding_above.begin(); + auto&& pad_e = padding_swap ? padding_above.begin() : padding_below.begin(); + + for (size_t i = 0; i < num_spatial; ++i, ++pad_b, ++pad_e, ++data_dim, ++filter_dim) { + int64_t filter_size = (static_cast(*filter_dim - 1)) * dilations[i] + 1; + auto filter_stride = static_cast(strides[i]); + auto output_size = (*data_dim + filter_stride - 1) / filter_stride; + + auto padding_needed = std::max(0, (output_size - 1) * filter_stride + filter_size - *data_dim); + *pad_b = padding_needed / 2; + *pad_e = padding_needed - *pad_b; + } } } diff --git a/src/plugins/intel_gpu/src/graph/impls/ocl/convolution.cpp b/src/plugins/intel_gpu/src/graph/impls/ocl/convolution.cpp index 51adecf9464b53..ab73f9e11d69f2 100644 --- a/src/plugins/intel_gpu/src/graph/impls/ocl/convolution.cpp +++ b/src/plugins/intel_gpu/src/graph/impls/ocl/convolution.cpp @@ -2,13 +2,14 @@ // SPDX-License-Identifier: Apache-2.0 // -#include "primitive_base.hpp" -#include "kernel_base.h" -#include "convolution_inst.h" #include "convolution/convolution_kernel_selector.h" #include "convolution/convolution_params.h" -#include "ngraph/validation_util.hpp" +#include "convolution_inst.h" +#include "convolution_shape_inference.hpp" #include "intel_gpu/plugin/common_utils.hpp" +#include "kernel_base.h" +#include "primitive_base.hpp" +#include "validation_util.hpp" namespace cldnn { namespace ocl { @@ -89,33 +90,30 @@ struct convolution_impl : typed_primitive_impl_ocl { ov::CoordinateDiff pads_end(primitive->padding_end.begin(), primitive->padding_end.end()); const auto auto_pad = primitive->auto_pad; conv_params.has_explicit_paddings = primitive->auto_pad == ov::op::PadType::EXPLICIT; + if (auto_pad == ov::op::PadType::SAME_UPPER || auto_pad == ov::op::PadType::SAME_LOWER) { const auto& input_layout = impl_param.get_input_layout(); - auto spatial_rank = input_layout.get_spatial_rank(); - std::vector dims; + const auto spatial_rank = input_layout.get_spatial_rank(); + + ov::PartialShape kernel; for (size_t i = 0; i < spatial_rank; i++) { - dims.push_back(static_cast(weights_layout.spatial(i))); + kernel.emplace_back(weights_layout.spatial(i)); } - ov::Shape kernel(dims.begin(), dims.end()); - pads_begin.clear(); - pads_end.clear(); - - OPENVINO_SUPPRESS_DEPRECATED_START - ngraph::try_apply_auto_padding(input_layout.get_partial_shape(), - kernel, - stride, - dilation, - auto_pad, - pads_end, - pads_begin); - OPENVINO_SUPPRESS_DEPRECATED_END - - pads_begin.resize(std::max(2, pads_begin.size()), 0); - pads_end.resize(std::max(2, pads_end.size()), 0); - } - if (auto_pad == ov::op::PadType::VALID) { - pads_begin = ov::CoordinateDiff(pads_begin.size(), 0); - pads_end = ov::CoordinateDiff(pads_end.size(), 0); + + // Use any forward convolution to apply padding + ov::op::v1::Convolution op; + op.set_dilations(dilation); + op.set_strides(stride); + op.set_auto_pad(auto_pad); + + ov::op::convolution::apply_auto_pad(&op, + input_layout.get_partial_shape(), + kernel, + pads_begin.begin(), + pads_end.begin()); + } else if (auto_pad == ov::op::PadType::VALID) { + std::fill(pads_begin.begin(), pads_begin.end(), 0); + std::fill(pads_end.begin(), pads_end.end(), 0); } uint32_t kx = weights_layout.spatial(0); diff --git a/src/plugins/intel_gpu/src/graph/impls/ocl/pooling.cpp b/src/plugins/intel_gpu/src/graph/impls/ocl/pooling.cpp index 6695de698d0d28..4a52cfaabceb2b 100644 --- a/src/plugins/intel_gpu/src/graph/impls/ocl/pooling.cpp +++ b/src/plugins/intel_gpu/src/graph/impls/ocl/pooling.cpp @@ -2,12 +2,12 @@ // SPDX-License-Identifier: Apache-2.0 // -#include "primitive_base.hpp" - -#include "pooling_inst.h" -#include "pooling/pooling_kernel_selector.h" #include "pooling/pooling_kernel_base.h" -#include "ngraph/validation_util.hpp" +#include "pooling/pooling_kernel_selector.h" +#include "pooling_inst.h" +#include "pooling_shape_inference_util.hpp" +#include "primitive_base.hpp" +#include "validation_util.hpp" namespace cldnn { namespace ocl { @@ -95,23 +95,12 @@ struct pooling_impl : typed_primitive_impl_ocl { ov::CoordinateDiff pads_end(primitive->pads_end.begin(), primitive->pads_end.end()); auto auto_pad = primitive->auto_pad; - if (auto_pad == ov::op::PadType::SAME_UPPER || auto_pad == ov::op::PadType::SAME_LOWER) { - pads_begin.clear(); - pads_end.clear(); - OPENVINO_SUPPRESS_DEPRECATED_START - ngraph::try_apply_auto_padding(input_layout.get_partial_shape(), - kernel, - stride, - dilation, - auto_pad, - pads_end, - pads_begin); - OPENVINO_SUPPRESS_DEPRECATED_END - } - if (auto_pad == ov::op::PadType::VALID) { - pads_begin = ov::CoordinateDiff(pads_begin.size(), 0); - pads_end = ov::CoordinateDiff(pads_end.size(), 0); - } + ov::op::v8::MaxPool op; + op.set_strides(stride); + op.set_kernel(kernel); + op.set_auto_pad(auto_pad); + + ov::op::pooling::apply_padding(&op, input_layout.get_partial_shape(), dilation, pads_begin, pads_end); auto spatial_rank = output_layout.get_spatial_rank(); diff --git a/src/plugins/intel_gpu/src/graph/pooling.cpp b/src/plugins/intel_gpu/src/graph/pooling.cpp index bd101fc694c64d..7b1df0f985836e 100644 --- a/src/plugins/intel_gpu/src/graph/pooling.cpp +++ b/src/plugins/intel_gpu/src/graph/pooling.cpp @@ -2,16 +2,15 @@ // SPDX-License-Identifier: Apache-2.0 // -#include "pooling_inst.h" -#include "sliding_window_utils.hpp" - -#include "ngraph/validation_util.hpp" +#include #include "intel_gpu/runtime/error_handler.hpp" -#include "primitive_type_base.h" #include "json_object.h" - -#include +#include "max_pool_shape_inference.hpp" +#include "pooling_inst.h" +#include "primitive_type_base.h" +#include "sliding_window_utils.hpp" +#include "validation_util.hpp" using namespace ov::intel_gpu; @@ -221,23 +220,12 @@ std::vector pooling_inst::calc_output_layouts(pooling_node const& /*node ov::CoordinateDiff pads_end(desc->pads_end.begin(), desc->pads_end.end()); auto auto_pad = desc->auto_pad; - if (auto_pad == ov::op::PadType::SAME_UPPER || auto_pad == ov::op::PadType::SAME_LOWER) { - pads_begin.clear(); - pads_end.clear(); - OPENVINO_SUPPRESS_DEPRECATED_START - ngraph::try_apply_auto_padding(input_shape, - kernel_size, - stride, - dilation, - auto_pad, - pads_end, - pads_begin); - OPENVINO_SUPPRESS_DEPRECATED_END - } - if (auto_pad == ov::op::PadType::VALID) { - pads_begin = ov::CoordinateDiff(pads_begin.size(), 0); - pads_end = ov::CoordinateDiff(pads_end.size(), 0); - } + ov::op::v8::MaxPool op; + op.set_strides(stride); + op.set_kernel(kernel_size); + op.set_auto_pad(auto_pad); + + ov::op::pooling::apply_padding(&op, input_layout.get_partial_shape(), dilation, pads_begin, pads_end); size_t spatial_size = input_shape.size() - 2; for (size_t i = 0; i < spatial_size; ++i) {