Skip to content

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

[GPU] Prevent sharing memory for onednn concat (#32386)

David Nam4890db571e13
diff --git a/src/plugins/intel_gpu/src/graph/graph_optimizer/basic_memory_dependencies.cpp b/src/plugins/intel_gpu/src/graph/graph_optimizer/basic_memory_dependencies.cpp
index 953dca8d6e7..cd9ba7a6b78 100644
--- a/src/plugins/intel_gpu/src/graph/graph_optimizer/basic_memory_dependencies.cpp
+++ b/src/plugins/intel_gpu/src/graph/graph_optimizer/basic_memory_dependencies.cpp
@@ -59,6 +59,31 @@ void basic_memory_dependencies::run(program& p) {
}
}
}
+
+ // onednn concatenation doesn't support non-zero padding which can occur for unaligned feature.
+ if (node->is_type<concatenation>()) {
+ auto is_feature_aligned = [](const cldnn::layout& l) {
+ if (!format::is_blocked(l.format)) {
+ return true;
+ }
+
+ const auto& order = format::internal_order(l.format);
+ int f_bs = 1;
+ for (const auto& [dim, bs] : format::block_sizes(l.format)) {
+ if (dim < order.size() && order[dim] == 'f') {
+ f_bs = bs;
+ }
+ }
+ return l.feature() % f_bs == 0;
+ };
+
+ if (node->is_dynamic() || (!node->is_dynamic() && !is_feature_aligned(node->get_output_layout()))) {
+ node->can_share_buffer(false);
+ for (auto& dep : node->get_dependencies()) {
+ dep.first->can_share_buffer(false);
+ }
+ }
+ }
}
// Note we iterate over processing order, it means if primitve has processing num greater than any of outputs,