Skip to content

Commit

Permalink
[GPU] Extend the cases where layouts are compatible
Browse files Browse the repository at this point in the history
  • Loading branch information
Lyamin-Roman committed Dec 20, 2024
1 parent a2b00ec commit bb0155a
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
17 changes: 14 additions & 3 deletions src/plugins/intel_gpu/src/runtime/layout.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -446,8 +446,6 @@ bool layout::compatible(const layout& other) const {
if (l1.is_dynamic() || l2.is_dynamic())
return false;

auto l1_size = l1.get_tensor();
auto l2_size = l2.get_tensor();
if (l1 == l2)
return true;
if (check_redundant_1d_along_feature(l1, l2))
Expand All @@ -459,7 +457,7 @@ bool layout::compatible(const layout& other) const {
if (format::is_default_format(l1.format) && format::is_default_format(l2.format) &&
!l1.data_padding && !l2.data_padding && l1.get_linear_size() == l2.get_linear_size())
return true;
if (l1_size != l2_size)
if (l1.get_shape() != l2.get_shape())
return false;
if (l1.get_linear_size() != l2.get_linear_size())
return false;
Expand Down Expand Up @@ -505,6 +503,19 @@ bool layout::compatible(const layout& other) const {
auto l1_pitch = l1.get_pitches();
auto l2_pitch = l2.get_pitches();

auto l1_padded_dims = l1.get_padded_dims();
auto l2_padded_dims = l2.get_padded_dims();

// Ignore pitches which will never be used (for padded dims with size == 1)
for (size_t i = 0; i < l1_padded_dims.size(); ++i) {
if (l1_padded_dims[i] == 1) {
l1_pitch[i] = 0;
}
if (l2_padded_dims[i] == 1) {
l2_pitch[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)
Expand Down
4 changes: 4 additions & 0 deletions src/plugins/intel_gpu/tests/unit/module_tests/layout_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,10 @@ INSTANTIATE_TEST_SUITE_P(smoke, layout_cmp_test,
layout{ov::PartialShape{4, 2, 3, 4, 5}, data_types::f16, format::is_os_zyx_isv16_osv16}, false, false},
{layout{ov::PartialShape{4, 2, 3, 4, 5}, data_types::f16, format::goiyx},
layout{ov::PartialShape{4, 2, 3, 4, 5}, data_types::f16, format::gioyx}, false, false},
{layout{ov::PartialShape{4, 1, 16, 16}, data_types::f16, format::bfyx},
layout{ov::PartialShape{4, 1, 16, 16}, data_types::f16, format::byxf}, false, true},
{layout{ov::PartialShape{2, 1, 2, 4}, data_types::f16, format::bfyx, padding({0, 0, 1, 0}, {0, 0, 1, 0})},
layout{ov::PartialShape{2, 1, 2, 4}, data_types::f16, format::bfyx, padding({0, 1, 0, 0}, {0, 0, 0, 0})}, false, false},
}));

struct layouts_transform_test_params {
Expand Down

0 comments on commit bb0155a

Please sign in to comment.