Skip to content

OpenVINO™ is an open source toolkit for optimizing and deploying AI inference

[GPU] Improve paddings representation (#25716)

cecilia peng8d4473390e7f
diff --git a/src/plugins/intel_gpu/include/intel_gpu/graph/serialization/layout_serializer.hpp b/src/plugins/intel_gpu/include/intel_gpu/graph/serialization/layout_serializer.hpp
index d0f54d66aed..c7a5313202e 100644
--- a/src/plugins/intel_gpu/include/intel_gpu/graph/serialization/layout_serializer.hpp
+++ b/src/plugins/intel_gpu/include/intel_gpu/graph/serialization/layout_serializer.hpp
@@ -55,6 +55,10 @@ public:
buffer << block_size.first;
buffer << block_size.second;
}
+ for (auto& block_size : traits.logic_block_sizes) {
+ buffer << block_size.first;
+ buffer << block_size.second;
+ }
}
};
@@ -80,6 +84,11 @@ public:
buffer >> axis_idx;
traits.block_sizes.push_back(std::make_pair(blk_size, axis_idx));
}
+ for (size_t i = 0; i < num_block_size; i++) {
+ buffer >> blk_size;
+ buffer >> axis_idx;
+ traits.logic_block_sizes.push_back(std::make_pair(blk_size, axis_idx));
+ }
}
};
diff --git a/src/plugins/intel_gpu/include/intel_gpu/runtime/format.hpp b/src/plugins/intel_gpu/include/intel_gpu/runtime/format.hpp
index 7fb92284edf..a54982b9672 100644
--- a/src/plugins/intel_gpu/include/intel_gpu/runtime/format.hpp
+++ b/src/plugins/intel_gpu/include/intel_gpu/runtime/format.hpp
@@ -42,6 +42,7 @@ struct format_traits {
std::string internal_order;
/// @brief Block sizes as a vector of pairs of dimension number and block size ordered from rare to often.
std::vector<std::pair<size_t, int>> block_sizes;
+ std::vector<std::pair<size_t, int>> logic_block_sizes;
/// @brief Characters representing batch dimensions in an order.
static const char* batch_chars() { return "bno"; }
/// @brief Characters representing feature map/channel dimensions in an order.
@@ -257,6 +258,7 @@ struct format {
static const std::string& internal_order(const format& fmt) { return fmt.traits().internal_order; }
/// @brief Returns block sizes for @p format.
static const std::vector<std::pair<size_t, int>>& block_sizes(const format& fmt) { return fmt.traits().block_sizes; }
+ static const std::vector<std::pair<size_t, int>>& logic_block_sizes(const format& fmt) { return fmt.traits().logic_block_sizes; }
/// @brief Returns number of dimensions contained within a @p format
static size_t dimension(const format& fmt) { return order(fmt).size(); }
/// @brief Checks if @p format is a winograd format
@@ -340,6 +342,7 @@ struct format {
const std::string& internal_order() const { return traits().internal_order; }
/// @brief Returns block sizes as vector of pairs of dimension and block size for that dimension.
const std::vector<std::pair<size_t, int>>& block_sizes() const { return traits().block_sizes; }
+ const std::vector<std::pair<size_t, int>>& logic_block_sizes() const { return traits().logic_block_sizes; }
/// @brief Returns number of dimensions contained within this format
size_t dimension() const { return traits()._order.size(); }
/// @brief Checks if @p format is a winograd format
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 c0bf40e2099..82cf01ab952 100644
--- a/src/plugins/intel_gpu/include/intel_gpu/runtime/layout.hpp
+++ b/src/plugins/intel_gpu/include/intel_gpu/runtime/layout.hpp
@@ -13,6 +13,8 @@
#include <limits>
#include <string>
#include <functional>
+#include <array>
+#include <bitset>
#include "openvino/core/partial_shape.hpp"
#include "openvino/core/type/element_type.hpp"
@@ -126,58 +128,54 @@ inline data_types element_type_to_data_type(ov::element::Type t) {
}
}
+constexpr size_t SHAPE_RANK_MAX = 9;
+
/// @brief Represents data padding information.
struct padding {
- /// @brief Filling value for padding area.
- float filling_value() const { return _filling_value; }
-
- /// @brief Gets lower padding sizes. For spatials, it means size of left (X) and top (Y) padding.
- /// @return Tensor with padding for top/left/lower bounds of data.
- tensor lower_size() const { return _lower_size; }
-
- /// @brief Gets upper padding sizes. For spatials, it means size of right (X) and bottom (Y) padding.
- /// @return Tensor with padding for bottom/right/upper bounds of data.
- tensor upper_size() const { return _upper_size; }
+ using DynamicDimsMask = std::bitset<SHAPE_RANK_MAX>;
+ static constexpr DynamicDimsMask EMPTY_MASK{0x0};
- void set_dynamic_pad(const tensor& dynamic_pad_dims) {
- _dynamic_pad_dims = dynamic_pad_dims;
- }
+ std::array<int32_t, SHAPE_RANK_MAX> _lower_size = {0}; ///< Lower padding sizes. For spatials, it means size of left (X) and top (Y) padding.
+ std::array<int32_t, SHAPE_RANK_MAX> _upper_size = {0}; ///< Upper padding sizes. For spatials, it means size of right (X) and bottom (Y) padding.
+ DynamicDimsMask _dynamic_dims_mask = EMPTY_MASK; ///< A mask saying which dimension has dynamic pad
- tensor get_dynamic_pad_dims() const {
- return _dynamic_pad_dims;
- }
/// @brief
- /// @param lower_sizes Top-left padding sizes. See @ref tensor::tensor(const std::vector<value_type>&, value_type) for details.
- /// @param upper_sizes Bottom-right padding sizes. See @ref tensor::tensor(const std::vector<value_type>&, value_type) for details.
- /// @param filling_value Filling value for padding area.
- padding(const std::vector<tensor::value_type>& lower_sizes,
- const std::vector<tensor::value_type>& upper_sizes,
- float filling_value = 0.0f,
- const tensor& dynamic_pad_dims = tensor(0))
- : _lower_size(to_abs(lower_sizes), 0),
- _upper_size(to_abs(upper_sizes), 0),
- _filling_value(filling_value),
- _dynamic_pad_dims(dynamic_pad_dims) {}
+ /// @param lower_sizes Top-left padding sizes, in the same size and order as shape.
+ /// @param upper_sizes Bottom-right padding sizes, in the same size and order as shape.
+ padding(const std::vector<int32_t>& lower_sizes,
+ const std::vector<int32_t>& upper_sizes,
+ const DynamicDimsMask& dynamic_pad_dims = EMPTY_MASK) {
+ // paddings
+ OPENVINO_ASSERT(lower_sizes.size() <= SHAPE_RANK_MAX);
+ OPENVINO_ASSERT(upper_sizes.size() <= SHAPE_RANK_MAX);
+ std::copy_n(lower_sizes.begin(), lower_sizes.size(), _lower_size.begin());
+ std::copy_n(upper_sizes.begin(), upper_sizes.size(), _upper_size.begin());
+ _dynamic_dims_mask = dynamic_pad_dims;
+ }
/// @brief Constrcuts symmetric padding.
- /// @param sizes Top-left and bottom-right padding sizes. See @ref tensor::tensor(const std::vector<value_type>&,
- /// value_type) for details.
- /// @param filling_value Filling value for padding area.
- explicit padding(const std::vector<tensor::value_type>& sizes, float filling_value = 0.0f, const tensor& dynamic_pad_dims = tensor(0))
- : padding(sizes, sizes, filling_value, dynamic_pad_dims) {}
+ /// @param sizes Top-left and bottom-right padding sizes, in the same size and order as shape.
+ explicit padding(const std::vector<int32_t>& sizes,
+ const DynamicDimsMask& dynamic_pad_dims = EMPTY_MASK)
+ : padding(sizes, sizes, dynamic_pad_dims) {}
/// @brief Constructs "zero-sized" padding.
- padding() : padding({0, 0, 0, 0}, 0, tensor(0)) {}
+ padding() : padding({}, EMPTY_MASK) {}
/// @brief Returns true if padding size is not zero.
explicit operator bool() const {
- return std::any_of(_lower_size.raw.begin(), _lower_size.raw.end(), [](const tensor::value_type& el) { return el != 0; }) ||
- std::any_of(_upper_size.raw.begin(), _upper_size.raw.end(), [](const tensor::value_type& el) { return el != 0; });
+ return std::any_of(_lower_size.begin(), _lower_size.end(), [](int32_t i){ return i > 0; }) ||
+ std::any_of(_upper_size.begin(), _upper_size.end(), [](int32_t i){ return i > 0; });
+ }
+
+ bool is_dynamic() const {
+ return _dynamic_dims_mask.any();
}
friend bool operator==(const padding& lhs, const padding& rhs) {
- return lhs._lower_size == rhs._lower_size && lhs._upper_size == rhs._upper_size &&
- lhs._filling_value == rhs._filling_value && lhs._dynamic_pad_dims == rhs._dynamic_pad_dims;
+ return lhs._dynamic_dims_mask == rhs._dynamic_dims_mask &&
+ lhs._lower_size == rhs._lower_size &&
+ lhs._upper_size == rhs._upper_size;
}
friend bool operator!=(const padding& lhs, const padding& rhs) {
@@ -185,61 +183,53 @@ struct padding {
}
friend bool operator<(const padding& lhs, const padding& rhs) {
- if (lhs._filling_value != rhs._filling_value)
- return (lhs._filling_value < rhs._filling_value);
- if (lhs._lower_size != rhs._lower_size)
- return (lhs._lower_size < rhs._lower_size);
- return (lhs._upper_size < rhs._upper_size);
+ OPENVINO_ASSERT(!lhs.is_dynamic() && !rhs.is_dynamic(), "[GPU] padding compare is called for dynamic shape");
+ if (lhs._lower_size < rhs._lower_size) return true;
+ else if (lhs._lower_size > rhs._lower_size) return false;
+ if (lhs._upper_size < rhs._upper_size) return true;
+ return false;
}
static padding max(padding const& lhs, padding const& rhs, float filling_value = 0.0f) {
- const auto& lower = tensor::max(lhs.lower_size(), rhs.lower_size());
- const auto& upper = tensor::max(lhs.upper_size(), rhs.upper_size());
- const auto& dynamic_pad_dims = tensor::max(lhs.get_dynamic_pad_dims(), rhs.get_dynamic_pad_dims());
- return padding{lower.sizes(), upper.sizes(), filling_value, dynamic_pad_dims};
+ auto ret = lhs;
+ for (size_t i = 0; i < SHAPE_RANK_MAX; ++i) {
+ ret._lower_size[i] = std::max(ret._lower_size[i], rhs._lower_size[i]);
+ ret._upper_size[i] = std::max(ret._upper_size[i], rhs._upper_size[i]);
+ }
+ ret._dynamic_dims_mask = ret._dynamic_dims_mask | rhs._dynamic_dims_mask;
+ return ret;
}
size_t hash() const {
size_t seed = 0;
- seed = cldnn::hash_combine(seed, _filling_value);
- seed = cldnn::hash_combine(seed, _lower_size.hash());
- seed = cldnn::hash_combine(seed, _upper_size.hash());
- seed = cldnn::hash_combine(seed, _dynamic_pad_dims.hash());
+ seed = hash_range(seed, std::begin(_lower_size), std::end(_lower_size));
+ seed = hash_range(seed, std::begin(_upper_size), std::end(_upper_size));
+ seed = cldnn::hash_combine(seed, _dynamic_dims_mask);
return seed;
}
void save(BinaryOutputBuffer& ob) const {
- ob << _lower_size.sizes();
- ob << _upper_size.sizes();
- ob << _filling_value;
- ob << _dynamic_pad_dims.sizes();
+ std::vector<int32_t> sizes;
+ sizes.assign(_lower_size.begin(), _lower_size.end());
+ ob << sizes;
+ sizes.assign(_upper_size.begin(), _upper_size.end());
+ ob << sizes;
+ OPENVINO_ASSERT(sizes.size() == _dynamic_dims_mask.size(), "invalid size.");
+ for (size_t i = 0; i < _dynamic_dims_mask.size(); i++)
+ sizes[i] = static_cast<int32_t>(_dynamic_dims_mask[i]);
+ ob << sizes;
}
void load(BinaryInputBuffer& ib) {
- std::vector<tensor::value_type> sizes;
+ std::vector<int32_t> sizes;
ib >> sizes;
- _lower_size = tensor(sizes);
+ std::copy_n(sizes.begin(), sizes.size(), _lower_size.begin());
ib >> sizes;
- _upper_size = tensor(sizes);
- ib >> _filling_value;
+ std::copy_n(sizes.begin(), sizes.size(), _upper_size.begin());
ib >> sizes;
- _dynamic_pad_dims = tensor(sizes);
- }
-
-private:
- tensor _lower_size; ///< Lower padding sizes. For spatials, it means size of left (X) and top (Y) padding.
- tensor _upper_size; ///< Upper padding sizes. For spatials, it means size of right (X) and bottom (Y) padding.
- // TODO: Add support for non-zero filling value (if necessary) or remove variable (if not necessary).
- float _filling_value; ///< Filling value for an element of padding. If data type of elements is different than float it is converted
- ///< to it using round-towards-nearest-even (for floating-point data types) or round-towards-zero (for integral
- ///< data types).
- tensor _dynamic_pad_dims = tensor(0);
-
- static std::vector<tensor::value_type> to_abs(const std::vector<tensor::value_type>& sizes) {
- std::vector<tensor::value_type> result;
- result.reserve(sizes.size());
- std::transform(sizes.cbegin(), sizes.cend(), std::back_inserter(result), [](const tensor::value_type& el) { return abs(el); });
- return result; // NRVO
+ OPENVINO_ASSERT(sizes.size() == _dynamic_dims_mask.size(), "invalid size.");
+ for (size_t i = 0; i < _dynamic_dims_mask.size(); i++)
+ _dynamic_dims_mask[i] = static_cast<bool>(sizes[i]);
}
};
@@ -268,7 +258,7 @@ struct layout {
: data_type(data_type)
, format(fmt)
, data_padding(apadding)
- , size(size) { }
+ , size(size) {}
layout(const layout& other) = default;
@@ -283,8 +273,8 @@ struct layout {
return *this;
data_type = other.data_type;
format = other.format;
- size = other.size;
data_padding = other.data_padding;
+ size = other.size;
return *this;
}
@@ -318,10 +308,7 @@ struct layout {
/// Number of elements to be stored in this layout
size_t count() const;
- /// Layout size with padding included
- tensor get_buffer_size() const;
-
- tensor get_pitches() const;
+ std::vector<tensor::value_type> get_pitches() const;
// @brief Calculates position within buffer of the data element pointed by the provided tensor.
// element == { 0,0,0,0 } means first no-padding (i.e. data) element
@@ -333,10 +320,6 @@ struct layout {
/// Modify padding in layout
layout with_padding(padding const& padd) const;
- bool has_dynamic_pad() const {
- return data_padding.get_dynamic_pad_dims() != tensor(0);
- }
-
/// Data type stored in @ref memory (see. @ref data_types)
ov::element::Type_t data_type;
@@ -439,6 +422,29 @@ struct layout {
return seed;
}
+ /// @brief Returns a vector of tensors values, ordered regarding to @p format from the default format.
+ /// @param _sizes an array that supports operator[] and stores data in the same order as shape.
+ /// e.g. it could be std::vector, std::array, or std::bitset, etc.
+ template <class TArray>
+ inline static std::vector<int32_t> format_sizes(const TArray _sizes, const cldnn::format &fmt,
+ const int32_t default_val = 1) {
+ const auto& output_order = fmt.order();
+ std::vector<int32_t> sizes(output_order.size(), default_val);
+
+ auto default_fmt = format::get_default_format(sizes.size(), format::is_weights_format(fmt), format::is_grouped(fmt));
+ const auto& default_order = default_fmt.order();
+
+ for (size_t i = 0; i < sizes.size(); ++i) {
+ auto c = output_order[i];
+ auto pos = default_order.find(c);
+ OPENVINO_ASSERT(pos != std::string::npos, "[GPU] Unknown coord type: ", c);
+
+ sizes[i] = static_cast<int32_t>(_sizes[pos]);
+ }
+
+ return sizes;
+ }
+
private:
/// The size of the @ref memory (excluding padding)
ov::PartialShape size;
diff --git a/src/plugins/intel_gpu/include/intel_gpu/runtime/memory.hpp b/src/plugins/intel_gpu/include/intel_gpu/runtime/memory.hpp
index a40823dc7a1..f869feba4a5 100644
--- a/src/plugins/intel_gpu/include/intel_gpu/runtime/memory.hpp
+++ b/src/plugins/intel_gpu/include/intel_gpu/runtime/memory.hpp
@@ -71,7 +71,7 @@ struct memory {
return true;
}
- if (l.data_padding.lower_size() != tensor(0) || l.data_padding.upper_size() != tensor(0)) {
+ if (l.data_padding) {
return true;
}
diff --git a/src/plugins/intel_gpu/include/intel_gpu/runtime/tensor.hpp b/src/plugins/intel_gpu/include/intel_gpu/runtime/tensor.hpp
index cb74433ec18..beebe9b868f 100644
--- a/src/plugins/intel_gpu/include/intel_gpu/runtime/tensor.hpp
+++ b/src/plugins/intel_gpu/include/intel_gpu/runtime/tensor.hpp
@@ -519,7 +519,7 @@ public:
/// @brief Calculates linear offset for given @p coord within current tensor.
/// @param coord The coordinate within current tensor.
- size_t get_linear_offset(const tensor& coord, cldnn::format fmt) const {
+ size_t get_linear_offset(const tensor& coord, const cldnn::format& fmt) const {
auto my_sizes = this->sizes(fmt);
auto adjusted_coords = coord.sizes(fmt);
diff --git a/src/plugins/intel_gpu/src/graph/convolution.cpp b/src/plugins/intel_gpu/src/graph/convolution.cpp
index 2fe94396b1a..04acd4b8305 100644
--- a/src/plugins/intel_gpu/src/graph/convolution.cpp
+++ b/src/plugins/intel_gpu/src/graph/convolution.cpp
@@ -241,12 +241,6 @@ convolution_inst::typed_primitive_inst(network& network, convolution_node const&
"Biases isn't 1D vector.");
}
- CLDNN_ERROR_NOT_EQUAL(node.id(),
- "Convolution padding mode",
- node.get_output_layout().data_padding.filling_value(),
- "padding value",
- 0.0f,
- "Unknown padding mode.");
CLDNN_ERROR_NOT_EQUAL(node.id(),
"Output feature size",
output_size.feature.size(),
diff --git a/src/plugins/intel_gpu/src/graph/deconvolution.cpp b/src/plugins/intel_gpu/src/graph/deconvolution.cpp
index c905c913b51..dc6c2af3052 100644
--- a/src/plugins/intel_gpu/src/graph/deconvolution.cpp
+++ b/src/plugins/intel_gpu/src/graph/deconvolution.cpp
@@ -325,12 +325,6 @@ deconvolution_inst::typed_primitive_inst(network& network, deconvolution_node co
"Spatial[0] of bias should be 1. Bias isn't 1D vector.");
}
- CLDNN_ERROR_NOT_EQUAL(node.id(),
- "deconvolution padding filling value",
- node.get_output_layout().data_padding.filling_value(),
- "padding mode",
- 0.0f,
- "Unknown padding mode in deconvolution.");
CLDNN_ERROR_NOT_EQUAL(node.id(),
"Weights feature maps number",
filter_inst.ifm() * filter_inst.group(),
diff --git a/src/plugins/intel_gpu/src/graph/error_handler.cpp b/src/plugins/intel_gpu/src/graph/error_handler.cpp
index c75c23db244..e51714a6f12 100644
--- a/src/plugins/intel_gpu/src/graph/error_handler.cpp
+++ b/src/plugins/intel_gpu/src/graph/error_handler.cpp
@@ -210,10 +210,6 @@ void error_on_mismatch_layout(const std::string& file,
if (layout_1.data_padding != layout_2.data_padding) {
error_msg << layout_1_id << " data padding mismatch: " << layout_2_id << " data padding." << std::endl;
- error_msg << layout_1_id << " upper data padding: " << layout_1.data_padding.upper_size() << ", "
- << layout_2_id << " upper data padding: " << layout_2.data_padding.upper_size() << std::endl;
- error_msg << layout_1_id << " lower data padding: " << layout_1.data_padding.lower_size() << ", "
- << layout_2_id << " lower data padding: " << layout_2.data_padding.lower_size() << std::endl;
}
if (layout_1.data_type != layout_2.data_type) {
error_msg << layout_1_id << " data type mismatch: " << layout_2_id << " data type." << std::endl;
diff --git a/src/plugins/intel_gpu/src/graph/fully_connected.cpp b/src/plugins/intel_gpu/src/graph/fully_connected.cpp
index b09416585e3..d0820a119d5 100644
--- a/src/plugins/intel_gpu/src/graph/fully_connected.cpp
+++ b/src/plugins/intel_gpu/src/graph/fully_connected.cpp
@@ -56,11 +56,11 @@ format::type get_preferred_format(fully_connected_node const& node, const kernel
bool no_spatial_padding = true;
// C++ 11 range loop shouldn't be used here because of incorrect iterator functionality in mutable_array_ref<>
- for (size_t i = 0; i < input_layout.data_padding.lower_size().spatial.size(); ++i) {
- no_spatial_padding &= (input_layout.data_padding.lower_size().spatial[i] == 0);
+ for (size_t i = 0; i < input_layout.get_spatial_rank(); ++i) {
+ no_spatial_padding &= (input_layout.data_padding._lower_size[2 + i] == 0);
}
- for (size_t i = 0; i < input_layout.data_padding.upper_size().spatial.size(); ++i) {
- no_spatial_padding &= (input_layout.data_padding.upper_size().spatial[i] == 0);
+ for (size_t i = 0; i < input_layout.get_spatial_rank(); ++i) {
+ no_spatial_padding &= (input_layout.data_padding._upper_size[2 + i] == 0);
}
if (input_layout.data_type == data_types::f32 &&
@@ -73,7 +73,7 @@ format::type get_preferred_format(fully_connected_node const& node, const kernel
if (input_layout.data_type == data_types::f16 &&
input_layout.format == format::bfyx &&
no_spatial_padding &&
- input_pitches.batch[0] % 2 == 0 &&
+ input_pitches[0] % 2 == 0 &&
input_layout.batch() != 16)
return format::bfyx;
@@ -183,12 +183,12 @@ kernel_impl_params fully_connected_inst::get_fake_aligned_params(kernel_impl_par
// Allow padding only for feature and outermost dimmension
auto can_apply_fake_alignment = true;
if (input_shape.size() == 3)
- can_apply_fake_alignment &= orig_input_layout.data_padding.lower_size().sizes()[1] == 0 &&
- orig_input_layout.data_padding.upper_size().sizes()[1] == 0;
+ can_apply_fake_alignment &= orig_input_layout.data_padding._lower_size[1] == 0 &&
+ orig_input_layout.data_padding._upper_size[1] == 0;
if (output_shape.size() == 3)
- can_apply_fake_alignment &= orig_output_layout.data_padding.lower_size().sizes()[1] == 0 &&
- orig_output_layout.data_padding.upper_size().sizes()[1] == 0;
+ can_apply_fake_alignment &= orig_output_layout.data_padding._lower_size[1] == 0 &&
+ orig_output_layout.data_padding._upper_size[1] == 0;
for (auto& fused_desc : orig_impl_param.fused_desc) {
if (fused_desc.has_outer_dep()) {
diff --git a/src/plugins/intel_gpu/src/graph/graph_optimizer/add_required_reorders.cpp b/src/plugins/intel_gpu/src/graph/graph_optimizer/add_required_reorders.cpp
index c7ef7bab303..84fc32ad9d7 100644
--- a/src/plugins/intel_gpu/src/graph/graph_optimizer/add_required_reorders.cpp
+++ b/src/plugins/intel_gpu/src/graph/graph_optimizer/add_required_reorders.cpp
@@ -161,31 +161,24 @@ void add_required_reorders::run(program& p) {
if (!input.is_in_data_flow() || input.is_constant())
continue;
- auto in_padding = input.get_output_layout().data_padding;
+ auto& in_layout = input.get_output_layout();
+ auto& in_padding = in_layout.data_padding;
if (static_cast<bool>(in_padding)) {
bool spatial_padding = false;
- for (size_t i = 0; i < in_padding.lower_size().spatial.size(); ++i) {
- spatial_padding |= (in_padding.lower_size().spatial[i] != 0);
+ for (size_t i = 0; i < in_layout.get_spatial_rank(); ++i) {
+ spatial_padding |= (in_padding._lower_size[2 + i] != 0);
}
- for (size_t i = 0; i < in_padding.upper_size().spatial.size(); ++i) {
- spatial_padding |= (in_padding.upper_size().spatial[i] != 0);
+ for (size_t i = 0; i < in_layout.get_spatial_rank(); ++i) {
+ spatial_padding |= (in_padding._upper_size[2 + i] != 0);
}
bool feature_padding = false;
- for (size_t i = 0; i < in_padding.lower_size().feature.size(); ++i) {
- feature_padding |= (in_padding.lower_size().feature[i] != 0);
- }
- for (size_t i = 0; i < in_padding.upper_size().feature.size(); ++i) {
- feature_padding |= (in_padding.upper_size().feature[i] != 0);
- }
+ feature_padding |= (in_padding._lower_size[1] != 0);
+ feature_padding |= (in_padding._upper_size[1] != 0);
bool batch_padding = false;
- for (size_t i = 0; i < in_padding.lower_size().batch.size(); ++i) {
- batch_padding |= (in_padding.lower_size().batch[i] != 0);
- }
- for (size_t i = 0; i < in_padding.upper_size().batch.size(); ++i) {
- batch_padding |= (in_padding.upper_size().batch[i] != 0);
- }
+ batch_padding |= (in_padding._lower_size[0] != 0);
+ batch_padding |= (in_padding._upper_size[0] != 0);
if (batch_padding && !feature_padding && !spatial_padding) {
batch_padding = false;
@@ -195,8 +188,8 @@ void add_required_reorders::run(program& p) {
cldnn::layout layout_padding = input.get_output_layout();
cldnn::layout layout_wo_padding = input.get_output_layout();
layout_wo_padding.data_padding = cldnn::padding{};
- layout_wo_padding.data_padding.lower_size().feature = layout_padding.data_padding.lower_size().feature;
- layout_wo_padding.data_padding.upper_size().feature = layout_padding.data_padding.upper_size().feature;
+ layout_wo_padding.data_padding._lower_size[1] = layout_padding.data_padding._lower_size[1];
+ layout_wo_padding.data_padding._upper_size[1] = layout_padding.data_padding._upper_size[1];
auto new_reorder = std::make_shared<reorder>(input.id() + "_padding_reorder_" + usr->id(), input.id(), layout_wo_padding);
auto& new_reorder_node = p.get_or_create(new_reorder);
p.add_intermediate(new_reorder_node, *usr, idx);
diff --git a/src/plugins/intel_gpu/src/graph/graph_optimizer/mark_runtime_skippable_nodes.cpp b/src/plugins/intel_gpu/src/graph/graph_optimizer/mark_runtime_skippable_nodes.cpp
index 1a22b47212b..3873c543df9 100644
--- a/src/plugins/intel_gpu/src/graph/graph_optimizer/mark_runtime_skippable_nodes.cpp
+++ b/src/plugins/intel_gpu/src/graph/graph_optimizer/mark_runtime_skippable_nodes.cpp
@@ -51,7 +51,7 @@ void mark_runtime_skippable_nodes::run(program& p) {
if (node.is_output() ||
node.has_fused_primitives() ||
(impl_params->get_input_layout(0).data_type != impl_params->get_output_layout().data_type) ||
- impl_params->get_input_layout(0).has_dynamic_pad())
+ impl_params->get_input_layout(0).data_padding.is_dynamic())
return;
// TODO: For now, all permutes with dynamic shape are applied.
diff --git a/src/plugins/intel_gpu/src/graph/graph_optimizer/prepare_buffer_fusing.cpp b/src/plugins/intel_gpu/src/graph/graph_optimizer/prepare_buffer_fusing.cpp
index 7792b536436..9f2895a008c 100644
--- a/src/plugins/intel_gpu/src/graph/graph_optimizer/prepare_buffer_fusing.cpp
+++ b/src/plugins/intel_gpu/src/graph/graph_optimizer/prepare_buffer_fusing.cpp
@@ -91,8 +91,8 @@ bool concat_in_place_optimization::match(const program_node& concat_node,
if (concat_node.is_dynamic()) {
for (size_t j = 0; j < concat_params.get_output_layout().get_rank(); j++) {
if (j != concat_axis_index) {
- if ((concat_params.get_output_layout().data_padding.lower_size().sizes(def_fmt)[j] != 0)
- || (concat_params.get_output_layout().data_padding.upper_size().sizes(def_fmt)[j] != 0))
+ if ((concat_params.get_output_layout().data_padding._lower_size[j] != 0)
+ || (concat_params.get_output_layout().data_padding._upper_size[j] != 0))
return false;
}
}
@@ -124,9 +124,9 @@ bool concat_in_place_optimization::match(const program_node& concat_node,
const auto& output_format = concat_params.get_output_layout().format;
const auto& output_datatype = concat_params.get_output_layout().data_type;
- auto lower_padd_in_axis = concat_params.get_output_layout().data_padding.lower_size().sizes(def_fmt)[concat_axis];
+ auto lower_padd_in_axis = concat_params.get_output_layout().data_padding._lower_size[concat_axis];
lower_padd_in_axis = std::max(lower_padd_in_axis,
- pred_params[0].get_output_layout().data_padding.lower_size().sizes(def_fmt)[concat_axis]);
+ pred_params[0].get_output_layout().data_padding._lower_size[concat_axis]);
size_t idx = 0;
for (const auto& pred : pred_nodes) {
@@ -217,9 +217,9 @@ bool concat_in_place_optimization::match(const program_node& concat_node,
// Check that there isn't already some padding between inputs in concat axis.
// If node has already been optimized we skip this check - this is just cascade adjustment.
if (!concat_node.can_be_optimized()) {
- if (idx != concat_node.get_dependencies().size() && input_padd.upper_size().sizes(def_fmt)[concat_axis] != 0)
+ if (idx != concat_node.get_dependencies().size() && input_padd._upper_size[concat_axis] != 0)
return false;
- if (idx != 0 && input_padd.lower_size().sizes(def_fmt)[concat_axis] != 0)
+ if (idx != 0 && input_padd._lower_size[concat_axis] != 0)
return false;
}
if (!concat_node.is_dynamic() || is_runtime)
@@ -282,23 +282,12 @@ void concat_in_place_optimization::update_in_place_concat_paddings(
std::vector<layout>& preds_layouts,
size_t concat_axis,
bool is_runtime) {
- auto concat_out_rank = concat_out_layout.get_rank();
- // We need to transform axis from bf[v][u][w][z]yx order to bfxy[z][w][u][v] due to tensor.sizes() usages here
- // should be removed once pad representation is changed
- auto concat_axis_legacy = concat_axis;
- if (concat_axis_legacy >= 2) {
- auto spatial_axis = concat_axis_legacy - 2;
- // Default and minimum number of dimensions is 4
- auto spatial_size = std::max<size_t>(concat_out_rank, 4) - 2;
- concat_axis_legacy = spatial_size - spatial_axis - 1 + 2;
- }
-
if (concat_out_layout.is_dynamic() && !is_runtime) {
// set dynamic pad dims for shape agnostic kernel
for (auto& dep_output_layout : preds_layouts) {
- auto info_dynamic_pad = tensor(0).sizes();
- info_dynamic_pad[concat_axis_legacy] = 1;
- dep_output_layout.data_padding.set_dynamic_pad(tensor(info_dynamic_pad));
+ padding::DynamicDimsMask info_dynamic_pad;
+ info_dynamic_pad[concat_axis] = 1;
+ dep_output_layout.data_padding._dynamic_dims_mask = info_dynamic_pad;
}
return;
}
@@ -310,18 +299,21 @@ void concat_in_place_optimization::update_in_place_concat_paddings(
padd = padding::max(padd, inputPadding);
}
- auto lower_padd = padd.lower_size().sizes();
- auto upper_padd = padd.upper_size().sizes();
+ std::vector<tensor::value_type> lower_padd, upper_padd;
+ for (size_t i = 0; i < concat_out_layout.get_rank(); i++) {
+ lower_padd.push_back(padd._lower_size[i]);
+ upper_padd.push_back(padd._upper_size[i]);
+ }
// For cascade adjustment override padding in concat axis to output padding.
// In other case match(...) already checked that only first/last input have lower/upper padding.
- lower_padd[concat_axis_legacy] = concat_out_layout.data_padding.lower_size().sizes()[concat_axis_legacy];
- upper_padd[concat_axis_legacy] = concat_out_layout.data_padding.upper_size().sizes()[concat_axis_legacy];
- auto dyn_pad_dims = lower_padd;
- dyn_pad_dims[concat_axis_legacy] = 1;
+ lower_padd[concat_axis] = concat_out_layout.data_padding._lower_size[concat_axis];
+ upper_padd[concat_axis] = concat_out_layout.data_padding._upper_size[concat_axis];
+ padding::DynamicDimsMask dyn_pad_dims;
+ dyn_pad_dims[concat_axis] = 1;
concat_out_layout.data_padding = padding(lower_padd, upper_padd);
- upper_padd[concat_axis_legacy] += concat_out_layout.get_dims()[concat_axis];
+ upper_padd[concat_axis] += concat_out_layout.get_dims()[concat_axis];
// apply concatenation in place optimization
for (auto& pred_layout : preds_layouts) {
@@ -330,25 +322,27 @@ void concat_in_place_optimization::update_in_place_concat_paddings(
//
// |--- lower padd ---| |---------- upper padd -----------|
// |-- output padd ---| ----- input1 ------|----- input2 -----|-- out padd --|
- upper_padd[concat_axis_legacy] -= input_length;
+ upper_padd[concat_axis] -= input_length;
// set new padding for input
if (is_runtime)
- pred_layout.data_padding = padding(lower_padd, upper_padd, 0.f, tensor(dyn_pad_dims));
+ pred_layout.data_padding = padding(lower_padd, upper_padd, dyn_pad_dims);
else
- pred_layout.data_padding = padding(lower_padd, upper_padd, 0.f);
+ pred_layout.data_padding = padding(lower_padd, upper_padd);
// move lower padd further
//
// |-------------- lower padd -------------|---------- upper padd -----------|
// |-- output padd ---| ----- input1 ------|----- input2 -----|-- out padd --|
- lower_padd[concat_axis_legacy] += input_length;
+ lower_padd[concat_axis] += input_length;
}
}
} // namespace cldnn
static bool can_reshape_be_optimized(const reshape_node& node) {
// In case if pad is not propagated, the primitive can't be optimized out
- if (!node.is_runtime_propagatable_padding() && node.get_input_layout(0).has_dynamic_pad() && !node.get_output_layout(0).has_dynamic_pad()) {
+ if (!node.is_runtime_propagatable_padding()
+ && node.get_input_layout(0).data_padding.is_dynamic()
+ && !node.get_output_layout(0).data_padding.is_dynamic()) {
return false;
}
@@ -370,9 +364,9 @@ static bool is_optimizable_padding_for_crop(const crop_node& node,
const layout& crop_layout,
const layout& input_layout,
const tensor offsets) {
- if (input_layout.data_padding.lower_size().batch[0] != 0 || input_layout.data_padding.upper_size().batch[0] != 0 ||
- input_layout.data_padding.lower_size().spatial[0] != 0 || input_layout.data_padding.upper_size().spatial[0] != 0 ||
- input_layout.data_padding.lower_size().spatial[1] != 0 || input_layout.data_padding.upper_size().spatial[1] != 0)
+ if (input_layout.data_padding._lower_size[0] != 0 || input_layout.data_padding._upper_size[0] != 0 ||
+ input_layout.data_padding._lower_size[2] != 0 || input_layout.data_padding._upper_size[2] != 0 ||
+ input_layout.data_padding._lower_size[3] != 0 || input_layout.data_padding._upper_size[3] != 0)
return false;
auto opt_lower_pad = offsets.feature[0];
@@ -401,11 +395,11 @@ bool crop_in_place_optimization::can_crop_be_optimized_along_feature(const layou
if (format == format::bfyx && crop_size.batch[0] == input_layout.batch() &&
crop_size.spatial[0] == input_layout.spatial(0) &&
- crop_size.spatial[1] == input_layout.spatial(1) && out_pad.lower_size().feature[0] == 0 &&
- out_pad.upper_size().feature[0] == 0 && out_pad.lower_size().batch[0] == 0 &&
- out_pad.upper_size().batch[0] == 0 && out_pad.lower_size().spatial[0] == 0 &&
- out_pad.lower_size().spatial[1] == 0 && out_pad.upper_size().spatial[0] == 0 &&
- out_pad.upper_size().spatial[1] == 0) {
+ crop_size.spatial[1] == input_layout.spatial(1) && out_pad._lower_size[1] == 0 &&
+ out_pad._upper_size[1] == 0 && out_pad._lower_size[0] == 0 &&
+ out_pad._upper_size[0] == 0 && out_pad._lower_size[2] == 0 &&
+ out_pad._lower_size[3] == 0 && out_pad._upper_size[2] == 0 &&
+ out_pad._upper_size[3] == 0) {
return true;
}
@@ -591,19 +585,11 @@ void crop_in_place_optimization::update_in_place_crop_padding_along_feature(cons
const tensor offsets,
size_t crop_axis,
bool is_runtime) {
- auto crop_axis_legacy = crop_axis;
- if (crop_axis_legacy >= 2) {
- auto spatial_axis = crop_axis_legacy - 2;
- // Default and minimum number of dimensions is 4
- auto spatial_size = std::max<size_t>(crop_layout.get_partial_shape().size(), 4) - 2;
- crop_axis_legacy = spatial_size - spatial_axis - 1 + 2;
- }
// If it's build-time and node is dynamic, only dynamic padding is set first
if ((crop_layout.is_dynamic() || input_layout.is_dynamic()) && !is_runtime) {
- auto info_dynamic_pad = tensor(0).sizes();
- info_dynamic_pad[crop_axis_legacy] = 1;
- auto dynamic_pad_mask = tensor(info_dynamic_pad);
- crop_layout.data_padding.set_dynamic_pad(dynamic_pad_mask);
+ padding::DynamicDimsMask info_dynamic_pad;
+ info_dynamic_pad[crop_axis] = 1;
+ crop_layout.data_padding._dynamic_dims_mask = info_dynamic_pad;
return;
}
@@ -617,25 +603,25 @@ void crop_in_place_optimization::update_in_place_crop_padding_along_feature(cons
// feature num of pad should be accumulated if dep has been optimized out.
if (dep.is_type<crop>() && dep.can_be_optimized()) {
auto dep_pad = dep.get_output_layout().data_padding;
- opt_lower_pad += dep_pad.lower_size().feature[0];
- opt_upper_pad += dep_pad.upper_size().feature[0];
+ opt_lower_pad += dep_pad._lower_size[1];
+ opt_upper_pad += dep_pad._upper_size[1];
}
std::vector<int32_t> lower_sizes;
- lower_sizes.push_back(out_pad.lower_size().batch[0]);
+ lower_sizes.push_back(out_pad._lower_size[0]);
lower_sizes.push_back(opt_lower_pad);
- lower_sizes.push_back(out_pad.lower_size().spatial[0]);
- lower_sizes.push_back(out_pad.lower_size().spatial[1]);
+ lower_sizes.push_back(out_pad._lower_size[2]);
+ lower_sizes.push_back(out_pad._lower_size[3]);
std::vector<int32_t> upper_sizes;
- upper_sizes.push_back(out_pad.upper_size().batch[0]);
+ upper_sizes.push_back(out_pad._upper_size[0]);
upper_sizes.push_back(opt_upper_pad);
- upper_sizes.push_back(out_pad.upper_size().spatial[0]);
- upper_sizes.push_back(out_pad.upper_size().spatial[1]);
+ upper_sizes.push_back(out_pad._upper_size[2]);
+ upper_sizes.push_back(out_pad._upper_size[3]);
// set padding
if (is_runtime) {
- auto dyn_pad_sizes = lower_sizes;
- dyn_pad_sizes[crop_axis_legacy] = 1;
- crop_layout.data_padding = padding(lower_sizes, upper_sizes, 0.f, tensor(dyn_pad_sizes));
+ padding::DynamicDimsMask dyn_pad_sizes;
+ dyn_pad_sizes[crop_axis] = 1;
+ crop_layout.data_padding = padding(lower_sizes, upper_sizes, dyn_pad_sizes);
} else {
crop_layout.data_padding = padding(lower_sizes, upper_sizes);
}
@@ -647,31 +633,17 @@ void crop_in_place_optimization::update_in_place_crop_padding_simple_data_format
const tensor offsets,
size_t crop_axis,
bool is_runtime) {
- auto convert_axis_to_legacy = [](size_t axis, size_t rank) {
- auto axis_legacy = axis;
- if (axis_legacy >= 2) {
- auto spatial_axis = axis_legacy - 2;
- // Default and minimum number of dimensions is 4
- auto spatial_size = std::max<size_t>(rank, 4) - 2;
- axis_legacy = spatial_size - spatial_axis - 1 + 2;
- }
-
- return axis_legacy;
- };
-
- auto crop_axis_legacy = convert_axis_to_legacy(crop_axis, crop_layout.get_partial_shape().size());
-
// If it's build-time and node is dynamic, only dynamic padding is set first
if ((crop_layout.is_dynamic() || input_layout.is_dynamic()) && !is_runtime) {
- auto dyn_pad_sizes = tensor(0).sizes();
- dyn_pad_sizes[crop_axis_legacy] = 1;
- crop_layout.data_padding.set_dynamic_pad(tensor(dyn_pad_sizes));
+ padding::DynamicDimsMask dyn_pad_sizes;
+ dyn_pad_sizes[crop_axis] = 1;
+ crop_layout.data_padding._dynamic_dims_mask = dyn_pad_sizes;
if (user_info.first && user_info.first->is_type<reshape>()) {
auto reshape_desc = user_info.first->as<reshape>().get_primitive();
auto reshape_mode = reshape_desc->mode;
if (reshape_mode == reshape::reshape_mode::base) {
- user_info.second.data_padding.set_dynamic_pad(tensor(dyn_pad_sizes));
+ user_info.second.data_padding._dynamic_dims_mask = dyn_pad_sizes;
} else if (reshape_mode == reshape::reshape_mode::unsqueeze || reshape_mode == reshape::reshape_mode::squeeze) {
auto reshape_ps = user_info.second.get_partial_shape();
auto output_pattern = reshape_desc->output_pattern;
@@ -683,10 +655,9 @@ void crop_in_place_optimization::update_in_place_crop_padding_simple_data_format
}
}
- auto dyn_pad_mask = tensor(0).sizes();
- auto reshape_axis_legacy = convert_axis_to_legacy(reshape_axis, reshape_ps.size());
- dyn_pad_mask[reshape_axis_legacy] = 1;
- user_info.second.data_padding.set_dynamic_pad(tensor(dyn_pad_mask));
+ padding::DynamicDimsMask dyn_pad_mask;
+ dyn_pad_mask[reshape_axis] = 1;
+ user_info.second.data_padding._dynamic_dims_mask = dyn_pad_mask;
}
}
return;
@@ -697,31 +668,31 @@ void crop_in_place_optimization::update_in_place_crop_padding_simple_data_format
std::vector<int32_t> lower_sizes;
lower_sizes.push_back(offsets.batch[0]);
lower_sizes.push_back(offsets.feature[0]);
- for (size_t i = 0; i < input_layout.get_spatial_rank(); i++) {
+ for (int32_t i = static_cast<int32_t>(input_layout.get_spatial_rank() - 1); i >= 0; i--) {
lower_sizes.push_back(offsets.spatial[i]);
}
std::vector<int32_t> upper_sizes;
upper_sizes.push_back(input_layout.batch() - offsets.batch[0] - crop_size.batch[0]);
upper_sizes.push_back(input_layout.feature() - offsets.feature[0] - crop_size.feature[0]);
- for (size_t i = 0; i < input_layout.get_spatial_rank(); i++) {
+ for (int32_t i = static_cast<int32_t>(input_layout.get_spatial_rank() - 1); i >= 0; i--) {
upper_sizes.push_back(input_layout.spatial(i) - offsets.spatial[i] - crop_size.spatial[i]);
}
if (is_runtime) {
- auto dyn_pad_sizes = lower_sizes;
- dyn_pad_sizes[crop_axis_legacy] = 1;
- crop_layout.data_padding = padding(lower_sizes, upper_sizes, 0.f, tensor(dyn_pad_sizes));
+ padding::DynamicDimsMask dyn_pad_sizes;
+ dyn_pad_sizes[crop_axis] = 1;
+ crop_layout.data_padding = padding(lower_sizes, upper_sizes, dyn_pad_sizes);
if (user_info.first) {
auto reshape_desc = user_info.first->as<reshape>().get_primitive();
auto reshape_mode = reshape_desc->mode;
if (reshape_mode == reshape::reshape_mode::base) {
auto reshape_rank = user_info.second.get_partial_shape().size();
auto reshape_last_dim = user_info.second.get_partial_shape().to_shape()[reshape_rank - 1];
- if (lower_sizes[crop_axis_legacy])
- lower_sizes[crop_axis_legacy] /= reshape_last_dim;
- if (upper_sizes[crop_axis_legacy])
- upper_sizes[crop_axis_legacy] /= reshape_last_dim;
- user_info.second.data_padding = padding(lower_sizes, upper_sizes, 0.f, tensor(dyn_pad_sizes));
+ if (lower_sizes[crop_axis])
+ lower_sizes[crop_axis] /= reshape_last_dim;
+ if (upper_sizes[crop_axis])
+ upper_sizes[crop_axis] /= reshape_last_dim;
+ user_info.second.data_padding = padding(lower_sizes, upper_sizes, dyn_pad_sizes);
} else {
auto reshape_ps = user_info.second.get_partial_shape();
auto output_pattern = reshape_desc->output_pattern;
@@ -736,14 +707,13 @@ void crop_in_place_optimization::update_in_place_crop_padding_simple_data_format
const auto output_rank = std::max(reshape_ps.size(), static_cast<size_t>(4));
std::vector<int32_t> reshape_lower_sizes(output_rank, 0);
std::vector<int32_t> reshape_upper_sizes(output_rank, 0);
- std::vector<int32_t> reshape_dyn_pad_mask(output_rank, 0);
+ padding::DynamicDimsMask reshape_dyn_pad_mask;
- const auto reshape_axis_legacy = convert_axis_to_legacy(reshape_axis, reshape_ps.size());
- reshape_lower_sizes[reshape_axis_legacy] = lower_sizes[crop_axis_legacy];
- reshape_upper_sizes[reshape_axis_legacy] = upper_sizes[crop_axis_legacy];
- reshape_dyn_pad_mask[reshape_axis_legacy] = 1;
+ reshape_lower_sizes[reshape_axis] = lower_sizes[crop_axis];
+ reshape_upper_sizes[reshape_axis] = upper_sizes[crop_axis];
+ reshape_dyn_pad_mask[reshape_axis] = 1;
- user_info.second.data_padding = padding(reshape_lower_sizes, reshape_upper_sizes, 0.f, tensor(reshape_dyn_pad_mask));
+ user_info.second.data_padding = padding(reshape_lower_sizes, reshape_upper_sizes, reshape_dyn_pad_mask);
}
}
} else {
@@ -880,28 +850,19 @@ void prepare_buffer_fusing::run(program& p) {
if (kv_out_layout.data_type != rv_prim->get_output_layout().data_type)
return;
- auto concat_axis_legacy = node.get_primitive()->concat_axis;
- if (concat_axis_legacy < 0)
- concat_axis_legacy = kv_out_layout.get_partial_shape().size() + concat_axis_legacy;
- if (concat_axis_legacy >= 2) {
- auto spatial_axis = concat_axis_legacy - 2;
- // Default and minimum number of dimensions is 4
- auto spatial_size = std::max<size_t>(kv_out_layout.get_partial_shape().size(), 4) - 2;
- concat_axis_legacy = spatial_size - spatial_axis - 1 + 2;
- }
+ auto concat_axis = node.get_primitive()->concat_axis;
if (kv_out_layout.is_dynamic()) {
// set dynamic pad dims for shape agnostic kernel
- auto info_dynamic_pad = tensor(0).sizes();
- info_dynamic_pad[concat_axis_legacy] = 1;
- auto dynamic_pad_mask = tensor(info_dynamic_pad);
- kv_out_layout.data_padding.set_dynamic_pad(dynamic_pad_mask);
+ padding::DynamicDimsMask info_dynamic_pad;
+ info_dynamic_pad[concat_axis] = 1;
+ kv_out_layout.data_padding._dynamic_dims_mask = info_dynamic_pad;
node.set_output_layout(kv_out_layout);
node.can_share_buffer(false);
- auto update_dep = [&dynamic_pad_mask](program_node* dep) {
+ auto update_dep = [&info_dynamic_pad](program_node* dep) {
auto prev_layout = dep->get_output_layout();
- prev_layout.data_padding.set_dynamic_pad(dynamic_pad_mask);
+ prev_layout.data_padding._dynamic_dims_mask = info_dynamic_pad;
dep->set_output_layout(prev_layout);
dep->can_share_buffer(false);
};
diff --git a/src/plugins/intel_gpu/src/graph/graph_optimizer/prepare_padding.cpp b/src/plugins/intel_gpu/src/graph/graph_optimizer/prepare_padding.cpp
index bba8c182d42..5ef58b7e5f4 100644
--- a/src/plugins/intel_gpu/src/graph/graph_optimizer/prepare_padding.cpp
+++ b/src/plugins/intel_gpu/src/graph/graph_optimizer/prepare_padding.cpp
@@ -58,6 +58,10 @@ void prepare_padding::run(program& p) {
format == format::b_fs_zyx_fsv32)
continue;
+ auto in_layout = prim_node.get_input_layout();
+ const auto spatial_rank = in_layout.get_spatial_rank();
+ if (spatial_rank > 3 || spatial_rank < 1) continue; // FIXME: should support spatial_rank > 3?
+
auto padding_begin = prim->padding_begin;
auto padding_end = prim->padding_end;
@@ -69,25 +73,35 @@ void prepare_padding::run(program& p) {
tensor::value_type pe_y = std::max<std::ptrdiff_t>(padding_end.size() >= 2 ? padding_end[padding_end.size() - 2] : 0, 0);
tensor::value_type pe_x = std::max<std::ptrdiff_t>(padding_end.size() >= 1 ? padding_end[padding_end.size() - 1] : 0, 0);
- tensor pad_l = tensor(0);
- tensor pad_u = tensor(0);
- pad_l.spatial[0] = pb_x;
- pad_l.spatial[1] = pb_y;
- pad_l.spatial[2] = pb_z;
-
- pad_u.spatial[0] = pe_x;
- pad_u.spatial[1] = pe_y;
- pad_u.spatial[2] = pe_z;
-
- auto in_layout = prim_node.get_input_layout();
-
- const auto& actual_lpad = in_layout.data_padding.lower_size();
- const auto& actual_upad = in_layout.data_padding.upper_size();
-
- auto needed_lpad = tensor::max(pad_l, actual_lpad);
- auto needed_upad = tensor::max(pad_u, actual_upad);
+ const auto& lower_sizes = in_layout.data_padding._lower_size;
+ const auto& upper_sizes = in_layout.data_padding._upper_size;
+
+ std::vector<int32_t> needed_lpad, needed_upad;
+ needed_lpad.push_back(lower_sizes[0]);
+ needed_lpad.push_back(lower_sizes[1]);
+
+ needed_upad.push_back(upper_sizes[0]);
+ needed_upad.push_back(upper_sizes[1]);
+ if (spatial_rank == 3) {
+ needed_lpad.push_back(std::max(pb_z, lower_sizes[2]));
+ needed_lpad.push_back(std::max(pb_y, lower_sizes[3]));
+ needed_lpad.push_back(std::max(pb_x, lower_sizes[4]));
+
+ needed_upad.push_back(std::max(pe_z, upper_sizes[2]));
+ needed_upad.push_back(std::max(pe_y, upper_sizes[3]));
+ needed_upad.push_back(std::max(pe_x, upper_sizes[4]));
+ } else if (spatial_rank == 2) {
+ needed_lpad.push_back(std::max(pb_y, lower_sizes[2]));
+ needed_lpad.push_back(std::max(pb_x, lower_sizes[3]));
+
+ needed_upad.push_back(std::max(pe_y, upper_sizes[2]));
+ needed_upad.push_back(std::max(pe_x, upper_sizes[3]));
+ } {
+ needed_lpad.push_back(std::max(pb_x, lower_sizes[2]));
+ needed_upad.push_back(std::max(pb_x, upper_sizes[2]));
+ }
- padding needed_padding(needed_lpad.sizes(), needed_upad.sizes());
+ padding needed_padding(needed_lpad, needed_upad);
add_required_padding(prim_node, needed_padding);
} else if (node->is_type<deconvolution>()) {
@@ -269,7 +283,13 @@ cldnn::padding prepare_padding::get_needed_padding_for_convolution(convolution_n
// round_up_to(left_padding + prev_prim_output_layout.spatial(0) + right_padding, 16));
// right_padding = needed_buffer_size_x - left_padding - prev_prim_output_layout.spatial(0);
- cldnn::padding needed_padding({0, 0, padding_begin_x, padding_begin_y, padding_begin_z}, {0, 0, padding_end_x, padding_end_y, padding_end_z}, 0);
+ cldnn::padding needed_padding = padding();
+ if (padding_begin.size() >= 3)
+ needed_padding = padding({0, 0, padding_begin_z, padding_begin_y, padding_begin_x}, {0, 0, padding_end_z, padding_end_y, padding_end_x}, 0);
+ else if (padding_begin.size() >= 2)
+ needed_padding = padding({0, 0, padding_begin_y, padding_begin_x}, {0, 0, padding_end_y, padding_end_x}, 0);
+ else if (padding_begin.size() >= 1)
+ needed_padding = padding({0, 0, padding_begin_x}, {0, 0, padding_end_x}, 0);
needed_padding = padding::max(prev_prim_output_layout.data_padding, needed_padding);
return needed_padding;
diff --git a/src/plugins/intel_gpu/src/graph/graph_optimizer/prepare_quantization.cpp b/src/plugins/intel_gpu/src/graph/graph_optimizer/prepare_quantization.cpp
index 2f6121ec282..93065ce183b 100644
--- a/src/plugins/intel_gpu/src/graph/graph_optimizer/prepare_quantization.cpp
+++ b/src/plugins/intel_gpu/src/graph/graph_optimizer/prepare_quantization.cpp
@@ -68,10 +68,10 @@ void prepare_quantization::prepare_scale_shift_opt(program &p, quantize_node& qu
auto sizes = l.get_tensor();
auto pitches = l.get_pitches();
- return (idx.batch[0] % sizes.batch[0])*pitches.batch[0]
- + (idx.feature[0] % sizes.feature[0])*pitches.feature[0]
- + (idx.spatial[1] % sizes.spatial[1])*pitches.spatial[1]
- + (idx.spatial[0] % sizes.spatial[0])*pitches.spatial[0];
+ return (idx.batch[0] % sizes.batch[0])*pitches[0]
+ + (idx.feature[0] % sizes.feature[0])*pitches[1]
+ + (idx.spatial[1] % sizes.spatial[1])*pitches[2 + 0] // y
+ + (idx.spatial[0] % sizes.spatial[0])*pitches[2 + 1]; // x
};
auto lock_memory = [&stream] (memory::ptr memory, std::function<void(std::size_t, float)>& set_data,
diff --git a/src/plugins/intel_gpu/src/graph/graph_optimizer/remove_redundant_reorders.cpp b/src/plugins/intel_gpu/src/graph/graph_optimizer/remove_redundant_reorders.cpp
index d19c64facd5..328629479b9 100644
--- a/src/plugins/intel_gpu/src/graph/graph_optimizer/remove_redundant_reorders.cpp
+++ b/src/plugins/intel_gpu/src/graph/graph_optimizer/remove_redundant_reorders.cpp
@@ -280,38 +280,40 @@ void remove_redundant_reorders::run(program& p) {
continue;
auto o_layout = r_node.get_output_layout();
- auto i_layout = r_node.get_input_layout(0);
+ const auto& i_layout = r_node.get_input_layout(0);
// Optimize reorder b_fs_yx_fsv16 -> bfyx when spatials are equal to 1. In this case we can reinterpret buffer,
// but pads need to be handled correctly.
if (i_layout.format == format::b_fs_yx_fsv16 && o_layout.format == format::bfyx && !r_node.is_output() &&
i_layout.spatial(0) == 1 && i_layout.spatial(1) == 1 &&
- i_layout.data_padding.upper_size().spatial[0] == 0 && i_layout.data_padding.lower_size().spatial[0] == 0 &&
- i_layout.data_padding.upper_size().spatial[1] == 0 && i_layout.data_padding.lower_size().spatial[1] == 0 &&
- o_layout.data_padding.upper_size() == (tensor)0 && o_layout.data_padding.lower_size() == (tensor)0 &&
+ i_layout.data_padding._upper_size[2] == 0 && i_layout.data_padding._lower_size[2] == 0 &&
+ i_layout.data_padding._upper_size[3] == 0 && i_layout.data_padding._lower_size[3] == 0 &&
+ !o_layout.data_padding &&
i_layout.data_type == o_layout.data_type &&
!layout_optimizer::onednn_check_preferred_impl_type_of_users(r_node)) {
// If the newly aligned pad is merged into output layout during post_optimize_graph phase
// and then buffer is reinterpreted, user node cannot handle pad properly for kernel execution
if (!update_implementations || (i_layout.feature() % 16 == 0 &&
- i_layout.data_padding == padding() && o_layout.data_padding == padding()) || i_layout.batch() == 1) {
+ !i_layout.data_padding && !o_layout.data_padding) || i_layout.batch() == 1) {
r_node.can_be_optimized(true);
r_node.requires_reinterpret(true);
- auto pad_lo = o_layout.data_padding.lower_size();
- auto pad_hi = o_layout.data_padding.upper_size();
+ std::vector<int32_t> pad_lo(o_layout.data_padding._lower_size.begin(),
+ o_layout.data_padding._lower_size.begin() + o_layout.get_rank());
+ std::vector<int32_t> pad_hi(o_layout.data_padding._upper_size.begin(),
+ o_layout.data_padding._upper_size.begin() + o_layout.get_rank());
- pad_lo.batch[0] = i_layout.data_padding.lower_size().batch[0];
- pad_hi.batch[0] = i_layout.data_padding.upper_size().batch[0];
+ pad_lo[0] = i_layout.data_padding._lower_size[0];
+ pad_hi[0] = i_layout.data_padding._upper_size[0];
- pad_lo.feature[0] = i_layout.data_padding.lower_size().feature[0];
- pad_hi.feature[0] = i_layout.data_padding.upper_size().feature[0];
+ pad_lo[1] = i_layout.data_padding._lower_size[1];
+ pad_hi[1] = i_layout.data_padding._upper_size[1];
if (i_layout.feature() % 16 != 0) {
- pad_hi.feature[0] += 16 - i_layout.feature() % 16;
+ pad_hi[1] += 16 - i_layout.feature() % 16;
}
- r_node.merge_output_padding(padding{pad_lo.sizes(), pad_hi.sizes()});
+ r_node.merge_output_padding(padding{pad_lo, pad_hi});
continue;
}
}
@@ -526,9 +528,10 @@ void remove_redundant_reorders::run(program& p) {
return false;
auto node_format = node->get_output_layout().format;
- for (size_t axis = 0; axis < node->get_input_layout(0).data_padding.lower_size().sizes(node_format).size(); axis++) {
+ auto sizes_in_format = layout::format_sizes(node->get_input_layout(0).data_padding._lower_size, node_format);
+ for (size_t axis = 0; axis < sizes_in_format.size(); axis++) {
if (!user->is_padding_supported(static_cast<int>(axis),
- node->get_input_layout(0).data_padding.lower_size().sizes(node_format)[axis]))
+ sizes_in_format[axis]))
return false;
}
}
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 c2a01b56c63..7d3e4ff7c4e 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
@@ -446,8 +446,8 @@ public:
const int input_buffer_size_y = input_buffer_size[2];
const int input_buffer_size_f = input_buffer_size[1];
const auto& input_padding = location_layout.data_padding;
- const int input_padding_lower_x = input_padding.lower_size().spatial[0];
- const int input_padding_lower_y = input_padding.lower_size().spatial[1];
+ const int input_padding_lower_x = input_padding._lower_size[2];
+ const int input_padding_lower_y = input_padding._lower_size[3];
for (int image = 0; image < num_of_images; ++image) {
std::vector<std::vector<bounding_box>>& label_to_bbox = locations[image];
@@ -540,13 +540,13 @@ public:
assert(num_of_priors * num_classes == input_confidence->get_layout().feature());
- const auto& input_buffer_size = input_confidence->get_layout().get_buffer_size();
- const int input_buffer_size_x = input_buffer_size.spatial[0];
- const int input_buffer_size_y = input_buffer_size.spatial[1];
- const int input_buffer_size_f = input_buffer_size.feature[0];
+ const auto& input_buffer_layout = input_confidence->get_layout();
+ const int input_buffer_size_x = input_buffer_layout.spatial(0);
+ const int input_buffer_size_y = input_buffer_layout.spatial(1);
+ const int input_buffer_size_f = input_buffer_layout.feature();
const auto& input_padding = input_confidence->get_layout().data_padding;
- const int input_padding_lower_x = input_padding.lower_size().spatial[0];
- const int input_padding_lower_y = input_padding.lower_size().spatial[1];
+ const int input_padding_lower_x = input_padding._lower_size[2];
+ const int input_padding_lower_y = input_padding._lower_size[3];
const int stride = input_buffer_size_y * input_buffer_size_x;
for (int image = 0; image < num_of_images; ++image) {
@@ -635,13 +635,12 @@ public:
assert(num_of_priors * num_classes == confidence_layout.feature());
- const auto& input_buffer_size = confidence_layout.get_buffer_size();
- const int input_buffer_size_x = input_buffer_size.spatial[0];
- const int input_buffer_size_y = input_buffer_size.spatial[1];
- const int input_buffer_size_f = input_buffer_size.feature[0];
+ const int input_buffer_size_x = confidence_layout.spatial(0);
+ const int input_buffer_size_y = confidence_layout.spatial(1);
+ const int input_buffer_size_f = confidence_layout.feature();
const auto& input_padding = confidence_layout.data_padding;
- const int input_padding_lower_x = input_padding.lower_size().spatial[0];
- const int input_padding_lower_y = input_padding.lower_size().spatial[1];
+ const int input_padding_lower_x = input_padding._lower_size[2];
+ const int input_padding_lower_y = input_padding._lower_size[3];
const int stride = input_buffer_size_y * input_buffer_size_x;
for (int image = 0; image < num_of_images; ++image) {
diff --git a/src/plugins/intel_gpu/src/graph/impls/ocl/custom_primitive.cpp b/src/plugins/intel_gpu/src/graph/impls/ocl/custom_primitive.cpp
index 2c0792e2fbc..7f867dda3a1 100644
--- a/src/plugins/intel_gpu/src/graph/impls/ocl/custom_primitive.cpp
+++ b/src/plugins/intel_gpu/src/graph/impls/ocl/custom_primitive.cpp
@@ -166,13 +166,14 @@ static void add_layout_to_jit(kernel_selector::jit_constants& mem_consts, const
// #define INPUT0_LOWER_PADDING (uint[]) { 0, 0, 0, 0 }
// #define INPUT0_UPPER_PADDING (uint[]) { 0, 0, 0, 0 }
mem_consts.AddConstant(
- kernel_selector::MakeJitConstant(name + "_LOWER_PADDING", l.data_padding.lower_size().sizes(format::bfyx)));
+ kernel_selector::MakeJitConstant(name + "_LOWER_PADDING", layout::format_sizes(l.data_padding._lower_size, format::bfyx)));
mem_consts.AddConstant(
- kernel_selector::MakeJitConstant(name + "_UPPER_PADDING", l.data_padding.upper_size().sizes(format::bfyx)));
+ kernel_selector::MakeJitConstant(name + "_UPPER_PADDING", layout::format_sizes(l.data_padding._upper_size, format::bfyx)));
// Pitches (in elements)
// #define INPUT0_PITCHES (uint[]) { b, f, h, w, }
- auto padded_sizes = l.get_buffer_size().sizes(format::bfyx);
+ // auto padded_sizes = l.get_buffer_size().sizes(format::bfyx);
+ auto padded_sizes = l.get_padded_dims();
std::vector<tensor::value_type> pitches(4);
switch (l.format) {
@@ -209,8 +210,8 @@ static void add_layout_to_jit(kernel_selector::jit_constants& mem_consts, const
// Offset (in elements)
// #define INPUT0_OFFSET 0
int32_t offset =
- (pitches[0] * l.data_padding.lower_size().batch[0]) + (pitches[1] * l.data_padding.lower_size().feature[0]) +
- (pitches[2] * l.data_padding.lower_size().spatial[1]) + (pitches[3] * l.data_padding.lower_size().spatial[0]);
+ (pitches[0] * l.data_padding._lower_size[0]) + (pitches[1] * l.data_padding._lower_size[1]) +
+ (pitches[2] * l.data_padding._lower_size[3]) + (pitches[3] * l.data_padding._lower_size[2]);
mem_consts.AddConstant(kernel_selector::MakeJitConstant(name + "_OFFSET", std::to_string(offset)));
}
diff --git a/src/plugins/intel_gpu/src/graph/impls/ocl/detection_output.cpp b/src/plugins/intel_gpu/src/graph/impls/ocl/detection_output.cpp
index f8b9165c132..bcadecfd032 100644
--- a/src/plugins/intel_gpu/src/graph/impls/ocl/detection_output.cpp
+++ b/src/plugins/intel_gpu/src/graph/impls/ocl/detection_output.cpp
@@ -55,8 +55,8 @@ public:
detectOutParams.clip_after_nms = primitive->clip_after_nms;
detectOutParams.conf_size_x = confidence_layout.get_padded_dims()[2];
detectOutParams.conf_size_y = confidence_layout.get_padded_dims()[3];
- detectOutParams.conf_padding_x = confidence_layout.data_padding.lower_size().spatial[0];
- detectOutParams.conf_padding_y = confidence_layout.data_padding.lower_size().spatial[1];
+ detectOutParams.conf_padding_x = confidence_layout.data_padding._lower_size[2];
+ detectOutParams.conf_padding_y = confidence_layout.data_padding._lower_size[3];
return params;
}
diff --git a/src/plugins/intel_gpu/src/graph/impls/ocl/kernel_selector_helper.cpp b/src/plugins/intel_gpu/src/graph/impls/ocl/kernel_selector_helper.cpp
index 6915da8b754..aa287a9faf2 100644
--- a/src/plugins/intel_gpu/src/graph/impls/ocl/kernel_selector_helper.cpp
+++ b/src/plugins/intel_gpu/src/graph/impls/ocl/kernel_selector_helper.cpp
@@ -842,9 +842,9 @@ kernel_selector::data_tensor convert_data_tensor(const layout& l, const tensor v
vals_ordered.push_back(vals_original[axis_order[i]]);
}
const auto& add_offsets = view_offset.sizes(l.format);
- const auto& lower_pad = pad.lower_size().sizes(l.format);
- const auto& upper_pad = pad.upper_size().sizes(l.format);
- const auto& dynamic_pad_dims = pad.get_dynamic_pad_dims().sizes(l.format);
+ const auto& lower_pad = layout::format_sizes(pad._lower_size, l.format);
+ const auto& upper_pad = layout::format_sizes(pad._upper_size, l.format);
+ const auto& dynamic_pad_dims = layout::format_sizes(pad._dynamic_dims_mask, l.format);
const auto ks_layout = to_data_layout(l.format);
kernel_selector::n_dims vec(kernel_selector::DataTensor::ChannelsCount(ks_layout));
diff --git a/src/plugins/intel_gpu/src/graph/impls/onednn/gemm_onednn.cpp b/src/plugins/intel_gpu/src/graph/impls/onednn/gemm_onednn.cpp
index 066d5a4739e..5eb133eccd9 100644
--- a/src/plugins/intel_gpu/src/graph/impls/onednn/gemm_onednn.cpp
+++ b/src/plugins/intel_gpu/src/graph/impls/onednn/gemm_onednn.cpp
@@ -113,7 +113,7 @@ protected:
out_fmt = onednn::convert_gemm_data_format(out_dims, out_l.format);
if (in0_l.data_padding) {
- dnnl::memory::dims in0_padded_dims = onednn::convert_gemm_tensor(in0_l.get_buffer_size(), rank, batched_dims_can_be_removed);
+ dnnl::memory::dims in0_padded_dims = onednn::convert_gemm_dims(in0_l.get_padded_dims(), rank, batched_dims_can_be_removed);
in0_strides = onednn::get_strides(in0_padded_dims);
if (prim->transpose_input0) {
std::swap(in0_strides[in0_strides.size() - 1], in0_strides[in0_strides.size() - 2]);
@@ -121,7 +121,7 @@ protected:
}
if (in1_l.data_padding) {
- dnnl::memory::dims in1_padded_dims = onednn::convert_gemm_tensor(in1_l.get_buffer_size(), rank, batched_dims_can_be_removed);
+ dnnl::memory::dims in1_padded_dims = onednn::convert_gemm_dims(in1_l.get_padded_dims(), rank, batched_dims_can_be_removed);
in1_strides = onednn::get_strides(in1_padded_dims);
if (prim->transpose_input1)
std::swap(in1_strides[in1_strides.size() - 1], in1_strides[in1_strides.size() - 2]);
diff --git a/src/plugins/intel_gpu/src/graph/impls/onednn/utils.cpp b/src/plugins/intel_gpu/src/graph/impls/onednn/utils.cpp
index fc9fcd30dbc..60694cadb83 100644
--- a/src/plugins/intel_gpu/src/graph/impls/onednn/utils.cpp
+++ b/src/plugins/intel_gpu/src/graph/impls/onednn/utils.cpp
@@ -60,6 +60,20 @@ dnnl::memory::dims convert_gemm_tensor(cldnn::tensor t, size_t dims, bool batche
return res;
}
+dnnl::memory::dims convert_gemm_dims(const std::vector<int32_t> &sizes, size_t dims, bool batched_dims_can_be_removed) {
+ dnnl::memory::dims res(sizes.begin(), sizes.end());
+ if (dims > 4) {
+ for (size_t i = 0; i < dims - 4; i++) {
+ res[i + 1] *= res[i];
+ }
+ res.erase(res.begin(), res.begin() + dims - 4);
+ }
+ if (res.size() == 4 && batched_dims_can_be_removed) {
+ res.erase(res.begin(), res.begin() + 2);
+ }
+ return res;
+}
+
dnnl::memory::format_tag convert_gemm_data_format(dnnl::memory::dims dims, format target) {
if (dims.size() == target.dimension()) {
auto tag = convert_data_format(target);
@@ -215,11 +229,11 @@ void combine_bf_with_first_spatial_dim(cldnn::layout& l) {
int64_t get_offset(cldnn::layout&& l, dnnl::memory::desc&& desc) {
int64_t offset = 0;
- auto b_padding = l.data_padding.lower_size().batch[0];
- auto f_padding = l.data_padding.lower_size().feature[0];
+ auto b_padding = l.data_padding._lower_size[0];
+ auto f_padding = l.data_padding._lower_size[1];
if (b_padding != 0) {
auto input_pitches = l.get_pitches();
- offset = b_padding * input_pitches.batch[0];
+ offset = b_padding * input_pitches[0];
} else if (f_padding != 0) {
offset = f_padding;
for (size_t i = 0; i < l.get_spatial_rank(); ++i) {
@@ -533,6 +547,15 @@ cldnn::format_traits convert_memory_desc_to_traits(const dnnl::memory::desc& des
}
std::string outer_order = get_external_order(order, is_weights, is_grouped);
+ std::vector<std::pair<size_t, int>> logic_block_sizes(inner_nblks);
+ for (int i = 0; i < inner_nblks; i++) {
+ auto c = internal_order[block_sizes[i].first];
+ auto pos = outer_order.find(c);
+ OPENVINO_ASSERT(pos != std::string::npos, "[GPU] Unknown coord type: ", c);
+
+ logic_block_sizes[i] = std::make_pair(order[pos], inner_blks[i]);
+ }
+
format_traits traits;
traits.batch_num = batch_num;
traits.feature_num = feature_num;
@@ -542,6 +565,7 @@ cldnn::format_traits convert_memory_desc_to_traits(const dnnl::memory::desc& des
traits.order = outer_order;
traits.internal_order = internal_order;
traits.block_sizes = block_sizes;
+ traits.logic_block_sizes = logic_block_sizes;
traits.str = "custom";
return traits;
diff --git a/src/plugins/intel_gpu/src/graph/impls/onednn/utils.hpp b/src/plugins/intel_gpu/src/graph/impls/onednn/utils.hpp
index e8127b698f5..363afc34172 100644
--- a/src/plugins/intel_gpu/src/graph/impls/onednn/utils.hpp
+++ b/src/plugins/intel_gpu/src/graph/impls/onednn/utils.hpp
@@ -26,6 +26,7 @@ void combine_bf_with_first_spatial_dim(cldnn::layout& l);
// cldnn -> onednn
dnnl::memory::dims convert_tensor(cldnn::tensor t, size_t dims = 2, bool is_grouped = false);
dnnl::memory::dims convert_gemm_tensor(cldnn::tensor t, size_t dims, bool batched_dims_can_be_removed);
+dnnl::memory::dims convert_gemm_dims(const std::vector<int32_t> &sizes, size_t dims, bool batched_dims_can_be_removed);
dnnl::memory::dims convert_spatials(cldnn::tensor t, size_t dims = 2);
dnnl::memory::dims flatten_tensor(cldnn::tensor t);
dnnl::memory::dims get_strides(dnnl::memory::dims dims);
diff --git a/src/plugins/intel_gpu/src/graph/include/kv_cache_inst.h b/src/plugins/intel_gpu/src/graph/include/kv_cache_inst.h
index 53ef32525ea..f3aa4de5ec3 100644
--- a/src/plugins/intel_gpu/src/graph/include/kv_cache_inst.h
+++ b/src/plugins/intel_gpu/src/graph/include/kv_cache_inst.h
@@ -54,32 +54,19 @@ public:
int32_t get_prealloc_iter_num() override;
- static void update_pad(layout& l, int64_t pad, int64_t sequence_axis_legacy) {
- const auto& dyn_pad_dims = l.data_padding.get_dynamic_pad_dims();
- const auto& lower_padd = l.data_padding.lower_size().sizes();
- auto upper_padd = l.data_padding.upper_size().sizes();
- upper_padd[sequence_axis_legacy] = pad;
- l.data_padding = padding(lower_padd, upper_padd, 0.f, dyn_pad_dims);
+ static void update_pad(layout& l, int64_t pad, int64_t sequence_axis) {
+ l.data_padding._upper_size[sequence_axis] = static_cast<int32_t>(pad);
}
- static int64_t get_sequence_axis_legacy(int64_t sequence_axis, size_t past_layout_rank) {
- auto sequence_axis_legacy = sequence_axis;
- if (sequence_axis_legacy < 0)
- sequence_axis_legacy = past_layout_rank + sequence_axis_legacy;
- if (sequence_axis_legacy >= 2) {
- auto spatial_axis = sequence_axis_legacy - 2;
- // Default and minimum number of dimensions is 4
- auto spatial_size = std::max<size_t>(past_layout_rank, 4) - 2;
- sequence_axis_legacy = spatial_size - spatial_axis - 1 + 2;
- }
- return sequence_axis_legacy;
+ static int64_t get_sequence_axis(int64_t sequence_axis, size_t past_layout_rank) {
+ return sequence_axis >= 0 ? sequence_axis : past_layout_rank + sequence_axis;
}
- static int64_t get_max_pad(const layout& target_layout, size_t buffer_size, int64_t legacy_sequence_axis, std::string target_name = "") {
+ static int64_t get_max_pad(const layout& target_layout, size_t buffer_size, int64_t sequence_axis, std::string target_name = "") {
if (buffer_size == 0)
return 0;
const size_t total_elements = target_layout.count();
- const int64_t concat_axis_size = target_layout.get_tensor().sizes()[legacy_sequence_axis];
+ const int64_t concat_axis_size = target_layout.get_shape()[sequence_axis];
const int64_t sequence_element_size = total_elements / concat_axis_size;
const int64_t max_sequence_elements = buffer_size / sequence_element_size;
auto max_pad = std::max<int64_t>(max_sequence_elements - concat_axis_size, 0);
diff --git a/src/plugins/intel_gpu/src/graph/include/reshape_inst.h b/src/plugins/intel_gpu/src/graph/include/reshape_inst.h
index 2904474fbdc..1bbfd94256a 100644
--- a/src/plugins/intel_gpu/src/graph/include/reshape_inst.h
+++ b/src/plugins/intel_gpu/src/graph/include/reshape_inst.h
@@ -89,7 +89,9 @@ public:
}
bool has_padding() const {
- return (this->get_output_layout().data_padding || input().get_output_layout(false).data_padding || input().get_output_layout(false).has_dynamic_pad());
+ return (this->get_output_layout().data_padding
+ || input().get_output_layout(false).data_padding
+ || input().get_output_layout(false).data_padding.is_dynamic());
}
bool has_outer_padding_offset() const {
@@ -99,15 +101,15 @@ public:
auto input_layout = input().get_output_layout(false);
auto input_pad = input_layout.data_padding;
for (size_t i = 0 ; i < input_layout.get_spatial_rank() ; i++) {
- if (input_pad.lower_size().spatial[i] != 0)
+ if (input_pad._lower_size[2 + i] != 0)
return false;
- if (input_pad.upper_size().spatial[i] != 0)
+ if (input_pad._upper_size[2 + i] != 0)
return false;
}
// Expected a padded input of only batch axis with 'bxxx' format
if (input_layout.format.dims_order()[0] != 0 ||
- input_pad.lower_size().feature[0] != 0)
+ input_pad._lower_size[1] != 0)
return false;
if (format::is_multi_blocked(input_layout.format))
@@ -121,7 +123,7 @@ public:
if (this->is_output() || this->has_fused_primitives())
return false;
- if (input().get_output_layout(false).has_dynamic_pad() && is_runtime_propagatable_padding())
+ if (input().get_output_layout(false).data_padding.is_dynamic() && is_runtime_propagatable_padding())
return true;
if (has_padding())
@@ -136,7 +138,7 @@ public:
auto input_layout = input().get_output_layout(false);
auto output_layout = this->get_output_layout();
- if (input_layout.has_dynamic_pad()) {
+ if (input_layout.data_padding.is_dynamic()) {
auto prim = typed_desc();
// TODO: If outer padding exists, ouput padding propagation is not supported in the base mode
if (prim->mode == reshape::reshape_mode::base)
@@ -159,9 +161,9 @@ public:
// adjust output padding if Reshape has an outer padding exists in an input
auto input_pitches = input_layout.get_pitches();
auto input_pad = input_layout.data_padding;
- size_t first_element_offset = input_pad.lower_size().batch[0];
+ size_t first_element_offset = input_pad._lower_size[0];
// feature and spatial size
- first_element_offset *= input_pitches.batch[0];
+ first_element_offset *= input_pitches[0];
size_t inner_size = 1;
for (size_t i = 0 ; i < output_layout.get_spatial_rank() ; i++) {
diff --git a/src/plugins/intel_gpu/src/graph/include/sliding_window_utils.hpp b/src/plugins/intel_gpu/src/graph/include/sliding_window_utils.hpp
index 85b627655d9..5f655915c0a 100644
--- a/src/plugins/intel_gpu/src/graph/include/sliding_window_utils.hpp
+++ b/src/plugins/intel_gpu/src/graph/include/sliding_window_utils.hpp
@@ -428,17 +428,31 @@ inline padding calc_sliding_window_needed_input_padding(const layout& actual_inp
}
const auto& actual_data_size = actual_input_layout.get_tensor();
- const auto& actual_lpad = actual_input_layout.data_padding.lower_size();
- const auto& actual_upad = actual_input_layout.data_padding.upper_size();
-
- auto needed_upad = tensor::max(needed_size.sub(actual_data_size), actual_upad);
-
- return padding(actual_lpad.sizes(),
- {actual_upad.batch[0],
- actual_upad.feature[0],
- needed_upad.spatial[0],
- needed_upad.spatial[1],
- needed_upad.spatial[2]});
+ const auto& actual_lpad = actual_input_layout.data_padding._lower_size;
+ const auto& actual_upad = actual_input_layout.data_padding._upper_size;
+
+ auto needed_upad = needed_size.sub(actual_data_size);
+
+ auto spatial_rank = actual_input_layout.get_spatial_rank();
+ OPENVINO_ASSERT(spatial_rank > 0 && spatial_rank <= 3);
+ if (spatial_rank >= 3)
+ return padding({actual_lpad[0], actual_lpad[1], actual_lpad[2], actual_lpad[3], actual_lpad[4]},
+ {actual_upad[0],
+ actual_upad[1],
+ std::max(needed_upad.spatial[2], actual_upad[2]),
+ std::max(needed_upad.spatial[1], actual_upad[3]),
+ std::max(needed_upad.spatial[0], actual_upad[4])});
+ else if (spatial_rank >= 2)
+ return padding({actual_lpad[0], actual_lpad[1], actual_lpad[2], actual_lpad[3]},
+ {actual_upad[0],
+ actual_upad[1],
+ std::max(needed_upad.spatial[1], actual_upad[2]),
+ std::max(needed_upad.spatial[0], actual_upad[3])});
+ else
+ return padding({actual_lpad[0], actual_lpad[1], actual_lpad[2]},
+ {actual_upad[0],
+ actual_upad[1],
+ std::max(needed_upad.spatial[0], actual_upad[2])});
}
} // namespace intel_gpu
diff --git a/src/plugins/intel_gpu/src/graph/layout_optimizer.cpp b/src/plugins/intel_gpu/src/graph/layout_optimizer.cpp
index 60cda961c08..f0be15f586f 100644
--- a/src/plugins/intel_gpu/src/graph/layout_optimizer.cpp
+++ b/src/plugins/intel_gpu/src/graph/layout_optimizer.cpp
@@ -1388,22 +1388,25 @@ bool layout_optimizer::are_data_types_suitable_for_onednn(program_node& node) {
bool layout_optimizer::are_layouts_suitable_for_onednn(program_node& node) {
auto input_layout = node.get_dependencies().front().first->get_output_layout();
auto in_padding = input_layout.data_padding;
- auto out_padding = node.get_output_layout().data_padding;
+ auto output_layout = node.get_output_layout();
+ auto out_padding = output_layout.data_padding;
// Check if padding exists
if (node.get_preferred_impl_type() == impl_types::onednn && (in_padding || out_padding)) {
// Check spatial padding
bool no_spatial_padding = true;
- for (size_t i = 0; i < in_padding.lower_size().spatial.size(); ++i) {
- no_spatial_padding &= (in_padding.lower_size().spatial[i] == 0);
+ auto input_spatial_rank = input_layout.get_spatial_rank();
+ auto output_spatial_rank = output_layout.get_spatial_rank();
+ for (size_t i = 0; i < input_spatial_rank; ++i) {
+ no_spatial_padding &= (in_padding._lower_size[2 + i] == 0);
}
- for (size_t i = 0; i < in_padding.upper_size().spatial.size(); ++i) {
- no_spatial_padding &= (in_padding.upper_size().spatial[i] == 0);
+ for (size_t i = 0; i < input_spatial_rank; ++i) {
+ no_spatial_padding &= (in_padding._upper_size[2 + i] == 0);
}
- for (size_t i = 0; i < out_padding.lower_size().spatial.size(); ++i) {
- no_spatial_padding &= (out_padding.lower_size().spatial[i] == 0);
+ for (size_t i = 0; i < output_spatial_rank; ++i) {
+ no_spatial_padding &= (out_padding._lower_size[2 + i] == 0);
}
- for (size_t i = 0; i < out_padding.upper_size().spatial.size(); ++i) {
- no_spatial_padding &= (out_padding.upper_size().spatial[i] == 0);
+ for (size_t i = 0; i < output_spatial_rank; ++i) {
+ no_spatial_padding &= (out_padding._upper_size[2 + i] == 0);
}
// Onednn supports outer padding of batch axis (first element offset) if its format is 'bxxx'
@@ -1411,18 +1414,10 @@ bool layout_optimizer::are_layouts_suitable_for_onednn(program_node& node) {
auto out_fmt = node.get_output_layout().format;
if (format::is_multi_blocked(input_layout.format) || format::is_multi_blocked(out_fmt) ||
input_layout.format.dims_order()[0] != 0 || out_fmt.dims_order()[0] != 0) {
- for (size_t i = 0; i < in_padding.lower_size().batch.size(); ++i) {
- no_batch_padding &= (in_padding.lower_size().batch[i] == 0);
- }
- for (size_t i = 0; i < in_padding.upper_size().batch.size(); ++i) {
- no_batch_padding &= (in_padding.upper_size().batch[i] == 0);
- }
- for (size_t i = 0; i < out_padding.lower_size().batch.size(); ++i) {
- no_batch_padding &= (out_padding.lower_size().batch[i] == 0);
- }
- for (size_t i = 0; i < out_padding.upper_size().batch.size(); ++i) {
- no_batch_padding &= (out_padding.upper_size().batch[i] == 0);
- }
+ no_batch_padding &= (in_padding._lower_size[0] == 0);
+ no_batch_padding &= (in_padding._upper_size[0] == 0);
+ no_batch_padding &= (out_padding._lower_size[0] == 0);
+ no_batch_padding &= (out_padding._upper_size[0] == 0);
}
return (no_spatial_padding && no_batch_padding);
}
diff --git a/src/plugins/intel_gpu/src/graph/primitive_inst.cpp b/src/plugins/intel_gpu/src/graph/primitive_inst.cpp
index f0a1e12e518..3e6b766ba12 100644
--- a/src/plugins/intel_gpu/src/graph/primitive_inst.cpp
+++ b/src/plugins/intel_gpu/src/graph/primitive_inst.cpp
@@ -429,7 +429,7 @@ void primitive_inst::update_shape() {
auto new_layouts = _node->type()->calc_output_layouts(*_node, *_impl_params);
for (size_t idx = 0; idx != new_layouts.size(); ++idx) {
auto& new_layout = new_layouts[idx];
- if (!_node->is_type<reshape>() || (!_node->get_input_layout(0).has_dynamic_pad() && !_node->can_be_optimized())) {
+ if (!_node->is_type<reshape>() || (!_node->get_input_layout(0).data_padding.is_dynamic() && !_node->can_be_optimized())) {
auto data_padding = padding::max(_impl_params->get_output_layout(idx).data_padding, new_layout.data_padding);
new_layout.data_padding = padding::max(_node->get_primitive()->get_output_padding(idx), data_padding);
}
@@ -668,10 +668,14 @@ event::ptr primitive_inst::realloc_if_needed() {
}
// update layout to ensure that it repsects paddings for correct allocation size
- if (_node_output_layout.data_padding.get_dynamic_pad_dims() != tensor(0)) {
- size_t rank = updated_layouts[0].get_partial_shape().size();
- auto current_buf_shape = updated_layouts[0].get_buffer_size().get_partial_shape(rank, std::min(static_cast<size_t>(4), rank));
- updated_layouts[0] = layout(current_buf_shape, updated_layouts[0].data_type, updated_layouts[0].format);
+ if (_node_output_layout.data_padding.is_dynamic()) {
+ auto current_dims = updated_layouts[0].get_padded_dims();
+
+ std::vector<size_t> current_buf_shape;
+ current_buf_shape.reserve(current_dims.size());
+ std::transform(current_dims.begin(), current_dims.end(),
+ std::back_inserter(current_buf_shape), [](const tensor::value_type& el) { return static_cast<size_t>(el); });
+ updated_layouts[0] = layout(ov::PartialShape(current_buf_shape), updated_layouts[0].data_type, updated_layouts[0].format);
}
int32_t tmp_prealloc_count = get_prealloc_iter_num();
@@ -743,15 +747,12 @@ event::ptr primitive_inst::realloc_if_needed() {
const auto& desc = _node->as<kv_cache>().get_primitive();
auto& present_layout = _impl_params->output_layouts[i];
const auto present_layout_rank = present_layout.get_partial_shape().size();
- const auto sequence_axis =
- desc->concat_axis >= 0 ? desc->concat_axis : present_layout_rank + desc->concat_axis;
-
- const auto sequence_axis_legacy = kv_cache_inst::get_sequence_axis_legacy(sequence_axis, present_layout_rank);
+ const auto sequence_axis = kv_cache_inst::get_sequence_axis(desc->concat_axis, present_layout_rank);
auto max_pad = kv_cache_inst::get_max_pad(present_layout,
_max_output_layout_count[i],
- sequence_axis_legacy,
+ sequence_axis,
"present_layout");
- kv_cache_inst::update_pad(present_layout, max_pad, sequence_axis_legacy);
+ kv_cache_inst::update_pad(present_layout, max_pad, sequence_axis);
GPU_DEBUG_TRACE_DETAIL << _impl_params->output_layouts[i].to_string() << std::endl;
set_shape_change();
} else {
@@ -795,27 +796,25 @@ event::ptr primitive_inst::realloc_if_needed() {
auto& variable = get_network().get_variable(desc->variable_info.variable_id);
auto present_layout = _impl_params->output_layouts[0];
auto present_layout_rank = present_layout.get_partial_shape().size();
- const auto sequence_axis = desc->concat_axis >= 0 ? desc->concat_axis
- : present_layout_rank + desc->concat_axis;
- auto sequence_axis_legacy =
- kv_cache_inst::get_sequence_axis_legacy(sequence_axis, present_layout_rank);
+ const auto sequence_axis =
+ kv_cache_inst::get_sequence_axis(desc->concat_axis, present_layout_rank);
GPU_DEBUG_TRACE_DETAIL << id() << " is kv_cache => set the variable with newly allocated output memory"
<< std::endl;
bool axis_is_outer_most = true;
- for (size_t dim = 0; dim < sequence_axis; ++dim) {
+ for (auto dim = 0; dim < sequence_axis; ++dim) {
if (present_layout.get_shape()[dim] > 1) {
axis_is_outer_most = false;
break;
}
}
- if (present_layout.data_padding.get_dynamic_pad_dims().sizes()[sequence_axis_legacy] == 1) {
+ if (present_layout.data_padding._dynamic_dims_mask[sequence_axis] == 1) {
// Apply padding of variable to make it be optimized in the next iteration
auto max_pad = kv_cache_inst::get_max_pad(present_layout,
_max_output_layout_count[0],
- sequence_axis_legacy,
+ sequence_axis,
"present_layout");
if (max_pad > 0) {
- kv_cache_inst::update_pad(present_layout, max_pad, sequence_axis_legacy);
+ kv_cache_inst::update_pad(present_layout, max_pad, sequence_axis);
if (!axis_is_outer_most) {
GPU_DEBUG_TRACE_DETAIL << id() << ": Update impl with new output padding" << std::endl;
set_shape_change();
@@ -930,10 +929,10 @@ void primitive_inst::fill_shape_info_data(const layout& runtime_layout, const la
GPU_DEBUG_TRACE_DETAIL << " shape_info[" << offset << "] = " << shape_with_max_rank[j] << std::endl;
shape_info_ptr[offset++] = static_cast<int32_t>(shape_with_max_rank[j]);
}
- auto dynamic_pad = node_layout.data_padding.get_dynamic_pad_dims().sizes(shape_info_fmt);
+ const auto& dynamic_pad = node_layout.data_padding._dynamic_dims_mask;
const auto& data_padding = runtime_layout.data_padding;
- auto lower_pads = data_padding.lower_size().sizes(shape_info_fmt);
- auto upper_pads = data_padding.upper_size().sizes(shape_info_fmt);
+ const auto& lower_pads = data_padding._lower_size;
+ const auto& upper_pads = data_padding._upper_size;
for (size_t j = 0; j < shape_with_max_rank.size(); ++j) {
if (dynamic_pad[j] == 1) {
GPU_DEBUG_TRACE_DETAIL << " shape_info[" << offset << "] = " << lower_pads[j]
@@ -1003,10 +1002,10 @@ bool primitive_inst::update_impl(bool use_async_compilation) {
}
for (auto& i : updated_params.input_layouts) {
- i.data_padding.set_dynamic_pad(tensor(0));
+ i.data_padding._dynamic_dims_mask = padding::EMPTY_MASK;
}
for (auto& o : updated_params.output_layouts) {
- o.data_padding.set_dynamic_pad(tensor(0));
+ o.data_padding._dynamic_dims_mask = padding::EMPTY_MASK;
}
const auto is_current_impl_dynamic = _impl && _impl->is_dynamic();
@@ -1096,7 +1095,7 @@ void primitive_inst::update_paddings() {
while (inst) {
reset_pad(*inst->_impl_params, inst->_node);
auto& users = inst->_node->get_users();
- if (users.size() == 1 && users.front()->get_output_layout(0).data_padding.get_dynamic_pad_dims() != tensor(0)) {
+ if (users.size() == 1 && users.front()->get_output_layout(0).data_padding.is_dynamic()) {
inst = inst->get_user_insts().front();
} else {
inst = nullptr;
@@ -1106,7 +1105,7 @@ void primitive_inst::update_paddings() {
return;
}
- if (_node->is_type<gather>() && _impl_params->output_layouts[0].data_padding.get_dynamic_pad_dims() != tensor(0)) {
+ if (_node->is_type<gather>() && _impl_params->output_layouts[0].data_padding.is_dynamic()) {
if (can_be_optimized())
_impl_params->output_layouts[0] = _impl_params->input_layouts[0];
else
@@ -1115,7 +1114,7 @@ void primitive_inst::update_paddings() {
}
// Reset paddings used in the previous iteration for crop before executing do_runtime_in_place_crop
for (auto u : get_user_insts()) {
- if (u->get_node().is_type<crop>() && u->_impl_params->output_layouts[0].data_padding.get_dynamic_pad_dims() != tensor(0)) {
+ if (u->get_node().is_type<crop>() && u->_impl_params->output_layouts[0].data_padding.is_dynamic()) {
if (u->get_node().can_be_optimized()) {
reset_pad(*u->_impl_params, u->_node);
}
@@ -1197,7 +1196,6 @@ void primitive_inst::do_runtime_in_place_kv_cache() {
auto& past_layout = _impl_params->input_layouts[0];
auto& new_layout = _impl_params->input_layouts[1];
auto& present_layout = _impl_params->output_layouts[0];
- const auto& sequence_axis = desc->concat_axis;
const auto& gather_axis = desc->gather_axis;
const auto prev_batch_size = static_cast<size_t>(past_layout.get_shape()[gather_axis]);
const auto beam_size = static_cast<size_t>(present_layout.get_shape()[gather_axis]);
@@ -1207,24 +1205,24 @@ void primitive_inst::do_runtime_in_place_kv_cache() {
return;
}
- auto sequence_axis_legacy = kv_cache_inst::get_sequence_axis_legacy(sequence_axis, past_layout.get_partial_shape().size());
- if (present_layout.data_padding.get_dynamic_pad_dims().sizes()[sequence_axis_legacy] != 1)
+ auto sequence_axis = kv_cache_inst::get_sequence_axis(desc->concat_axis, past_layout.get_partial_shape().size());
+ if (present_layout.data_padding._dynamic_dims_mask[sequence_axis] != 1)
return;
GPU_DEBUG_TRACE_DETAIL << "[do runtime kv_cache opt] " << id() << " initial present_layout : " << present_layout.to_string() << std::endl;
GPU_DEBUG_TRACE_DETAIL << "[do runtime kv_cache opt] " << id() << " initial past_layout : " << past_layout.to_string() << std::endl;
- auto max_pad = kv_cache_inst::get_max_pad(past_layout, _deps[0].first->_max_output_layout_count[0], sequence_axis_legacy, "past_layout");
+ auto max_pad = kv_cache_inst::get_max_pad(past_layout, _deps[0].first->_max_output_layout_count[0], sequence_axis, "past_layout");
const auto new_seq_len = static_cast<int64_t>(new_layout.get_shape()[sequence_axis]);
// In chatbot scenario, when chat history must be stored in kvcache, new_seq_len may not be 1 even if max_pad is greater than 0
if (max_pad - new_seq_len >= 0) {
- kv_cache_inst::update_pad(present_layout, max_pad - new_seq_len, sequence_axis_legacy);
+ kv_cache_inst::update_pad(present_layout, max_pad - new_seq_len, sequence_axis);
GPU_DEBUG_TRACE_DETAIL << "[do runtime_in_place_kv_cache] " << id() << " Updated present_layout's pad : " << present_layout.to_string() << std::endl;
auto& variable = get_network().get_variable(desc->variable_info.variable_id);
variable.set_layout(present_layout);
GPU_DEBUG_TRACE_DETAIL << "[do_runtime_in_place_kv_cache] " << id() << "Updated variable with present_layout"
<< variable.get_layout().to_string() << " is_set = " << variable.is_set() << std::endl;
- if (past_layout.data_padding.upper_size().sizes()[sequence_axis_legacy] > 0 && variable.is_set()) {
- kv_cache_inst::update_pad(past_layout, max_pad, sequence_axis_legacy);
+ if (past_layout.data_padding._upper_size[sequence_axis] > 0 && variable.is_set()) {
+ kv_cache_inst::update_pad(past_layout, max_pad, sequence_axis);
_impl_params->_can_be_optimized = true;
GPU_DEBUG_TRACE_DETAIL << "[do_runtime_in_place_kv_cache] " << id() << " Updated past layout's pad : " << past_layout.to_string() << std::endl;
}
@@ -1285,7 +1283,7 @@ void primitive_inst::do_runtime_skip_gather() {
for (int64_t i = 0; i < static_cast<int32_t>(idx_shape[0]); ++i) {
if (idx_data[i] != i) {
GPU_DEBUG_TRACE_DETAIL << "--- Cannot optimize because idx_data [" << i << "] (" << idx_data[i] << ") != " << i << std::endl;
- if (_impl_params->output_layouts[0].data_padding.get_dynamic_pad_dims() != tensor(0))
+ if (_impl_params->output_layouts[0].data_padding.is_dynamic())
_impl_params->output_layouts[0].data_padding = padding();
set_can_be_optimized(false);
return;
diff --git a/src/plugins/intel_gpu/src/graph/program_node.cpp b/src/plugins/intel_gpu/src/graph/program_node.cpp
index 09c35ce474a..3c21800c66d 100644
--- a/src/plugins/intel_gpu/src/graph/program_node.cpp
+++ b/src/plugins/intel_gpu/src/graph/program_node.cpp
@@ -38,7 +38,7 @@ static size_t get_shape_data_size(const layout& l) {
return 0;
size_t size = layout::max_rank(); // all dimenstions are stored
- auto dynamic_pad = l.data_padding.get_dynamic_pad_dims().sizes(format::get_default_format(layout::max_rank()));
+ const auto& dynamic_pad = l.data_padding._dynamic_dims_mask;
for (size_t j = 0; j < layout::max_rank(); ++j) {
if (dynamic_pad[j] == 1) {
size += 2; // lower + upper
@@ -608,10 +608,13 @@ bool program_node::is_padding_supported(int axis, int padding) const {
}
bool program_node::is_padded_spatial(size_t idx) const {
- auto lower_size = get_output_layout(idx).data_padding.lower_size();
- auto upper_size = get_output_layout(idx).data_padding.upper_size();
- return std::any_of(lower_size.spatial.begin(), lower_size.spatial.end(), [](const tensor::value_type& el) { return el != 0; }) ||
- std::any_of(upper_size.spatial.begin(), upper_size.spatial.end(), [](const tensor::value_type& el) { return el != 0; });
+ auto& layout = get_output_layout(idx);
+ const auto& lower_size = layout.data_padding._lower_size;
+ const auto& upper_size = layout.data_padding._upper_size;
+ return std::any_of(std::begin(lower_size) + 2, std::begin(lower_size) + layout.get_spatial_rank() - 1,
+ [](const tensor::value_type& el) { return el != 0; }) ||
+ std::any_of(std::begin(upper_size) + 2, std::begin(upper_size) + layout.get_spatial_rank() - 1,
+ [](const tensor::value_type& el) { return el != 0; });
}
void program_node::set_selected_impl(std::unique_ptr<primitive_impl> impl) {
diff --git a/src/plugins/intel_gpu/src/graph/resample.cpp b/src/plugins/intel_gpu/src/graph/resample.cpp
index 7f253265334..29d2fec685b 100644
--- a/src/plugins/intel_gpu/src/graph/resample.cpp
+++ b/src/plugins/intel_gpu/src/graph/resample.cpp
@@ -203,8 +203,10 @@ std::string resample_inst::to_string(resample_node const& node) {
resample_info.add("nearest_mode:", "simple");
resample_info.add("output_size", desc->output_size);
- resample_info.add("output padding lower size", desc->output_paddings[0].lower_size());
- resample_info.add("output padding upper size", desc->output_paddings[0].upper_size());
+ resample_info.add("output padding lower size", std::vector<tensor::value_type>(desc->output_paddings[0]._lower_size.begin(),
+ desc->output_paddings[0]._lower_size.end()));
+ resample_info.add("output padding upper size", std::vector<tensor::value_type>(desc->output_paddings[0]._upper_size.begin(),
+ desc->output_paddings[0]._upper_size.end()));
node_info->add("resample_info", resample_info);
node_info->dump(primitive_description);
diff --git a/src/plugins/intel_gpu/src/graph/reshape.cpp b/src/plugins/intel_gpu/src/graph/reshape.cpp
index a4bf3878535..0830dc3e5b9 100644
--- a/src/plugins/intel_gpu/src/graph/reshape.cpp
+++ b/src/plugins/intel_gpu/src/graph/reshape.cpp
@@ -23,7 +23,7 @@ padding propagate_padding(const layout& in_layout, const ov::PartialShape& out_s
return padding();
auto in_pad = in_layout.data_padding;
- if (in_pad.get_dynamic_pad_dims() == tensor(0)) {
+ if (!in_pad.is_dynamic()) {
return padding();
}
@@ -38,9 +38,9 @@ padding propagate_padding(const layout& in_layout, const ov::PartialShape& out_s
auto default_format = format::get_default_format(rank);
- auto pad_lower = in_pad.lower_size().sizes(default_format);
- auto pad_upper = in_pad.upper_size().sizes(default_format);
- auto pad_mask = in_pad.get_dynamic_pad_dims().sizes(default_format);
+ auto pad_lower = layout::format_sizes(in_pad._lower_size, default_format);
+ auto pad_upper = layout::format_sizes(in_pad._upper_size, default_format);
+ auto pad_mask = layout::format_sizes(in_pad._dynamic_dims_mask, default_format);
std::vector<int32_t> update_pad_lower;
std::vector<int32_t> update_pad_upper;
@@ -97,14 +97,13 @@ padding propagate_padding(const layout& in_layout, const ov::PartialShape& out_s
}
}
- auto convert_pad = [](const std::vector<int32_t> pad) {
- return tensor(format::get_default_format(pad.size()), pad, 0);
- };
-
- return padding(convert_pad(update_pad_lower).sizes(),
- convert_pad(update_pad_upper).sizes(),
- 0.0f,
- convert_pad(update_pad_mask));
+ // TODO: rework this method
+ padding::DynamicDimsMask ret_update_pad_mask;
+ OPENVINO_ASSERT(update_pad_mask.size() <= ret_update_pad_mask.size(), "invalid update_pad_mask.size().");
+ for (size_t i = 0; i < update_pad_mask.size(); i++) {
+ ret_update_pad_mask[i] = update_pad_mask[i];
+ }
+ return padding(update_pad_lower, update_pad_upper, ret_update_pad_mask);
}
layout reshape_inst::calc_output_layout(reshape_node const& node, kernel_impl_params const& impl_param) {
diff --git a/src/plugins/intel_gpu/src/plugin/variable_state.cpp b/src/plugins/intel_gpu/src/plugin/variable_state.cpp
index 4d8cdae95e4..b24ddbd314a 100644
--- a/src/plugins/intel_gpu/src/plugin/variable_state.cpp
+++ b/src/plugins/intel_gpu/src/plugin/variable_state.cpp
@@ -58,10 +58,11 @@ void VariableState::set_layout(const cldnn::layout& new_layout) {
void VariableState::set_state(const ov::SoPtr<ov::ITensor>& state) {
auto src_shape = state->get_shape();
size_t src_rank = src_shape.size();
+ cldnn::padding::DynamicDimsMask dynamic_pad_dims;
+ for (size_t i = 0; i < src_rank; i++) dynamic_pad_dims[i] = m_layout.data_padding._dynamic_dims_mask[i];
m_layout.data_padding = cldnn::padding(std::vector<int32_t>(src_rank, 0),
std::vector<int32_t>(src_rank, 0),
- 0,
- m_layout.data_padding.get_dynamic_pad_dims());
+ dynamic_pad_dims);
auto src_stride = state->get_strides();
for (size_t i = 0; i < src_rank; ++i) {
src_stride[i] = src_stride[i] / (state->get_element_type().bitwidth()/8);
@@ -71,8 +72,8 @@ void VariableState::set_state(const ov::SoPtr<ov::ITensor>& state) {
// check whether the src tensor is padded
std::vector<size_t> src_stride_no_pad(src_rank, 1);
- std::vector<int32_t> upper_pad(std::max<size_t>(src_rank, 4), 0);
- std::vector<int32_t> lower_pad(std::max<size_t>(src_rank, 4), 0);
+ std::vector<int32_t> upper_pad(src_rank, 0);
+ std::vector<int32_t> lower_pad(src_rank, 0);
for (int32_t i = static_cast<int32_t>(src_stride.size()) - 1; i >= 0; --i) {
if (i <= static_cast<int32_t>(src_stride.size()) - 2)
src_stride_no_pad[i] = src_stride_no_pad[i + 1] * src_shape[i + 1];
@@ -80,13 +81,8 @@ void VariableState::set_state(const ov::SoPtr<ov::ITensor>& state) {
OPENVINO_ASSERT(src_stride[i] > src_stride_no_pad[i]);
size_t padded_size = src_stride[i] / src_stride[i + 1];
size_t non_padded_size = src_stride_no_pad[i] / src_stride_no_pad[i + 1];
- int32_t pad_dim_legacy = i + 1;
- if (pad_dim_legacy >= 2) {
- int32_t spatial_axis = pad_dim_legacy - 2;
- int32_t spatial_size = std::max<int32_t>(static_cast<int32_t>(src_rank), 4) - 2;
- pad_dim_legacy = spatial_size - spatial_axis - 1 + 2;
- }
- upper_pad[pad_dim_legacy] = static_cast<int32_t>(padded_size) - static_cast<int32_t>(non_padded_size);
+ int32_t pad_dim = i + 1;
+ upper_pad[pad_dim] = static_cast<int32_t>(padded_size) - static_cast<int32_t>(non_padded_size);
}
}
cldnn::padding src_padd = cldnn::padding(lower_pad, upper_pad, 0.f);
@@ -107,7 +103,7 @@ void VariableState::update_device_buffer() {
if (actual_size < m_layout.bytes_count()) {
const auto alloc_type = m_context->get_engine().use_unified_shared_memory() ? cldnn::allocation_type::usm_device : cldnn::allocation_type::cl_mem;
- const auto current_buf_size = m_layout.get_buffer_size().sizes();
+ const auto current_buf_size = m_layout.get_padded_dims();
ov::Shape current_shape(current_buf_size.begin(), current_buf_size.end());
const auto alloc_shape = predict_shape(m_name, cldnn::layout(current_shape, m_layout.data_type, m_layout.format), *m_shape_predictor);
const auto alloc_layout = cldnn::layout(alloc_shape, m_layout.data_type, m_layout.format);
diff --git a/src/plugins/intel_gpu/src/runtime/format.cpp b/src/plugins/intel_gpu/src/runtime/format.cpp
index a4a8ad36681..7aca55d3f0b 100644
--- a/src/plugins/intel_gpu/src/runtime/format.cpp
+++ b/src/plugins/intel_gpu/src/runtime/format.cpp
@@ -21,151 +21,151 @@ static const std::map<format::type, format_traits> format_traits_map {
// Order - dims changing order from rare to often
// Inner order - dims order for internal storage in _sizes array
// Block sizes - vector of pairs of dimension number (by inner order) and block size ordered from rare to often
- // Format B F S G Dims order Order Inner order Block sizes
- FMT_TRAITS(yxfb, 1, 1, 2, 0, {2, 3, 1, 0}, "yxfb", "bfxy", {}),
- FMT_TRAITS(byxf, 1, 1, 2, 0, {0, 2, 3, 1}, "byxf", "bfxy", {}),
- FMT_TRAITS(bfyx, 1, 1, 2, 0, {0, 1, 2, 3}, "bfyx", "bfxy", {}),
- FMT_TRAITS(bfxy, 1, 1, 2, 0, {0, 1, 3, 2}, "bfxy", "bfxy", {}),
- FMT_TRAITS(fbyx, 1, 1, 2, 0, {1, 0, 2, 3}, "fbyx", "bfxy", {}),
- FMT_TRAITS(fyxb, 1, 1, 2, 0, {1, 2, 3, 0}, "fyxb", "bfxy", {}),
- FMT_TRAITS(fybx, 1, 1, 2, 0, {1, 2, 0, 3}, "fybx", "bfxy", {}),
- FMT_TRAITS(xbfy, 1, 1, 2, 0, {3, 0, 1, 2}, "xbfy", "bfxy", {}),
- FMT_TRAITS(ybfx, 1, 1, 2, 0, {2, 0, 1, 3}, "ybfx", "bfxy", {}),
- FMT_TRAITS(byfx, 1, 1, 2, 0, {0, 2, 1, 3}, "byfx", "bfxy", {}),
- FMT_TRAITS(bxfy, 1, 1, 2, 0, {0, 3, 1, 2}, "bxfy", "bfxy", {}),
- FMT_TRAITS(b_fs_yx_fsv2, 1, 1, 2, 0, {0, 1, 2, 3}, "bfyx", "bfxy", {{1, 2}}),
- FMT_TRAITS(b_fs_yx_fsv4, 1, 1, 2, 0, {0, 1, 2, 3}, "bfyx", "bfxy", {{1, 4}}),
- FMT_TRAITS(b_fs_yx_fsv8, 1, 1, 2, 0, {0, 1, 2, 3}, "bfyx", "bfxy", {{1, 8}}),
- FMT_TRAITS(b_fs_yx_fsv16, 1, 1, 2, 0, {0, 1, 2, 3}, "bfyx", "bfxy", {{1, 16}}),
- FMT_TRAITS(b_fs_yx_fsv32, 1, 1, 2, 0, {0, 1, 2, 3}, "bfyx", "bfxy", {{1, 32}}),
- FMT_TRAITS(b_fs_zyx_fsv2, 1, 1, 3, 0, {0, 1, 2, 3, 4}, "bfzyx", "bfxyz", {{1, 2}}),
- FMT_TRAITS(b_fs_zyx_fsv4, 1, 1, 3, 0, {0, 1, 2, 3, 4}, "bfzyx", "bfxyz", {{1, 4}}),
- FMT_TRAITS(b_fs_zyx_fsv8, 1, 1, 3, 0, {0, 1, 2, 3, 4}, "bfzyx", "bfxyz", {{1, 8}}),
- FMT_TRAITS(b_fs_zyx_fsv32, 1, 1, 3, 0, {0, 1, 2, 3, 4}, "bfzyx", "bfxyz", {{1, 32}}),
- FMT_TRAITS(bs_fs_fsv8_bsv8, 1, 1, 0, 0, {0, 1}, "bf", "bf", {{0, 8}, {1, 8}}),
- FMT_TRAITS(bs_fs_fsv8_bsv16, 1, 1, 0, 0, {0, 1}, "bf", "bf", {{0, 16}, {1, 8}}),
- FMT_TRAITS(bs_f_bsv16, 1, 1, 0, 0, {0, 1}, "bf", "bf", {{0, 16}}),
- FMT_TRAITS(winograd_2x3_s1_data, 1, 1, 2, 0, {0, 2, 3, 1}, "bxyf", "bfxy", {}),
- FMT_TRAITS(bzyxf, 1, 1, 3, 0, {0, 2, 3, 4, 1}, "bzyxf", "bfxyz", {}),
- FMT_TRAITS(bfzyx, 1, 1, 3, 0, {0, 1, 2, 3, 4}, "bfzyx", "bfxyz", {}),
- FMT_TRAITS(bfwzyx, 1, 1, 4, 0, {0, 1, 2, 3, 4, 5}, "bfwzyx", "bfxyzw", {}),
- FMT_TRAITS(bfuwzyx, 1, 1, 5, 0, {0, 1, 2, 3, 4, 5, 6}, "bfuwzyx", "bfxyzwu", {}),
- FMT_TRAITS(bfvuwzyx, 1, 1, 6, 0, {0, 1, 2, 3, 4, 5, 6, 7}, "bfvuwzyx", "bfxyzwuv", {}),
- FMT_TRAITS(fs_b_yx_fsv32, 1, 1, 2, 0, {1, 0, 2, 3}, "fbyx", "bfxy", {{1, 32}}),
- FMT_TRAITS(b_fs_zyx_fsv16, 1, 1, 3, 0, {0, 1, 2, 3, 4}, "bfzyx", "bfxyz", {{1, 16}}),
- FMT_TRAITS(bs_fs_zyx_bsv16_fsv32, 1, 1, 3, 0, {0, 1, 2, 3, 4}, "bfzyx", "bfxyz", {{0, 16 }, {1, 32}}),
- FMT_TRAITS(bs_fs_zyx_bsv16_fsv16, 1, 1, 3, 0, {0, 1, 2, 3, 4}, "bfzyx", "bfxyz", {{0, 16 }, {1, 16}}),
- FMT_TRAITS(bs_fs_yx_bsv16_fsv16, 1, 1, 2, 0, {0, 1, 2, 3}, "bfyx", "bfxy", {{0, 16 }, {1, 16}}),
- FMT_TRAITS(bs_fs_yx_bsv16_fsv32, 1, 1, 2, 0, {0, 1, 2, 3}, "bfyx", "bfxy", {{0, 16 }, {1, 32}}),
- FMT_TRAITS(bs_fs_yx_bsv4_fsv4, 1, 1, 2, 0, {0, 1, 2, 3}, "bfyx", "bfxy", {{0, 4 }, {1, 4}}),
- FMT_TRAITS(bs_fs_yx_bsv8_fsv4, 1, 1, 2, 0, {0, 1, 2, 3}, "bfyx", "bfxy", {{0, 8 }, {1, 4}}),
- FMT_TRAITS(bs_fs_zyx_bsv8_fsv4, 1, 1, 3, 0, {0, 1, 2, 3, 4}, "bfzyx", "bfxyz", {{0, 8 }, {1, 4}}),
- FMT_TRAITS(bs_fs_yx_bsv16_fsv8, 1, 1, 2, 0, {0, 1, 2, 3}, "bfyx", "bfxy", {{0, 16 }, {1, 8}}),
- FMT_TRAITS(bs_fs_zyx_bsv16_fsv8, 1, 1, 3, 0, {0, 1, 2, 3, 4}, "bfzyx", "bfxyz", {{0, 16 }, {1, 8}}),
- FMT_TRAITS(bs_fs_yx_bsv16_fsv4, 1, 1, 2, 0, {0, 1, 2, 3}, "bfyx", "bfxy", {{0, 16 }, {1, 4}}),
- FMT_TRAITS(bs_fs_zyx_bsv16_fsv4, 1, 1, 3, 0, {0, 1, 2, 3, 4}, "bfzyx", "bfxyz", {{0, 16 }, {1, 4}}),
- FMT_TRAITS(bs_fs_yx_bsv16_fsv2, 1, 1, 2, 0, {0, 1, 2, 3}, "bfyx", "bfxy", {{0, 16 }, {1, 2}}),
- FMT_TRAITS(bs_fs_zyx_bsv16_fsv2, 1, 1, 3, 0, {0, 1, 2, 3, 4}, "bfzyx", "bfxyz", {{0, 16 }, {1, 2}}),
- FMT_TRAITS(bs_fs_yx_bsv8_fsv2, 1, 1, 2, 0, {0, 1, 2, 3}, "bfyx", "bfxy", {{0, 8 }, {1, 2}}),
- FMT_TRAITS(bs_fs_zyx_bsv8_fsv2, 1, 1, 3, 0, {0, 1, 2, 3, 4}, "bfzyx", "bfxyz", {{0, 8 }, {1, 2}}),
- FMT_TRAITS(bs_fs_yx_bsv4_fsv2, 1, 1, 2, 0, {0, 1, 2, 3}, "bfyx", "bfxy", {{0, 4 }, {1, 2}}),
- FMT_TRAITS(bs_fs_zyx_bsv4_fsv4, 1, 1, 3, 0, {0, 1, 2, 3, 4}, "bfzyx", "bfxyz", {{0, 4 }, {1, 4}}),
- FMT_TRAITS(bs_fs_zyx_bsv4_fsv2, 1, 1, 3, 0, {0, 1, 2, 3, 4}, "bfzyx", "bfxyz", {{0, 4 }, {1, 2}}),
- FMT_TRAITS(bs_fs_zyx_bsv32_fsv32, 1, 1, 3, 0, {0, 1, 2, 3, 4}, "bfzyx", "bfxyz", {{0, 32 }, {1, 32}}),
- FMT_TRAITS(bs_fs_zyx_bsv32_fsv16, 1, 1, 3, 0, {0, 1, 2, 3, 4}, "bfzyx", "bfxyz", {{0, 32 }, {1, 16}}),
- FMT_TRAITS(bs_fs_yx_bsv32_fsv32, 1, 1, 2, 0, {0, 1, 2, 3}, "bfyx", "bfxy", {{0, 32 }, {1, 32}}),
- FMT_TRAITS(bs_fs_yx_bsv32_fsv16, 1, 1, 2, 0, {0, 1, 2, 3}, "bfyx", "bfxy", {{0, 32 }, {1, 16}}),
- FMT_TRAITS(nv12, 1, 1, 2, 0, {0, 1, 2, 3}, "bfyx", "bfxy", {}),
- FMT_TRAITS(image_2d_rgba, 1, 1, 2, 0, {0, 1, 2, 3}, "bfyx", "bfxy", {}),
-
- FMT_TRAITS(oiyx, 1, 1, 2, 0, {0, 1, 2, 3}, "oiyx", "oixy", {}),
- FMT_TRAITS(ioyx, 1, 1, 2, 0, {1, 0, 2, 3}, "ioyx", "oixy", {}),
- FMT_TRAITS(iyxo, 1, 1, 2, 0, {1, 2, 3, 0}, "iyxo", "oixy", {}),
- FMT_TRAITS(oyxi, 1, 1, 2, 0, {0, 2, 3, 1}, "oyxi", "oixy", {}),
- FMT_TRAITS(oyix, 1, 1, 2, 0, {0, 2, 1, 3}, "oyix", "oixy", {}),
- FMT_TRAITS(oxiy, 1, 1, 2, 0, {0, 3, 1, 2}, "oxiy", "oixy", {}),
- FMT_TRAITS(yxio, 1, 1, 2, 0, {2, 3, 1, 0}, "yxio", "oixy", {}),
- FMT_TRAITS(oizyx, 1, 1, 3, 0, {0, 1, 2, 3, 4}, "oizyx", "oixyz", {}),
- FMT_TRAITS(iozyx, 1, 1, 3, 0, {1, 0, 2, 3, 4}, "iozyx", "oixyz", {}),
- FMT_TRAITS(os_is_yx_isv16_osv16, 1, 1, 2, 0, {0, 1, 2, 3}, "oiyx", "oixy", {{1, 16}, {0, 16}}),
- FMT_TRAITS(o_is_yx_isv4, 1, 1, 2, 0, {0, 1, 2, 3}, "oiyx", "oixy", {{1, 4}}),
- FMT_TRAITS(o_is_yx_isv16, 1, 1, 2, 0, {0, 1, 2, 3}, "oiyx", "oixy", {{1, 16}}),
- FMT_TRAITS(os_iyx_osv16, 1, 1, 2, 0, {0, 1, 2, 3}, "oiyx", "oixy", {{0, 16}}),
- FMT_TRAITS(os_iyx_osv32, 1, 1, 2, 0, {0, 1, 2, 3}, "oiyx", "oixy", {{0, 32}}),
- FMT_TRAITS(os_iyx_osv64, 1, 1, 2, 0, {0, 1, 2, 3}, "oiyx", "oixy", {{0, 64}}),
- FMT_TRAITS(winograd_2x3_s1_weights, 1, 1, 2, 0, {0, 1, 2, 3}, "oiyx", "oixy", {}),
- FMT_TRAITS(winograd_2x3_s1_fused_weights, 1, 1, 2, 0, {3, 2, 1, 0}, "xyio", "oixy", {}),
- FMT_TRAITS(winograd_6x3_s1_fused_weights, 1, 1, 2, 0, {3, 2, 1, 0}, "xyio", "oixy", {}),
- FMT_TRAITS(image_2d_weights_winograd_6x3_s1_fbxyb, 1, 1, 2, 0, {1, 0, 3, 2}, "ioxy", "oixy", {}),
- FMT_TRAITS(image_2d_weights_winograd_6x3_s1_xfbyb, 1, 1, 2, 0, {3, 1, 0, 2}, "xioy", "oixy", {}),
- FMT_TRAITS(image_2d_weights_c4_fyx_b, 1, 1, 2, 0, {0, 1, 2, 3}, "oiyx", "oixy", {}),
- FMT_TRAITS(image_2d_weights_c1_b_fyx, 1, 1, 2, 0, {0, 1, 2, 3}, "oiyx", "oixy", {}),
- FMT_TRAITS(os_is_yx_isa8_osv16_isv4, 1, 1, 2, 0, {0, 1, 2, 3}, "oiyx", "oixy", {{1, 8}, {0, 16}, {1, 4}}),
- FMT_TRAITS(os_is_yx_osa4_isa8_osv8_isv4, 1, 1, 2, 0, {0, 1, 2, 3}, "oiyx", "oixy", {{0, 4}, {1, 8}, {0, 8}, {1, 4}}),
- FMT_TRAITS(os_is_zyx_osa4_isa8_osv8_isv4, 1, 1, 3, 0, {0, 1, 2, 3, 4}, "oizyx", "oixyz", {{0, 4}, {1, 8}, {0, 8}, {1, 4}}),
- FMT_TRAITS(os_is_zyx_isa8_osv8_isv4, 1, 1, 3, 0, {0, 1, 2, 3, 4}, "oizyx", "oixyz", {{1, 8}, {0, 8}, {1, 4}}),
- FMT_TRAITS(os_is_zyx_isa8_osv16_isv4, 1, 1, 3, 0, {0, 1, 2, 3, 4}, "oizyx", "oixyz", {{1, 8}, {0, 16}, {1, 4}}),
- FMT_TRAITS(os_is_yx_osa4_isa8_osv8_isv4_swizzled_by_4, 1, 1, 2, 0, {0, 1, 2, 3}, "oiyx", "oixy", {{0, 32}, {1, 32}}),
- FMT_TRAITS(os_is_zyx_osa4_isa8_osv8_isv4_swizzled_by_4, 1, 1, 3, 0, {0, 1, 2, 3, 4}, "oizyx", "oixyz", {{0, 32}, {1, 32}}),
- FMT_TRAITS(os_is_yx_osv16_isv4, 1, 1, 2, 0, {0, 1, 2, 3}, "oiyx", "oixy", {{0, 16}, {1, 4}}),
- FMT_TRAITS(os_is_yx_osv8_isv4, 1, 1, 2, 0, {0, 1, 2, 3}, "oiyx", "oixy", {{0, 8}, {1, 4}}),
- FMT_TRAITS(os_is_zyx_osv16_isv16, 1, 1, 3, 0, {0, 1, 2, 3, 4}, "oizyx", "oixyz", {{0, 16}, {1, 16}}),
- FMT_TRAITS(os_is_yx_osv32_isv4_swizzled_by_2, 1, 1, 2, 0, {0, 1, 2, 3}, "oiyx", "oixy", {{0, 32}, {1, 4}}),
- FMT_TRAITS(os_is_yx_osv32_isv4, 1, 1, 2, 0, {0, 1, 2, 3}, "oiyx", "oixy", {{0, 32}, {1, 4}}),
- FMT_TRAITS(os_is_zyx_osv32_isv4, 1, 1, 3, 0, {0, 1, 2, 3, 4}, "oizyx", "oixyz", {{0, 32}, {1, 4}}),
- FMT_TRAITS(os_is_zyx_isv16_osv16, 1, 1, 3, 0, {0, 1, 2, 3, 4}, "oizyx", "oixyz", {{1, 16}, {0, 16}}),
- FMT_TRAITS(is_os_zyx_isv16_osv16, 1, 1, 3, 0, {1, 0, 2, 3, 4}, "iozyx", "oixyz", {{1, 16}, {0, 16}}),
- FMT_TRAITS(is_os_yx_isv16_osv16, 1, 1, 2, 0, {1, 0, 2, 3}, "ioyx", "oixy", {{1, 16}, {0, 16}}),
- FMT_TRAITS(os_is_zyx_isa8_osv8_isv4, 1, 1, 3, 0, {0, 1, 2, 3, 4}, "oizyx", "oixyz", {{1, 8}, {0, 8}, {1, 4}}),
- FMT_TRAITS(os_is_zyx_isa8_osv16_isv4, 1, 1, 3, 0, {0, 1, 2, 3, 4}, "oizyx", "oixyz", {{1, 8}, {0, 16}, {1, 4}}),
- FMT_TRAITS(os_is_yx_isa8_osv8_isv4, 1, 1, 2, 0, {0, 1, 2, 3}, "oiyx", "oixy", {{1, 8}, {0, 8}, {1, 4}}),
- FMT_TRAITS(os_is_zyx_isv8_osv16_isv2, 1, 1, 3, 0, {0, 1, 2, 3, 4}, "oizyx", "oixyz", {{1, 8}, {0, 16}, {1, 2}}),
- FMT_TRAITS(os_zyxi_osv16, 1, 1, 3, 0, {0, 2, 3, 4, 1}, "ozyxi", "oixyz", {{0, 16}}),
- FMT_TRAITS(os_is_yx_isv8_osv16_isv2, 1, 1, 2, 0, {0, 1, 2, 3}, "oiyx", "oixy", {{1, 8}, {0, 16}, {1, 2}}),
- FMT_TRAITS(os_is_yx_osv16_isv16, 1, 1, 2, 0, {0, 1, 2, 3}, "oiyx", "oixy", {{0, 16}, {1, 16}}),
- FMT_TRAITS(os_is_yx_osv32_isv2, 1, 1, 2, 0, {0, 1, 2, 3}, "oiyx", "oixy", {{0, 32}}),
- FMT_TRAITS(os_is_zyx_osv32_isv16, 1, 1, 3, 0, {0, 1, 2, 3, 4}, "oizyx", "oixyz", {{0, 32}, {1, 16}}),
- FMT_TRAITS(os_is_zyx_osv64_isv16, 1, 1, 3, 0, {0, 1, 2, 3, 4}, "oizyx", "oixyz", {{0, 64}, {1, 16}}),
- FMT_TRAITS(os_iyx_osv8, 1, 1, 2, 0, {0, 1, 2, 3}, "oiyx", "oixy", {{0, 8}}),
- FMT_TRAITS(os_iyx_osv32__ai32, 1, 1, 2, 0, {0, 1, 2, 3}, "oiyx", "oixy", {{0, 32}}),
- FMT_TRAITS(i_yxs_os_yxsv2_osv16, 1, 1, 2, 0, {1, 2, 3, 0}, "iyxo", "oixy", {{0, 16}}),
- FMT_TRAITS(iy_xs_os_xsv2_osv8__ao32, 1, 1, 2, 0, {1, 2, 3, 0}, "iyxo", "oixy", {{2, 2}, {0, 8}}),
- FMT_TRAITS(iy_xs_os_xsv2_osv16__ao32, 1, 1, 2, 0, {1, 2, 3, 0}, "iyxo", "oixy", {{2, 2}, {0, 16}}),
- FMT_TRAITS(os_i_osv16, 1, 1, 0, 0, {0, 1}, "oi", "oi", {{0, 16}}),
- FMT_TRAITS(os_i_osv16__ai8, 1, 1, 0, 0, {0, 1}, "oi", "oi", {{1, 8}, {0, 16}}),
- FMT_TRAITS(os_i_osv8__ai8, 1, 1, 0, 0, {0, 1}, "oi", "oi", {{1, 8}, {0, 8}}),
-
- FMT_TRAITS(goiyx, 1, 1, 2, 1, {0, 1, 2, 3, 4}, "goiyx", "oixy????g", {}),
- FMT_TRAITS(gioyx, 1, 1, 2, 1, {0, 2, 1, 3, 4}, "gioyx", "oixy????g", {}),
- FMT_TRAITS(goizyx, 1, 1, 3, 1, {0, 1, 2, 3, 4, 5}, "goizyx", "oixyz???g", {}),
- FMT_TRAITS(giozyx, 1, 1, 3, 1, {0, 2, 1, 3, 4, 5}, "giozyx", "oixyz???g", {}),
- FMT_TRAITS(g_os_iyx_osv8, 1, 1, 2, 1, {0, 1, 2, 3, 4}, "goiyx", "oixy????g", {{0, 8}}),
- FMT_TRAITS(g_os_iyx_osv16, 1, 1, 2, 1, {0, 1, 2, 3, 4}, "goiyx", "oixy????g", {{0, 16}}),
- FMT_TRAITS(g_os_iyx_osv32, 1, 1, 2, 1, {0, 1, 2, 3, 4}, "goiyx", "oixy????g", {{0, 32}}),
- FMT_TRAITS(gs_oiyx_gsv16, 1, 1, 2, 1, {0, 1, 2, 3, 4}, "goiyx", "oixy????g", {{8, 16}}),
- FMT_TRAITS(gs_oizyx_gsv16, 1, 1, 3, 1, {0, 1, 2, 3, 4, 5}, "goizyx", "oixyz???g", {{8, 16}}),
- FMT_TRAITS(gs_oiyx_gsv32, 1, 1, 2, 1, {0, 1, 2, 3, 4}, "goiyx", "oixy????g", {{8, 32}}),
- FMT_TRAITS(gyxio, 1, 1, 2, 1, {0, 3, 4, 2, 1}, "gyxio", "oixy????g", {}),
- FMT_TRAITS(g_is_os_zyx_isv16_osv16, 1, 1, 3, 1, {0, 2, 1, 3, 4, 5}, "giozyx", "oixyz???g", {{1, 16}, {0, 16}}),
- FMT_TRAITS(g_is_os_yx_isv16_osv16, 1, 1, 2, 1, {0, 2, 1, 3, 4}, "gioyx", "oixy????g", {{1, 16}, {0, 16}}),
- FMT_TRAITS(g_os_is_zyx_isv8_osv16_isv2, 1, 1, 3, 1, {0, 1, 2, 3, 4, 5}, "goizyx", "oixyz???g", {{1, 8}, {0, 16}, {1, 2}}),
- FMT_TRAITS(g_os_is_yx_isv8_osv16_isv2, 1, 1, 2, 1, {0, 1, 2, 3, 4}, "goiyx", "oixy????g", {{1, 8}, {0, 16}, {1, 2}}),
- FMT_TRAITS(g_os_is_zyx_isv16_osv16, 1, 1, 3, 1, {0, 1, 2, 3, 4, 5}, "goizyx", "oixyz???g", {{0, 16}, {1, 16}}),
- FMT_TRAITS(g_os_is_yx_osv16_isv4, 1, 1, 2, 1, {0, 1, 2, 3, 4}, "goiyx", "oixy????g", {{0, 16}, {1, 4}}),
- FMT_TRAITS(g_os_is_zyx_osv16_isv16, 1, 1, 3, 1, {0, 1, 2, 3, 4, 5}, "goizyx", "oixyz???g", {{0, 16}, {1, 16}}),
- FMT_TRAITS(g_os_zyx_is_osv16_isv4, 1, 1, 3, 1, {0, 1, 2, 3, 4, 5}, "gozyxi", "oixyz???g", {{0, 16}, {1, 4}}),
- FMT_TRAITS(g_os_zyx_is_osv16_isv16, 1, 1, 3, 1, {0, 1, 2, 3, 4, 5}, "gozyxi", "oixyz???g", {{0, 16}, {1, 16}}),
- FMT_TRAITS(g_os_zyx_is_osv16_isv32, 1, 1, 3, 1, {0, 1, 2, 3, 4, 5}, "gozyxi", "oixyz???g", {{0, 16}, {1, 32}}),
- FMT_TRAITS(g_os_zyx_is_osv32_isv4, 1, 1, 3, 1, {0, 1, 2, 3, 4, 5}, "gozyxi", "oixyz???g", {{0, 32}, {1, 4}}),
- FMT_TRAITS(g_os_zyx_is_osv32_isv16, 1, 1, 3, 1, {0, 1, 2, 3, 4, 5}, "gozyxi", "oixyz???g", {{0, 32}, {1, 16}}),
- FMT_TRAITS(g_os_zyx_is_osv32_isv32, 1, 1, 3, 1, {0, 1, 2, 3, 4, 5}, "gozyxi", "oixyz???g", {{0, 32}, {1, 32}}),
- FMT_TRAITS(gs_oi_yxs_gsv4_yxsv4, 1, 1, 2, 1, {0, 1, 2, 3, 4}, "goiyx", "oixy????g", {{8, 4}}),
- FMT_TRAITS(gs_oi_yxs_gsv16_yxsv4, 1, 1, 2, 1, {0, 1, 2, 3, 4}, "goiyx", "oixy????g", {{8, 16}}),
- FMT_TRAITS(gs_oi_yxs_gsv32_yxsv4, 1, 1, 2, 1, {0, 1, 2, 3, 4}, "goiyx", "oixy????g", {{8, 32}}),
- FMT_TRAITS(g_os_is_yx_isv16_osv16, 1, 1, 2, 1, {0, 1, 2, 3, 4}, "goiyx", "oixy????g", {{1, 16}, {0, 16}}),
- FMT_TRAITS(gi_yxs_os_yxsv2_osv16, 1, 1, 2, 1, {0, 2, 3, 4, 1}, "giyxo", "oixy????g", {{0, 16}}),
- FMT_TRAITS(giy_xs_os_xsv2_osv8__ao32, 1, 1, 2, 1, {0, 2, 3, 4, 1}, "giyxo", "oixy????g", {{2, 2}, {0, 8}}),
- FMT_TRAITS(giy_xs_os_xsv2_osv16__ao32, 1, 1, 2, 1, {0, 2, 3, 4, 1}, "giyxo", "oixy????g", {{2, 2}, {0, 16}}),
+ // Format B F S G Dims order Order Inner order Block sizes Block Sizes (in logical order)
+ FMT_TRAITS(yxfb, 1, 1, 2, 0, {2, 3, 1, 0}, "yxfb", "bfxy", {}, {}), // NOLINT
+ FMT_TRAITS(byxf, 1, 1, 2, 0, {0, 2, 3, 1}, "byxf", "bfxy", {}, {}), // NOLINT
+ FMT_TRAITS(bfyx, 1, 1, 2, 0, {0, 1, 2, 3}, "bfyx", "bfxy", {}, {}), // NOLINT
+ FMT_TRAITS(bfxy, 1, 1, 2, 0, {0, 1, 3, 2}, "bfxy", "bfxy", {}, {}), // NOLINT
+ FMT_TRAITS(fbyx, 1, 1, 2, 0, {1, 0, 2, 3}, "fbyx", "bfxy", {}, {}), // NOLINT
+ FMT_TRAITS(fyxb, 1, 1, 2, 0, {1, 2, 3, 0}, "fyxb", "bfxy", {}, {}), // NOLINT
+ FMT_TRAITS(fybx, 1, 1, 2, 0, {1, 2, 0, 3}, "fybx", "bfxy", {}, {}), // NOLINT
+ FMT_TRAITS(xbfy, 1, 1, 2, 0, {3, 0, 1, 2}, "xbfy", "bfxy", {}, {}), // NOLINT
+ FMT_TRAITS(ybfx, 1, 1, 2, 0, {2, 0, 1, 3}, "ybfx", "bfxy", {}, {}), // NOLINT
+ FMT_TRAITS(byfx, 1, 1, 2, 0, {0, 2, 1, 3}, "byfx", "bfxy", {}, {}), // NOLINT
+ FMT_TRAITS(bxfy, 1, 1, 2, 0, {0, 3, 1, 2}, "bxfy", "bfxy", {}, {}), // NOLINT
+ FMT_TRAITS(b_fs_yx_fsv2, 1, 1, 2, 0, {0, 1, 2, 3}, "bfyx", "bfxy", {{1, 2}}, {{1, 2}}), // NOLINT
+ FMT_TRAITS(b_fs_yx_fsv4, 1, 1, 2, 0, {0, 1, 2, 3}, "bfyx", "bfxy", {{1, 4}}, {{1, 4}}), // NOLINT
+ FMT_TRAITS(b_fs_yx_fsv8, 1, 1, 2, 0, {0, 1, 2, 3}, "bfyx", "bfxy", {{1, 8}}, {{1, 8}}), // NOLINT
+ FMT_TRAITS(b_fs_yx_fsv16, 1, 1, 2, 0, {0, 1, 2, 3}, "bfyx", "bfxy", {{1, 16}}, {{1, 16}}), // NOLINT
+ FMT_TRAITS(b_fs_yx_fsv32, 1, 1, 2, 0, {0, 1, 2, 3}, "bfyx", "bfxy", {{1, 32}}, {{1, 32}}), // NOLINT
+ FMT_TRAITS(b_fs_zyx_fsv2, 1, 1, 3, 0, {0, 1, 2, 3, 4}, "bfzyx", "bfxyz", {{1, 2}}, {{1, 2}}), // NOLINT
+ FMT_TRAITS(b_fs_zyx_fsv4, 1, 1, 3, 0, {0, 1, 2, 3, 4}, "bfzyx", "bfxyz", {{1, 4}}, {{1, 4}}), // NOLINT
+ FMT_TRAITS(b_fs_zyx_fsv8, 1, 1, 3, 0, {0, 1, 2, 3, 4}, "bfzyx", "bfxyz", {{1, 8}}, {{1, 8}}), // NOLINT
+ FMT_TRAITS(b_fs_zyx_fsv32, 1, 1, 3, 0, {0, 1, 2, 3, 4}, "bfzyx", "bfxyz", {{1, 32}}, {{1, 32}}), // NOLINT
+ FMT_TRAITS(bs_fs_fsv8_bsv8, 1, 1, 0, 0, {0, 1}, "bf", "bf", {{0, 8}, {1, 8}}, {{0, 8}, {1, 8}}), // NOLINT
+ FMT_TRAITS(bs_fs_fsv8_bsv16, 1, 1, 0, 0, {0, 1}, "bf", "bf", {{0, 16}, {1, 8}}, {{0, 16}, {1, 8}}), // NOLINT
+ FMT_TRAITS(bs_f_bsv16, 1, 1, 0, 0, {0, 1}, "bf", "bf", {{0, 16}}, {{0, 16}}), // NOLINT
+ FMT_TRAITS(winograd_2x3_s1_data, 1, 1, 2, 0, {0, 2, 3, 1}, "bxyf", "bfxy", {}, {}), // NOLINT
+ FMT_TRAITS(bzyxf, 1, 1, 3, 0, {0, 2, 3, 4, 1}, "bzyxf", "bfxyz", {}, {}), // NOLINT
+ FMT_TRAITS(bfzyx, 1, 1, 3, 0, {0, 1, 2, 3, 4}, "bfzyx", "bfxyz", {}, {}), // NOLINT
+ FMT_TRAITS(bfwzyx, 1, 1, 4, 0, {0, 1, 2, 3, 4, 5}, "bfwzyx", "bfxyzw", {}, {}), // NOLINT
+ FMT_TRAITS(bfuwzyx, 1, 1, 5, 0, {0, 1, 2, 3, 4, 5, 6}, "bfuwzyx", "bfxyzwu", {}, {}), // NOLINT
+ FMT_TRAITS(bfvuwzyx, 1, 1, 6, 0, {0, 1, 2, 3, 4, 5, 6, 7}, "bfvuwzyx", "bfxyzwuv", {}, {}), // NOLINT
+ FMT_TRAITS(fs_b_yx_fsv32, 1, 1, 2, 0, {1, 0, 2, 3}, "fbyx", "bfxy", {{1, 32}}, {{1, 32}}), // NOLINT
+ FMT_TRAITS(b_fs_zyx_fsv16, 1, 1, 3, 0, {0, 1, 2, 3, 4}, "bfzyx", "bfxyz", {{1, 16}}, {{1, 16}}), // NOLINT
+ FMT_TRAITS(bs_fs_zyx_bsv16_fsv32, 1, 1, 3, 0, {0, 1, 2, 3, 4}, "bfzyx", "bfxyz", {{0, 16 }, {1, 32}}, {{0, 16 }, {1, 32}}), // NOLINT
+ FMT_TRAITS(bs_fs_zyx_bsv16_fsv16, 1, 1, 3, 0, {0, 1, 2, 3, 4}, "bfzyx", "bfxyz", {{0, 16 }, {1, 16}}, {{0, 16 }, {1, 16}}), // NOLINT
+ FMT_TRAITS(bs_fs_yx_bsv16_fsv16, 1, 1, 2, 0, {0, 1, 2, 3}, "bfyx", "bfxy", {{0, 16 }, {1, 16}}, {{0, 16 }, {1, 16}}), // NOLINT
+ FMT_TRAITS(bs_fs_yx_bsv16_fsv32, 1, 1, 2, 0, {0, 1, 2, 3}, "bfyx", "bfxy", {{0, 16 }, {1, 32}}, {{0, 16 }, {1, 32}}), // NOLINT
+ FMT_TRAITS(bs_fs_yx_bsv4_fsv4, 1, 1, 2, 0, {0, 1, 2, 3}, "bfyx", "bfxy", {{0, 4 }, {1, 4}}, {{0, 4 }, {1, 4}}), // NOLINT
+ FMT_TRAITS(bs_fs_yx_bsv8_fsv4, 1, 1, 2, 0, {0, 1, 2, 3}, "bfyx", "bfxy", {{0, 8 }, {1, 4}}, {{0, 8 }, {1, 4}}), // NOLINT
+ FMT_TRAITS(bs_fs_zyx_bsv8_fsv4, 1, 1, 3, 0, {0, 1, 2, 3, 4}, "bfzyx", "bfxyz", {{0, 8 }, {1, 4}}, {{0, 8 }, {1, 4}}), // NOLINT
+ FMT_TRAITS(bs_fs_yx_bsv16_fsv8, 1, 1, 2, 0, {0, 1, 2, 3}, "bfyx", "bfxy", {{0, 16 }, {1, 8}}, {{0, 16 }, {1, 8}}), // NOLINT
+ FMT_TRAITS(bs_fs_zyx_bsv16_fsv8, 1, 1, 3, 0, {0, 1, 2, 3, 4}, "bfzyx", "bfxyz", {{0, 16 }, {1, 8}}, {{0, 16 }, {1, 8}}), // NOLINT
+ FMT_TRAITS(bs_fs_yx_bsv16_fsv4, 1, 1, 2, 0, {0, 1, 2, 3}, "bfyx", "bfxy", {{0, 16 }, {1, 4}}, {{0, 16 }, {1, 4}}), // NOLINT
+ FMT_TRAITS(bs_fs_zyx_bsv16_fsv4, 1, 1, 3, 0, {0, 1, 2, 3, 4}, "bfzyx", "bfxyz", {{0, 16 }, {1, 4}}, {{0, 16 }, {1, 4}}), // NOLINT
+ FMT_TRAITS(bs_fs_yx_bsv16_fsv2, 1, 1, 2, 0, {0, 1, 2, 3}, "bfyx", "bfxy", {{0, 16 }, {1, 2}}, {{0, 16 }, {1, 2}}), // NOLINT
+ FMT_TRAITS(bs_fs_zyx_bsv16_fsv2, 1, 1, 3, 0, {0, 1, 2, 3, 4}, "bfzyx", "bfxyz", {{0, 16 }, {1, 2}}, {{0, 16 }, {1, 2}}), // NOLINT
+ FMT_TRAITS(bs_fs_yx_bsv8_fsv2, 1, 1, 2, 0, {0, 1, 2, 3}, "bfyx", "bfxy", {{0, 8 }, {1, 2}}, {{0, 8 }, {1, 2}}), // NOLINT
+ FMT_TRAITS(bs_fs_zyx_bsv8_fsv2, 1, 1, 3, 0, {0, 1, 2, 3, 4}, "bfzyx", "bfxyz", {{0, 8 }, {1, 2}}, {{0, 8 }, {1, 2}}), // NOLINT
+ FMT_TRAITS(bs_fs_yx_bsv4_fsv2, 1, 1, 2, 0, {0, 1, 2, 3}, "bfyx", "bfxy", {{0, 4 }, {1, 2}}, {{0, 4 }, {1, 2}}), // NOLINT
+ FMT_TRAITS(bs_fs_zyx_bsv4_fsv4, 1, 1, 3, 0, {0, 1, 2, 3, 4}, "bfzyx", "bfxyz", {{0, 4 }, {1, 4}}, {{0, 4 }, {1, 4}}), // NOLINT
+ FMT_TRAITS(bs_fs_zyx_bsv4_fsv2, 1, 1, 3, 0, {0, 1, 2, 3, 4}, "bfzyx", "bfxyz", {{0, 4 }, {1, 2}}, {{0, 4 }, {1, 2}}), // NOLINT
+ FMT_TRAITS(bs_fs_zyx_bsv32_fsv32, 1, 1, 3, 0, {0, 1, 2, 3, 4}, "bfzyx", "bfxyz", {{0, 32 }, {1, 32}}, {{0, 32 }, {1, 32}}), // NOLINT
+ FMT_TRAITS(bs_fs_zyx_bsv32_fsv16, 1, 1, 3, 0, {0, 1, 2, 3, 4}, "bfzyx", "bfxyz", {{0, 32 }, {1, 16}}, {{0, 32 }, {1, 16}}), // NOLINT
+ FMT_TRAITS(bs_fs_yx_bsv32_fsv32, 1, 1, 2, 0, {0, 1, 2, 3}, "bfyx", "bfxy", {{0, 32 }, {1, 32}}, {{0, 32 }, {1, 32}}), // NOLINT
+ FMT_TRAITS(bs_fs_yx_bsv32_fsv16, 1, 1, 2, 0, {0, 1, 2, 3}, "bfyx", "bfxy", {{0, 32 }, {1, 16}}, {{0, 32 }, {1, 16}}), // NOLINT
+ FMT_TRAITS(nv12, 1, 1, 2, 0, {0, 1, 2, 3}, "bfyx", "bfxy", {}, {}), // NOLINT
+ FMT_TRAITS(image_2d_rgba, 1, 1, 2, 0, {0, 1, 2, 3}, "bfyx", "bfxy", {}, {}), // NOLINT
+
+ FMT_TRAITS(oiyx, 1, 1, 2, 0, {0, 1, 2, 3}, "oiyx", "oixy", {}, {}), // NOLINT
+ FMT_TRAITS(ioyx, 1, 1, 2, 0, {1, 0, 2, 3}, "ioyx", "oixy", {}, {}), // NOLINT
+ FMT_TRAITS(iyxo, 1, 1, 2, 0, {1, 2, 3, 0}, "iyxo", "oixy", {}, {}), // NOLINT
+ FMT_TRAITS(oyxi, 1, 1, 2, 0, {0, 2, 3, 1}, "oyxi", "oixy", {}, {}), // NOLINT
+ FMT_TRAITS(oyix, 1, 1, 2, 0, {0, 2, 1, 3}, "oyix", "oixy", {}, {}), // NOLINT
+ FMT_TRAITS(oxiy, 1, 1, 2, 0, {0, 3, 1, 2}, "oxiy", "oixy", {}, {}), // NOLINT
+ FMT_TRAITS(yxio, 1, 1, 2, 0, {2, 3, 1, 0}, "yxio", "oixy", {}, {}), // NOLINT
+ FMT_TRAITS(oizyx, 1, 1, 3, 0, {0, 1, 2, 3, 4}, "oizyx", "oixyz", {}, {}), // NOLINT
+ FMT_TRAITS(iozyx, 1, 1, 3, 0, {1, 0, 2, 3, 4}, "iozyx", "oixyz", {}, {}), // NOLINT
+ FMT_TRAITS(os_is_yx_isv16_osv16, 1, 1, 2, 0, {0, 1, 2, 3}, "oiyx", "oixy", {{1, 16}, {0, 16}}, {{1, 16}, {0, 16}}), // NOLINT
+ FMT_TRAITS(o_is_yx_isv4, 1, 1, 2, 0, {0, 1, 2, 3}, "oiyx", "oixy", {{1, 4}}, {{1, 4}}), // NOLINT
+ FMT_TRAITS(o_is_yx_isv16, 1, 1, 2, 0, {0, 1, 2, 3}, "oiyx", "oixy", {{1, 16}}, {{1, 16}}), // NOLINT
+ FMT_TRAITS(os_iyx_osv16, 1, 1, 2, 0, {0, 1, 2, 3}, "oiyx", "oixy", {{0, 16}}, {{0, 16}}), // NOLINT
+ FMT_TRAITS(os_iyx_osv32, 1, 1, 2, 0, {0, 1, 2, 3}, "oiyx", "oixy", {{0, 32}}, {{0, 32}}), // NOLINT
+ FMT_TRAITS(os_iyx_osv64, 1, 1, 2, 0, {0, 1, 2, 3}, "oiyx", "oixy", {{0, 64}}, {{0, 64}}), // NOLINT
+ FMT_TRAITS(winograd_2x3_s1_weights, 1, 1, 2, 0, {0, 1, 2, 3}, "oiyx", "oixy", {}, {}), // NOLINT
+ FMT_TRAITS(winograd_2x3_s1_fused_weights, 1, 1, 2, 0, {3, 2, 1, 0}, "xyio", "oixy", {}, {}), // NOLINT
+ FMT_TRAITS(winograd_6x3_s1_fused_weights, 1, 1, 2, 0, {3, 2, 1, 0}, "xyio", "oixy", {}, {}), // NOLINT
+ FMT_TRAITS(image_2d_weights_winograd_6x3_s1_fbxyb, 1, 1, 2, 0, {1, 0, 3, 2}, "ioxy", "oixy", {}, {}), // NOLINT
+ FMT_TRAITS(image_2d_weights_winograd_6x3_s1_xfbyb, 1, 1, 2, 0, {3, 1, 0, 2}, "xioy", "oixy", {}, {}), // NOLINT
+ FMT_TRAITS(image_2d_weights_c4_fyx_b, 1, 1, 2, 0, {0, 1, 2, 3}, "oiyx", "oixy", {}, {}), // NOLINT
+ FMT_TRAITS(image_2d_weights_c1_b_fyx, 1, 1, 2, 0, {0, 1, 2, 3}, "oiyx", "oixy", {}, {}), // NOLINT
+ FMT_TRAITS(os_is_yx_isa8_osv16_isv4, 1, 1, 2, 0, {0, 1, 2, 3}, "oiyx", "oixy", {{1, 8}, {0, 16}, {1, 4}}, {{1, 8}, {0, 16}, {1, 4}}), // NOLINT
+ FMT_TRAITS(os_is_yx_osa4_isa8_osv8_isv4, 1, 1, 2, 0, {0, 1, 2, 3}, "oiyx", "oixy", {{0, 4}, {1, 8}, {0, 8}, {1, 4}}, {{0, 4}, {1, 8}, {0, 8}, {1, 4}}), // NOLINT
+ FMT_TRAITS(os_is_zyx_osa4_isa8_osv8_isv4, 1, 1, 3, 0, {0, 1, 2, 3, 4}, "oizyx", "oixyz", {{0, 4}, {1, 8}, {0, 8}, {1, 4}}, {{0, 4}, {1, 8}, {0, 8}, {1, 4}}), // NOLINT
+ FMT_TRAITS(os_is_zyx_isa8_osv8_isv4, 1, 1, 3, 0, {0, 1, 2, 3, 4}, "oizyx", "oixyz", {{1, 8}, {0, 8}, {1, 4}}, {{1, 8}, {0, 8}, {1, 4}}), // NOLINT
+ FMT_TRAITS(os_is_zyx_isa8_osv16_isv4, 1, 1, 3, 0, {0, 1, 2, 3, 4}, "oizyx", "oixyz", {{1, 8}, {0, 16}, {1, 4}}, {{1, 8}, {0, 16}, {1, 4}}), // NOLINT
+ FMT_TRAITS(os_is_yx_osa4_isa8_osv8_isv4_swizzled_by_4, 1, 1, 2, 0, {0, 1, 2, 3}, "oiyx", "oixy", {{0, 32}, {1, 32}}, {{0, 32}, {1, 32}}), // NOLINT
+ FMT_TRAITS(os_is_zyx_osa4_isa8_osv8_isv4_swizzled_by_4, 1, 1, 3, 0, {0, 1, 2, 3, 4}, "oizyx", "oixyz", {{0, 32}, {1, 32}}, {{0, 32}, {1, 32}}), // NOLINT
+ FMT_TRAITS(os_is_yx_osv16_isv4, 1, 1, 2, 0, {0, 1, 2, 3}, "oiyx", "oixy", {{0, 16}, {1, 4}}, {{0, 16}, {1, 4}}), // NOLINT
+ FMT_TRAITS(os_is_yx_osv8_isv4, 1, 1, 2, 0, {0, 1, 2, 3}, "oiyx", "oixy", {{0, 8}, {1, 4}}, {{0, 8}, {1, 4}}), // NOLINT
+ FMT_TRAITS(os_is_zyx_osv16_isv16, 1, 1, 3, 0, {0, 1, 2, 3, 4}, "oizyx", "oixyz", {{0, 16}, {1, 16}}, {{0, 16}, {1, 16}}), // NOLINT
+ FMT_TRAITS(os_is_yx_osv32_isv4_swizzled_by_2, 1, 1, 2, 0, {0, 1, 2, 3}, "oiyx", "oixy", {{0, 32}, {1, 4}}, {{0, 32}, {1, 4}}), // NOLINT
+ FMT_TRAITS(os_is_yx_osv32_isv4, 1, 1, 2, 0, {0, 1, 2, 3}, "oiyx", "oixy", {{0, 32}, {1, 4}}, {{0, 32}, {1, 4}}), // NOLINT
+ FMT_TRAITS(os_is_zyx_osv32_isv4, 1, 1, 3, 0, {0, 1, 2, 3, 4}, "oizyx", "oixyz", {{0, 32}, {1, 4}}, {{0, 32}, {1, 4}}), // NOLINT
+ FMT_TRAITS(os_is_zyx_isv16_osv16, 1, 1, 3, 0, {0, 1, 2, 3, 4}, "oizyx", "oixyz", {{1, 16}, {0, 16}}, {{1, 16}, {0, 16}}), // NOLINT
+ FMT_TRAITS(is_os_zyx_isv16_osv16, 1, 1, 3, 0, {1, 0, 2, 3, 4}, "iozyx", "oixyz", {{1, 16}, {0, 16}}, {{1, 16}, {0, 16}}), // NOLINT
+ FMT_TRAITS(is_os_yx_isv16_osv16, 1, 1, 2, 0, {1, 0, 2, 3}, "ioyx", "oixy", {{1, 16}, {0, 16}}, {{1, 16}, {0, 16}}), // NOLINT
+ FMT_TRAITS(os_is_zyx_isa8_osv8_isv4, 1, 1, 3, 0, {0, 1, 2, 3, 4}, "oizyx", "oixyz", {{1, 8}, {0, 8}, {1, 4}}, {{1, 8}, {0, 8}, {1, 4}}), // NOLINT
+ FMT_TRAITS(os_is_zyx_isa8_osv16_isv4, 1, 1, 3, 0, {0, 1, 2, 3, 4}, "oizyx", "oixyz", {{1, 8}, {0, 16}, {1, 4}}, {{1, 8}, {0, 16}, {1, 4}}), // NOLINT
+ FMT_TRAITS(os_is_yx_isa8_osv8_isv4, 1, 1, 2, 0, {0, 1, 2, 3}, "oiyx", "oixy", {{1, 8}, {0, 8}, {1, 4}}, {{1, 8}, {0, 8}, {1, 4}}), // NOLINT
+ FMT_TRAITS(os_is_zyx_isv8_osv16_isv2, 1, 1, 3, 0, {0, 1, 2, 3, 4}, "oizyx", "oixyz", {{1, 8}, {0, 16}, {1, 2}}, {{1, 8}, {0, 16}, {1, 2}}), // NOLINT
+ FMT_TRAITS(os_zyxi_osv16, 1, 1, 3, 0, {0, 2, 3, 4, 1}, "ozyxi", "oixyz", {{0, 16}}, {{0, 16}}), // NOLINT
+ FMT_TRAITS(os_is_yx_isv8_osv16_isv2, 1, 1, 2, 0, {0, 1, 2, 3}, "oiyx", "oixy", {{1, 8}, {0, 16}, {1, 2}}, {{1, 8}, {0, 16}, {1, 2}}), // NOLINT
+ FMT_TRAITS(os_is_yx_osv16_isv16, 1, 1, 2, 0, {0, 1, 2, 3}, "oiyx", "oixy", {{0, 16}, {1, 16}}, {{0, 16}, {1, 16}}), // NOLINT
+ FMT_TRAITS(os_is_yx_osv32_isv2, 1, 1, 2, 0, {0, 1, 2, 3}, "oiyx", "oixy", {{0, 32}}, {{0, 32}}), // NOLINT
+ FMT_TRAITS(os_is_zyx_osv32_isv16, 1, 1, 3, 0, {0, 1, 2, 3, 4}, "oizyx", "oixyz", {{0, 32}, {1, 16}}, {{0, 32}, {1, 16}}), // NOLINT
+ FMT_TRAITS(os_is_zyx_osv64_isv16, 1, 1, 3, 0, {0, 1, 2, 3, 4}, "oizyx", "oixyz", {{0, 64}, {1, 16}}, {{0, 64}, {1, 16}}), // NOLINT
+ FMT_TRAITS(os_iyx_osv8, 1, 1, 2, 0, {0, 1, 2, 3}, "oiyx", "oixy", {{0, 8}}, {{0, 8}}), // NOLINT
+ FMT_TRAITS(os_iyx_osv32__ai32, 1, 1, 2, 0, {0, 1, 2, 3}, "oiyx", "oixy", {{0, 32}}, {{0, 32}}), // NOLINT
+ FMT_TRAITS(i_yxs_os_yxsv2_osv16, 1, 1, 2, 0, {1, 2, 3, 0}, "iyxo", "oixy", {{0, 16}}, {{0, 16}}), // NOLINT
+ FMT_TRAITS(iy_xs_os_xsv2_osv8__ao32, 1, 1, 2, 0, {1, 2, 3, 0}, "iyxo", "oixy", {{2, 2}, {0, 8}}, {{3, 2}, {0, 8}}), // NOLINT
+ FMT_TRAITS(iy_xs_os_xsv2_osv16__ao32, 1, 1, 2, 0, {1, 2, 3, 0}, "iyxo", "oixy", {{2, 2}, {0, 16}}, {{3, 2}, {0, 16}}), // NOLINT
+ FMT_TRAITS(os_i_osv16, 1, 1, 0, 0, {0, 1}, "oi", "oi", {{0, 16}}, {{0, 16}}), // NOLINT
+ FMT_TRAITS(os_i_osv16__ai8, 1, 1, 0, 0, {0, 1}, "oi", "oi", {{1, 8}, {0, 16}}, {{1, 8}, {0, 16}}), // NOLINT
+ FMT_TRAITS(os_i_osv8__ai8, 1, 1, 0, 0, {0, 1}, "oi", "oi", {{1, 8}, {0, 8}}, {{1, 8}, {0, 8}}), // NOLINT
+
+ FMT_TRAITS(goiyx, 1, 1, 2, 1, {0, 1, 2, 3, 4}, "goiyx", "oixy????g", {}, {}), // NOLINT
+ FMT_TRAITS(gioyx, 1, 1, 2, 1, {0, 2, 1, 3, 4}, "gioyx", "oixy????g", {}, {}), // NOLINT
+ FMT_TRAITS(goizyx, 1, 1, 3, 1, {0, 1, 2, 3, 4, 5}, "goizyx", "oixyz???g", {}, {}), // NOLINT
+ FMT_TRAITS(giozyx, 1, 1, 3, 1, {0, 2, 1, 3, 4, 5}, "giozyx", "oixyz???g", {}, {}), // NOLINT
+ FMT_TRAITS(g_os_iyx_osv8, 1, 1, 2, 1, {0, 1, 2, 3, 4}, "goiyx", "oixy????g", {{0, 8}}, {{1, 8}}), // NOLINT
+ FMT_TRAITS(g_os_iyx_osv16, 1, 1, 2, 1, {0, 1, 2, 3, 4}, "goiyx", "oixy????g", {{0, 16}}, {{1, 16}}), // NOLINT
+ FMT_TRAITS(g_os_iyx_osv32, 1, 1, 2, 1, {0, 1, 2, 3, 4}, "goiyx", "oixy????g", {{0, 32}}, {{1, 32}}), // NOLINT
+ FMT_TRAITS(gs_oiyx_gsv16, 1, 1, 2, 1, {0, 1, 2, 3, 4}, "goiyx", "oixy????g", {{8, 16}}, {{0, 16}}), // NOLINT
+ FMT_TRAITS(gs_oizyx_gsv16, 1, 1, 3, 1, {0, 1, 2, 3, 4, 5}, "goizyx", "oixyz???g", {{8, 16}}, {{0, 16}}), // NOLINT
+ FMT_TRAITS(gs_oiyx_gsv32, 1, 1, 2, 1, {0, 1, 2, 3, 4}, "goiyx", "oixy????g", {{8, 32}}, {{0, 32}}), // NOLINT
+ FMT_TRAITS(gyxio, 1, 1, 2, 1, {0, 3, 4, 2, 1}, "gyxio", "oixy????g", {}, {}), // NOLINT
+ FMT_TRAITS(g_is_os_zyx_isv16_osv16, 1, 1, 3, 1, {0, 2, 1, 3, 4, 5}, "giozyx", "oixyz???g", {{1, 16}, {0, 16}}, {{2, 16}, {1, 16}}), // NOLINT
+ FMT_TRAITS(g_is_os_yx_isv16_osv16, 1, 1, 2, 1, {0, 2, 1, 3, 4}, "gioyx", "oixy????g", {{1, 16}, {0, 16}}, {{2, 16}, {1, 16}}), // NOLINT
+ FMT_TRAITS(g_os_is_zyx_isv8_osv16_isv2, 1, 1, 3, 1, {0, 1, 2, 3, 4, 5}, "goizyx", "oixyz???g", {{1, 8}, {0, 16}, {1, 2}}, {{2, 8}, {1, 16}, {2, 2}}), // NOLINT
+ FMT_TRAITS(g_os_is_yx_isv8_osv16_isv2, 1, 1, 2, 1, {0, 1, 2, 3, 4}, "goiyx", "oixy????g", {{1, 8}, {0, 16}, {1, 2}}, {{2, 8}, {1, 16}, {2, 2}}), // NOLINT
+ FMT_TRAITS(g_os_is_zyx_isv16_osv16, 1, 1, 3, 1, {0, 1, 2, 3, 4, 5}, "goizyx", "oixyz???g", {{0, 16}, {1, 16}}, {{1, 16}, {2, 16}}), // NOLINT
+ FMT_TRAITS(g_os_is_yx_osv16_isv4, 1, 1, 2, 1, {0, 1, 2, 3, 4}, "goiyx", "oixy????g", {{0, 16}, {1, 4}}, {{1, 16}, {2, 4}}), // NOLINT
+ FMT_TRAITS(g_os_is_zyx_osv16_isv16, 1, 1, 3, 1, {0, 1, 2, 3, 4, 5}, "goizyx", "oixyz???g", {{0, 16}, {1, 16}}, {{1, 16}, {2, 16}}), // NOLINT
+ FMT_TRAITS(g_os_zyx_is_osv16_isv4, 1, 1, 3, 1, {0, 1, 2, 3, 4, 5}, "gozyxi", "oixyz???g", {{0, 16}, {1, 4}}, {{1, 16}, {5, 4}}), // NOLINT
+ FMT_TRAITS(g_os_zyx_is_osv16_isv16, 1, 1, 3, 1, {0, 1, 2, 3, 4, 5}, "gozyxi", "oixyz???g", {{0, 16}, {1, 16}}, {{1, 16}, {5, 16}}), // NOLINT
+ FMT_TRAITS(g_os_zyx_is_osv16_isv32, 1, 1, 3, 1, {0, 1, 2, 3, 4, 5}, "gozyxi", "oixyz???g", {{0, 16}, {1, 32}}, {{1, 16}, {5, 32}}), // NOLINT
+ FMT_TRAITS(g_os_zyx_is_osv32_isv4, 1, 1, 3, 1, {0, 1, 2, 3, 4, 5}, "gozyxi", "oixyz???g", {{0, 32}, {1, 4}}, {{1, 32}, {5, 4}}), // NOLINT
+ FMT_TRAITS(g_os_zyx_is_osv32_isv16, 1, 1, 3, 1, {0, 1, 2, 3, 4, 5}, "gozyxi", "oixyz???g", {{0, 32}, {1, 16}}, {{1, 32}, {5, 16}}), // NOLINT
+ FMT_TRAITS(g_os_zyx_is_osv32_isv32, 1, 1, 3, 1, {0, 1, 2, 3, 4, 5}, "gozyxi", "oixyz???g", {{0, 32}, {1, 32}}, {{1, 32}, {5, 32}}), // NOLINT
+ FMT_TRAITS(gs_oi_yxs_gsv4_yxsv4, 1, 1, 2, 1, {0, 1, 2, 3, 4}, "goiyx", "oixy????g", {{8, 4}}, {{0, 4}}), // NOLINT
+ FMT_TRAITS(gs_oi_yxs_gsv16_yxsv4, 1, 1, 2, 1, {0, 1, 2, 3, 4}, "goiyx", "oixy????g", {{8, 16}}, {{0, 16}}), // NOLINT
+ FMT_TRAITS(gs_oi_yxs_gsv32_yxsv4, 1, 1, 2, 1, {0, 1, 2, 3, 4}, "goiyx", "oixy????g", {{8, 32}}, {{0, 32}}), // NOLINT
+ FMT_TRAITS(g_os_is_yx_isv16_osv16, 1, 1, 2, 1, {0, 1, 2, 3, 4}, "goiyx", "oixy????g", {{1, 16}, {0, 16}}, {{2, 16}, {1, 16}}), // NOLINT
+ FMT_TRAITS(gi_yxs_os_yxsv2_osv16, 1, 1, 2, 1, {0, 2, 3, 4, 1}, "giyxo", "oixy????g", {{0, 16}}, {{1, 16}}), // NOLINT
+ FMT_TRAITS(giy_xs_os_xsv2_osv8__ao32, 1, 1, 2, 1, {0, 2, 3, 4, 1}, "giyxo", "oixy????g", {{2, 2}, {0, 8}}, {{4, 2}, {1, 8}}), // NOLINT
+ FMT_TRAITS(giy_xs_os_xsv2_osv16__ao32, 1, 1, 2, 1, {0, 2, 3, 4, 1}, "giyxo", "oixy????g", {{2, 2}, {0, 16}}, {{4, 2}, {1, 16}}), // NOLINT
};
const format_traits& format::traits(type fmt) {
diff --git a/src/plugins/intel_gpu/src/runtime/layout.cpp b/src/plugins/intel_gpu/src/runtime/layout.cpp
index 965d7cfac76..a2b7e62ea0c 100644
--- a/src/plugins/intel_gpu/src/runtime/layout.cpp
+++ b/src/plugins/intel_gpu/src/runtime/layout.cpp
@@ -9,8 +9,14 @@
#include <algorithm>
#include "openvino/core/dimension.hpp"
#include "openvino/core/partial_shape.hpp"
+#include "intel_gpu/runtime/utils.hpp"
+
+#include "intel_gpu/runtime/debug_configuration.hpp"
namespace cldnn {
+/* c++11 requires to have a definition in cpp file */
+constexpr padding::DynamicDimsMask padding::EMPTY_MASK;
+
static inline bool check_redundant_1d_along_feature(layout const& l1, layout const& l2);
namespace {
@@ -112,13 +118,30 @@ std::vector<tensor::value_type> layout::get_dims() const {
}
std::vector<tensor::value_type> layout::get_padded_dims() const {
- if (is_dynamic())
- throw std::runtime_error("[GPU] get_padded_dims() is called for dynamic shape");
+ OPENVINO_ASSERT(!is_dynamic() || has_upper_bound(), "[GPU] get_tensor() is called for dynamic shape without upper bound");
+ ov::Shape shape = is_dynamic() ? size.get_max_shape() : size.to_shape();
- auto default_fmt = format::get_default_format(format.dimension(), format::is_weights_format(format), format::is_grouped(format));
- const auto& t = get_tensor();
- auto padded_size = t.add(data_padding.lower_size()).add(data_padding.upper_size());
- return padded_size.sizes(default_fmt);
+ std::vector<tensor::value_type> dims;
+ for (auto dim : shape) {
+ dims.push_back(static_cast<tensor::value_type>(dim));
+ }
+
+ auto rank = std::max(format.dimension(), dims.size());
+ auto default_fmt = format::get_default_format(rank, format::is_weights_format(format), format::is_grouped(format));
+ if (default_fmt.dimension() > dims.size()) {
+ dims.insert(dims.end(), default_fmt.dimension() - dims.size(), 1);
+ }
+
+ while (dims.size() > default_fmt.dimension()) {
+ dims.pop_back();
+ }
+
+ std::vector<tensor::value_type> res(dims.size());
+ for (size_t i = 0; i < res.size(); i++) {
+ res[i] = dims[i] + data_padding._upper_size[i] + data_padding._lower_size[i];
+ }
+
+ return res;
}
static format to_weights_format(format f, bool is_grouped) {
@@ -182,9 +205,13 @@ std::string layout::to_string() const {
<< "\tdata_type=" << ov::element::Type(data_type) << ";\n"
<< "\tformat=" << format.to_string() << ";\n"
<< "\tshape=" << size << ";\n"
- << "\tpad_l=" << data_padding.lower_size().to_string() << ";\n"
- << "\tpad_u=" << data_padding.upper_size().to_string() << ";\n"
- << "\tdyn_pad_dims" << data_padding.get_dynamic_pad_dims().to_string() << ";\n"
+ << "\tpad_l=[";
+ std::copy(std::begin(data_padding._lower_size), std::end(data_padding._lower_size), std::ostream_iterator<tensor::value_type>(s, ", "));
+ s << "];\n"
+ << "\tpad_u=[";
+ std::copy(std::begin(data_padding._upper_size), std::end(data_padding._upper_size), std::ostream_iterator<tensor::value_type>(s, ", "));
+ s << "];\n"
+ << "\tdyn_pad_dims=[" << data_padding._dynamic_dims_mask.to_string() << "];\n"
<< "}";
return s.str();
}
@@ -206,7 +233,7 @@ std::string layout::to_short_string() const {
s << ov::element::Type(data_type) << ":" << format.to_string() << ":";
dump_shape(s, size);
- if (data_padding.get_dynamic_pad_dims() != tensor(0)) {
+ if (data_padding.is_dynamic()) {
s << ":dyn_pad_dims";
} else {
if (data_padding)
@@ -293,27 +320,30 @@ void layout::set_partial_shape(const ov::PartialShape& size) {
this->size = size;
}
-tensor layout::get_buffer_size() const {
- if (is_dynamic() && !has_upper_bound()) {
- throw std::runtime_error("[GPU] get_buffer_size() is called for dynamic shape");
- }
+std::vector<tensor::value_type> layout::get_pitches() const {
+ const auto& padded_dims = get_padded_dims();
+ auto sizes = format_sizes(padded_dims, format);
- const auto& t = get_tensor();
+ std::vector<tensor::value_type> pitches_fmt(sizes.size(), size_t(1));
+ std::partial_sum(sizes.rbegin(), sizes.rend() - 1, pitches_fmt.rbegin() + 1, std::multiplies<tensor::value_type>());
- return t.add(data_padding.lower_size()).add(data_padding.upper_size());
-}
-
-tensor layout::get_pitches() const {
- const auto& sizes = get_buffer_size().sizes(format);
+ // reorder back to default format order
+ auto pitches = tensor(format, pitches_fmt).sizes(format::get_default_format(format.dimension(),
+ format::is_weights_format(format),
+ format::is_grouped(format)));
- std::vector<tensor::value_type> pitches(sizes.size(), tensor::value_type(1));
- std::partial_sum(sizes.rbegin(), sizes.rend() - 1, pitches.rbegin() + 1, std::multiplies<tensor::value_type>());
- return {format, pitches};
+ return pitches;
}
+
size_t layout::get_linear_offset(tensor element) const {
- const auto& l_padd = data_padding.lower_size();
- const auto& u_padd = data_padding.upper_size();
+ auto default_fmt = format::get_default_format(format.dimension(), format::is_weights_format(format), format::is_grouped(format));
+
+ std::vector<tensor::value_type> lower_sizes, upper_sizes;
+ lower_sizes.assign(data_padding._lower_size.begin(), data_padding._lower_size.begin() + format.dimension());
+ upper_sizes.assign(data_padding._upper_size.begin(), data_padding._upper_size.begin() + format.dimension());
+ const auto& l_padd = tensor(default_fmt, lower_sizes, 0);
+ const auto& u_padd = tensor(default_fmt, upper_sizes, 0);
const auto& t = get_tensor();
@@ -333,16 +363,16 @@ size_t layout::get_linear_offset(tensor element) const {
auto padded_size = t + l_padd + u_padd;
auto padded_element = element + l_padd;
-
return padded_size.get_linear_offset(padded_element, format);
}
/// @brief Get aligned linear size calculated as multiplication of all elements.
size_t layout::get_linear_size() const {
- auto sizes = get_buffer_size().sizes();
+ auto sizes = get_padded_dims();
std::set<size_t> processed_dims;
- const auto& blocks = format.block_sizes();
+ const auto& blocks = format.logic_block_sizes();
+
for (size_t i = 0; i < blocks.size(); i++) {
if (processed_dims.count(blocks[i].first))
continue;
@@ -412,8 +442,6 @@ layout layout::with_padding(padding const& padd) const {
bool layout::compatible(const layout& other) const {
auto& l1 = *this;
auto& l2 = other;
- const auto& l1_pad = l1.data_padding;
- const auto& l2_pad = l2.data_padding;
if (l1.is_dynamic() || l2.is_dynamic())
return false;
@@ -429,7 +457,7 @@ bool layout::compatible(const layout& other) const {
// Reorders between bfyx, bfzyx, bfwzyx can be reinterpeted as reshape when
// there is no padding and both hold same number of elements.
if (format::is_default_format(l1.format) && format::is_default_format(l2.format) &&
- !l1_pad && !l2_pad && l1.get_linear_size() == l2.get_linear_size())
+ !l1.data_padding && !l2.data_padding && l1.get_linear_size() == l2.get_linear_size())
return true;
if (l1_size != l2_size)
return false;
@@ -477,14 +505,6 @@ bool layout::compatible(const layout& other) const {
auto l1_pitch = l1.get_pitches();
auto l2_pitch = l2.get_pitches();
- // ignore pitches which will never be used (for dims with size == 1)
- for (size_t i = 0; i < tensor_dim_max; ++i)
- if (l1_size.raw[i] == 1)
- l1_pitch.raw[i] = 0;
- for (size_t i = 0; i < tensor_dim_max; ++i)
- if (l2_size.raw[i] == 1)
- l2_pitch.raw[i] = 0;
-
auto l1_offset = l1.get_linear_offset();
auto l2_offset = l2.get_linear_offset();
if (l1_pitch == l2_pitch && l1_offset == l2_offset)
diff --git a/src/plugins/intel_gpu/tests/unit/dynamic_execution/is_valid_fusion_test.cpp b/src/plugins/intel_gpu/tests/unit/dynamic_execution/is_valid_fusion_test.cpp
index 3c7ec5181e3..ac44dfb073c 100644
--- a/src/plugins/intel_gpu/tests/unit/dynamic_execution/is_valid_fusion_test.cpp
+++ b/src/plugins/intel_gpu/tests/unit/dynamic_execution/is_valid_fusion_test.cpp
@@ -85,7 +85,7 @@ TEST(eltwise_activation_fusing_test, basic_dynamic_rank4) {
auto output_mem = outputs.begin()->second.get_memory();
cldnn::mem_lock<float> output_mem_ptr(output_mem, get_test_stream());
- for (size_t i = 0; i < output_mem->get_layout().get_buffer_size().count(); ++i) {
+ for (size_t i = 0; i < output_mem->get_layout().get_linear_size(); ++i) {
ASSERT_EQ(output_mem_ptr[i], ref[i]);
}
}
diff --git a/src/plugins/intel_gpu/tests/unit/dynamic_execution/memory_realloc_test.cpp b/src/plugins/intel_gpu/tests/unit/dynamic_execution/memory_realloc_test.cpp
index 7d36c89d717..cf33ea908f2 100644
--- a/src/plugins/intel_gpu/tests/unit/dynamic_execution/memory_realloc_test.cpp
+++ b/src/plugins/intel_gpu/tests/unit/dynamic_execution/memory_realloc_test.cpp
@@ -103,7 +103,7 @@ TEST(memory_reuse_realloc_reset_test, basic_conv_with_padding) {
auto outputs_2 = network.execute();
auto output_mem_2 = outputs_2.begin()->second.get_memory();
cldnn::mem_lock<float> output_mem_2_ptr(output_mem_2, get_test_stream());
- for (size_t i = 0; i < output_mem_2->get_layout().get_buffer_size().count(); ++i) {
+ for (size_t i = 0; i < output_mem_2->get_layout().get_linear_size(); ++i) {
ASSERT_EQ(output_mem_2_ptr[i], ref_output_2[i]);
}
// check padding of second run of reorder
diff --git a/src/plugins/intel_gpu/tests/unit/dynamic_execution/optimized_out_execution_test.cpp b/src/plugins/intel_gpu/tests/unit/dynamic_execution/optimized_out_execution_test.cpp
index 27df164b5af..d9ee1b69be9 100644
--- a/src/plugins/intel_gpu/tests/unit/dynamic_execution/optimized_out_execution_test.cpp
+++ b/src/plugins/intel_gpu/tests/unit/dynamic_execution/optimized_out_execution_test.cpp
@@ -106,7 +106,7 @@ TEST(optimized_out_execution_test, concat_blocked_format) {
auto output_mem = outputs.begin()->second.get_memory();
cldnn::mem_lock<ov::float16> output_mem_ptr(output_mem, get_test_stream());
- for (size_t i = 0; i < output_mem->get_layout().get_buffer_size().count(); ++i) {
+ for (size_t i = 0; i < output_mem->get_layout().get_linear_size(); ++i) {
ASSERT_EQ(output_mem_ptr[i], ref[i]);
}
}
diff --git a/src/plugins/intel_gpu/tests/unit/dynamic_execution/priorbox_test.cpp b/src/plugins/intel_gpu/tests/unit/dynamic_execution/priorbox_test.cpp
index 3516b4f7f20..51f25ee0af3 100644
--- a/src/plugins/intel_gpu/tests/unit/dynamic_execution/priorbox_test.cpp
+++ b/src/plugins/intel_gpu/tests/unit/dynamic_execution/priorbox_test.cpp
@@ -157,7 +157,7 @@ TEST(priorbox_constant_propagation_test, basic) {
std::vector<float> ref_concat = ref;
ref_concat.insert(ref_concat.end(), ref.begin(), ref.end());
- for (size_t i = 0; i < output_mem->get_layout().get_buffer_size().count(); ++i) {
+ for (size_t i = 0; i < output_mem->get_layout().get_linear_size(); ++i) {
ASSERT_EQ(output_mem_ptr[i], ref_concat[i]);
}
}
diff --git a/src/plugins/intel_gpu/tests/unit/dynamic_execution/stateful_model.cpp b/src/plugins/intel_gpu/tests/unit/dynamic_execution/stateful_model.cpp
index f1473170630..4b24fb996b3 100644
--- a/src/plugins/intel_gpu/tests/unit/dynamic_execution/stateful_model.cpp
+++ b/src/plugins/intel_gpu/tests/unit/dynamic_execution/stateful_model.cpp
@@ -224,9 +224,28 @@ TEST(stateful_model, check_dynamic_pad_for_kv_cache) {
auto pad = tensor(0);
pad.batch[0] = 1;
- ASSERT_EQ(read_value_inst->get_output_layout(0).data_padding.get_dynamic_pad_dims(), pad);
- ASSERT_EQ(gather_inst->get_output_layout(0).data_padding.get_dynamic_pad_dims(), pad);
- ASSERT_EQ(kv_cache_inst->get_output_layout(0).data_padding.get_dynamic_pad_dims(), pad);
+
+ {
+ std::vector<tensor::value_type> dynamic_pad_mask;
+ const auto& dynamic_pad_dims = read_value_inst->get_output_layout(0).data_padding._dynamic_dims_mask;
+ for (size_t i = 0; i < dynamic_pad_dims.size(); i++)
+ dynamic_pad_mask.push_back(dynamic_pad_dims[i]);
+ ASSERT_EQ(tensor(dynamic_pad_mask, 0), pad);
+ }
+ {
+ std::vector<tensor::value_type> dynamic_pad_mask;
+ const auto& dynamic_pad_dims = gather_inst->get_output_layout(0).data_padding._dynamic_dims_mask;
+ for (size_t i = 0; i < dynamic_pad_dims.size(); i++)
+ dynamic_pad_mask.push_back(dynamic_pad_dims[i]);
+ ASSERT_EQ(tensor(dynamic_pad_mask, 0), pad);
+ }
+ {
+ std::vector<tensor::value_type> dynamic_pad_mask;
+ const auto& dynamic_pad_dims = kv_cache_inst->get_output_layout(0).data_padding._dynamic_dims_mask;
+ for (size_t i = 0; i < dynamic_pad_dims.size(); i++)
+ dynamic_pad_mask.push_back(dynamic_pad_dims[i]);
+ ASSERT_EQ(tensor(dynamic_pad_mask, 0), pad);
+ }
}
} // stateful_model_tests
diff --git a/src/plugins/intel_gpu/tests/unit/module_tests/format_test.cpp b/src/plugins/intel_gpu/tests/unit/module_tests/format_test.cpp
index 0c20b757c88..d28d5e02441 100644
--- a/src/plugins/intel_gpu/tests/unit/module_tests/format_test.cpp
+++ b/src/plugins/intel_gpu/tests/unit/module_tests/format_test.cpp
@@ -112,6 +112,21 @@ public:
ASSERT_EQ(blocks.at(idx).first, param.inner_block.at(idx).first);
ASSERT_EQ(blocks.at(idx).second, param.inner_block.at(idx).second);
}
+
+ auto logic_blocks = format::logic_block_sizes(param.in_format);
+ ASSERT_EQ(logic_blocks.size(), param.inner_block.size());
+ for (size_t idx = 0; idx < logic_blocks.size(); idx++) {
+ auto c = param.in_format.internal_order()[param.inner_block.at(idx).first];
+ auto pos = param.in_format.order().find(c);
+ if (pos == std::string::npos)
+ throw std::domain_error(std::string("Unknown coord type: ") + c);
+
+ auto expected_logic_idx = param.in_format.dims_order()[pos];
+ auto expected_logic_size = param.inner_block.at(idx).second;
+
+ ASSERT_EQ(logic_blocks.at(idx).first, expected_logic_idx);
+ ASSERT_EQ(logic_blocks.at(idx).second, expected_logic_size);
+ }
}
INSTANTIATE_TEST_SUITE_P(smoke, axes_test_format,
@@ -126,6 +141,12 @@ INSTANTIATE_TEST_SUITE_P(smoke, axes_test_format,
{format::gs_oiyx_gsv32, {{8, 32}}, {{8, 32}}},
{format::gs_oiyx_gsv16, {{8, 16}}, {{8, 16}}},
{format::gs_oizyx_gsv16, {{8, 16}}, {{8, 16}}},
+ {format::i_yxs_os_yxsv2_osv16, {{0, 16}}, {{0, 16}}},
+ {format::iy_xs_os_xsv2_osv8__ao32, {{2, 2}, {0, 8}}, {{2, 2}, {0, 8}}},
+ {format::g_is_os_zyx_isv16_osv16, {{1, 16}, {0, 16}}, {{1, 16}, {0, 16}}},
+ {format::g_is_os_yx_isv16_osv16, {{1, 16}, {0, 16}}, {{1, 16}, {0, 16}}},
+ {format::gi_yxs_os_yxsv2_osv16, {{0, 16}}, {{0, 16}}},
+ {format::giy_xs_os_xsv2_osv8__ao32, {{2, 2}, {0, 8}}, {{2, 2}, {0, 8}}},
}),
axes_test_format::PrintToString);
diff --git a/src/plugins/intel_gpu/tests/unit/module_tests/layout_test.cpp b/src/plugins/intel_gpu/tests/unit/module_tests/layout_test.cpp
index 3837a49ad5c..7c666819176 100644
--- a/src/plugins/intel_gpu/tests/unit/module_tests/layout_test.cpp
+++ b/src/plugins/intel_gpu/tests/unit/module_tests/layout_test.cpp
@@ -17,6 +17,8 @@ struct layout_test_params {
std::vector<tensor::value_type> size;
std::vector<tensor::value_type> expected_aligned_size;
std::vector<size_t> expected_order;
+ padding padd;
+ std::vector<tensor::value_type> expected_pitches;
};
class data_layout_test : public testing::TestWithParam<layout_test_params> { };
@@ -33,7 +35,7 @@ TEST_P(data_layout_test, size_check) {
ASSERT_FALSE(format::is_weights_format(p.fmt));
- auto l = layout(p.dt, p.fmt, tensor{default_fmt, p.size});
+ auto l = layout(p.dt, p.fmt, tensor{default_fmt, p.size}, p.padd);
size_t expected_count = std::accumulate(p.size.begin(), p.size.end(), 1, std::multiplies<int>());
size_t expected_bytes_count = std::accumulate(p.expected_aligned_size.begin(), p.expected_aligned_size.end(), 1, std::multiplies<int>()) *
@@ -77,23 +79,31 @@ TEST_P(data_layout_test, size_check) {
ASSERT_EQ(ordered_dims[i], dims[p.expected_order[i]]);
ASSERT_EQ(ordered_dims[i], p.size[p.expected_order[i]]);
}
+
+ ASSERT_EQ(l.get_pitches(), p.expected_pitches);
}
INSTANTIATE_TEST_SUITE_P(smoke, data_layout_test,
testing::ValuesIn(std::vector<layout_test_params>{
- {data_types::f32, format::bfyx, {2, 33, 3, 5}, {2, 33, 3, 5}, {0, 1, 2, 3}},
- {data_types::f16, format::bfzyx, {2, 33, 3, 5, 4}, {2, 33, 3, 5, 4}, {0, 1, 2, 3, 4}},
- {data_types::i8, format::bfwzyx, {2, 33, 3, 5, 4, 6}, {2, 33, 3, 5, 4, 6}, {0, 1, 2, 3, 4, 5}},
- {data_types::u8, format::yxfb, {2, 33, 3, 5}, {2, 33, 3, 5}, {2, 3, 1, 0}},
- {data_types::f32, format::byxf, {2, 33, 3, 5}, {2, 33, 3, 5}, {0, 2, 3, 1}},
- {data_types::f32, format::fyxb, {2, 33, 3, 5}, {2, 33, 3, 5}, {1, 2, 3, 0}},
- {data_types::f32, format::b_fs_yx_fsv16, {2, 33, 3, 5}, {2, 48, 3, 5}, {0, 1, 2, 3}},
- {data_types::f32, format::b_fs_yx_fsv32, {2, 33, 3, 5}, {2, 64, 3, 5}, {0, 1, 2, 3}},
- {data_types::f32, format::b_fs_zyx_fsv16, {2, 33, 3, 5, 6}, {2, 48, 3, 5, 6}, {0, 1, 2, 3, 4}},
- {data_types::f32, format::b_fs_zyx_fsv32, {2, 33, 3, 5, 6}, {2, 64, 3, 5, 6}, {0, 1, 2, 3, 4}},
- {data_types::f32, format::bs_fs_zyx_bsv16_fsv16, {2, 33, 3, 5, 6}, {16, 48, 3, 5, 6}, {0, 1, 2, 3, 4}},
- {data_types::f32, format::bs_fs_yx_bsv16_fsv16, {2, 33, 3, 5}, {16, 48, 3, 5}, {0, 1, 2, 3}},
- {data_types::f32, format::bs_fs_yx_bsv4_fsv4, {2, 33, 3, 5}, {4, 36, 3, 5}, {0, 1, 2, 3}},
+ {data_types::f32, format::bfyx, {1, 15, 5, 5}, {1, 17, 11, 9}, {0, 1, 2, 3}, padding{{0, 1, 3, 2}, 0}/*padding in shape order*/, {1683, 99, 9, 1} /*expected pitches in shape order*/},
+ {data_types::f32, format::bfyx, {1, 15, 5, 5}, {1, 15, 5, 5}, {0, 1, 2, 3}, {}, {375, 25, 5, 1}},
+ {data_types::f32, format::byxf, {1, 15, 5, 5}, {1, 17, 11, 9}, {0, 2, 3, 1}, padding{{0, 1, 3, 2}, 0}/*padding in shape order*/, {1683, 1, 153, 17} /*expected pitches in shape order*/},
+ {data_types::f32, format::byxf, {1, 15, 5, 5}, {1, 15, 5, 5}, {0, 2, 3, 1}, {}, {375, 1, 75, 15}},
+ {data_types::f32, format::bfyx, {2, 33, 3, 5}, {2, 33, 3, 5}, {0, 1, 2, 3}, {}, {495, 15, 5, 1}},
+ {data_types::f16, format::bfzyx, {2, 33, 3, 5, 4}, {2, 33, 3, 5, 4}, {0, 1, 2, 3, 4}, {}, {1980, 60, 20, 4, 1}},
+ {data_types::i8, format::bfwzyx, {2, 33, 3, 5, 4, 6}, {2, 33, 3, 5, 4, 6}, {0, 1, 2, 3, 4, 5}, {}, {11880, 360, 120, 24, 6, 1}},
+ {data_types::u8, format::yxfb, {2, 33, 3, 5}, {2, 33, 3, 5}, {2, 3, 1, 0}, {}, {1, 2, 330, 66}},
+ {data_types::f32, format::byxf, {2, 33, 3, 5}, {2, 33, 3, 5}, {0, 2, 3, 1}, {}, {495, 1, 165, 33}},
+ {data_types::f32, format::fyxb, {2, 33, 3, 5}, {2, 33, 3, 5}, {1, 2, 3, 0}, {}, {1, 30, 10, 2}},
+ {data_types::f32, format::b_fs_yx_fsv16, {2, 33, 3, 5}, {2, 48, 3, 5}, {0, 1, 2, 3}, {}, {495, 15, 5, 1}},
+ {data_types::f32, format::b_fs_yx_fsv32, {2, 33, 3, 5}, {2, 64, 3, 5}, {0, 1, 2, 3}, {}, {495, 15, 5, 1}},
+ {data_types::f32, format::b_fs_zyx_fsv16, {2, 33, 3, 5, 6}, {2, 48, 3, 5, 6}, {0, 1, 2, 3, 4}, {}, {2970, 90, 30, 6, 1}},
+ {data_types::f32, format::b_fs_zyx_fsv32, {2, 33, 3, 5, 6}, {2, 64, 3, 5, 6}, {0, 1, 2, 3, 4}, {}, {2970, 90, 30, 6, 1}},
+ {data_types::f32, format::bs_fs_zyx_bsv16_fsv16, {2, 33, 3, 5, 6}, {16, 48, 3, 5, 6}, {0, 1, 2, 3, 4}, {}, {2970, 90, 30, 6, 1}},
+ {data_types::f32, format::bs_fs_yx_bsv16_fsv16, {2, 33, 3, 5}, {16, 48, 3, 5}, {0, 1, 2, 3}, {}, {495, 15, 5, 1}},
+ {data_types::f32, format::bs_fs_yx_bsv4_fsv4, {2, 33, 3, 5}, {4, 36, 3, 5}, {0, 1, 2, 3}, {}, {495, 15, 5, 1}},
+ {data_types::f32, format::bfzyx, {3, 2, 2, 2, 2}, {3, 2, 2, 2, 2}, {0, 1, 2, 3, 4}, {}, {16, 8, 4, 2, 1}},
+ {data_types::f32, format::bzyxf, {3, 2, 2, 2, 2}, {3, 2, 2, 2, 2}, {0, 2, 3, 4, 1}, {}, {16, 1, 8, 4, 2}},
}));
class weights_layout_test : public testing::TestWithParam<layout_test_params> { };
@@ -116,7 +126,7 @@ TEST_P(weights_layout_test, size_check) {
}
}
- auto l = layout(p.dt, p.fmt, tensor{default_fmt, p.size});
+ auto l = layout(p.dt, p.fmt, tensor{default_fmt, p.size}, p.padd);
size_t expected_count = std::accumulate(p.size.begin(), p.size.end(), 1, std::multiplies<tensor::value_type>());
size_t expected_bytes_count = std::accumulate(p.expected_aligned_size.begin(),
@@ -170,16 +180,22 @@ TEST_P(weights_layout_test, size_check) {
ASSERT_EQ(ordered_dims[i], dims[p.expected_order[i]]);
ASSERT_EQ(ordered_dims[i], p.size[p.expected_order[i]]);
}
+
+ if (p.expected_pitches.size() > 0)
+ ASSERT_EQ(l.get_pitches(), p.expected_pitches);
+ else {
+ l.get_pitches();
+ }
}
INSTANTIATE_TEST_SUITE_P(smoke, weights_layout_test,
testing::ValuesIn(std::vector<layout_test_params>{
- {data_types::f32, format::oiyx, {2, 15, 3, 5}, {2, 15, 3, 5}, {0, 1, 2, 3}},
- {data_types::f32, format::ioyx, {2, 15, 3, 5}, {2, 15, 3, 5}, {1, 0, 2, 3}},
- {data_types::f32, format::yxio, {2, 15, 3, 5}, {2, 15, 3, 5}, {2, 3, 1, 0}},
- {data_types::f32, format::goiyx, {4, 2, 15, 3, 5}, {4, 2, 15, 3, 5}, {0, 1, 2, 3, 4}},
- {data_types::f32, format::goizyx, {4, 2, 15, 3, 5, 6}, {4, 2, 15, 3, 5, 6}, {0, 1, 2, 3, 4, 5}},
- {data_types::f32, format::giozyx, {4, 2, 15, 3, 5, 6}, {4, 2, 15, 3, 5, 6}, {0, 2, 1, 3, 4, 5}},
+ {data_types::f32, format::oiyx, {2, 15, 3, 5}, {2, 15, 3, 5}, {0, 1, 2, 3}, {}, {225, 15, 5, 1}},
+ {data_types::f32, format::ioyx, {2, 15, 3, 5}, {2, 15, 3, 5}, {1, 0, 2, 3}, {}, {15, 30, 5, 1}},
+ {data_types::f32, format::yxio, {2, 15, 3, 5}, {2, 15, 3, 5}, {2, 3, 1, 0}, {}, {1, 2, 150, 30}},
+ {data_types::f32, format::goiyx, {4, 2, 15, 3, 5}, {4, 2, 15, 3, 5}, {0, 1, 2, 3, 4}, {}, {450, 225, 15, 5, 1}},
+ {data_types::f32, format::goizyx, {4, 2, 15, 3, 5, 6}, {4, 2, 15, 3, 5, 6}, {0, 1, 2, 3, 4, 5}, {}, {2700, 1350, 90, 30, 6, 1}},
+ {data_types::f32, format::giozyx, {4, 2, 15, 3, 5, 6}, {4, 2, 15, 3, 5, 6}, {0, 2, 1, 3, 4, 5}, {}, {2700, 90, 180, 30, 6, 1}},
}));
@@ -209,6 +225,8 @@ INSTANTIATE_TEST_SUITE_P(smoke, layout_cmp_test,
layout{ov::PartialShape{1, 2, 3, 4}, data_types::f16, format::bfyx}, false, false},
{layout{ov::PartialShape{1, 2, 3, 4}, data_types::f16, format::bfyx},
layout{ov::PartialShape{1, 2, 1, 3, 4}, data_types::f16, format::bfzyx}, false, true},
+ {layout{ov::PartialShape{3, 2, 2, 2, 2}, data_types::f16, format::bzyxf},
+ layout{ov::PartialShape{3, 2, 2, 2, 2}, data_types::f16, format::bfzyx}, false, false},
{layout{ov::PartialShape{1, 2, 3, 4}, data_types::f16, format::bfyx},
layout{ov::PartialShape{1, 2, 3, 4, 1, 1}, data_types::f16, format::bfwzyx}, false, true},
{layout{ov::PartialShape{1, 2, 3, 4, 1, 1}, data_types::f16, format::bfwzyx},
@@ -223,6 +241,8 @@ INSTANTIATE_TEST_SUITE_P(smoke, layout_cmp_test,
layout{ov::PartialShape{1, 32, 4, 4}, data_types::f32, format::b_fs_yx_fsv32, padding({0, 0, 0, 0}, 0)}, false, false},
{layout{ov::PartialShape{1, 32, 4, 4}, data_types::f32, format::b_fs_yx_fsv32, padding({0, 0, 1, 1}, 0)},
layout{ov::PartialShape{1, 32, 4, 4}, data_types::f32, format::b_fs_yx_fsv32, padding({0, 0, 1, 1}, 0)}, true, true},
+ {layout{ov::PartialShape{1, 2, 4, 3}, data_types::f16, format::bfyx, padding({0, 0, 2, 1}, 0)},
+ layout{ov::PartialShape{1, 2, 6, 7}, data_types::f16, format::bfyx, padding({0, 0, 0, 0}, 0)}, false, false},
{layout{ov::PartialShape{10, 20}, data_types::f16, format::bfyx},
layout{ov::PartialShape{10, 20}, data_types::f16, format::os_iyx_osv16}, false, false},
{layout{ov::PartialShape{1, 16, 1, 1}, data_types::f16, format::bfyx},
diff --git a/src/plugins/intel_gpu/tests/unit/onednn/utils_test.cpp b/src/plugins/intel_gpu/tests/unit/onednn/utils_test.cpp
index 4b7806fedeb..07fa13047bc 100644
--- a/src/plugins/intel_gpu/tests/unit/onednn/utils_test.cpp
+++ b/src/plugins/intel_gpu/tests/unit/onednn/utils_test.cpp
@@ -198,6 +198,7 @@ TEST_P(memory_desc_to_fmt_conversion_test, test_match_data_format) {
ASSERT_EQ(result.order, param.expected.order);
ASSERT_EQ(result.internal_order, param.expected.internal_order);
ASSERT_EQ(result.block_sizes, param.expected.block_sizes);
+ ASSERT_EQ(result.logic_block_sizes, param.expected.logic_block_sizes);
}
INSTANTIATE_TEST_SUITE_P(smoke, memory_desc_to_fmt_conversion_test,
@@ -205,55 +206,55 @@ INSTANTIATE_TEST_SUITE_P(smoke, memory_desc_to_fmt_conversion_test,
{
{1, 3, 8, 8}, dnnl::memory::data_type::f16, dnnl::memory::format_tag::abcd, false,
format_traits{
- "custom", 1, 1, 2, 0, {0, 1, 2, 3}, "oiyx", "oixy?", {}
+ "custom", 1, 1, 2, 0, {0, 1, 2, 3}, "oiyx", "oixy?", {}, {}
}
},
{
{16, 16, 8, 8}, dnnl::memory::data_type::u8, dnnl::memory::format_tag::ABcd16b16a, false,
format_traits{
- "custom", 1, 1, 2, 0, {0, 1, 2, 3}, "oiyx", "oixy?", {{1, 16}, {0, 16}}
+ "custom", 1, 1, 2, 0, {0, 1, 2, 3}, "oiyx", "oixy?", {{1, 16}, {0, 16}}, {{1, 16}, {0, 16}}
}
},
{
{8, 4, 16, 16, 16}, dnnl::memory::data_type::f16, dnnl::memory::format_tag::ABcde8a4b, false,
format_traits{
- "custom", 1, 1, 3, 0, {0, 1, 2, 3, 4}, "oizyx", "oixyz", {{0, 8}, {1, 4}}
+ "custom", 1, 1, 3, 0, {0, 1, 2, 3, 4}, "oizyx", "oixyz", {{0, 8}, {1, 4}}, {{0, 8}, {1, 4}}
}
},
{
{16, 16, 8, 8}, dnnl::memory::data_type::f16, dnnl::memory::format_tag::ABcd2a8b8a2b, false,
format_traits{
- "custom", 1, 1, 2, 0, {0, 1, 2, 3}, "oiyx", "oixy?", {{0, 2}, {1, 8}, {0, 8}, {1, 2}}
+ "custom", 1, 1, 2, 0, {0, 1, 2, 3}, "oiyx", "oixy?", {{0, 2}, {1, 8}, {0, 8}, {1, 2}}, {{0, 2}, {1, 8}, {0, 8}, {1, 2}}
}
},
{
{64, 64, 8, 8}, dnnl::memory::data_type::u8, dnnl::memory::format_tag::BAcd4b8a8b4a, false,
format_traits{
- "custom", 1, 1, 2, 0, {1, 0, 2, 3}, "ioyx", "oixy?", {{1, 4}, {0, 8}, {1, 8}, {0, 4}}
+ "custom", 1, 1, 2, 0, {1, 0, 2, 3}, "ioyx", "oixy?", {{1, 4}, {0, 8}, {1, 8}, {0, 4}}, {{1, 4}, {0, 8}, {1, 8}, {0, 4}}
}
},
{
{32, 32, 8, 8}, dnnl::memory::data_type::u8, dnnl::memory::format_tag::BAcd4b8a8b4a, false, // same format as above but different sizes
format_traits{
- "custom", 1, 1, 2, 0, {0, 1, 2, 3}, "oiyx", "oixy?", {{1, 4}, {0, 8}, {1, 8}, {0, 4}} // Order is different due to A=B=1 (strides are equal)
+ "custom", 1, 1, 2, 0, {0, 1, 2, 3}, "oiyx", "oixy?", {{1, 4}, {0, 8}, {1, 8}, {0, 4}}, {{1, 4}, {0, 8}, {1, 8}, {0, 4}} // Order is different due to A=B=1 (strides are equal)
}
},
{
{65, 32, 8, 8}, dnnl::memory::data_type::u8, dnnl::memory::format_tag::BAcd4b8a8b4a, false, // same format as above but different sizes
format_traits{
- "custom", 1, 1, 2, 0, {1, 0, 2, 3}, "ioyx", "oixy?", {{1, 4}, {0, 8}, {1, 8}, {0, 4}}
+ "custom", 1, 1, 2, 0, {1, 0, 2, 3}, "ioyx", "oixy?", {{1, 4}, {0, 8}, {1, 8}, {0, 4}}, {{1, 4}, {0, 8}, {1, 8}, {0, 4}}
}
},
{
{10, 20, 30, 40, 50}, dnnl::memory::data_type::f32, dnnl::memory::format_tag::AcdeB24a2b, true,
format_traits{
- "custom", 1, 1, 2, 1, {0, 2, 3, 4, 1}, "giyxo", "oixy????g", {{8, 24}, {0, 2}}
+ "custom", 1, 1, 2, 1, {0, 2, 3, 4, 1}, "giyxo", "oixy????g", {{8, 24}, {0, 2}}, {{0, 24}, {1, 2}}
}
},
{
{10, 60, 70, 40, 50}, dnnl::memory::data_type::f32, dnnl::memory::format_tag::aCBde4c8b8c4b, true,
format_traits{
- "custom", 1, 1, 2, 1, {0, 2, 1, 3, 4}, "gioyx", "oixy????g", {{1, 4}, {0, 8}, {1, 8}, {0, 4}}
+ "custom", 1, 1, 2, 1, {0, 2, 1, 3, 4}, "gioyx", "oixy????g", {{1, 4}, {0, 8}, {1, 8}, {0, 4}}, {{2, 4}, {1, 8}, {2, 8}, {1, 4}}
}
},
}),
diff --git a/src/plugins/intel_gpu/tests/unit/passes/prepare_buffer_fusing_test.cpp b/src/plugins/intel_gpu/tests/unit/passes/prepare_buffer_fusing_test.cpp
index 84b55347fab..6640db80ac5 100644
--- a/src/plugins/intel_gpu/tests/unit/passes/prepare_buffer_fusing_test.cpp
+++ b/src/plugins/intel_gpu/tests/unit/passes/prepare_buffer_fusing_test.cpp
@@ -651,7 +651,8 @@ TEST(prepare_buffer_fusing, in_place_crop_static) {
std::vector<float> out1 = { 13.f, 58.f, -51.f, -108.f, -11.f, -62.f, 57.f, 100.f };
std::vector<float> out2 = { 18.5f, -18.f, 1.f, -4.f, -8.5f, 6.f, 13.f, 8.f };
- std::vector<float> out3 = { 13.f, 58.f, -51.f, -108.f, 18.5f, -18.f, 1.f, -4.f, -11.f, -62.f, 57.f, 100.f, -8.5f, 6.f, 13.f, 8.f };
+ std::vector<float> out3 = { 13.f, 58.f, -51.f, -108.f, 18.5f, -18.f, 1.f, -4.f,
+ -11.f, -62.f, 57.f, 100.f, -8.5f, 6.f, 13.f, 8.f };
topology topology(
input_layout("input", input_mem->get_layout()),
@@ -683,20 +684,20 @@ TEST(prepare_buffer_fusing, in_place_crop_static) {
auto output = outputs.at("output1").get_memory();
cldnn::mem_lock<float> output_ptr(output, get_test_stream());
- for (size_t i = 0; i < out1.size(); i++)
- ASSERT_EQ(output_ptr[i], out1[i]);
-
auto output_2 = outputs.at("output2").get_memory();
cldnn::mem_lock<float> output_ptr_2(output_2, get_test_stream());
- for (size_t i = 0; i < out2.size(); i++)
- ASSERT_EQ(output_ptr_2[i], out2[i]);
-
auto output_3 = outputs.at("output3").get_memory();
cldnn::mem_lock<float> output_ptr_3(output_3, get_test_stream());
for (size_t i = 0; i < out3.size(); i++)
ASSERT_EQ(output_ptr_3[i], out3[i]);
+
+ for (size_t i = 0; i < out1.size(); i++)
+ ASSERT_EQ(output_ptr[i], out1[i]);
+
+ for (size_t i = 0; i < out2.size(); i++)
+ ASSERT_EQ(output_ptr_2[i], out2[i]);
}
TEST(prepare_buffer_fusing, in_place_crop_dynamic) {
diff --git a/src/plugins/intel_gpu/tests/unit/passes/prepare_padding_test.cpp b/src/plugins/intel_gpu/tests/unit/passes/prepare_padding_test.cpp
index c92b8e57613..dafe81c1f0d 100644
--- a/src/plugins/intel_gpu/tests/unit/passes/prepare_padding_test.cpp
+++ b/src/plugins/intel_gpu/tests/unit/passes/prepare_padding_test.cpp
@@ -39,7 +39,7 @@ TEST(prepare_padding, groupconv_with_output) {
program_wrapper::apply_opt_pass<prepare_padding>(*prog, true);
const auto& node = prog->get_node("reorder_input_conv");
auto params = node.get_kernel_impl_params();
- ASSERT_EQ(params->get_output_layout().data_padding.upper_size().spatial[2], 0);
+ ASSERT_EQ(params->get_output_layout().data_padding._upper_size[2 + 0], 2);
}
TEST(prepare_padding, mvn_conv) {
diff --git a/src/plugins/intel_gpu/tests/unit/passes/remove_redundant_reorders_tests.cpp b/src/plugins/intel_gpu/tests/unit/passes/remove_redundant_reorders_tests.cpp
index 09fea8c1f7b..1fbeab7e67a 100644
--- a/src/plugins/intel_gpu/tests/unit/passes/remove_redundant_reorders_tests.cpp
+++ b/src/plugins/intel_gpu/tests/unit/passes/remove_redundant_reorders_tests.cpp
@@ -103,7 +103,7 @@ TEST(remove_redundant_reorders, optimize_fsv16_to_bfyx) {
ASSERT_NE(prog, nullptr);
auto& fc_node = prog->get_node("fc");
auto fc_in_layout = fc_node.get_input_layouts();
- ASSERT_EQ(fc_in_layout.front().data_padding.upper_size().feature[0], 0);
+ ASSERT_EQ(fc_in_layout.front().data_padding._upper_size[1], 0);
}
TEST(remove_redundant_reorders, skip_reorder_fusing_when_sibling_not_support_padding) {
diff --git a/src/plugins/intel_gpu/tests/unit/shape_infer/reshape_si_test.cpp b/src/plugins/intel_gpu/tests/unit/shape_infer/reshape_si_test.cpp
index 97a50f2d9e0..d2199ed02e3 100644
--- a/src/plugins/intel_gpu/tests/unit/shape_infer/reshape_si_test.cpp
+++ b/src/plugins/intel_gpu/tests/unit/shape_infer/reshape_si_test.cpp
@@ -33,7 +33,7 @@ struct reshape_test_params {
inline padding get_pad(format fmt, std::vector<int64_t> axes, bool is_dynamic) {
std::vector<int32_t> lower(fmt.dimension(), 0);
std::vector<int32_t> upper(fmt.dimension(), 0);
- std::vector<int32_t> mask(fmt.dimension(), 0);
+ padding::DynamicDimsMask mask; // empty mask resetted
auto start_pad_val = 13;
for (auto& axis : axes) {
@@ -45,7 +45,7 @@ inline padding get_pad(format fmt, std::vector<int64_t> axes, bool is_dynamic) {
start_pad_val += 5;
}
- return padding(tensor(fmt, lower, 0).sizes(), tensor(fmt, upper, 0).sizes(), 0.0f, tensor(fmt, mask, 0));
+ return padding(lower, upper, mask);
}
class reshape_test_two_inputs : public testing::TestWithParam<reshape_test_params> {};
@@ -223,12 +223,12 @@ INSTANTIATE_TEST_SUITE_P(smoke, squeeze_test,
layout{ov::PartialShape{}, data_types::f32, format::bfyx}
},
{
- layout{ov::PartialShape{1, 1, 10, 20, 30}, data_types::f32, format::bfzyx, get_pad(format::bfyx, {2, 3}, true)},
+ layout{ov::PartialShape{1, 1, 10, 20, 30}, data_types::f32, format::bfzyx, get_pad(format::bfzyx, {3, 4}, true)},
layout{ov::PartialShape{1}, data_types::i64, format::bfyx}, {1}, ov::PartialShape::dynamic(4),
layout{ov::PartialShape{1, 10, 20, 30}, data_types::f32, format::bfyx, get_pad(format::bfyx, {2, 3}, true)},
},
{
- layout{ov::PartialShape{1, 1, 10, 1, 30}, data_types::f32, format::bfzyx, get_pad(format::bfyx, {2, 3}, true)},
+ layout{ov::PartialShape{1, 1, 10, 1, 30}, data_types::f32, format::bfzyx, get_pad(format::bfzyx, {3, 4}, true)},
layout{ov::PartialShape{1}, data_types::i64, format::bfyx}, {3}, ov::PartialShape::dynamic(4),
layout{ov::PartialShape{1, 1, 10, 30}, data_types::f32, format::bfyx}, // pad is removed
}
diff --git a/src/plugins/intel_gpu/tests/unit/test_cases/activation_simple_gpu_test.cpp b/src/plugins/intel_gpu/tests/unit/test_cases/activation_simple_gpu_test.cpp
index 38a778f24f5..069105c9444 100644
--- a/src/plugins/intel_gpu/tests/unit/test_cases/activation_simple_gpu_test.cpp
+++ b/src/plugins/intel_gpu/tests/unit/test_cases/activation_simple_gpu_test.cpp
@@ -1396,13 +1396,13 @@ TEST(activation_f32_fw_gpu, relu_basic_output_padding_yxfb) {
auto output_memory = outputs.at("relu").get_memory();
auto output_layout = output_memory->get_layout();
- auto output_size = output_layout.get_buffer_size();
+ auto output_size = output_layout.get_padded_dims();
cldnn::mem_lock<float> output_ptr(output_memory, get_test_stream());
- int y_size = output_size.spatial[1];
- int x_size = output_size.spatial[0];
- int f_size = output_size.feature[0];
- int b_size = output_size.batch[0];
+ int y_size = output_size[2 + 0];
+ int x_size = output_size[2 + 1];
+ int f_size = output_size[1];
+ int b_size = output_size[0];
ASSERT_EQ(output_layout.format, format::yxfb);
ASSERT_EQ(y_size, 10);
ASSERT_EQ(x_size, 11);
@@ -1778,17 +1778,17 @@ struct activation_random_test : testing::TestWithParam<activation_random_test_pa
template <typename T>
void fill_random_typed(memory::ptr mem, int min, int max, int k) {
auto l = mem->get_layout();
- size_t b = l.batch();
- size_t f = l.feature();
- size_t x = l.spatial(0);
- size_t y = l.spatial(1);
+ auto b = l.batch();
+ auto f = l.feature();
+ auto x = l.spatial(0);
+ auto y = l.spatial(1);
auto data = rg.generate_random_4d<T>(b, f, y, x, min, max, k);
mem_lock<T> ptr{mem, get_test_stream()};
- for (size_t bi = 0; bi < b; ++bi) {
- for (size_t fi = 0; fi < f; ++fi) {
- for (size_t yi = 0; yi < y; ++yi) {
- for (size_t xi = 0; xi < x; ++xi) {
+ for (auto bi = 0; bi < b; ++bi) {
+ for (auto fi = 0; fi < f; ++fi) {
+ for (auto yi = 0; yi < y; ++yi) {
+ for (auto xi = 0; xi < x; ++xi) {
auto coords = tensor(batch(bi), feature(fi), spatial(xi, yi, 0, 0));
auto offset = mem->get_layout().get_linear_offset(coords);
ptr[offset] = data[bi][fi][yi][xi];
@@ -1822,23 +1822,23 @@ struct activation_random_test : testing::TestWithParam<activation_random_test_pa
void compare_outputs(const memory::ptr out_ref, const memory::ptr out_opt) {
auto output_lay = out_ref->get_layout();
auto opt_output_lay = out_opt->get_layout();
- size_t b = output_lay.batch();
- size_t f = output_lay.feature();
- size_t x = output_lay.spatial(0);
- size_t y = output_lay.spatial(1);
+ auto b = output_lay.batch();
+ auto f = output_lay.feature();
+ auto x = output_lay.spatial(0);
+ auto y = output_lay.spatial(1);
cldnn::mem_lock<T> ref_ptr(out_ref, get_test_stream());
cldnn::mem_lock<T> opt_ptr(out_opt, get_test_stream());
auto ref_x_pitch = get_x_pitch(output_lay);
auto opt_x_pitch = get_x_pitch(opt_output_lay);
- for (size_t bi = 0; bi < b; ++bi) {
- for (size_t fi = 0; fi < f; ++fi) {
- for (size_t yi = 0; yi < y; ++yi) {
+ for (auto bi = 0; bi < b; ++bi) {
+ for (auto fi = 0; fi < f; ++fi) {
+ for (auto yi = 0; yi < y; ++yi) {
auto ref_out_coords = tensor(batch(bi), feature(fi), spatial(0, yi, 0, 0));
auto ref_out_offset = output_lay.get_linear_offset(ref_out_coords);
auto opt_out_offset = opt_output_lay.get_linear_offset(ref_out_coords);
- for (size_t xi = 0; xi < x; ++xi) {
+ for (auto xi = 0; xi < x; ++xi) {
auto ref_out_val = ref_ptr[ref_out_offset + xi * ref_x_pitch];
auto opt_out_val = opt_ptr[opt_out_offset + xi * opt_x_pitch];
if (ref_out_val != opt_out_val) {
diff --git a/src/plugins/intel_gpu/tests/unit/test_cases/convolution_gpu_test.cpp b/src/plugins/intel_gpu/tests/unit/test_cases/convolution_gpu_test.cpp
index 9602168b892..198bc7a7d08 100644
--- a/src/plugins/intel_gpu/tests/unit/test_cases/convolution_gpu_test.cpp
+++ b/src/plugins/intel_gpu/tests/unit/test_cases/convolution_gpu_test.cpp
@@ -2460,7 +2460,7 @@ TEST(convolution_f32_fw_gpu, basic_convolution_input_and_output_padding) {
{ 2, 1 },
false,
ov::op::PadType::EXPLICIT);
- conv.output_paddings = { padding{ { 0,0,x_pad,y_pad }, 0 } };
+ conv.output_paddings = { padding{ { 0,0,y_pad,x_pad }, 0 } };
topology topology(
input_layout("input", input->get_layout()),
@@ -6012,7 +6012,10 @@ void blockedFormatZeroCheck(cldnn::memory::ptr out_mem) {
batch_blocked = true;
const int block_size = 16;
- auto output_tensor = out_mem->get_layout().get_buffer_size();
+ const auto& padded_dims = out_mem->get_layout().get_padded_dims();
+ auto default_fmt = format::get_default_format(padded_dims.size(),
+ format::is_weights_format(out_mem->get_layout().format), format::is_grouped(out_mem->get_layout().format));
+ auto output_tensor = tensor(default_fmt, padded_dims);
const int b = output_tensor.batch[0];
const int f = output_tensor.feature[0];
const int spatials = std::accumulate(output_tensor.spatial.begin(), output_tensor.spatial.end(), 1, std::multiplies<int>());
@@ -9189,18 +9192,18 @@ public:
// Output padding
auto p1 = std::make_shared<convolution>("convolution_no_relu", input_info("input0"), weights, bias, 1, stride_sizes[1], dilation_sizes[1], pad_sizes[1], pad_sizes[1], false, ov::op::PadType::EXPLICIT);
- p1->output_paddings = {{ { 0, 0, 2, 4 }, { 0, 0, 0, 19 } }};
+ p1->output_paddings = {{ { 0, 0, 4, 2 }, { 0, 0, 19, 0 } }};
all_layer_params.push_back(p1);
auto p2 = std::make_shared<convolution>("convolution_no_relu", input_info("input0"), weights, bias, 1, stride_sizes[2], dilation_sizes[2], pad_sizes[2], pad_sizes[2], false, ov::op::PadType::EXPLICIT);
- p2->output_paddings = {{ { 0, 0, 1, 0 }, { 0, 0, 13, 9 } }};
+ p2->output_paddings = {{ { 0, 0, 0, 1 }, { 0, 0, 9, 13 } }};
all_layer_params.push_back(p2);
// Input + Output padding
auto p3 = std::make_shared<convolution>("convolution_no_relu", input_info("reorder0"), weights, bias, 1, stride_sizes[0], dilation_sizes[0], pad_sizes[0], pad_sizes[0], false, ov::op::PadType::EXPLICIT);
- p3->output_paddings = {{ { 0, 0, 1, 5 }, { 0, 0, 19, 4 } }};
+ p3->output_paddings = {{ { 0, 0, 5, 1 }, { 0, 0, 4, 19 } }};
all_layer_params.push_back(p3);
auto p4 = std::make_shared<convolution>("convolution_no_relu", input_info("reorder0"), weights, bias, 1, stride_sizes[3], dilation_sizes[3], pad_sizes[3], pad_sizes[3], false, ov::op::PadType::EXPLICIT);
- p4->output_paddings = {{ { 0, 0, 1, 2 }, { 0, 0, 3, 4 } }};
+ p4->output_paddings = {{ { 0, 0, 2, 1 }, { 0, 0, 4, 3 } }};
all_layer_params.push_back(p4);
return all_layer_params;
@@ -9340,7 +9343,10 @@ public:
cldnn::mem_lock<Type> bias_mem(inputs[2], get_test_stream());
cldnn::mem_lock<Type> output_mem(output, get_test_stream());
- tensor output_buffer_size = output->get_layout().get_buffer_size();
+ const auto& padded_dims = output->get_layout().get_padded_dims();
+ auto default_fmt = format::get_default_format(padded_dims.size(),
+ format::is_weights_format(output->get_layout().format), format::is_grouped(output->get_layout().format));
+ tensor output_buffer_size = tensor(default_fmt, padded_dims);
// Initialized output with zeros.
std::fill(output_mem.begin(), output_mem.end(), static_cast<Type>(0));
@@ -9351,8 +9357,8 @@ public:
for (int y = 0; y < output_size_y; y++) {
for (int x = 0; x < output_size_x; x++) {
int output_index = (b * output_buffer_size.feature[0] + out_f) * output_buffer_size.spatial[1] * output_buffer_size.spatial[0];
- tensor lower_output_padding = convolution->output_paddings[0].lower_size();
- output_index += (lower_output_padding.spatial[1] + y) * output_buffer_size.spatial[0] + lower_output_padding.spatial[0] + x;
+ const auto& lower_output_padding = convolution->output_paddings[0]._lower_size;
+ output_index += (lower_output_padding[2 + 0] + y) * output_buffer_size.spatial[0] + lower_output_padding[2 + 1] + x;
output_mem[output_index] += bias_mem[out_f];
}
@@ -9376,8 +9382,8 @@ public:
int output_yi = y;
int output_xi = x;
auto output_index = (output_bi * output_buffer_size.feature[0] + output_fi) * output_buffer_size.spatial[1] * output_buffer_size.spatial[0];
- tensor lower_output_padding = convolution->output_paddings[0].lower_size();
- output_index += (lower_output_padding.spatial[1] + output_yi) * output_buffer_size.spatial[0] + lower_output_padding.spatial[0] + output_xi;
+ const auto& lower_output_padding = convolution->output_paddings[0]._lower_size;
+ output_index += (lower_output_padding[2 + 0] + output_yi) * output_buffer_size.spatial[0] + lower_output_padding[2 + 1] + output_xi;
for (int kernel_y = 0; kernel_y < weights_size.spatial[1]; kernel_y++) {
int input_yi = static_cast<int>(y * stride[0] - pad[0] + kernel_y * dilation[0]);
diff --git a/src/plugins/intel_gpu/tests/unit/test_cases/eltwise_gpu_test.cpp b/src/plugins/intel_gpu/tests/unit/test_cases/eltwise_gpu_test.cpp
index 5900edff6be..fa529293b92 100644
--- a/src/plugins/intel_gpu/tests/unit/test_cases/eltwise_gpu_test.cpp
+++ b/src/plugins/intel_gpu/tests/unit/test_cases/eltwise_gpu_test.cpp
@@ -97,9 +97,9 @@ void generic_eltwise_test(cldnn::format test_input_fmt, int input_b, int input_f
topology topology;
topology.add(input_layout("input1", input1->get_layout()));
topology.add(input_layout("input2", input2->get_layout()));
- topology.add(reorder("reorder1", input_info("input1"), input1->get_layout().with_padding(padding{{ 0, 0, input_padding_x, input_padding_y }, 0 })));
+ topology.add(reorder("reorder1", input_info("input1"), input1->get_layout().with_padding(padding{{ 0, 0, input_padding_y, input_padding_x }, 0 })));
auto eltwise_prim = eltwise("eltwise", { input_info("reorder1"), input_info("input2") }, mode, DEFAULT_BROADCAST_SPEC);
- eltwise_prim.output_paddings = { padding{ { 0, 0, output_padding_x, output_padding_y }, 0 } };
+ eltwise_prim.output_paddings = { padding{ { 0, 0, output_padding_y, output_padding_x }, 0 } };
topology.add(eltwise_prim);
primitive_id out_id = "eltwise";
if (relu)
@@ -267,9 +267,9 @@ void generic_eltwise_int_test(cldnn::format test_input_fmt,
topology topology;
topology.add(input_layout("input1", input1->get_layout()));
topology.add(input_layout("input2", input2->get_layout()));
- topology.add(reorder("reorder1", input_info("input1"), input1->get_layout().with_padding(padding{{ 0, 0, input_padding_x, input_padding_y }, 0 })));
+ topology.add(reorder("reorder1", input_info("input1"), input1->get_layout().with_padding(padding{{ 0, 0, input_padding_y, input_padding_x }, 0 })));
auto eltwise_prim = eltwise("eltwise", { input_info("reorder1"), input_info("input2") }, mode, DEFAULT_BROADCAST_SPEC);
- eltwise_prim.output_paddings = { padding{ { 0, 0, output_padding_x, output_padding_y }, 0 } };
+ eltwise_prim.output_paddings = { padding{ { 0, 0, output_padding_y, output_padding_x }, 0 } };
topology.add(eltwise_prim);
network network(engine, topology, get_test_default_config(engine));
@@ -1647,7 +1647,8 @@ TEST(eltwise_gpu_f32, dynamic_padding) {
ov::Shape in_shape = {2, 2, 2, 2};
auto in_layout_1 = layout{ov::PartialShape::dynamic(in_shape.size()), data_types::f32, format::bfyx};
auto in_const_layout = layout{{1, 1, 1, 2}, data_types::f32, format::bfyx};
- auto in_layout_2 = layout{ov::PartialShape::dynamic(in_shape.size()), data_types::f32, format::bfyx, {{0, 0, 1, 0}, {0, 0, 1, 0}, 0.0f, tensor({0, 0, 1, 0}, 0)}};
+ const padding::DynamicDimsMask mask("1000");
+ auto in_layout_2 = layout{ov::PartialShape::dynamic(in_shape.size()), data_types::f32, format::bfyx, padding{{0, 0, 0, 1}, {0, 0, 0, 1}, mask}};
auto in_mem_layout = layout{ov::PartialShape(in_shape), data_types::f32, format::bfyx};
auto in_const_mem_layout = layout{{1, 1, 1, 2}, data_types::f32, format::bfyx};
auto input1 = engine.allocate_memory(in_mem_layout);
@@ -2868,8 +2869,8 @@ TEST(eltwise_gpu_f32, max_basic_in4x4x4x4_input_padding) {
topology topology;
topology.add(input_layout("input", input->get_layout()));
topology.add(input_layout("input2", input2->get_layout()));
- topology.add(reorder("reorder", input_info("input"), input->get_layout().with_padding(padding{ { 0, 0, 2, 1 }, 0 })));
- topology.add(reorder("reorder2", input_info("input2"), input->get_layout().with_padding(padding{ { 0, 0, 2, 1 }, 0 })));
+ topology.add(reorder("reorder", input_info("input"), input->get_layout().with_padding(padding{ { 0, 0, 1, 2 }, 0 })));
+ topology.add(reorder("reorder2", input_info("input2"), input->get_layout().with_padding(padding{ { 0, 0, 1, 2 }, 0 })));
topology.add(eltwise("eltwise", { input_info("reorder"), input_info("reorder2") }, eltwise_mode::max));
set_values(input, {
@@ -3139,9 +3140,9 @@ TEST(eltwise_gpu_f32, max_3inputs_in4x4x4x4_input_padding) {
topology.add(input_layout("input", input->get_layout()));
topology.add(input_layout("input2", input2->get_layout()));
topology.add(input_layout("input3", input3->get_layout()));
- topology.add(reorder("reorder", input_info("input"), input->get_layout().with_padding(padding{ { 0, 0, 2, 1 }, 0 })));
- topology.add(reorder("reorder2", input_info("input2"), input->get_layout().with_padding(padding{ { 0, 0, 2, 1 }, 0 })));
- topology.add(reorder("reorder3", input_info("input3"), input->get_layout().with_padding(padding{ { 0, 0, 2, 1 }, 0 })));
+ topology.add(reorder("reorder", input_info("input"), input->get_layout().with_padding(padding{ { 0, 0, 1, 2 }, 0 })));
+ topology.add(reorder("reorder2", input_info("input2"), input->get_layout().with_padding(padding{ { 0, 0, 1, 2 }, 0 })));
+ topology.add(reorder("reorder3", input_info("input3"), input->get_layout().with_padding(padding{ { 0, 0, 1, 2 }, 0 })));
topology.add(eltwise("eltwise", { input_info("reorder"), input_info("reorder2"), input_info("reorder3") }, eltwise_mode::max));
set_values(input, {
@@ -3804,7 +3805,7 @@ TEST(eltwise_gpu_f16, bfyx_and_fs_b_yx_fsv32_output_padding) {
golden_topology.add(input_layout("input1", input1->get_layout()));
golden_topology.add(input_layout("input2", input2->get_layout()));
auto golden_eltwise_prim = eltwise("eltwise", input_info("input1"), input_info("input2"), eltwise_mode::sum, DEFAULT_BROADCAST_SPEC);
- golden_eltwise_prim.output_paddings = { padding{ {0,0,5,10} , 0 } };
+ golden_eltwise_prim.output_paddings = { padding{ {0,0,10,5} , 0 } };
golden_topology.add(golden_eltwise_prim);
network golden_network(engine, golden_topology, get_test_default_config(engine));
@@ -3822,10 +3823,10 @@ TEST(eltwise_gpu_f16, bfyx_and_fs_b_yx_fsv32_output_padding) {
FS_B_YX_FSV32_OUTPUT_topology.add(reorder("reorder1", input_info("input1"), layout(data_types::f16, format::fs_b_yx_fsv32, input_tensor)));
FS_B_YX_FSV32_OUTPUT_topology.add(reorder("reorder2", input_info("input2"), layout(data_types::f16, format::byxf, input_tensor)));
auto FS_B_YX_FSV32_OUTPUT_eltwise_prim = eltwise("eltwise", input_info("reorder1"), input_info("reorder2"), eltwise_mode::sum, DEFAULT_BROADCAST_SPEC);
- FS_B_YX_FSV32_OUTPUT_eltwise_prim.output_paddings = { padding{ {0,0,5,10} , 0 } };
+ FS_B_YX_FSV32_OUTPUT_eltwise_prim.output_paddings = { padding{ {0,0,10,5} , 0 } };
FS_B_YX_FSV32_OUTPUT_topology.add(FS_B_YX_FSV32_OUTPUT_eltwise_prim);
FS_B_YX_FSV32_OUTPUT_topology.add(reorder("reorderOutput", input_info("eltwise"), layout(data_types::f16, format::bfyx, input_tensor,
- padding{ {0,0,5,10} , 0 })));
+ padding{ {0,0,10,5} , 0 })));
network FS_B_YX_FSV32_OUTPUT_network(engine, FS_B_YX_FSV32_OUTPUT_topology, get_test_default_config(engine));
FS_B_YX_FSV32_OUTPUT_network.set_input_data("input1", input1);
@@ -3842,10 +3843,10 @@ TEST(eltwise_gpu_f16, bfyx_and_fs_b_yx_fsv32_output_padding) {
BYXF_OUTPUT_topology.add(reorder("reorder1", input_info("input1"), layout(data_types::f16, format::byxf, input_tensor)));
BYXF_OUTPUT_topology.add(reorder("reorder2", input_info("input2"), layout(data_types::f16, format::fs_b_yx_fsv32, input_tensor)));
auto BYXF_OUTPUT_eltwise_prim = eltwise("eltwise", input_info("reorder1"), input_info("reorder2"), eltwise_mode::sum, DEFAULT_BROADCAST_SPEC);
- BYXF_OUTPUT_eltwise_prim.output_paddings = { padding{ {0,0,5,10} , 0 } };
+ BYXF_OUTPUT_eltwise_prim.output_paddings = { padding{ {0,0,10,5} , 0 } };
BYXF_OUTPUT_topology.add(BYXF_OUTPUT_eltwise_prim);
BYXF_OUTPUT_topology.add(reorder("reorderOutput", input_info("eltwise"), layout(data_types::f16, format::bfyx, input_tensor,
- padding{ {0,0,5,10} , 0 })));
+ padding{ {0,0,10,5} , 0 })));
network BYXF_OUTPUT_network(engine, BYXF_OUTPUT_topology, get_test_default_config(engine));
BYXF_OUTPUT_network.set_input_data("input1", input1);
@@ -3892,8 +3893,8 @@ TEST(eltwise_gpu_f16, bfyx_and_fs_b_yx_fsv32_input_padding)
topology golden_topology;
golden_topology.add(input_layout("input1", input1->get_layout()));
golden_topology.add(input_layout("input2", input2->get_layout()));
- golden_topology.add(reorder("reorder1", input_info("input1"), layout(data_types::f16, format::bfyx, input_tensor, padding{ {0,0,10,15},0.0f })));
- golden_topology.add(reorder("reorder2", input_info("input2"), layout(data_types::f16, format::bfyx, input_tensor, padding{ {0,0,5,7},0.0f })));
+ golden_topology.add(reorder("reorder1", input_info("input1"), layout(data_types::f16, format::bfyx, input_tensor, padding{ {0,0,15,10}})));
+ golden_topology.add(reorder("reorder2", input_info("input2"), layout(data_types::f16, format::bfyx, input_tensor, padding{ {0,0,7,5}})));
golden_topology.add(eltwise("eltwise", input_info("input1"), input_info("input2"), eltwise_mode::sum));
network golden_network(engine, golden_topology, get_test_default_config(engine));
@@ -3908,8 +3909,8 @@ TEST(eltwise_gpu_f16, bfyx_and_fs_b_yx_fsv32_input_padding)
topology FS_B_YX_FSV32_OUTPUT_topology;
FS_B_YX_FSV32_OUTPUT_topology.add(input_layout("input1", input1->get_layout()));
FS_B_YX_FSV32_OUTPUT_topology.add(input_layout("input2", input2->get_layout()));
- FS_B_YX_FSV32_OUTPUT_topology.add(reorder("reorder1", input_info("input1"), layout(data_types::f16, format::fs_b_yx_fsv32, input_tensor, padding{ {0,0,10,15},0.0f })));
- FS_B_YX_FSV32_OUTPUT_topology.add(reorder("reorder2", input_info("input2"), layout(data_types::f16, format::byxf, input_tensor, padding{ {0,0,5,7},0.0f })));
+ FS_B_YX_FSV32_OUTPUT_topology.add(reorder("reorder1", input_info("input1"), layout(data_types::f16, format::fs_b_yx_fsv32, input_tensor, padding{ {0,0,15,10} })));
+ FS_B_YX_FSV32_OUTPUT_topology.add(reorder("reorder2", input_info("input2"), layout(data_types::f16, format::byxf, input_tensor, padding{ {0,0,7,5} })));
FS_B_YX_FSV32_OUTPUT_topology.add(eltwise("eltwise", input_info("reorder1"), input_info("reorder2"), eltwise_mode::sum));
FS_B_YX_FSV32_OUTPUT_topology.add(reorder("reorderOutput", input_info("eltwise"), layout(data_types::f16, format::bfyx, input_tensor)));
@@ -3925,8 +3926,8 @@ TEST(eltwise_gpu_f16, bfyx_and_fs_b_yx_fsv32_input_padding)
topology BYXF_OUTPUT_topology;
BYXF_OUTPUT_topology.add(input_layout("input1", input1->get_layout()));
BYXF_OUTPUT_topology.add(input_layout("input2", input2->get_layout()));
- BYXF_OUTPUT_topology.add(reorder("reorder1", input_info("input1"), layout(data_types::f16, format::byxf, input_tensor, padding{ {0,0,10,15},0.0f })));
- BYXF_OUTPUT_topology.add(reorder("reorder2", input_info("input2"), layout(data_types::f16, format::fs_b_yx_fsv32, input_tensor, padding{ {0,0,5,7},0.0f })));
+ BYXF_OUTPUT_topology.add(reorder("reorder1", input_info("input1"), layout(data_types::f16, format::byxf, input_tensor, padding{ {0,0,15,10} })));
+ BYXF_OUTPUT_topology.add(reorder("reorder2", input_info("input2"), layout(data_types::f16, format::fs_b_yx_fsv32, input_tensor, padding{ {0,0,7,5} })));
BYXF_OUTPUT_topology.add(eltwise("eltwise", input_info("reorder1"), input_info("reorder2"), eltwise_mode::sum));
BYXF_OUTPUT_topology.add(reorder("reorderOutput", input_info("eltwise"), layout(data_types::f16, format::bfyx, input_tensor)));
diff --git a/src/plugins/intel_gpu/tests/unit/test_cases/gemm_gpu_test.cpp b/src/plugins/intel_gpu/tests/unit/test_cases/gemm_gpu_test.cpp
index 86e054ec932..7d62a2d437a 100644
--- a/src/plugins/intel_gpu/tests/unit/test_cases/gemm_gpu_test.cpp
+++ b/src/plugins/intel_gpu/tests/unit/test_cases/gemm_gpu_test.cpp
@@ -415,19 +415,19 @@ public:
ov::Shape in2_shape_aligned = { aligned_batch1_size, aligned_batch2_size, aligned_k_size, aligned_n_size };
// Use dynamic padding for all BFYX dimensions
- tensor dyn_pad_dims_input1({0, 0, 0, 0}, 0);
- tensor dyn_pad_dims_input2({0, 0, 0, 0}, 0);
+ padding::DynamicDimsMask dyn_pad_dims_input1;
+ padding::DynamicDimsMask dyn_pad_dims_input2;
if (n_dim_only) {
- dyn_pad_dims_input1 = tensor({0, 0, 0, 0}, 0);
- dyn_pad_dims_input2 = tensor({0, 0, 1, 0}, 0);
+ dyn_pad_dims_input1 = 0ul;
+ dyn_pad_dims_input2 = padding::DynamicDimsMask("1000");
} else {
- dyn_pad_dims_input1 = tensor({1, 1, 1, 1}, 0);
- dyn_pad_dims_input2 = tensor({1, 1, 1, 1}, 0);
+ dyn_pad_dims_input1 = padding::DynamicDimsMask("1111");
+ dyn_pad_dims_input2 = padding::DynamicDimsMask("1111");
}
- auto in1_layout = layout{ {-1, -1, -1, -1}, data_types::f16, format::bfyx, padding({0, 0, 0, 0}, {0, 0, 0, 0}, 0.0f, dyn_pad_dims_input1)};
- auto in2_layout = layout{ {-1, -1, -1, -1}, data_types::f16, format::bfyx, padding({0, 0, 0, 0}, {0, 0, 0, 0}, 0.0f, dyn_pad_dims_input2)};
+ auto in1_layout = layout{ {-1, -1, -1, -1}, data_types::f16, format::bfyx, padding({0, 0, 0, 0}, {0, 0, 0, 0}, dyn_pad_dims_input1)};
+ auto in2_layout = layout{ {-1, -1, -1, -1}, data_types::f16, format::bfyx, padding({0, 0, 0, 0}, {0, 0, 0, 0}, dyn_pad_dims_input2)};
auto aligned_input1_mem = engine.allocate_memory({ov::PartialShape(in1_shape_aligned), data_types::f16, format::bfyx});
auto aligned_input2_mem = engine.allocate_memory({ov::PartialShape(in2_shape_aligned), data_types::f16, format::bfyx});
@@ -435,14 +435,14 @@ public:
auto input1_mem = engine.reinterpret_buffer(*aligned_input1_mem, layout{ov::PartialShape(in1_shape),
data_types::f16,
format::bfyx,
- n_dim_only ? padding({0, 0, 0, 0}, {0, 0, 0, 0}, 0.0f, dyn_pad_dims_input1) :
- padding({padding_size_batch1, 0, 0, 0}, {0, padding_size_batch2, padding_size_k, padding_size_m}, 0.0f, dyn_pad_dims_input1)});
+ n_dim_only ? padding({0, 0, 0, 0}, {0, 0, 0, 0}, dyn_pad_dims_input1) :
+ padding({padding_size_batch1, 0, 0, 0}, {0, padding_size_batch2, padding_size_m, padding_size_k}, dyn_pad_dims_input1)});
auto input2_mem = engine.reinterpret_buffer(*aligned_input2_mem, layout{ov::PartialShape(in2_shape),
data_types::f16,
format::bfyx,
- n_dim_only ? padding({0, 0, 0, 0}, {0, 0, padding_size_n, 0}, 0.0f, dyn_pad_dims_input2) :
- padding({0, padding_size_batch2, 0, 0}, {padding_size_batch1, 0, padding_size_n, padding_size_k}, 0.0f, dyn_pad_dims_input2)});
+ n_dim_only ? padding({0, 0, 0, 0}, {0, 0, 0, padding_size_n}, dyn_pad_dims_input2) :
+ padding({0, padding_size_batch2, 0, 0}, {padding_size_batch1, 0, padding_size_k, padding_size_n}, dyn_pad_dims_input2)});
auto input_1_data = rg.generate_random_1d<ov::float16>(ov::shape_size(in1_shape), -2, 2);
auto input_2_data = rg.generate_random_1d<ov::float16>(ov::shape_size(in2_shape), -2, 2);
@@ -2707,19 +2707,19 @@ public:
ov::Shape in2_shape_aligned = { aligned_batch1_size, aligned_batch2_size, aligned_k_size, aligned_n_size };
// Use dynamic padding for all BFYX dimensions
- tensor dyn_pad_dims_input1({0, 0, 0, 0}, 0);
- tensor dyn_pad_dims_input2({0, 0, 0, 0}, 0);
+ padding::DynamicDimsMask dyn_pad_dims_input1;
+ padding::DynamicDimsMask dyn_pad_dims_input2;
if (n_dim_only) {
- dyn_pad_dims_input1 = tensor({0, 0, 0, 0}, 0);
- dyn_pad_dims_input2 = tensor({0, 0, 1, 0}, 0);
+ dyn_pad_dims_input1 = padding::EMPTY_MASK; //tensor({0, 0, 0, 0}, 0).sizes();
+ dyn_pad_dims_input2 = padding::DynamicDimsMask("1000"); //tensor({0, 0, 1, 0}, 0).sizes();
} else {
- dyn_pad_dims_input1 = tensor({1, 1, 1, 1}, 0);
- dyn_pad_dims_input2 = tensor({1, 1, 1, 1}, 0);
+ dyn_pad_dims_input1 = padding::DynamicDimsMask("1111"); //tensor({1, 1, 1, 1}, 0).sizes();
+ dyn_pad_dims_input2 = padding::DynamicDimsMask("1111"); //tensor({1, 1, 1, 1}, 0).sizes();
}
- auto in1_layout = layout{ {-1, -1, -1, -1}, data_types::f16, format::bfyx, padding({0, 0, 0, 0}, {0, 0, 0, 0}, 0.0f, dyn_pad_dims_input1)};
- auto in2_layout = layout{ {-1, -1, -1, -1}, data_types::f16, format::bfyx, padding({0, 0, 0, 0}, {0, 0, 0, 0}, 0.0f, dyn_pad_dims_input2)};
+ auto in1_layout = layout{ {-1, -1, -1, -1}, data_types::f16, format::bfyx, padding({0, 0, 0, 0}, {0, 0, 0, 0}, dyn_pad_dims_input1)};
+ auto in2_layout = layout{ {-1, -1, -1, -1}, data_types::f16, format::bfyx, padding({0, 0, 0, 0}, {0, 0, 0, 0}, dyn_pad_dims_input2)};
auto aligned_input1_mem = engine.allocate_memory({ov::PartialShape(in1_shape_aligned), data_types::f16, format::bfyx});
auto aligned_input2_mem = engine.allocate_memory({ov::PartialShape(in2_shape_aligned), data_types::f16, format::bfyx});
@@ -2727,14 +2727,14 @@ public:
auto input1_mem = engine.reinterpret_buffer(*aligned_input1_mem, layout{ov::PartialShape(in1_shape),
data_types::f16,
format::bfyx,
- n_dim_only ? padding({0, 0, 0, 0}, {0, 0, 0, 0}, 0.0f, dyn_pad_dims_input1) :
- padding({0, 0, 0, 0}, {padding_size_batch1, padding_size_batch2, padding_size_k, padding_size_m}, 0.0f, dyn_pad_dims_input1)});
+ n_dim_only ? padding({0, 0, 0, 0}, {0, 0, 0, 0}, dyn_pad_dims_input1) :
+ padding({0, 0, 0, 0}, {padding_size_batch1, padding_size_batch2, padding_size_m, padding_size_k}, dyn_pad_dims_input1)});
auto input2_mem = engine.reinterpret_buffer(*aligned_input2_mem, layout{ov::PartialShape(in2_shape),
data_types::f16,
format::bfyx,
- n_dim_only ? padding({0, 0, 0, 0}, {0, 0, padding_size_n, 0}, 0.0f, dyn_pad_dims_input2) :
- padding({0, 0, 0, 0}, {padding_size_batch1, padding_size_batch2, padding_size_n, padding_size_k}, 0.0f, dyn_pad_dims_input2)});
+ n_dim_only ? padding({0, 0, 0, 0}, {0, 0, 0, padding_size_n}, dyn_pad_dims_input2) :
+ padding({0, 0, 0, 0}, {padding_size_batch1, padding_size_batch2, padding_size_k, padding_size_n}, dyn_pad_dims_input2)});
auto input_1_data = rg.generate_random_1d<ov::float16>(ov::shape_size(in1_shape), -2, 2);
auto input_2_data = rg.generate_random_1d<ov::float16>(ov::shape_size(in2_shape), -2, 2);
@@ -2858,12 +2858,10 @@ public:
ov::Shape in1_shape_aligned = in1_shape;
ov::Shape in2_shape_aligned = { 1, BATCH_SIZE, aligned_n_size, K_SIZE };
- tensor dyn_pad_dims_input2({0, 0, 0, 0}, 0);
- dyn_pad_dims_input2 = tensor({0, 0, 0, 1}, 0);
-
+ padding::DynamicDimsMask dyn_pad_dims_input2("0100"); // {0, 0, 1, 0};
auto in1_layout = layout{ {-1, -1, -1, -1}, data_types::f16, format::bfyx};
- auto in2_layout = layout{ {-1, -1, -1, -1}, data_types::f16, format::bfyx, padding({0, 0, 0, 0}, {0, 0, 0, 0}, 0.0f, dyn_pad_dims_input2)};
+ auto in2_layout = layout{ {-1, -1, -1, -1}, data_types::f16, format::bfyx, padding({0, 0, 0, 0}, {0, 0, 0, 0}, dyn_pad_dims_input2)};
auto aligned_input2_mem = engine.allocate_memory({ov::PartialShape(in2_shape_aligned), data_types::f16, format::bfyx});
@@ -2872,7 +2870,7 @@ public:
auto input2_mem = engine.reinterpret_buffer(*aligned_input2_mem, layout{ov::PartialShape(in2_shape),
data_types::f16,
format::bfyx,
- padding({0, 0, 0, 0}, {0, 0, 0, padding_size_n}, 0.0f, dyn_pad_dims_input2)});
+ padding({0, 0, 0, 0}, {0, 0, padding_size_n, 0}, dyn_pad_dims_input2)});
auto input_1_data = rg.generate_random_1d<ov::float16>(ov::shape_size(in1_shape), -2, 2);
auto input_2_data = rg.generate_random_1d<ov::float16>(ov::shape_size(in2_shape), -2, 2);
diff --git a/src/plugins/intel_gpu/tests/unit/test_cases/hash_key_gpu_test.cpp b/src/plugins/intel_gpu/tests/unit/test_cases/hash_key_gpu_test.cpp
index c2f6c1a3198..fb302229980 100644
--- a/src/plugins/intel_gpu/tests/unit/test_cases/hash_key_gpu_test.cpp
+++ b/src/plugins/intel_gpu/tests/unit/test_cases/hash_key_gpu_test.cpp
@@ -44,7 +44,7 @@ public:
const auto params_hash = prim_inst->get_impl_params()->hash();
ASSERT_EQ(primitive_hash, 4145865612957978777UL);
- ASSERT_EQ(params_hash, 13330229854511334999UL);
+ ASSERT_EQ(params_hash, 5324604476707368882UL);
}
void test_fc_basic(bool is_caching_test) {
@@ -72,10 +72,10 @@ public:
const auto params_hash = primitve->type->get_fake_aligned_params(*prim_inst->get_impl_params()).hash();
if (!engine.get_device_info().supports_immad) {
ASSERT_EQ(primitive_hash, 8017451717095756666UL);
- ASSERT_EQ(params_hash, 4374037685392472517UL);
+ ASSERT_EQ(params_hash, 8889154389021912103UL);
} else {
ASSERT_EQ(primitive_hash, 8017451717095756666UL);
- ASSERT_EQ(params_hash, 17704411706121042861UL);
+ ASSERT_EQ(params_hash, 10847775446937354749UL);
}
}
@@ -105,7 +105,7 @@ public:
const auto params_hash = prim_inst->get_impl_params()->hash();
ASSERT_EQ(primitive_hash, 8439414674502129643UL);
- ASSERT_EQ(params_hash, 18030913546439900045UL);
+ ASSERT_EQ(params_hash, 17825246500238118561UL);
}
void test_gemm_basic(bool is_caching_test) {
@@ -128,7 +128,7 @@ public:
const auto primitive_hash = primitve->hash();
const auto params_hash = prim_inst->get_impl_params()->hash();
ASSERT_EQ(primitive_hash, 13388149315122571178UL);
- ASSERT_EQ(params_hash, 2108356776161884759UL);
+ ASSERT_EQ(params_hash, 17826282051937408484UL);
}
void test_permute_basic(bool is_caching_test) {
@@ -149,7 +149,7 @@ public:
const auto params_hash = prim_inst->get_impl_params()->hash();
ASSERT_EQ(primitive_hash, 4658575237077439700UL);
- ASSERT_EQ(params_hash, 10588150284756843899UL);
+ ASSERT_EQ(params_hash, 13514742184580394157UL);
}
void test_reorder_basic(bool is_caching_test) {
@@ -176,7 +176,7 @@ public:
const auto params_hash = prim_inst->get_impl_params()->hash();
ASSERT_EQ(primitive_hash, 16293979194373117693UL);
- ASSERT_EQ(params_hash, 3339057685641907457UL);
+ ASSERT_EQ(params_hash, 17794336956091484480UL);
}
void test_reshape_basic(bool is_caching_test) {
@@ -202,7 +202,7 @@ public:
const auto params_hash = prim_inst->get_impl_params()->hash();
ASSERT_EQ(primitive_hash, 1534749073560581535UL);
- ASSERT_EQ(params_hash, 4349925423879269352UL);
+ ASSERT_EQ(params_hash, 6798482801217293235UL);
}
void test_conv_basic(bool is_caching_test) {
@@ -227,7 +227,7 @@ public:
const auto params_hash = prim_inst->get_impl_params()->hash();
ASSERT_EQ(primitive_hash, 13549661972131371304UL);
- ASSERT_EQ(params_hash, 17196242702975187963UL);
+ ASSERT_EQ(params_hash, 8974374790280144289UL);
}
void test_quantize_basic(bool is_caching_test) {
@@ -257,7 +257,7 @@ public:
const auto primitive_hash = primitve->hash();
const auto params_hash = prim_inst->get_impl_params()->hash();
ASSERT_EQ(primitive_hash, 4135863035456568493UL);
- ASSERT_EQ(params_hash, 11563701278302723583UL);
+ ASSERT_EQ(params_hash, 2000365791052292402UL);
}
};
diff --git a/src/plugins/intel_gpu/tests/unit/test_cases/lru_caches_gpu_test.cpp b/src/plugins/intel_gpu/tests/unit/test_cases/lru_caches_gpu_test.cpp
index 299490e3d48..ba4e6c95307 100644
--- a/src/plugins/intel_gpu/tests/unit/test_cases/lru_caches_gpu_test.cpp
+++ b/src/plugins/intel_gpu/tests/unit/test_cases/lru_caches_gpu_test.cpp
@@ -133,8 +133,8 @@ struct ImplHasher {
} // namespace
TEST(lru_cache, collisions) {
- auto l1 = layout{{1, 3, 40, 20}, data_types::f32, format::bfyx};
- auto l2 = layout{{1, 3, 39, 83}, data_types::f32, format::bfyx};
+ auto l1 = layout{{1, 3, 27, 85}, data_types::f32, format::bfyx};
+ auto l2 = layout{{1, 3, 26, 24}, data_types::f32, format::bfyx};
auto input1_prim = std::make_shared<input_layout>("input1", l1);
auto input2_prim = std::make_shared<input_layout>("input2", l2);
diff --git a/src/plugins/intel_gpu/tests/unit/test_cases/one_hot_gpu_test.cpp b/src/plugins/intel_gpu/tests/unit/test_cases/one_hot_gpu_test.cpp
index 6ffebdc586b..ecb92fd90ff 100644
--- a/src/plugins/intel_gpu/tests/unit/test_cases/one_hot_gpu_test.cpp
+++ b/src/plugins/intel_gpu/tests/unit/test_cases/one_hot_gpu_test.cpp
@@ -98,11 +98,11 @@ void generic_one_hot_test_int(cldnn::format test_input_fmt, int input_b, int inp
VVVVF<T> output_cpu = one_hot_cpu<T>(input_rnd, one_hot_axis, one_hot_limit, input_padding_y, input_padding_x, output_padding_y, output_padding_x);
ASSERT_EQ(output_layout.format.value, test_input_fmt.value);
- tensor output_tensor = output_layout.get_buffer_size();
- int y_size = output_tensor.spatial[1];
- int x_size = output_tensor.spatial[0];
- int f_size = output_tensor.feature[0];
- int b_size = output_tensor.batch[0];
+ auto output_tensor = output_layout.get_padded_dims();
+ int y_size = output_tensor[2];
+ int x_size = output_tensor[3];
+ int f_size = output_tensor[1];
+ int b_size = output_tensor[0];
ASSERT_EQ(y_size, (int)output_cpu[0][0].size());
ASSERT_EQ(x_size, (int)output_cpu[0][0][0].size());
ASSERT_EQ(f_size, (int)output_cpu[0].size());
@@ -195,12 +195,12 @@ TEST(one_hot_gpu_i32, bfzyx_ax4) {
auto output_layout = output_memory->get_layout();
cldnn::mem_lock<int32_t> output_ptr(output_memory, get_test_stream());
- tensor output_tensor = output_layout.get_buffer_size();
- int z_size = output_tensor.spatial[2];
- int y_size = output_tensor.spatial[1];
- int x_size = output_tensor.spatial[0];
- int f_size = output_tensor.feature[0];
- int b_size = output_tensor.batch[0];
+ auto output_tensor = output_layout.get_padded_dims();
+ int z_size = output_tensor[2];
+ int y_size = output_tensor[3];
+ int x_size = output_tensor[4];
+ int f_size = output_tensor[1];
+ int b_size = output_tensor[0];
ASSERT_EQ(z_size, 2);
ASSERT_EQ(y_size, 1);
ASSERT_EQ(x_size, 5);
@@ -254,12 +254,12 @@ TEST(one_hot_gpu_i64, bfzyx_ax4) {
auto output_layout = output_memory->get_layout();
cldnn::mem_lock<int64_t> output_ptr(output_memory, get_test_stream());
- tensor output_tensor = output_layout.get_buffer_size();
- int z_size = output_tensor.spatial[2];
- int y_size = output_tensor.spatial[1];
- int x_size = output_tensor.spatial[0];
- int f_size = output_tensor.feature[0];
- int b_size = output_tensor.batch[0];
+ auto output_tensor = output_layout.get_padded_dims();
+ int z_size = output_tensor[2];
+ int y_size = output_tensor[3];
+ int x_size = output_tensor[4];
+ int f_size = output_tensor[1];
+ int b_size = output_tensor[0];
ASSERT_EQ(z_size, 2);
ASSERT_EQ(y_size, 1);
ASSERT_EQ(x_size, 5);
@@ -366,12 +366,12 @@ TEST(one_hot_gpu_i64_to_f32, bfyx_ax4) {
auto output_layout = output_memory->get_layout();
cldnn::mem_lock<float> output_ptr(output_memory, get_test_stream());
- tensor output_tensor = output_layout.get_buffer_size();
- int z_size = output_tensor.spatial[2];
- int y_size = output_tensor.spatial[1];
- int x_size = output_tensor.spatial[0];
- int f_size = output_tensor.feature[0];
- int b_size = output_tensor.batch[0];
+ auto output_tensor = output_layout.get_padded_dims();
+ int z_size = output_tensor[2];
+ int y_size = output_tensor[3];
+ int x_size = output_tensor[4];
+ int f_size = output_tensor[1];
+ int b_size = output_tensor[0];
ASSERT_EQ(z_size, 2);
ASSERT_EQ(y_size, 1);
ASSERT_EQ(x_size, 5);
@@ -417,12 +417,12 @@ TEST(one_hot_gpu_i32, bfzyx_ax0) {
auto output_layout = output_memory->get_layout();
cldnn::mem_lock<int32_t> output_ptr(output_memory, get_test_stream());
- tensor output_tensor = output_layout.get_buffer_size();
- int z_size = output_tensor.spatial[2];
- int y_size = output_tensor.spatial[1];
- int x_size = output_tensor.spatial[0];
- int f_size = output_tensor.feature[0];
- int b_size = output_tensor.batch[0];
+ auto output_tensor = output_layout.get_padded_dims();
+ int z_size = output_tensor[2];
+ int y_size = output_tensor[3];
+ int x_size = output_tensor[4];
+ int f_size = output_tensor[1];
+ int b_size = output_tensor[0];
ASSERT_EQ(z_size, 1);
ASSERT_EQ(y_size, 1);
ASSERT_EQ(x_size, 2);
@@ -472,12 +472,12 @@ TEST(one_hot_gpu_i64, bfzyx_ax0) {
auto output_layout = output_memory->get_layout();
cldnn::mem_lock<int64_t> output_ptr(output_memory, get_test_stream());
- tensor output_tensor = output_layout.get_buffer_size();
- int z_size = output_tensor.spatial[2];
- int y_size = output_tensor.spatial[1];
- int x_size = output_tensor.spatial[0];
- int f_size = output_tensor.feature[0];
- int b_size = output_tensor.batch[0];
+ auto output_tensor = output_layout.get_padded_dims();
+ int z_size = output_tensor[2];
+ int y_size = output_tensor[3];
+ int x_size = output_tensor[4];
+ int f_size = output_tensor[1];
+ int b_size = output_tensor[0];
ASSERT_EQ(z_size, 1);
ASSERT_EQ(y_size, 1);
ASSERT_EQ(x_size, 2);
@@ -527,12 +527,12 @@ TEST(one_hot_gpu_i32, bfzyx_ax1) {
auto output_layout = output_memory->get_layout();
cldnn::mem_lock<int32_t> output_ptr(output_memory, get_test_stream());
- tensor output_tensor = output_layout.get_buffer_size();
- int z_size = output_tensor.spatial[2];
- int y_size = output_tensor.spatial[1];
- int x_size = output_tensor.spatial[0];
- int f_size = output_tensor.feature[0];
- int b_size = output_tensor.batch[0];
+ auto output_tensor = output_layout.get_padded_dims();
+ int z_size = output_tensor[2];
+ int y_size = output_tensor[3];
+ int x_size = output_tensor[4];
+ int f_size = output_tensor[1];
+ int b_size = output_tensor[0];
ASSERT_EQ(z_size, 1);
ASSERT_EQ(y_size, 1);
ASSERT_EQ(x_size, 2);
@@ -582,12 +582,12 @@ TEST(one_hot_gpu_i64, bfzyx_ax1) {
auto output_layout = output_memory->get_layout();
cldnn::mem_lock<int64_t> output_ptr(output_memory, get_test_stream());
- tensor output_tensor = output_layout.get_buffer_size();
- int z_size = output_tensor.spatial[2];
- int y_size = output_tensor.spatial[1];
- int x_size = output_tensor.spatial[0];
- int f_size = output_tensor.feature[0];
- int b_size = output_tensor.batch[0];
+ auto output_tensor = output_layout.get_padded_dims();
+ int z_size = output_tensor[2];
+ int y_size = output_tensor[3];
+ int x_size = output_tensor[4];
+ int f_size = output_tensor[1];
+ int b_size = output_tensor[0];
ASSERT_EQ(z_size, 1);
ASSERT_EQ(y_size, 1);
ASSERT_EQ(x_size, 2);
@@ -637,12 +637,12 @@ TEST(one_hot_gpu_i32, bfzyx_ax2) {
auto output_layout = output_memory->get_layout();
cldnn::mem_lock<int32_t> output_ptr(output_memory, get_test_stream());
- tensor output_tensor = output_layout.get_buffer_size();
- int z_size = output_tensor.spatial[2];
- int y_size = output_tensor.spatial[1];
- int x_size = output_tensor.spatial[0];
- int f_size = output_tensor.feature[0];
- int b_size = output_tensor.batch[0];
+ auto output_tensor = output_layout.get_padded_dims();
+ int z_size = output_tensor[2];
+ int y_size = output_tensor[3];
+ int x_size = output_tensor[4];
+ int f_size = output_tensor[1];
+ int b_size = output_tensor[0];
ASSERT_EQ(z_size, 3);
ASSERT_EQ(y_size, 1);
ASSERT_EQ(x_size, 2);
@@ -692,12 +692,12 @@ TEST(one_hot_gpu_i64, bfzyx_ax2) {
auto output_layout = output_memory->get_layout();
cldnn::mem_lock<int64_t> output_ptr(output_memory, get_test_stream());
- tensor output_tensor = output_layout.get_buffer_size();
- int z_size = output_tensor.spatial[2];
- int y_size = output_tensor.spatial[1];
- int x_size = output_tensor.spatial[0];
- int f_size = output_tensor.feature[0];
- int b_size = output_tensor.batch[0];
+ auto output_tensor = output_layout.get_padded_dims();
+ int z_size = output_tensor[2];
+ int y_size = output_tensor[3];
+ int x_size = output_tensor[4];
+ int f_size = output_tensor[1];
+ int b_size = output_tensor[0];
ASSERT_EQ(z_size, 3);
ASSERT_EQ(y_size, 1);
ASSERT_EQ(x_size, 2);
@@ -747,12 +747,12 @@ TEST(one_hot_gpu_i32, bfzyx_ax3) {
auto output_layout = output_memory->get_layout();
cldnn::mem_lock<int32_t> output_ptr(output_memory, get_test_stream());
- tensor output_tensor = output_layout.get_buffer_size();
- int z_size = output_tensor.spatial[2];
- int y_size = output_tensor.spatial[1];
- int x_size = output_tensor.spatial[0];
- int f_size = output_tensor.feature[0];
- int b_size = output_tensor.batch[0];
+ auto output_tensor = output_layout.get_padded_dims();
+ int z_size = output_tensor[2];
+ int y_size = output_tensor[3];
+ int x_size = output_tensor[4];
+ int f_size = output_tensor[1];
+ int b_size = output_tensor[0];
ASSERT_EQ(z_size, 1);
ASSERT_EQ(y_size, 3);
ASSERT_EQ(x_size, 2);
diff --git a/src/plugins/intel_gpu/tests/unit/test_cases/pooling_gpu_test.cpp b/src/plugins/intel_gpu/tests/unit/test_cases/pooling_gpu_test.cpp
index 9f594616d69..9de124918f4 100644
--- a/src/plugins/intel_gpu/tests/unit/test_cases/pooling_gpu_test.cpp
+++ b/src/plugins/intel_gpu/tests/unit/test_cases/pooling_gpu_test.cpp
@@ -913,7 +913,7 @@ TEST(pooling_forward_gpu, offsets_max_yxfb_bfyx_f32_wsiz2x2_wstr2x2_i3x3x1x1_out
auto output_prim = outputs.begin()->second.get_memory();
ASSERT_EQ((int)output_prim->get_layout().count(), 4);
- ASSERT_EQ((int)output_prim->get_layout().get_buffer_size().count(), 16);
+ ASSERT_EQ((int)output_prim->get_layout().get_linear_size(), 16);
cldnn::mem_lock<float> output_ptr (output_prim, get_test_stream());
for (size_t i = 0; i < expected.size(); ++i) {
@@ -958,7 +958,7 @@ TEST(pooling_forward_gpu, offsets_avg_yxfb_bfyx_f32_wsiz2x2_wstr2x2_i2x2x1x1_inp
topology topology;
topology.add(input_layout("input_prim", input_prim->get_layout()));
- topology.add(reorder("reorder", input_info("input_prim"), input_prim->get_layout().with_padding(padding{ {0,0,1,2}, 0 })));
+ topology.add(reorder("reorder", input_info("input_prim"), input_prim->get_layout().with_padding(padding{ {0,0,2,1}, 0 })));
auto pool = pooling("pool_prim", input_info("reorder"), pooling_mode::average, {2, 2}, {2, 2}, {1, 1}, {1, 1}, ov::op::PadType::EXPLICIT, ov::op::RoundingType::FLOOR);
pool.output_paddings = { padding{{0, 0, 2, 2}, 0} };
topology.add(pool);
@@ -1023,7 +1023,7 @@ TEST(pooling_forward_gpu, offsets_max_yxfb_bfyx_f32_wsiz2x2_wstr2x2_i3x3x1x1_inp
topology topology;
topology.add(input_layout("input_prim", input_prim->get_layout()));
- topology.add(reorder("reorder", input_info("input_prim"), input_prim->get_layout().with_padding(padding{ { 0, 0, 1, 2 }, 0 })));
+ topology.add(reorder("reorder", input_info("input_prim"), input_prim->get_layout().with_padding(padding{ { 0, 0, 2, 1 }, 0 })));
auto pool = pooling("pool_prim", input_info("reorder"), pooling_mode::max, {2, 2}, {2, 2}, {1, 1}, {1, 1}, ov::op::PadType::EXPLICIT, ov::op::RoundingType::FLOOR);
pool.output_paddings = { padding{{0, 0, 1, 1}, 0} };
topology.add(pool);
@@ -1051,7 +1051,7 @@ TEST(pooling_forward_gpu, offsets_max_yxfb_bfyx_f32_wsiz2x2_wstr2x2_i3x3x1x1_inp
auto output_prim = outputs.begin()->second.get_memory();
ASSERT_EQ((int)output_prim->get_layout().count(), 4);
- ASSERT_EQ((int)output_prim->get_layout().get_buffer_size().count(), 16);
+ ASSERT_EQ((int)output_prim->get_layout().get_linear_size(), 16);
cldnn::mem_lock<float> output_ptr (output_prim, get_test_stream());
for (size_t i = 0; i < expected.size(); ++i) {
@@ -1096,7 +1096,7 @@ TEST(pooling_forward_gpu, avg_yxfb_bfyx_f32_wsiz2x2_wstr2x2_i2x2x1x1_inpad2x1_ou
topology topology;
topology.add(input_layout("input_prim", input_prim->get_layout()));
- topology.add(reorder("reorder", input_info("input_prim"), input_prim->get_layout().with_padding(padding{ { 0, 0, 2, 1 }, 0 })));
+ topology.add(reorder("reorder", input_info("input_prim"), input_prim->get_layout().with_padding(padding{ { 0, 0, 1, 2 }, 0 })));
auto pool = pooling("pool_prim", input_info("reorder"), pooling_mode::average, { 2, 2 }, { 2, 2 }, { 0, 0 }, { 0, 0 }, ov::op::PadType::EXPLICIT, ov::op::RoundingType::FLOOR);
pool.output_paddings = { padding{ { 0, 0, 2, 2 }, 0 } };
topology.add(pool);
@@ -1166,7 +1166,7 @@ TEST(pooling_forward_gpu, max_yxfb_bfyx_f32_wsiz2x2_wstr2x2_i3x3x1x1_inpad2x1_ou
topology topology;
topology.add(input_layout("input_prim", input_prim->get_layout()));
- topology.add(reorder("reorder", input_info("input_prim"), input_prim->get_layout().with_padding(padding{ { 0, 0, 2, 1 }, 0 })));
+ topology.add(reorder("reorder", input_info("input_prim"), input_prim->get_layout().with_padding(padding{ { 0, 0, 1, 2 }, 0 })));
auto pool = pooling("pool_prim", input_info("reorder"), pooling_mode::max, {2, 2}, {2, 2}, {1, 1}, {1, 1}, ov::op::PadType::EXPLICIT, ov::op::RoundingType::FLOOR);
pool.output_paddings = { padding{{0, 0, 1, 1}, 0} };
topology.add(pool);
@@ -1197,7 +1197,7 @@ TEST(pooling_forward_gpu, max_yxfb_bfyx_f32_wsiz2x2_wstr2x2_i3x3x1x1_inpad2x1_ou
auto output_prim = outputs.begin()->second.get_memory();
ASSERT_EQ((int)output_prim->get_layout().count(), 9);
- ASSERT_EQ((int)output_prim->get_layout().get_buffer_size().count(), 25);
+ ASSERT_EQ((int)output_prim->get_layout().get_linear_size(), 25);
cldnn::mem_lock<float> output_ptr (output_prim, get_test_stream());
for (size_t i = 0; i < expected.size(); ++i) {
@@ -1755,7 +1755,7 @@ TEST(pooling_forward_gpu, fs_b_yx_fsv32_max_1x1x3x3_input_2x2_pool_2x2_stride_2x
auto output_prim = outputs.begin()->second.get_memory();
ASSERT_EQ((int)output_prim->get_layout().count(), 4);
- ASSERT_EQ((int)output_prim->get_layout().get_buffer_size().count(), 16);
+ ASSERT_EQ((int)output_prim->get_layout().get_linear_size(), 16);
cldnn::mem_lock<ov::float16> output_ptr(output_prim, get_test_stream());
@@ -1801,7 +1801,7 @@ TEST(pooling_forward_gpu, fs_b_yx_fsv32_max_1x1x5x5_input_2x2_pool_2x2_stride_2x
topology topology;
topology.add(input_layout("input_prim", input_prim->get_layout()));
- topology.add(reorder("reorder_input", input_info("input_prim"), layout(data_types::f16, format::fs_b_yx_fsv32, input_tensor, padding{ { 0, 0, 2, 1 } , 0 })));
+ topology.add(reorder("reorder_input", input_info("input_prim"), layout(data_types::f16, format::fs_b_yx_fsv32, input_tensor, padding{ { 0, 0, 1, 2 } , 0 })));
auto pool = pooling("pool_prim", input_info("reorder_input"), pooling_mode::max, {2, 2}, {2, 2}, {1, 1}, {1, 1}, ov::op::PadType::EXPLICIT, ov::op::RoundingType::FLOOR);
pool.output_paddings = { padding{{0, 0, 1, 1}, 0} };
topology.add(pool);
@@ -1833,7 +1833,7 @@ TEST(pooling_forward_gpu, fs_b_yx_fsv32_max_1x1x5x5_input_2x2_pool_2x2_stride_2x
auto output_prim = outputs.begin()->second.get_memory();
ASSERT_EQ((int)output_prim->get_layout().count(), 9);
- ASSERT_EQ((int)output_prim->get_layout().get_buffer_size().count(), 25);
+ ASSERT_EQ((int)output_prim->get_layout().get_linear_size(), 25);
cldnn::mem_lock<ov::float16> output_ptr(output_prim, get_test_stream());
@@ -1880,9 +1880,9 @@ TEST(pooling_forward_gpu, fs_b_yx_fsv32_avg_65x5x6x7_input_3x3_pool_4x4_stride_3
{ //GOLDEN TOPOLOGY
topology golden_topology;
golden_topology.add(input_layout("input", input_prim->get_layout()));
- golden_topology.add(reorder("reorder_input", input_info("input"), input_prim->get_layout().with_padding(padding{ {0,0,x_in_pad,y_in_pad},0 })));
+ golden_topology.add(reorder("reorder_input", input_info("input"), input_prim->get_layout().with_padding(padding{ {0,0,y_in_pad,x_in_pad},0 })));
auto pool = pooling("golden_pooling", input_info("reorder_input"), pooling_mode::average, { pool_size, pool_size }, { stride_size, stride_size }, { 0, 0 }, { 0, 0 }, ov::op::PadType::EXPLICIT, ov::op::RoundingType::FLOOR);
- pool.output_paddings = { padding{ { 0, 0, x_out_pad, y_out_pad }, 0 }};
+ pool.output_paddings = { padding{ { 0, 0, y_out_pad, x_out_pad }, 0 }};
golden_topology.add(pool);
network golden_network(engine, golden_topology, get_test_default_config(engine));
golden_network.set_input_data("input", input_prim);
@@ -1898,11 +1898,11 @@ TEST(pooling_forward_gpu, fs_b_yx_fsv32_avg_65x5x6x7_input_3x3_pool_4x4_stride_3
{ //FSV32 TOPOLOGY
topology golden_topology;
golden_topology.add(input_layout("input", input_prim->get_layout()));
- golden_topology.add(reorder("reorder_input", input_info("input"), layout(data_types::f16, format::fs_b_yx_fsv32, input_tensor, padding{ {0, 0, x_in_pad, y_in_pad}, 0 })));
+ golden_topology.add(reorder("reorder_input", input_info("input"), layout(data_types::f16, format::fs_b_yx_fsv32, input_tensor, padding{ {0, 0, y_in_pad, x_in_pad}, 0 })));
auto pool = pooling("fsv32_pooling", input_info("reorder_input"), pooling_mode::average, { pool_size, pool_size }, { stride_size, stride_size }, { 0, 0 }, { 0, 0 }, ov::op::PadType::EXPLICIT, ov::op::RoundingType::FLOOR);
- pool.output_paddings = { padding{ { 0, 0, x_out_pad, y_out_pad }, 0 }};
+ pool.output_paddings = { padding{ { 0, 0, y_out_pad, x_out_pad }, 0 }};
golden_topology.add(pool);
- golden_topology.add(reorder("reorder_pooling", input_info("fsv32_pooling"), layout(data_types::f16, format::bfyx, input_tensor, padding{ { 0,0,x_out_pad,y_out_pad },0 })));
+ golden_topology.add(reorder("reorder_pooling", input_info("fsv32_pooling"), layout(data_types::f16, format::bfyx, input_tensor, padding{ { 0,0,y_out_pad,x_out_pad },0 })));
network fsv32_network(engine, golden_topology, get_test_default_config(engine));
fsv32_network.set_input_data("input", input_prim);
@@ -2949,12 +2949,12 @@ public:
// Output padding
auto p1 = std::make_shared<pooling>("pooling", input_info("input0"), pooling_mode, size, stride, generate_pad(2, 3, size), generate_pad(2, 3, size), ov::op::PadType::EXPLICIT, ov::op::RoundingType::FLOOR);
- p1->output_paddings = {{ { 0, 0, 1, 5 }, { 0, 0, 19, 4 } }};
+ p1->output_paddings = {{ { 0, 0, 5, 1 }, { 0, 0, 4, 19 } }};
all_layer_params.emplace_back(p1);
// Input + output padding
auto p2 = std::make_shared<pooling>("pooling", input_info("reorder0"), pooling_mode, size, stride, generate_pad(2, 3, size), generate_pad(2, 3, size), ov::op::PadType::EXPLICIT, ov::op::RoundingType::FLOOR);
- p2->output_paddings = {{ { 0, 0, 2, 1 }, { 0, 0, 3, 4 } }};
+ p2->output_paddings = {{ { 0, 0, 1, 2 }, { 0, 0, 4, 3 } }};
all_layer_params.emplace_back(p2);
}
}
@@ -3068,8 +3068,8 @@ public:
cldnn::mem_lock<Type> input_mem(inputs[0], get_test_stream());
cldnn::mem_lock<Type> output_mem(output, get_test_stream());
- int output_width = output->get_layout().get_buffer_size().spatial[0];
- int output_height = output->get_layout().get_buffer_size().spatial[1];
+ int output_width = output->get_layout().get_padded_dims()[2 + 1]; // x
+ int output_height = output->get_layout().get_padded_dims()[2 + 0]; // y
const auto input_desc = get_linear_memory_desc(inputs[0]->get_layout());
const auto output_desc = get_linear_memory_desc(output->get_layout());
@@ -3078,7 +3078,7 @@ public:
{
case cldnn::pooling_mode::max:
{
- for (int i = 0; i < (int)output->get_layout().get_buffer_size().count(); i++)
+ for (int i = 0; i < (int)output->get_layout().get_linear_size(); i++)
{
output_mem[i] = (generic_params->data_type == data_types::f32) ? -FLT_MAX : -65504;
}
@@ -3145,7 +3145,7 @@ public:
return y*x;
};
- for (int i = 0; i < (int)output->get_layout().get_buffer_size().count(); i++)
+ for (int i = 0; i < (int)output->get_layout().get_linear_size(); i++)
{
output_mem[i] = 0;
}
@@ -3166,8 +3166,8 @@ public:
pad_y_start = std::max(pad_y_start, 0);
int output_index = (b * feature + f) * output_height * output_width;
- tensor lower_padding = pooling->output_paddings[0].lower_size();
- output_index += (lower_padding.spatial[1] + h) * output_width + lower_padding.spatial[0] + w;
+ const auto& lower_padding = pooling->output_paddings[0]._lower_size;
+ output_index += (lower_padding[2 + 0] + h) * output_width + lower_padding[2 + 1] + w;
int num_of_elements = 0;
for (int y = pad_y_start; y < pad_y_end; y++)
diff --git a/src/plugins/intel_gpu/tests/unit/test_cases/reorder_gpu_test.cpp b/src/plugins/intel_gpu/tests/unit/test_cases/reorder_gpu_test.cpp
index 3be608cef56..257812352e8 100644
--- a/src/plugins/intel_gpu/tests/unit/test_cases/reorder_gpu_test.cpp
+++ b/src/plugins/intel_gpu/tests/unit/test_cases/reorder_gpu_test.cpp
@@ -1340,11 +1340,11 @@ TEST(reorder_gpu_f32, dynamic_bfyx_to_bfyx_dynamic_padding_x) {
auto& engine = get_test_engine();
ov::Shape in_shape{1, 1, 4, 2};
- tensor dyn_pad_dims({0, 0, 1, 0}, 0);
+ padding::DynamicDimsMask dyn_pad_dims("1000"); // {0, 0, 0, 1}
layout in_dynamic_layout{ov::PartialShape::dynamic(in_shape.size()),
data_types::f16,
format::bfyx,
- padding({0, 0, 0, 0}, {0, 0, 0, 0}, 0.0f, dyn_pad_dims /*dynamic_pad_dim : x*/)};
+ padding({0, 0, 0, 0}, {0, 0, 0, 0}, dyn_pad_dims /*dynamic_pad_dim : x*/)};
std::vector<float> subtract_val = {};
topology topology(input_layout("input", in_dynamic_layout),
@@ -1363,7 +1363,7 @@ TEST(reorder_gpu_f32, dynamic_bfyx_to_bfyx_dynamic_padding_x) {
auto input_mem = engine.allocate_memory({ov::PartialShape(in_shape),
data_types::f16,
format::bfyx,
- padding({0, 0, 2, 0}, {0, 0, 1, 0}, 0.0f, dyn_pad_dims)});
+ padding({0, 0, 0, 2}, {0, 0, 0, 1}, dyn_pad_dims)});
set_values<ov::float16>(input_mem, {
ov::float16(0.f), ov::float16(0.f), // padding
ov::float16(1.f), ov::float16(2.f), // data
@@ -1402,11 +1402,11 @@ TEST(reorder_gpu_f32, dynamic_bfyx_to_bfyx_dynamic_padding_f) {
auto& engine = get_test_engine();
ov::Shape in_shape{2, 3, 2, 1};
- tensor dyn_pad_dims({0, 1, 0, 0}, 0);
+ padding::DynamicDimsMask dyn_pad_dims("10");
layout in_dynamic_layout{ov::PartialShape::dynamic(in_shape.size()),
data_types::f16,
format::bfyx,
- padding({0, 0, 0, 0}, {0, 0, 0, 0}, 0.0f, dyn_pad_dims /*dynamic_pad_dim : x*/)};
+ padding({0, 0, 0, 0}, {0, 0, 0, 0}, dyn_pad_dims)};
std::vector<float> subtract_val = {};
topology topology(input_layout("input", in_dynamic_layout),
@@ -1425,7 +1425,7 @@ TEST(reorder_gpu_f32, dynamic_bfyx_to_bfyx_dynamic_padding_f) {
auto input_mem = engine.allocate_memory({ov::PartialShape(in_shape),
data_types::f16,
format::bfyx,
- padding({0, 2, 0, 0}, {0, 1, 0, 0}, 0.0f, dyn_pad_dims)});
+ padding({0, 2, 0, 0}, {0, 1, 0, 0}, dyn_pad_dims)});
set_values<ov::float16>(input_mem, {
ov::float16(0.f), ov::float16(0.f), // f before
ov::float16(0.f), ov::float16(0.f), // f before
@@ -1805,8 +1805,8 @@ TEST(reorder_gpu_opt, remove_redundant_reorder_reorder_with_padding)
// r2 would be removed, but the padding value should be remained at the input primitive of r2.
std::vector<int32_t> gt = {0, 0, 1, 1};
auto r1_output_data_padding = net.get_primitive("r1")->get_output_layout().data_padding;
- auto upper_padding = r1_output_data_padding.upper_size().sizes();
- auto lower_padding = r1_output_data_padding.lower_size().sizes();
+ const auto& upper_padding = r1_output_data_padding._upper_size;
+ const auto& lower_padding = r1_output_data_padding._lower_size;
for (int32_t i = 0 ; i < 4; i++) {
ASSERT_EQ(upper_padding[i], gt[i]);
ASSERT_EQ(lower_padding[i], gt[i]);
@@ -2411,7 +2411,7 @@ TEST(reorder_gpu_f32, bfzyx_to_bsv16_fsv16_padded)
topology topology(
input_layout("input", input->get_layout()),
- reorder("reorder", input_info("input"), output_layout.with_padding(padding({ 0, 0, x_pad, y_pad, 0 }, 0.f))));
+ reorder("reorder", input_info("input"), output_layout.with_padding(padding({ 0, 0, z_pad, y_pad, x_pad }, 0.f))));
network network(engine, topology, get_test_default_config(engine));
network.set_input_data("input", input);
diff --git a/src/plugins/intel_gpu/tests/unit/test_cases/reshape_gpu_test.cpp b/src/plugins/intel_gpu/tests/unit/test_cases/reshape_gpu_test.cpp
index 535630bcdcc..094e7ffc2d4 100644
--- a/src/plugins/intel_gpu/tests/unit/test_cases/reshape_gpu_test.cpp
+++ b/src/plugins/intel_gpu/tests/unit/test_cases/reshape_gpu_test.cpp
@@ -88,15 +88,21 @@ void generic_reshape_test(format fmt, tensor const& input_size, tensor const& re
//output size should be equal to requested plus output padding
ASSERT_TRUE(output->get_layout().get_tensor() == reshape_size);
- ASSERT_TRUE(output->get_layout().get_buffer_size() == reshape_size.add(output_padd.lower_size()).add(output_padd.upper_size()));
+ auto output_fmt = output->get_layout().format;
+ auto default_fmt = format::get_default_format(output_fmt.dimension(), format::is_weights_format(output_fmt), format::is_grouped(output_fmt));
+ std::vector<tensor::value_type> lower_sizes, upper_sizes;
+ lower_sizes.assign(output_padd._lower_size.begin(), output_padd._lower_size.begin() + output_fmt.dimension());
+ upper_sizes.assign(output_padd._upper_size.begin(), output_padd._upper_size.begin() + output_fmt.dimension());
+ ASSERT_TRUE(tensor(default_fmt, output->get_layout().get_padded_dims()) ==
+ reshape_size.add(tensor(default_fmt, lower_sizes, 0)).add(tensor(default_fmt, upper_sizes, 0)));
{
cldnn::mem_lock<const ElemType> output_ptr(output, get_test_stream());
auto output_itr = output_ptr.begin();
auto sizes = reshape_size.sizes(fmt);
- auto lower = output_padd.lower_size().sizes(fmt);
- auto upper = output_padd.upper_size().sizes(fmt);
+ auto lower = tensor(default_fmt, lower_sizes, 0).sizes(fmt);
+ auto upper = tensor(default_fmt, upper_sizes, 0).sizes(fmt);
auto buffer_sizes = sizes;
int32_t accum = 1;
for (size_t i = 1; i <= sizes.size(); ++i) {
@@ -546,7 +552,7 @@ void test_basic_bfwzyx(bool is_caching_test) {
topology topology;
topology.add(input_layout("input", input->get_layout()));
auto reshape_prim = reshape("reshape", input_info("input"), tensor(batch(1), feature(1), spatial(2, 2, 3, 3)), cldnn::reshape::reshape_mode::base);
- reshape_prim.output_paddings = {padding({0, 0, 0, 0, 0, 1}, 0.f)};
+ reshape_prim.output_paddings = {padding({0, 0, 1, 0, 0, 0}, 0.f)};
topology.add(reshape_prim);
// clang-format off
diff --git a/src/plugins/intel_gpu/tests/unit/test_cases/spatial_concatenate_gpu_test.cpp b/src/plugins/intel_gpu/tests/unit/test_cases/spatial_concatenate_gpu_test.cpp
index e2c585027a4..c51a484eb74 100644
--- a/src/plugins/intel_gpu/tests/unit/test_cases/spatial_concatenate_gpu_test.cpp
+++ b/src/plugins/intel_gpu/tests/unit/test_cases/spatial_concatenate_gpu_test.cpp
@@ -182,8 +182,8 @@ public:
void test_test04(bool is_caching_test) {
auto& engine = get_test_engine();
- memory::ptr input1 = engine.allocate_memory(layout{ data_types::f32, format::bfyx,{ 1, 1, 2, 2 }, padding({ 0, 0, 0, 0 }, { 0, 0, 1, 0 }) });
- memory::ptr input2 = engine.allocate_memory(layout{ data_types::f32, format::bfyx,{ 1, 1, 2, 2 }, padding({ 0, 0, 0, 1 }, 0.0f) });
+ memory::ptr input1 = engine.allocate_memory(layout{ data_types::f32, format::bfyx,{ 1, 1, 2, 2 }, padding({ 0, 0, 0, 0 }, { 0, 0, 0, 1 }) });
+ memory::ptr input2 = engine.allocate_memory(layout{ data_types::f32, format::bfyx,{ 1, 1, 2, 2 }, padding({ 0, 0, 1, 0 }, 0.0f) });
set_values(input1, {
1.0f, 2.0f, 0.0f,
@@ -206,7 +206,7 @@ public:
tpl.add(input_layout("in1", input1->get_layout()));
tpl.add(input_layout("in2", input2->get_layout()));
auto concat = concatenation("conc", { input_info("in1"), input_info("in2") }, 3);
- concat.output_paddings = {padding({ 0, 0, 2, 0 }, { 0, 0, 0, 0 }) };
+ concat.output_paddings = {padding({ 0, 0, 0, 2 }, { 0, 0, 0, 0 }) };
tpl.add(concat);
cldnn::network::ptr net = get_network(engine, tpl, get_test_default_config(engine), get_test_stream_ptr(), is_caching_test);
diff --git a/src/plugins/intel_gpu/tests/unit/test_cases/swiglu_gpu_test.cpp b/src/plugins/intel_gpu/tests/unit/test_cases/swiglu_gpu_test.cpp
index b01aa9bb708..2f24dba140d 100644
--- a/src/plugins/intel_gpu/tests/unit/test_cases/swiglu_gpu_test.cpp
+++ b/src/plugins/intel_gpu/tests/unit/test_cases/swiglu_gpu_test.cpp
@@ -32,10 +32,10 @@ void swiglu_ref(const memory::ptr input, memory::ptr output, int32_t split_lengt
for (uint32_t f = 0; f < feature_size; ++f) {
for (uint32_t y = 0; y < y_size; ++y) {
for (uint32_t x = 0; x < x_size; ++x) {
- auto tensor_src = tensor(batch(b), feature(f), spatial(x, y, 0, 0));
- auto tensor_dst = tensor(batch(b), feature(f), spatial(x, y, 0, 0));
- size_t src_offset = input_layout.get_linear_offset(tensor_src);
- size_t dst_offset = output_layout.get_linear_offset(tensor_dst);
+ size_t src_offset = input_layout.get_linear_offset({static_cast<int32_t>(b), static_cast<int32_t>(f),
+ static_cast<int32_t>(x), static_cast<int32_t>(y), 0, 0});
+ size_t dst_offset = output_layout.get_linear_offset({static_cast<int32_t>(b), static_cast<int32_t>(f),
+ static_cast<int32_t>(x), static_cast<int32_t>(y), 0, 0});
res = src[src_offset];
res = (res / (static_cast<T>(1) + (std::exp((-(static_cast<T>(1) * res))))));
res *= src[src_offset + static_cast<size_t>(split_length)];
diff --git a/src/plugins/intel_gpu/tests/unit/test_utils/test_utils.cpp b/src/plugins/intel_gpu/tests/unit/test_utils/test_utils.cpp
index 59024d38735..474182801db 100644
--- a/src/plugins/intel_gpu/tests/unit/test_utils/test_utils.cpp
+++ b/src/plugins/intel_gpu/tests/unit/test_utils/test_utils.cpp
@@ -150,20 +150,20 @@ void generic_test::compare_buffers(const memory::ptr out, const memory::ptr ref)
}
static size_t calc_offfset(const layout & layout, const pitches& p) {
- auto lower_padding = layout.data_padding.lower_size();
+ const auto& lower_padding = layout.data_padding._lower_size;
if (layout.format == format::bfzyx) {
return
- p.b * lower_padding.batch[0] +
- p.f * lower_padding.feature[0] +
- p.z * lower_padding.spatial[2] +
- p.y * lower_padding.spatial[1] +
- p.x * lower_padding.spatial[0];
+ p.b * lower_padding[0] +
+ p.f * lower_padding[1] +
+ p.z * lower_padding[2 + 2] +
+ p.y * lower_padding[2 + 1] +
+ p.x * lower_padding[2 + 0];
} else {
return
- p.b * lower_padding.batch[0] +
- p.f * lower_padding.feature[0] +
- p.y * lower_padding.spatial[1] +
- p.x * lower_padding.spatial[0];
+ p.b * lower_padding[0] +
+ p.f * lower_padding[1] +
+ p.y * lower_padding[2 + 1] +
+ p.x * lower_padding[2 + 0];
}
}
@@ -173,38 +173,38 @@ memory_desc generic_test::get_linear_memory_desc(const layout & layout) {
switch (layout.format) {
case format::bfyx: {
p.x = 1;
- p.y = layout.get_buffer_size().sizes(format::bfyx)[3] * p.x;
- p.f = layout.get_buffer_size().sizes(format::bfyx)[2] * p.y;
- p.b = layout.get_buffer_size().sizes(format::bfyx)[1] * p.f;
+ p.y = tensor(layout.get_padded_dims()).sizes(format::bfyx)[3] * p.x;
+ p.f = tensor(layout.get_padded_dims()).sizes(format::bfyx)[2] * p.y;
+ p.b = tensor(layout.get_padded_dims()).sizes(format::bfyx)[1] * p.f;
break;
}
case format::yxfb: {
p.b = 1;
- p.f = layout.get_buffer_size().sizes(format::yxfb)[3] * p.b;
- p.x = layout.get_buffer_size().sizes(format::yxfb)[2] * p.f;
- p.y = layout.get_buffer_size().sizes(format::yxfb)[1] * p.x;
+ p.f = tensor(layout.get_padded_dims()).sizes(format::yxfb)[3] * p.b;
+ p.x = tensor(layout.get_padded_dims()).sizes(format::yxfb)[2] * p.f;
+ p.y = tensor(layout.get_padded_dims()).sizes(format::yxfb)[1] * p.x;
break;
}
case format::fyxb: {
p.b = 1;
- p.x = layout.get_buffer_size().sizes(format::fyxb)[3] * p.b;
- p.y = layout.get_buffer_size().sizes(format::fyxb)[2] * p.x;
- p.f = layout.get_buffer_size().sizes(format::fyxb)[1] * p.y;
+ p.x = tensor(layout.get_padded_dims()).sizes(format::fyxb)[3] * p.b;
+ p.y = tensor(layout.get_padded_dims()).sizes(format::fyxb)[2] * p.x;
+ p.f = tensor(layout.get_padded_dims()).sizes(format::fyxb)[1] * p.y;
break;
}
case format::byxf: {
p.f = 1;
- p.x = layout.get_buffer_size().sizes(format::byxf)[3] * p.f;
- p.y = layout.get_buffer_size().sizes(format::byxf)[2] * p.x;
- p.b = layout.get_buffer_size().sizes(format::byxf)[1] * p.y;
+ p.x = tensor(layout.get_padded_dims()).sizes(format::byxf)[3] * p.f;
+ p.y = tensor(layout.get_padded_dims()).sizes(format::byxf)[2] * p.x;
+ p.b = tensor(layout.get_padded_dims()).sizes(format::byxf)[1] * p.y;
break;
}
case format::bfzyx: {
p.x = 1;
- p.y = layout.get_buffer_size().sizes(format::bfzyx)[4] * p.x;
- p.z = layout.get_buffer_size().sizes(format::bfzyx)[3] * p.y;
- p.f = layout.get_buffer_size().sizes(format::bfzyx)[2] * p.z;
- p.b = layout.get_buffer_size().sizes(format::bfzyx)[1] * p.f;
+ p.y = tensor(layout.get_padded_dims()).sizes(format::bfzyx)[4] * p.x;
+ p.z = tensor(layout.get_padded_dims()).sizes(format::bfzyx)[3] * p.y;
+ p.f = tensor(layout.get_padded_dims()).sizes(format::bfzyx)[2] * p.z;
+ p.b = tensor(layout.get_padded_dims()).sizes(format::bfzyx)[1] * p.f;
break;
}
default: {
diff --git a/src/plugins/intel_gpu/tests/unit/test_utils/test_utils.h b/src/plugins/intel_gpu/tests/unit/test_utils/test_utils.h
index 5dce1b4343b..69ea71de762 100644
--- a/src/plugins/intel_gpu/tests/unit/test_utils/test_utils.h
+++ b/src/plugins/intel_gpu/tests/unit/test_utils/test_utils.h
@@ -270,7 +270,7 @@ void set_values_per_batch_and_feature(cldnn::memory::ptr mem, std::vector<T> arg
for (cldnn::tensor::value_type f = 0; f < l.feature(); ++f) {
for (cldnn::tensor::value_type y = 0; y < l.spatial(1); ++y) {
for (cldnn::tensor::value_type x = 0; x < l.spatial(0); ++x) {
- unsigned int input_it = b*pitches.batch[0] + f*pitches.feature[0] + y*pitches.spatial[1] + x*pitches.spatial[0];
+ unsigned int input_it = b*pitches[0] + f*pitches[1] + y*pitches[0 + 2] + x*pitches[1 + 2];
mem_ptr[input_it] = args[b*l.feature() + f];
}
}
@@ -481,9 +481,14 @@ inline void PrintTupleTo(const std::tuple<std::shared_ptr<test_params>, std::sha
str << std::endl << "Test params: " << test_param->print();
+ const auto& lower_size = primitive->output_paddings[0]._lower_size;
+ const auto& upper_size = primitive->output_paddings[0]._upper_size;
str << "Layer params:\n"
- << "Output padding lower size: " << test_param->print_tensor(primitive->output_paddings[0].lower_size())
- << " upper size: " << test_param->print_tensor(primitive->output_paddings[0].upper_size()) << '\n';
+ << "Output padding lower size: ";
+ std::copy(std::begin(lower_size), std::end(lower_size), std::ostream_iterator<char>(std::cout, " "));
+ str << " upper size: ";
+ std::copy(std::begin(upper_size), std::end(upper_size), std::ostream_iterator<char>(std::cout, " "));
+ str << '\n';
//TODO: do layers not have param dumping? we could consider adding it