OpenVINO™ is an open source toolkit for optimizing and deploying AI inference
C++ aicomputer-visiondeep-learningdeploy-aidiffusion-modelsgenerative-aigood-first-issueinferencellm-inferencenatural-language-processingnlpopenvinooptimize-aiperformance-boostrecommendation-systemspeech-recognitionstable-diffusiontransformersyolo
[GPU] Support 2d input1/2(cos/sin) in rope ocl_v2 kernel (#29914)
Wilson Seok91125f6fb848
diff --git a/src/plugins/intel_gpu/src/graph/impls/ocl_v2/rope_opt.cl b/src/plugins/intel_gpu/src/graph/impls/ocl_v2/rope_opt.clindex 91d2b67d55a..8e04aa421ce 100644--- a/src/plugins/intel_gpu/src/graph/impls/ocl_v2/rope_opt.cl+++ b/src/plugins/intel_gpu/src/graph/impls/ocl_v2/rope_opt.cl@@ -316,9 +316,7 @@ KERNEL(rope_opt)#endif#endif- uint cos_sin_b = b < INPUT1_BATCH_NUM ? b : 0;- uint cos_sin_h = h < INPUT1_FEATURE_NUM ? h : 0;- uint cos_sin_p = p;+uint cos_sin_p = p;#ifdef ENABLE_GATHERuint gather_b = b < INPUT3_BATCH_NUM ? b : 0;#if GATHER_RANK == 4@@ -331,6 +329,10 @@ KERNEL(rope_opt)#endifcos_sin_p = gather[gather_idx];#endif++#if INPUT1_DIMS == 4 && INPUT2_DIMS == 4+ uint cos_sin_b = b < INPUT1_BATCH_NUM ? b : 0;+ uint cos_sin_h = h < INPUT1_FEATURE_NUM ? h : 0;cos_sin_p = cos_sin_p < INPUT1_SIZE_Y ? cos_sin_p : 0;#ifndef SIN_COS_HAVE_DYNAMIC_PADDINGS@@ -341,6 +343,23 @@ KERNEL(rope_opt)#elseuint cos_idx = INPUT1_GET_INDEX(cos_sin_b, cos_sin_h, cos_sin_p, 0);uint sin_idx = INPUT2_GET_INDEX(cos_sin_b, cos_sin_h, cos_sin_p, 0);+#endif+#elif INPUT1_DIMS == 2 && INPUT2_DIMS == 2+ uint cos_sin_b = 0;+ uint cos_sin_h = 0;+ cos_sin_p = cos_sin_p < INPUT1_BATCH_NUM ? cos_sin_p : 0;++ #ifndef SIN_COS_HAVE_DYNAMIC_PADDINGS+ uint cos_sin_idx = INPUT1_GET_INDEX(cos_sin_p, 0, 0, 0);++ uint cos_idx = cos_sin_idx;+ uint sin_idx = cos_sin_idx;+#else+ uint cos_idx = INPUT1_GET_INDEX(cos_sin_p, 0, 0, 0);+ uint sin_idx = INPUT2_GET_INDEX(cos_sin_p, 0, 0, 0);+#endif+#else+# error "rope_opt.cl - 4 or 2 of INPUT1_DIMS/INPUT2_DIMS is supported only"#endifuint output_idx = OUTPUT_GET_INDEX(b, h, p, 0);diff --git a/src/plugins/intel_gpu/src/graph/impls/ocl_v2/utils/jitter.cpp b/src/plugins/intel_gpu/src/graph/impls/ocl_v2/utils/jitter.cppindex 1f7bfdfd02c..cfd2b539f8c 100644--- a/src/plugins/intel_gpu/src/graph/impls/ocl_v2/utils/jitter.cpp+++ b/src/plugins/intel_gpu/src/graph/impls/ocl_v2/utils/jitter.cpp@@ -421,7 +421,7 @@ JitConstants make_layout_jit_constants(const std::string& name, const cldnn::layJitConstants definitions{{name + "_VIEW_OFFSET", to_code_string(0)}, // FIXME{name + "_LENGTH", to_code_string(value.is_static() ? value.count() : 0)},- {name + "_DIMS", to_code_string(value.get_rank())},+ {name + "_DIMS", to_code_string(value.get_partial_shape().size())}, // Use actual shape dimension not format dimension{name + "_SIMPLE", to_code_string(cldnn::format::is_simple_data_format(value.format))},{name + "_GROUPED", to_code_string(cldnn::format::is_grouped(value.format))},{name + "_LAYOUT_" + to_code_string(format_string(value.format)), "1"},