From ac27cd6fe75f18373381e2fb94b826889c1fd26d Mon Sep 17 00:00:00 2001 From: Taylor Yeonbok Lee Date: Wed, 1 May 2024 02:47:19 -0700 Subject: [PATCH] [GPU] Fix transposed shape calculation for static model (#24329) ### Details: - Fix transposed shape calculation for static model where the transposed order is less then canonicalized shape ### Tickets: - 140091 --- .../intel_gpu/src/graph/impls/ocl/gemm.cpp | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/plugins/intel_gpu/src/graph/impls/ocl/gemm.cpp b/src/plugins/intel_gpu/src/graph/impls/ocl/gemm.cpp index 8d0efede6ee..bcbae3b9dc7 100644 --- a/src/plugins/intel_gpu/src/graph/impls/ocl/gemm.cpp +++ b/src/plugins/intel_gpu/src/graph/impls/ocl/gemm.cpp @@ -188,11 +188,20 @@ public: (primitive->input_rank == primitive->weight_rank); if (is_broadcastable) { auto transpose_pshape = [](const ov::PartialShape pshape, const std::vector& order) { - auto transposed_pshape = ov::PartialShape::dynamic(pshape.rank()); - for (size_t i = 0; i < order.size(); i++) { - transposed_pshape[i] = pshape[order[i]]; + if (order.size() < pshape.size()) { + auto transposed_pshape = pshape; + auto rank_diff = pshape.size() - order.size(); + for (size_t i = 0; i < order.size(); i++) { + transposed_pshape[i + rank_diff] = pshape[rank_diff + order[i]]; + } + return transposed_pshape; + } else { + auto transposed_pshape = ov::PartialShape::dynamic(pshape.rank()); + for (size_t i = 0; i < order.size(); i++) { + transposed_pshape[i] = pshape[order[i]]; + } + return transposed_pshape; } - return transposed_pshape; }; size_t max_rank = input0_pshape.size(); auto default_order = ov::intel_gpu::op::Gemm::default_order(max_rank);