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 19, 2024
1 parent a2b00ec commit 222c4f0
Showing 1 changed file with 14 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

0 comments on commit 222c4f0

Please sign in to comment.