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] Optimize MVN and reorders for nnUNet INT8 5D model (#34949)
Sungeun Kim29da988dd17f
diff --git a/src/plugins/intel_gpu/docs/gpu_kernels.md b/src/plugins/intel_gpu/docs/gpu_kernels.mdindex 959bf5b6546..c6acee9ad8e 100644--- a/src/plugins/intel_gpu/docs/gpu_kernels.md+++ b/src/plugins/intel_gpu/docs/gpu_kernels.md@@ -30,11 +30,11 @@ public:// The list of available kernels is usually specified in kernel_selector c-tor using `Attach` method whith creates instance of each type// and append it to implementations list.// In this case we have 3 available kernels for MVN operation. Kernels might have different priorities and support only subset of operation parameters-// E.g. MVNKernel_b_fs_yx_fsv16_imad supports only `fsv16` blocked layouts and INT8/UINT8 input data types+// E.g. MVNKernel_b_fs_yx_fsv16 supports `fsv16`/`fsv32` blocked layouts and F16/F32/INT8/UINT8 input data typesmvn_kernel_selector::mvn_kernel_selector() {Attach<MVNKernelRef>();Attach<MVNKernelBfyxOpt>();- Attach<MVNKernel_b_fs_yx_fsv16_imad>();+ Attach<MVNKernel_b_fs_yx_fsv16>();}// This method is used to get the optimal kernel for given parametersdiff --git a/src/plugins/intel_gpu/src/graph/deconvolution.cpp b/src/plugins/intel_gpu/src/graph/deconvolution.cppindex 0e8ac831d6b..e16cb8b9290 100644--- a/src/plugins/intel_gpu/src/graph/deconvolution.cpp+++ b/src/plugins/intel_gpu/src/graph/deconvolution.cpp@@ -107,19 +107,15 @@ std::vector<layout> deconvolution_inst::calc_output_layouts(deconvolution_node cauto weights_layout = *impl_param.weights_layout;weights_layout = weights_layout.convert_to_weights_layout(desc->grouped_weights_shape);- if (input_layout.is_dynamic())- return {layout{ShapeType::dynamic(input_layout.get<ShapeType>().rank()), input_layout.data_type, input_layout.format}};-auto input_type = input_layout.data_type;- auto output_type = input_type;- if ((input_type == data_types::i8 || input_type == data_types::u8) && !impl_param.has_fused_primitives()) {- output_type = data_types::f32;- }-+ auto output_type = (input_type == data_types::u8 || input_type == data_types::i8) ? data_types::f32 : input_type;if (impl_param.has_fused_primitives()) {output_type = impl_param.get_output_element_type();}+ if (input_layout.is_dynamic())+ return {layout{ShapeType::dynamic(input_layout.get<ShapeType>().rank()), output_type, input_layout.format}};+auto strides = desc->stride;auto dilations = desc->dilations;auto pads_begin = desc->pads_begin;diff --git a/src/plugins/intel_gpu/src/graph/graph_optimizer/prepare_primitive_fusing.cpp b/src/plugins/intel_gpu/src/graph/graph_optimizer/prepare_primitive_fusing.cppindex 822f5ca244a..69a8fd6cfee 100644--- a/src/plugins/intel_gpu/src/graph/graph_optimizer/prepare_primitive_fusing.cpp+++ b/src/plugins/intel_gpu/src/graph/graph_optimizer/prepare_primitive_fusing.cpp@@ -995,7 +995,12 @@ void prepare_primitive_fusing::fuse_simple_primitives(program &p) {should_fuse |= input_data.is_type<normalize>() && quantize_node.get_scale_shift_opt() &&in_dt_is_i8_u8;- should_fuse |= input_data.is_type<deconvolution>() && quantize_node.get_scale_shift_opt();+ // oneDNN deconv uses conv backward-data internally, which does not support+ // float-to-int8 output narrowing (e.g., f16->u8). Prevent fusion in this case+ // to keep deconv output as float (optimized kernel) + separate quantize.+ should_fuse |= input_data.is_type<deconvolution>() && quantize_node.get_scale_shift_opt() &&+ !(lo.has_all_enabled_onednn_impls_optimization_attribute() &&+ !in_dt_is_i8_u8 && out_dt_is_i8_u8);should_fuse |= input_data.is_type<gather>() && quantize_node.get_scale_shift_opt();diff --git a/src/plugins/intel_gpu/src/graph/impls/ocl/mvn.cpp b/src/plugins/intel_gpu/src/graph/impls/ocl/mvn.cppindex d70940311d9..be33a6babb8 100644--- a/src/plugins/intel_gpu/src/graph/impls/ocl/mvn.cpp+++ b/src/plugins/intel_gpu/src/graph/impls/ocl/mvn.cpp@@ -122,7 +122,11 @@ attach_mvn_impl::attach_mvn_impl() {auto dyn_formats = {format::bfyx,- format::bfzyx+ format::bfzyx,+ format::b_fs_yx_fsv16,+ format::b_fs_zyx_fsv16,+ format::b_fs_yx_fsv32,+ format::b_fs_zyx_fsv32};implementation_map<mvn>::add(impl_types::ocl,@@ -156,8 +160,7 @@ attach_mvn_impl::attach_mvn_impl() {std::make_tuple(data_types::f32, format::bs_fs_zyx_bsv16_fsv16),std::make_tuple(data_types::f16, format::bs_fs_zyx_bsv16_fsv16),- // TODO: uncomment this code when fsv32 optimizations for MVN will be implemented- /*std::make_tuple(data_types::f32, format::b_fs_yx_fsv32),+ std::make_tuple(data_types::f32, format::b_fs_yx_fsv32),std::make_tuple(data_types::f16, format::b_fs_yx_fsv32),std::make_tuple(data_types::u8, format::b_fs_yx_fsv32),std::make_tuple(data_types::i8, format::b_fs_yx_fsv32),@@ -165,7 +168,7 @@ attach_mvn_impl::attach_mvn_impl() {std::make_tuple(data_types::f32, format::b_fs_zyx_fsv32),std::make_tuple(data_types::f16, format::b_fs_zyx_fsv32),std::make_tuple(data_types::u8, format::b_fs_zyx_fsv32),- std::make_tuple(data_types::i8, format::b_fs_zyx_fsv32),*/+ std::make_tuple(data_types::i8, format::b_fs_zyx_fsv32),std::make_tuple(data_types::f32, format::b_fs_yx_fsv16),std::make_tuple(data_types::f16, format::b_fs_yx_fsv16),diff --git a/src/plugins/intel_gpu/src/graph/layout_optimizer.cpp b/src/plugins/intel_gpu/src/graph/layout_optimizer.cppindex 1398523a6de..5de06f63d82 100644--- a/src/plugins/intel_gpu/src/graph/layout_optimizer.cpp+++ b/src/plugins/intel_gpu/src/graph/layout_optimizer.cpp@@ -137,10 +137,6 @@ bool layout_optimizer::is_format_supported(program_node& node, format::type fmt)if (node.is_type<fully_connected>() && fmt == format::byxf)return false;- if (node.is_type<mvn>() && fmt == format::b_fs_yx_fsv16 &&- node.get_input_layout(0).data_type != data_types::i8 &&- node.get_input_layout(0).data_type != data_types::u8)- return false;if (node.is_type<input_layout>())return node.get_output_layout().format == fmt;@@ -160,7 +156,9 @@ bool layout_optimizer::can_fuse_reorder(program_node& prev, program_node& next,auto next_dt = next.get_output_layout().data_type;auto use_onednn_impls = has_all_enabled_onednn_impls_optimization_attribute();- if ((prev.is_dynamic() || next.is_dynamic()) && !next.is_type<convolution>())+ // Under dynamic shape, skip reorder fusion except for primitives whose kernels handle+ // cross-layout inputs at runtime: convolution, and MVN (fsv16/fsv32, see rule below).+ if ((prev.is_dynamic() || next.is_dynamic()) && !next.is_type<convolution>() && !next.is_type<mvn>())return false;// Not to fuse reorder if this removal changes input format of its next node which has reuse in fused_op@@ -208,6 +206,15 @@ bool layout_optimizer::can_fuse_reorder(program_node& prev, program_node& next,|| fmt_next == format::bs_fs_yx_bsv32_fsv16 || fmt_next == format::bs_fs_yx_bsv32_fsv32))return true;+ // MVN kernel can accept cross-layout input between fsv16 and fsv32.+ // Symmetric to the producer-direction rule in can_fuse_reorder_to_prev.+ if (next.is_type<mvn>() &&+ (fmt_prev == format::b_fs_yx_fsv16 || fmt_prev == format::b_fs_yx_fsv32 ||+ fmt_prev == format::b_fs_zyx_fsv16 || fmt_prev == format::b_fs_zyx_fsv32) &&+ (fmt_next == format::b_fs_yx_fsv16 || fmt_next == format::b_fs_yx_fsv32 ||+ fmt_next == format::b_fs_zyx_fsv16 || fmt_next == format::b_fs_zyx_fsv32))+ return true;+if (next.is_type<pooling>() &&(((prev_simple && next_simple) && (prev_dt == next_dt)) ||((fmt_prev == format::b_fs_yx_fsv4 && fmt_next == format::bfyx) && (prev_dt == data_types::u8 || prev_dt == data_types::i8))))@@ -403,7 +410,8 @@ bool layout_optimizer::can_fuse_reorder_to_prev(program_node& prev, reorder_nodebool is_dynamic = false;if (prev.is_dynamic() || (!node.get_users().empty() && node.get_users().front()->is_dynamic())) {if (!prev.is_type<permute>() &&- !prev.is_type<group_normalization>()) {+ !prev.is_type<group_normalization>() &&+ !prev.is_type<mvn>()) {return false;}is_dynamic = true;@@ -448,6 +456,15 @@ bool layout_optimizer::can_fuse_reorder_to_prev(program_node& prev, reorder_node|| fmt_next == format::bs_fs_yx_bsv32_fsv16 || fmt_next == format::bs_fs_yx_bsv32_fsv32))return true;+ // MVN kernel can work cross-layout between fsv16 and fsv32.+ // Actual kernel support is verified by has_impl_for check in remove_redundant_reorders.+ if (prev.is_type<mvn>() &&+ (fmt_prev == format::b_fs_yx_fsv16 || fmt_prev == format::b_fs_yx_fsv32 ||+ fmt_prev == format::b_fs_zyx_fsv16 || fmt_prev == format::b_fs_zyx_fsv32) &&+ (fmt_next == format::b_fs_yx_fsv16 || fmt_next == format::b_fs_yx_fsv32 ||+ fmt_next == format::b_fs_zyx_fsv16 || fmt_next == format::b_fs_zyx_fsv32))+ return true;+if (prev.is_type<one_hot>() &&!data_type_traits::is_floating_point(dt_prev) &&data_type_traits::is_floating_point(dt_next) &&@@ -1414,11 +1431,6 @@ format layout_optimizer::get_preferred_format(program_node& node) {expected = format::get_default_format(node.get_output_layout().get_rank());} else if (node.is_type<deconvolution>()) {expected = get_expected_format(node.as<deconvolution>());- } else if (node.is_type<mvn>()) {- auto input_layout = node.get_input_layout(0);- if (input_layout.data_type == data_types::f32 || input_layout.data_type == data_types::f16) {- expected = format::get_default_format(input_layout.get_rank());- }} else if (node.is_type<resample>()) {// if the resample is in the last part of the network and there are no users using blocked format,// it is better to reorder to bfyx before resample is done.diff --git a/src/plugins/intel_gpu/src/graph/registry/reorder_impls.cpp b/src/plugins/intel_gpu/src/graph/registry/reorder_impls.cppindex 65df220dc9c..d278b298d42 100644--- a/src/plugins/intel_gpu/src/graph/registry/reorder_impls.cpp+++ b/src/plugins/intel_gpu/src/graph/registry/reorder_impls.cpp@@ -19,11 +19,23 @@ namespace ov::intel_gpu {using namespace cldnn;+// Formats listed here gate the dynamic-shape OCL reorder path: both in and out+// layouts must be in this set for the dynamic ImplementationManager to be offered.+// Each entry requires a dynamic-capable kernel (Ref covers all; bfyx_to_blocked_format+// handles bfyx/bfzyx -> blocked; fsv handles blocked <-> blocked). Entries below+// match what reorder_gpu_optimization.dynamic_* tests exercise; extend only when a+// production network needs a new dynamic reorder path + a matching optimized kernel.static std::vector<format> supported_dyn_formats = {format::bfyx,format::bfzyx,format::bfwzyx,- format::b_fs_yx_fsv16+ format::b_fs_yx_fsv4,+ format::b_fs_yx_fsv16,+ format::b_fs_yx_fsv32,+ format::b_fs_zyx_fsv16,+ format::b_fs_zyx_fsv32,+ format::bs_fs_yx_bsv16_fsv16,+ format::bs_fs_zyx_bsv16_fsv32,};const std::vector<std::shared_ptr<cldnn::ImplementationManager>>& Registry<reorder>::get_implementations() {diff --git a/src/plugins/intel_gpu/src/kernel_selector/cl_kernels/mvn_gpu_b_fs_yx_bsv32.cl b/src/plugins/intel_gpu/src/kernel_selector/cl_kernels/mvn_gpu_b_fs_yx_bsv32.clnew file mode 100644index 00000000000..523fd537370--- /dev/null+++ b/src/plugins/intel_gpu/src/kernel_selector/cl_kernels/mvn_gpu_b_fs_yx_bsv32.cl@@ -0,0 +1,409 @@+// Copyright (C) 2018-2026 Intel Corporation+// SPDX-License-Identifier: Apache-2.0+//+// This file is intentionally split from mvn_gpu_b_fs_yx_fsv16.cl.+// Both files share the accumulate/reduce helpers and define their own+// ITEMS_NUM via the preprocessor. Keeping them in one CL file would leak+// ITEMS_NUM across batch-compiled kernels and produce wrong dispatches.+// Do not merge them back without introducing a per-kernel JIT for ITEMS_NUM.++#include "include/batch_headers/fetch_data.cl"+#include "include/batch_headers/imad.cl"+#include "include/batch_headers/sub_group_block_read.cl"+#include "include/batch_headers/sub_group_block_write.cl"+#include "include/batch_headers/sub_group_shuffle.cl"++#include "mvn_gpu_b_fs_yx_fsv16_accumulate.cl"+#include "mvn_gpu_b_fs_yx_fsv16_reduce.cl"++// MVN - performs mean-variance normalization, that is normalizes the input data to have+// 0 mean and if NORMALIZE_VARIANCE is set to have variance 1.+//+// Below is a set of 5 kernels:+// mvn_mean_1, mvn_mean_2, mvn_var_1, mvn_var_2, mvn_final+// that can perform mvn operation in two modes.+//+// Basic mode:+// In this mode only mvn_final kernel is used. It performs required reductions for mean+// and variance in this single kernel using single work-group for slice of data-sets+// and reducing intermidiate values with local memory.+// It does not require any additional jit constants.+// lws: LWS x 1 x 1+// gws: LWS x feature x batch+//+// Parallel mode:+// In this mode all kernels are used to provide extra paralellism with global memory+// and host side synchronization with evets/in-order queue.+// To calculate mean:+// mvn_mean_1 kernel should be first enqueued, provided extra global memory on second input+// allowing to store intermidate results from all work-groups.+// To activate this kernel MVN_KERNEL_MEAN_1 must be defined and evaluate to true/1.+// lws: LWS x 1 x 1+// gws: LWS * ITEM_GROUPS x feature x batch+// This kernel will calculate partial results for each ITEM_GROUPS work-groups and store it into global memory.+//+// mvn_mean_2 kernel must be next enqueued in order to further reduce previous results using single work-group.+// This kernel expects on first input the result of mvn_mean_1 and on second input global memory of size+// batch * align(feature, FSV) should be provided to store final mean values.+// It needs to be ensured that mvn_mean_1 kernel has finished and stored its partial results into memory.+// To activate this kernel MVN_KERNEL_MEAN_2 must be defined and evaluate to true/1.+// lws: LWS x 1 x 1+// gws: LWS x feature x batch+//+// If required analogously the mvn_var_1 and mvn_var_2 kernels should be enqueud, additionally providing results from+// mvn_mean_2 kernel.+//+// Finally the mvn_final kernel should be enqueued with provided buffers with outputs from previous kernels+// (mvn_mean_2, mvn_var_2). To enable parallel mode PRECALC_MEAN and optionally PRECALC_VARIANCE definitions should be+// used. As at this stage there is no further need to synchronize and this kernel will perform simple normalization+// given known mean and inverse of variance. Due to this this kernel can be enqueued with full paralellization, not+// limiting it to single work-group.+// lws: SIMD x 1 x 1+// gws: (x * y) / SIMD * SIMD x feature x batch+//+// Required jit constants:+// SIMD - Sub-group/simd size.+// LWS - Local work-size along 0th dimension, must be multiple of SIMD.+// GWS - Global work-size along 0th dimension.+// In basic mode this must be equal to LWS.+// In parallel mode this must be equal to LWS * ITEM_GROUPS, except in mvn_final kernel where it has no restrictions.+// ITEM_GROUPS - Number of work-groups performing accumulation in parallel mode. Should be the same in both stages of parallel kernels.++#define FSV 16+#define SG_NUM (LWS / SIMD)++#define INPUT_TYPE2 MAKE_VECTOR_TYPE(INPUT0_TYPE, 2)+#define INPUT_TYPE4 MAKE_VECTOR_TYPE(INPUT0_TYPE, 4)+#define INPUT_TYPE8 MAKE_VECTOR_TYPE(INPUT0_TYPE, 8)+#define INPUT_PACKED_TYPE MAKE_VECTOR_TYPE(INPUT0_TYPE, FSV)+#define OUTPUT_PACKED_TYPE MAKE_VECTOR_TYPE(OUTPUT_TYPE, FSV)+#define MEAN_PACKED_TYPE MAKE_VECTOR_TYPE(MEAN_TYPE, FSV)+#define INT_PACKED_TYPE MAKE_VECTOR_TYPE(int, FSV)+#define ACC_PACKED_TYPE MAKE_VECTOR_TYPE(ACCUMULATOR_TYPE, FSV)+#define ACT_PACKED_TYPE MAKE_VECTOR_TYPE(ACTIVATION_TYPE, FSV)++#define TO_MEAN_PACKED_TYPE CAT(convert_, MEAN_PACKED_TYPE)+#define TO_ACT_PACKED_TYPE CAT(convert_, ACT_PACKED_TYPE)++#define ITEMS_NUM (OUTPUT_SIZE_X * OUTPUT_SIZE_Y * OUTPUT_SIZE_Z)++// ================================================================================================+#if MVN_KERNEL_MEAN_1++DECLARE_PACKED_ACCUMULATE(accumulate_sum_input, ACCUMULATOR_TYPE, INPUT0_TYPE, FSV, INPUT_SLICE_PITCH, ITEMS_NUM, GWS, ACCUMULATE_SUM)++#if SG_NUM != 1+DECLARE_WG_PACKED_REDUCE_ADD(reduce_sum_across_sg, ACCUMULATOR_TYPE, FSV, SG_NUM, REDUCE_NO_POST_OP)+#else+DECLARE_SG_PACKED_REDUCE_ADD(reduce_sum_inside_sg, ACCUMULATOR_TYPE, FSV, REDUCE_NO_POST_OP)+#endif++REQD_SUB_GROUP_SIZE(SIMD)+__attribute__((reqd_work_group_size(LWS, 1, 1)))+KERNEL(mvn_mean_1)(const __global INPUT0_TYPE* input,+ __global ACCUMULATOR_TYPE* intermidiate_sum) {+ uint b = get_global_id(2);+ uint f = get_global_id(1) * FSV;+ uint flat_data_set_group = b * CEIL_DIV(OUTPUT_FEATURE_NUM, FSV) + get_global_id(1);++ uint items_group = get_group_id(0);+ const uint sgid = get_sub_group_id();+ const uint sglid = get_sub_group_local_id();++#if INPUT0_DIMS == 5+ const uint data_sets_offset = INPUT0_GET_INDEX(b, f, 0, 0, 0);+#else // INPUT0_DIMS == 4+ const uint data_sets_offset = INPUT0_GET_INDEX(b, f, 0, 0);+#endif++ ACC_PACKED_TYPE partial_sum = FUNC_CALL(accumulate_sum_input)(input, data_sets_offset, get_global_id(0));++#if SG_NUM != 1+ __local int slm_acc[(SG_NUM - 1) * FSV];+ int full_sum = FUNC_CALL(reduce_sum_across_sg)(partial_sum, slm_acc);+#else+ int full_sum = FUNC_CALL(reduce_sum_inside_sg)(partial_sum);+#endif++ if (sgid == 0 && (sglid < FSV || SIMD == FSV)) {+ intermidiate_sum[flat_data_set_group * ITEM_GROUPS * FSV + items_group * FSV + sglid] = full_sum;+ }+}+// ================================================================================================+#elif MVN_KERNEL_MEAN_2++DECLARE_PACKED_ACCUMULATE(accumulate_sum_input, ACCUMULATOR_TYPE, ACCUMULATOR_TYPE, FSV, FSV, ITEM_GROUPS, LWS, ACCUMULATE_SUM)++#define CALC_MEAN(sum) ((sum) / ITEMS_NUM)+#if SG_NUM != 1+DECLARE_WG_PACKED_REDUCE_ADD(reduce_mean_across_sg, MEAN_TYPE, FSV, SG_NUM, CALC_MEAN)+#else+DECLARE_SG_PACKED_REDUCE_ADD(reduce_mean_inside_sg, MEAN_TYPE, FSV, CALC_MEAN)+#endif++REQD_SUB_GROUP_SIZE(SIMD)+__attribute__((reqd_work_group_size(LWS, 1, 1)))+KERNEL(mvn_mean_2)(const __global ACCUMULATOR_TYPE* intermidiate_sum,+ __global MEAN_TYPE* intermidiate_mean) {+ uint b = get_global_id(2);+ uint f = get_global_id(1) * FSV;+ uint flat_data_set_group = b * CEIL_DIV(OUTPUT_FEATURE_NUM, FSV) + get_global_id(1);++ const uint sgid = get_sub_group_id();+ const uint sglid = get_sub_group_local_id();++ const uint data_sets_offset = flat_data_set_group * ITEM_GROUPS * FSV;++ ACC_PACKED_TYPE complete_sum = FUNC_CALL(accumulate_sum_input)(intermidiate_sum, data_sets_offset, get_local_id(0));++#if SG_NUM != 1+ __local MEAN_TYPE slm_acc[(SG_NUM - 1) * FSV];+ MEAN_TYPE mean = FUNC_CALL(reduce_mean_across_sg)(TO_MEAN_PACKED_TYPE(complete_sum), slm_acc);+#else+ MEAN_TYPE mean = FUNC_CALL(reduce_mean_inside_sg)(TO_MEAN_PACKED_TYPE(complete_sum));+#endif++ if (sgid == 0 && (sglid < FSV || SIMD == FSV)) {+ intermidiate_mean[flat_data_set_group * FSV + sglid] = mean;+ }+}+// ================================================================================================+#elif MVN_KERNEL_VAR_1++#define EXTRA_ARGS_DECL_IMPL , MEAN_TYPE mean+#define EXTRA_ARGS_IMPL , mean+#define EXTRA_ARGS_DECL EXTRA_ARGS_DECL_IMPL+#define EXTRA_ARGS EXTRA_ARGS_IMPL+#define ACCUMULATE_SUM_SQ_DEV(curr, next, idx, mean) ACCUMULATE_SUM_SQ(curr, TO_MEAN_TYPE(next) - _sub_group_shuffle(mean, idx), idx)+DECLARE_PACKED_ACCUMULATE_EARGS(accumulate_sum_sq_dev, MEAN_TYPE, INPUT0_TYPE, FSV, INPUT_SLICE_PITCH, ITEMS_NUM, GWS, ACCUMULATE_SUM_SQ_DEV, EXTRA_ARGS_DECL, EXTRA_ARGS)++#if SG_NUM != 1+DECLARE_WG_PACKED_REDUCE_ADD(reduce_sum_across_sg, MEAN_TYPE, FSV, SG_NUM, REDUCE_NO_POST_OP)+#else+DECLARE_SG_PACKED_REDUCE_ADD(reduce_sum_inside_sg, MEAN_TYPE, FSV, REDUCE_NO_POST_OP)+#endif++REQD_SUB_GROUP_SIZE(SIMD)+__attribute__((reqd_work_group_size(LWS, 1, 1)))+KERNEL(mvn_var_1)(const __global INPUT0_TYPE* input,+ const __global MEAN_TYPE* means,+ __global MEAN_TYPE* intermidiate_sum) {+ uint b = get_global_id(2);+ uint f = get_global_id(1) * FSV;+ uint flat_data_set_group = b * CEIL_DIV(OUTPUT_FEATURE_NUM, FSV) + get_global_id(1);++ uint items_group = get_group_id(0);+ const uint sgid = get_sub_group_id();+ const uint sglid = get_sub_group_local_id();++#if INPUT0_DIMS == 5+ const uint data_sets_offset = INPUT0_GET_INDEX(b, f, 0, 0, 0);+#else // INPUT0_DIMS == 4+ const uint data_sets_offset = INPUT0_GET_INDEX(b, f, 0, 0);+#endif++ MEAN_TYPE mean = means[flat_data_set_group * FSV + sglid];+ MEAN_PACKED_TYPE partial_sum = FUNC_CALL(accumulate_sum_sq_dev)(input, data_sets_offset, get_global_id(0), mean);++#if SG_NUM != 1+ __local MEAN_TYPE slm_acc[(SG_NUM - 1) * FSV];+ MEAN_TYPE full_sum = FUNC_CALL(reduce_sum_across_sg)(partial_sum, slm_acc);+#else+ MEAN_TYPE full_sum = FUNC_CALL(reduce_sum_inside_sg)(partial_sum);+#endif++ if (sgid == 0 && (sglid < FSV || SIMD == FSV)) {+ intermidiate_sum[flat_data_set_group * ITEM_GROUPS * FSV + items_group * FSV + sglid] = full_sum;+ }+}+// ================================================================================================+#elif MVN_KERNEL_VAR_2++DECLARE_PACKED_ACCUMULATE(accumulate_sum, MEAN_TYPE, MEAN_TYPE, FSV, FSV, ITEM_GROUPS, LWS, ACCUMULATE_SUM)+#if defined EPS_OUTSIDE_SQRT+ #define CALC_INVERSE_VARIANCE(sum_diff_sq) native_powr(native_sqrt((sum_diff_sq) / ITEMS_NUM) + (MEAN_TYPE)EPSILON, (MEAN_TYPE)-1.f);+#elif defined EPS_INSIDE_SQRT+ #define CALC_INVERSE_VARIANCE(sum_diff_sq) native_powr((sum_diff_sq) / ITEMS_NUM + (MEAN_TYPE)EPSILON, (MEAN_TYPE)-0.5f)+#endif+#if SG_NUM != 1+DECLARE_WG_PACKED_REDUCE_ADD(reduce_var_across_sg, MEAN_TYPE, FSV, SG_NUM, CALC_INVERSE_VARIANCE)+#else+DECLARE_SG_PACKED_REDUCE_ADD(reduce_var_inside_sg, MEAN_TYPE, FSV, CALC_INVERSE_VARIANCE)+#endif++REQD_SUB_GROUP_SIZE(SIMD)+__attribute__((reqd_work_group_size(LWS, 1, 1)))+KERNEL(mvn_var_2)(const __global MEAN_TYPE* intermidiate_sum,+ __global MEAN_TYPE* intermidiate_ivar) {+ uint b = get_global_id(2);+ uint f = get_global_id(1) * FSV;+ uint flat_data_set_group = b * CEIL_DIV(OUTPUT_FEATURE_NUM, FSV) + get_global_id(1);++ uint items_group = get_group_id(0);+ const uint sgid = get_sub_group_id();+ const uint sglid = get_sub_group_local_id();++ const uint data_sets_offset = flat_data_set_group * ITEM_GROUPS * FSV;++ MEAN_PACKED_TYPE complete_sum = FUNC_CALL(accumulate_sum)(intermidiate_sum, data_sets_offset, get_local_id(0));++#if SG_NUM != 1+ __local MEAN_TYPE slm_acc[(SG_NUM - 1) * FSV];+ MEAN_TYPE inv_variance = FUNC_CALL(reduce_var_across_sg)(complete_sum, slm_acc);+#else+ MEAN_TYPE inv_variance = FUNC_CALL(reduce_var_inside_sg)(complete_sum);+#endif++ if (sgid == 0 && (sglid < FSV || SIMD == FSV)) {+ intermidiate_ivar[flat_data_set_group * FSV + sglid] = inv_variance;+ }+}++// ================================================================================================+#elif MVN_KERNEL_MAIN_BSV32++REQD_SUB_GROUP_SIZE(SIMD)+KERNEL(mvn_final_bsv32)(+ const __global INPUT0_TYPE* input,+ __global OUTPUT_TYPE* restrict output+#if HAS_FUSED_OPS_DECLS+ , FUSED_OPS_DECLS+#endif+ , const __global MEAN_TYPE* means+#if PRECALC_VARIANCE+ , const __global MEAN_TYPE* variances+#endif+) {+ uint b = get_global_id(2);+ uint f = get_global_id(1) * FSV;+ uint flat_data_set_group = b * CEIL_DIV(OUTPUT_FEATURE_NUM, FSV) + get_global_id(1);++ MEAN_PACKED_TYPE mean_vals = ((const __global MEAN_PACKED_TYPE*)(means + (flat_data_set_group * FSV)))[0];++#if PRECALC_VARIANCE+ MEAN_PACKED_TYPE inv_variance = ((const __global MEAN_PACKED_TYPE*)(variances + (flat_data_set_group * FSV)))[0];+#else // !PRECALC_VARIANCE+ MEAN_PACKED_TYPE inv_variance = (MEAN_PACKED_TYPE)(MEAN_VAL_ONE);+#endif++ if (b >= OUTPUT_BATCH_NUM || f >= OUTPUT_FEATURE_NUM)+ return;++ const uint output_spatial = get_global_id(0);+ uint x = output_spatial % OUTPUT_SIZE_X;+ uint y = output_spatial / OUTPUT_SIZE_X;+ uint input_offset = INPUT0_GET_INDEX(b, f, y, x);+ uint output_offset = OUTPUT_GET_INDEX(b, f, y, x);++ INPUT_PACKED_TYPE in_pack = ((const __global INPUT_PACKED_TYPE*)(input + input_offset))[0];+ ACT_PACKED_TYPE normalized_vec = fma((TO_ACT_PACKED_TYPE(in_pack) - TO_ACT_PACKED_TYPE(mean_vals)),+ TO_ACT_PACKED_TYPE(inv_variance), (ACT_PACKED_TYPE)0);+ OUTPUT_PACKED_TYPE result_vec = OUTPUT_VAL_ZERO;++ unroll_for (uint fi = 0; fi < FSV; fi++) {+ ACTIVATION_TYPE normalized = normalized_vec[fi];+# if HAS_FUSED_OPS+ FUSED_OPS;+ result_vec[fi] = FUSED_OPS_RESULT;+# else+ result_vec[fi] = TO_OUTPUT_TYPE(normalized);+# endif+ }++ vstore16(result_vec, 0, &output[output_offset]);+}++#elif MVN_KERNEL_MEAN_VAR_BSV32++// Mean:+DECLARE_PACKED_ACCUMULATE(accumulate_sum_input, ACCUMULATOR_TYPE, INPUT0_TYPE, FSV, INPUT_SLICE_PITCH, ITEMS_NUM, LWS, ACCUMULATE_SUM)++#define CALC_MEAN(sum) ((sum) / ITEMS_NUM)+#if SG_NUM != 1+DECLARE_WG_PACKED_REDUCE_ADD(reduce_mean, MEAN_TYPE, FSV, SG_NUM, CALC_MEAN)+#else+DECLARE_SG_PACKED_REDUCE_ADD(reduce_mean, MEAN_TYPE, FSV, CALC_MEAN)+#endif++// Variance:+#define EXTRA_ARGS_DECL_IMPL , MEAN_TYPE mean+#define EXTRA_ARGS_IMPL , mean+#define EXTRA_ARGS_DECL EXTRA_ARGS_DECL_IMPL+#define EXTRA_ARGS EXTRA_ARGS_IMPL+#define ACCUMULATE_SUM_SQ_DEV(curr, next, idx, mean) ACCUMULATE_SUM_SQ(curr, TO_MEAN_TYPE(next) - _sub_group_shuffle(mean, idx), idx)+DECLARE_PACKED_ACCUMULATE_EARGS(accumulate_sum_sq_dev, MEAN_TYPE, INPUT0_TYPE, FSV, INPUT_SLICE_PITCH, ITEMS_NUM, LWS, ACCUMULATE_SUM_SQ_DEV, EXTRA_ARGS_DECL, EXTRA_ARGS)++#if defined EPS_OUTSIDE_SQRT+ #define CALC_INVERSE_VARIANCE(sum_diff_sq) native_powr(native_sqrt((sum_diff_sq) / ITEMS_NUM) + (MEAN_TYPE)EPSILON, (MEAN_TYPE)-1.f);+#elif defined EPS_INSIDE_SQRT+ #define CALC_INVERSE_VARIANCE(sum_diff_sq) native_powr((sum_diff_sq) / ITEMS_NUM + (MEAN_TYPE)EPSILON, (MEAN_TYPE)-0.5f)+#endif+#if SG_NUM != 1+DECLARE_WG_PACKED_REDUCE_ADD(reduce_inverse_variance, MEAN_TYPE, FSV, SG_NUM, CALC_INVERSE_VARIANCE)+#else+DECLARE_SG_PACKED_REDUCE_ADD(reduce_inverse_variance, MEAN_TYPE, FSV, CALC_INVERSE_VARIANCE)+#endif++REQD_SUB_GROUP_SIZE(SIMD)+__attribute__((reqd_work_group_size(LWS, 1, 1)))+KERNEL(mvn_mean_var_bsv32)(+ const __global INPUT0_TYPE* input,+ __global MEAN_TYPE* means+#if NORMALIZE_VARIANCE+ , __global MEAN_TYPE* variances+#endif+) {+ uint b = get_global_id(2);+ uint f = get_global_id(1) * FSV;+ uint flat_data_set_group = b * CEIL_DIV(OUTPUT_FEATURE_NUM, FSV) + get_global_id(1);++ const uint sgid = get_sub_group_id();+ const uint sglid = get_sub_group_local_id();+ const uint data_sets_offset = INPUT0_GET_INDEX(b, f, 0, 0);++ ACC_PACKED_TYPE partial_sum = FUNC_CALL(accumulate_sum_input)(input, data_sets_offset, get_local_id(0));+#if SG_NUM != 1+ __local MEAN_TYPE slm_mean_acc[(SG_NUM - 1) * FSV];+ MEAN_TYPE mean = FUNC_CALL(reduce_mean)(TO_MEAN_PACKED_TYPE(partial_sum), slm_mean_acc);+#else+ MEAN_TYPE mean = FUNC_CALL(reduce_mean)(TO_MEAN_PACKED_TYPE(partial_sum));+#endif++#if NORMALIZE_VARIANCE+ MEAN_PACKED_TYPE partial_dev = FUNC_CALL(accumulate_sum_sq_dev)(input, data_sets_offset, get_local_id(0), mean);+ #if SG_NUM != 1+ __local MEAN_TYPE slm_var_acc[(SG_NUM - 1) * FSV];+ MEAN_TYPE inv_variance = FUNC_CALL(reduce_inverse_variance)(partial_dev, slm_var_acc);+ #else+ MEAN_TYPE inv_variance = FUNC_CALL(reduce_inverse_variance)(partial_dev);+ #endif+#endif++ if (sgid == 0 && (sglid < FSV || SIMD == FSV)) {+ means[flat_data_set_group * FSV + sglid] = mean;+ #if NORMALIZE_VARIANCE+ variances[flat_data_set_group * FSV + sglid] = inv_variance;+ #endif+ }+}+#endif+// ================================================================================================++#undef FSV+#undef INPUT_SLICE_PITCH+#undef SG_NUM+#undef ITEMS_NUM++#undef INPUT_TYPE2+#undef INPUT_TYPE4+#undef INPUT_TYPE8+#undef INPUT_PACKED_TYPE+#undef OUTPUT_PACKED_TYPE+#undef INT_PACKED_TYPE+#undef MEAN_PACKED_TYPE+#undef TO_MEAN_PACKED_TYPE++#undef INPUT_PACKED_BLOCK_READ+#undef OUTPUT_PAD_IN_ITEMS++#undef USE_IMADdiff --git a/src/plugins/intel_gpu/src/kernel_selector/cl_kernels/mvn_gpu_b_fs_yx_fsv16_imad.cl b/src/plugins/intel_gpu/src/kernel_selector/cl_kernels/mvn_gpu_b_fs_yx_fsv16.clsimilarity index 80%rename from src/plugins/intel_gpu/src/kernel_selector/cl_kernels/mvn_gpu_b_fs_yx_fsv16_imad.clrename to src/plugins/intel_gpu/src/kernel_selector/cl_kernels/mvn_gpu_b_fs_yx_fsv16.clindex 591bb949fef..dc81722f346 100644--- a/src/plugins/intel_gpu/src/kernel_selector/cl_kernels/mvn_gpu_b_fs_yx_fsv16_imad.cl+++ b/src/plugins/intel_gpu/src/kernel_selector/cl_kernels/mvn_gpu_b_fs_yx_fsv16.cl@@ -8,8 +8,8 @@#include "include/batch_headers/sub_group_block_write.cl"#include "include/batch_headers/sub_group_shuffle.cl"-#include "mvn_gpu_b_fs_yx_fsv16_imad_accumulate.cl"-#include "mvn_gpu_b_fs_yx_fsv16_imad_reduce.cl"+#include "mvn_gpu_b_fs_yx_fsv16_accumulate.cl"+#include "mvn_gpu_b_fs_yx_fsv16_reduce.cl"// MVN - performs mean-variance normalization, that is normalizes the input data to have// 0 mean and if NORMALIZE_VARIANCE is set to have variance 1.@@ -66,6 +66,8 @@#define FSV 16#define SG_NUM (LWS / SIMD)+#define ISP_STRIDE (INPUT_SLICE_PITCH / FSV)+#define OSP_STRIDE (OUTPUT_SLICE_PITCH / FSV)#define INPUT_TYPE2 MAKE_VECTOR_TYPE(INPUT0_TYPE, 2)#define INPUT_TYPE4 MAKE_VECTOR_TYPE(INPUT0_TYPE, 4)@@ -80,12 +82,31 @@#define TO_MEAN_PACKED_TYPE CAT(convert_, MEAN_PACKED_TYPE)#define TO_ACT_PACKED_TYPE CAT(convert_, ACT_PACKED_TYPE)-#define ITEMS_NUM (OUTPUT_SIZE_X * OUTPUT_SIZE_Y * OUTPUT_SIZE_Z)+// ITEMS_NUM must be provided exclusively via JIT by every kernel class+// that uses this CL file (fsv16).+// JIT-defined constants are automatically #undef'd between batch-compiled+// kernels, preventing stale macro leakage across compilation units.+// Do NOT add a #ifndef fallback here — a CL-side #define escapes the+// JIT #undef system and leaks into subsequent batch-compiled kernels.++// OUTPUT_PAD_IN_ITEMS is used in #if preprocessor directives.+// For dynamic shapes, OUTPUT_PAD_* macros may expand to shape_info[N]+// references that the preprocessor cannot evaluate. Always take the+// padded output path (OUTPUT_GET_INDEX) in dynamic mode for safety.+#if IS_DYNAMIC+#define OUTPUT_PAD_IN_ITEMS 1+#else+#define OUTPUT_PAD_IN_ITEMS (OUTPUT_PAD_BEFORE_SIZE_X != 0 || OUTPUT_PAD_AFTER_SIZE_X != 0 || OUTPUT_PAD_BEFORE_SIZE_Y != 0)+#endif// ================================================================================================#if MVN_KERNEL_MEAN_1+#if IS_DYNAMIC+DECLARE_PACKED_ACCUMULATE_DYN(accumulate_sum_input, ACCUMULATOR_TYPE, INPUT0_TYPE, FSV, INPUT_SLICE_PITCH, GWS, ACCUMULATE_SUM)+#elseDECLARE_PACKED_ACCUMULATE(accumulate_sum_input, ACCUMULATOR_TYPE, INPUT0_TYPE, FSV, INPUT_SLICE_PITCH, ITEMS_NUM, GWS, ACCUMULATE_SUM)+#endif#if SG_NUM != 1DECLARE_WG_PACKED_REDUCE_ADD(reduce_sum_across_sg, ACCUMULATOR_TYPE, FSV, SG_NUM, REDUCE_NO_POST_OP)@@ -94,9 +115,17 @@ DECLARE_SG_PACKED_REDUCE_ADD(reduce_sum_inside_sg, ACCUMULATOR_TYPE, FSV, REDUCE#endifREQD_SUB_GROUP_SIZE(SIMD)+#if !IS_DYNAMIC__attribute__((reqd_work_group_size(LWS, 1, 1)))-KERNEL(mvn_mean_1)(const __global INPUT0_TYPE* input,- __global ACCUMULATOR_TYPE* intermidiate_sum) {+#endif+KERNEL(mvn_mean_1)(+ OPTIONAL_SHAPE_INFO_ARG+ const __global INPUT0_TYPE* input,+ __global ACCUMULATOR_TYPE* intermidiate_sum+#if IS_DYNAMIC+ , uint items_num+#endif+) {uint b = get_global_id(2);uint f = get_global_id(1) * FSV;uint flat_data_set_group = b * CEIL_DIV(OUTPUT_FEATURE_NUM, FSV) + get_global_id(1);@@ -111,13 +140,17 @@ KERNEL(mvn_mean_1)(const __global INPUT0_TYPE* input,const uint data_sets_offset = INPUT0_GET_INDEX(b, f, 0, 0);#endif+#if IS_DYNAMIC+ ACC_PACKED_TYPE partial_sum = FUNC_CALL(accumulate_sum_input)(input, data_sets_offset, get_global_id(0), items_num);+#elseACC_PACKED_TYPE partial_sum = FUNC_CALL(accumulate_sum_input)(input, data_sets_offset, get_global_id(0));+#endif#if SG_NUM != 1- __local int slm_acc[(SG_NUM - 1) * FSV];- int full_sum = FUNC_CALL(reduce_sum_across_sg)(partial_sum, slm_acc);+ __local ACCUMULATOR_TYPE slm_acc[(SG_NUM - 1) * FSV];+ ACCUMULATOR_TYPE full_sum = FUNC_CALL(reduce_sum_across_sg)(partial_sum, slm_acc);#else- int full_sum = FUNC_CALL(reduce_sum_inside_sg)(partial_sum);+ ACCUMULATOR_TYPE full_sum = FUNC_CALL(reduce_sum_inside_sg)(partial_sum);#endifif (sgid == 0 && (sglid < FSV || SIMD == FSV)) {@@ -129,17 +162,33 @@ KERNEL(mvn_mean_1)(const __global INPUT0_TYPE* input,DECLARE_PACKED_ACCUMULATE(accumulate_sum_input, ACCUMULATOR_TYPE, ACCUMULATOR_TYPE, FSV, FSV, ITEM_GROUPS, LWS, ACCUMULATE_SUM)+#if IS_DYNAMIC+#if SG_NUM != 1+DECLARE_WG_PACKED_REDUCE_ADD(reduce_mean_across_sg, MEAN_TYPE, FSV, SG_NUM, REDUCE_NO_POST_OP)+#else+DECLARE_SG_PACKED_REDUCE_ADD(reduce_mean_inside_sg, MEAN_TYPE, FSV, REDUCE_NO_POST_OP)+#endif+#else#define CALC_MEAN(sum) ((sum) / ITEMS_NUM)#if SG_NUM != 1DECLARE_WG_PACKED_REDUCE_ADD(reduce_mean_across_sg, MEAN_TYPE, FSV, SG_NUM, CALC_MEAN)#elseDECLARE_SG_PACKED_REDUCE_ADD(reduce_mean_inside_sg, MEAN_TYPE, FSV, CALC_MEAN)#endif+#endifREQD_SUB_GROUP_SIZE(SIMD)+#if !IS_DYNAMIC__attribute__((reqd_work_group_size(LWS, 1, 1)))-KERNEL(mvn_mean_2)(const __global ACCUMULATOR_TYPE* intermidiate_sum,- __global MEAN_TYPE* intermidiate_mean) {+#endif+KERNEL(mvn_mean_2)(+ OPTIONAL_SHAPE_INFO_ARG+ const __global ACCUMULATOR_TYPE* intermidiate_sum,+ __global MEAN_TYPE* intermidiate_mean+#if IS_DYNAMIC+ , uint items_num+#endif+) {uint b = get_global_id(2);uint f = get_global_id(1) * FSV;uint flat_data_set_group = b * CEIL_DIV(OUTPUT_FEATURE_NUM, FSV) + get_global_id(1);@@ -157,6 +206,9 @@ KERNEL(mvn_mean_2)(const __global ACCUMULATOR_TYPE* intermidiate_sum,#elseMEAN_TYPE mean = FUNC_CALL(reduce_mean_inside_sg)(TO_MEAN_PACKED_TYPE(complete_sum));#endif+#if IS_DYNAMIC+ mean = mean / items_num;+#endifif (sgid == 0 && (sglid < FSV || SIMD == FSV)) {intermidiate_mean[flat_data_set_group * FSV + sglid] = mean;@@ -170,7 +222,11 @@ KERNEL(mvn_mean_2)(const __global ACCUMULATOR_TYPE* intermidiate_sum,#define EXTRA_ARGS_DECL EXTRA_ARGS_DECL_IMPL#define EXTRA_ARGS EXTRA_ARGS_IMPL#define ACCUMULATE_SUM_SQ_DEV(curr, next, idx, mean) ACCUMULATE_SUM_SQ(curr, TO_MEAN_TYPE(next) - _sub_group_shuffle(mean, idx), idx)+#if IS_DYNAMIC+DECLARE_PACKED_ACCUMULATE_DYN_EARGS(accumulate_sum_sq_dev, MEAN_TYPE, INPUT0_TYPE, FSV, INPUT_SLICE_PITCH, GWS, ACCUMULATE_SUM_SQ_DEV, EXTRA_ARGS_DECL, EXTRA_ARGS)+#elseDECLARE_PACKED_ACCUMULATE_EARGS(accumulate_sum_sq_dev, MEAN_TYPE, INPUT0_TYPE, FSV, INPUT_SLICE_PITCH, ITEMS_NUM, GWS, ACCUMULATE_SUM_SQ_DEV, EXTRA_ARGS_DECL, EXTRA_ARGS)+#endif#if SG_NUM != 1DECLARE_WG_PACKED_REDUCE_ADD(reduce_sum_across_sg, MEAN_TYPE, FSV, SG_NUM, REDUCE_NO_POST_OP)@@ -179,10 +235,18 @@ DECLARE_SG_PACKED_REDUCE_ADD(reduce_sum_inside_sg, MEAN_TYPE, FSV, REDUCE_NO_POS#endifREQD_SUB_GROUP_SIZE(SIMD)+#if !IS_DYNAMIC__attribute__((reqd_work_group_size(LWS, 1, 1)))-KERNEL(mvn_var_1)(const __global INPUT0_TYPE* input,- const __global MEAN_TYPE* means,- __global MEAN_TYPE* intermidiate_sum) {+#endif+KERNEL(mvn_var_1)(+ OPTIONAL_SHAPE_INFO_ARG+ const __global INPUT0_TYPE* input,+ const __global MEAN_TYPE* means,+ __global MEAN_TYPE* intermidiate_sum+#if IS_DYNAMIC+ , uint items_num+#endif+) {uint b = get_global_id(2);uint f = get_global_id(1) * FSV;uint flat_data_set_group = b * CEIL_DIV(OUTPUT_FEATURE_NUM, FSV) + get_global_id(1);@@ -198,7 +262,11 @@ KERNEL(mvn_var_1)(const __global INPUT0_TYPE* input,#endifMEAN_TYPE mean = means[flat_data_set_group * FSV + sglid];+#if IS_DYNAMIC+ MEAN_PACKED_TYPE partial_sum = FUNC_CALL(accumulate_sum_sq_dev)(input, data_sets_offset, get_global_id(0), items_num, mean);+#elseMEAN_PACKED_TYPE partial_sum = FUNC_CALL(accumulate_sum_sq_dev)(input, data_sets_offset, get_global_id(0), mean);+#endif#if SG_NUM != 1__local MEAN_TYPE slm_acc[(SG_NUM - 1) * FSV];@@ -215,6 +283,13 @@ KERNEL(mvn_var_1)(const __global INPUT0_TYPE* input,#elif MVN_KERNEL_VAR_2DECLARE_PACKED_ACCUMULATE(accumulate_sum, MEAN_TYPE, MEAN_TYPE, FSV, FSV, ITEM_GROUPS, LWS, ACCUMULATE_SUM)+#if IS_DYNAMIC+#if SG_NUM != 1+DECLARE_WG_PACKED_REDUCE_ADD(reduce_var_across_sg, MEAN_TYPE, FSV, SG_NUM, REDUCE_NO_POST_OP)+#else+DECLARE_SG_PACKED_REDUCE_ADD(reduce_var_inside_sg, MEAN_TYPE, FSV, REDUCE_NO_POST_OP)+#endif+#else#if defined EPS_OUTSIDE_SQRT#define CALC_INVERSE_VARIANCE(sum_diff_sq) native_powr(native_sqrt((sum_diff_sq) / ITEMS_NUM) + (MEAN_TYPE)EPSILON, (MEAN_TYPE)-1.f);#elif defined EPS_INSIDE_SQRT@@ -225,11 +300,20 @@ DECLARE_WG_PACKED_REDUCE_ADD(reduce_var_across_sg, MEAN_TYPE, FSV, SG_NUM, CALC_#elseDECLARE_SG_PACKED_REDUCE_ADD(reduce_var_inside_sg, MEAN_TYPE, FSV, CALC_INVERSE_VARIANCE)#endif+#endifREQD_SUB_GROUP_SIZE(SIMD)+#if !IS_DYNAMIC__attribute__((reqd_work_group_size(LWS, 1, 1)))-KERNEL(mvn_var_2)(const __global MEAN_TYPE* intermidiate_sum,- __global MEAN_TYPE* intermidiate_ivar) {+#endif+KERNEL(mvn_var_2)(+ OPTIONAL_SHAPE_INFO_ARG+ const __global MEAN_TYPE* intermidiate_sum,+ __global MEAN_TYPE* intermidiate_ivar+#if IS_DYNAMIC+ , uint items_num+#endif+) {uint b = get_global_id(2);uint f = get_global_id(1) * FSV;uint flat_data_set_group = b * CEIL_DIV(OUTPUT_FEATURE_NUM, FSV) + get_global_id(1);@@ -248,137 +332,16 @@ KERNEL(mvn_var_2)(const __global MEAN_TYPE* intermidiate_sum,#elseMEAN_TYPE inv_variance = FUNC_CALL(reduce_var_inside_sg)(complete_sum);#endif-- if (sgid == 0 && (sglid < FSV || SIMD == FSV)) {- intermidiate_ivar[flat_data_set_group * FSV + sglid] = inv_variance;- }-}--// ================================================================================================-#elif MVN_KERNEL_MAIN_BSV32--REQD_SUB_GROUP_SIZE(SIMD)-KERNEL(mvn_final_bsv32)(- const __global INPUT0_TYPE* input,- __global OUTPUT_TYPE* restrict output-#if HAS_FUSED_OPS_DECLS- , FUSED_OPS_DECLS-#endif- , const __global MEAN_TYPE* means-#if PRECALC_VARIANCE- , const __global MEAN_TYPE* variances-#endif-) {- uint b = get_global_id(2);- uint f = get_global_id(1) * FSV;- uint flat_data_set_group = b * CEIL_DIV(OUTPUT_FEATURE_NUM, FSV) + get_global_id(1);-- MEAN_PACKED_TYPE mean_vals = ((const __global MEAN_PACKED_TYPE*)(means + (flat_data_set_group * FSV)))[0];--#if PRECALC_VARIANCE- MEAN_PACKED_TYPE inv_variance = ((const __global MEAN_PACKED_TYPE*)(variances + (flat_data_set_group * FSV)))[0];-#else // !PRECALC_VARIANCE- MEAN_PACKED_TYPE inv_variance = (MEAN_PACKED_TYPE)(MEAN_VAL_ONE);-#endif-- if (b >= OUTPUT_BATCH_NUM || f >= OUTPUT_FEATURE_NUM)- return;-- const uint output_spatial = get_global_id(0);- uint x = output_spatial % OUTPUT_SIZE_X;- uint y = output_spatial / OUTPUT_SIZE_X;- uint input_offset = INPUT0_GET_INDEX(b, f, y, x);- uint output_offset = OUTPUT_GET_INDEX(b, f, y, x);-- INPUT_PACKED_TYPE in_pack = ((const __global INPUT_PACKED_TYPE*)(input + input_offset))[0];- ACT_PACKED_TYPE normalized_vec = fma((TO_ACT_PACKED_TYPE(in_pack) - TO_ACT_PACKED_TYPE(mean_vals)),- TO_ACT_PACKED_TYPE(inv_variance), (ACT_PACKED_TYPE)0);- OUTPUT_PACKED_TYPE result_vec = OUTPUT_VAL_ZERO;-- unroll_for (uint fi = 0; fi < FSV; fi++) {- ACTIVATION_TYPE normalized = normalized_vec[fi];-# if HAS_FUSED_OPS- FUSED_OPS;- result_vec[fi] = FUSED_OPS_RESULT;-# else- result_vec[fi] = TO_OUTPUT_TYPE(normalized);-# endif- }-- vstore16(result_vec, 0, &output[output_offset]);-}--#elif MVN_KERNEL_MEAN_VAR_BSV32--// Mean:-DECLARE_PACKED_ACCUMULATE(accumulate_sum_input, ACCUMULATOR_TYPE, INPUT0_TYPE, FSV, INPUT_SLICE_PITCH, ITEMS_NUM, LWS, ACCUMULATE_SUM)--#define CALC_MEAN(sum) ((sum) / ITEMS_NUM)-#if SG_NUM != 1-DECLARE_WG_PACKED_REDUCE_ADD(reduce_mean, MEAN_TYPE, FSV, SG_NUM, CALC_MEAN)-#else-DECLARE_SG_PACKED_REDUCE_ADD(reduce_mean, MEAN_TYPE, FSV, CALC_MEAN)-#endif--// Variance:-#define EXTRA_ARGS_DECL_IMPL , MEAN_TYPE mean-#define EXTRA_ARGS_IMPL , mean-#define EXTRA_ARGS_DECL EXTRA_ARGS_DECL_IMPL-#define EXTRA_ARGS EXTRA_ARGS_IMPL-#define ACCUMULATE_SUM_SQ_DEV(curr, next, idx, mean) ACCUMULATE_SUM_SQ(curr, TO_MEAN_TYPE(next) - _sub_group_shuffle(mean, idx), idx)-DECLARE_PACKED_ACCUMULATE_EARGS(accumulate_sum_sq_dev, MEAN_TYPE, INPUT0_TYPE, FSV, INPUT_SLICE_PITCH, ITEMS_NUM, LWS, ACCUMULATE_SUM_SQ_DEV, EXTRA_ARGS_DECL, EXTRA_ARGS)-+#if IS_DYNAMIC#if defined EPS_OUTSIDE_SQRT- #define CALC_INVERSE_VARIANCE(sum_diff_sq) native_powr(native_sqrt((sum_diff_sq) / ITEMS_NUM) + (MEAN_TYPE)EPSILON, (MEAN_TYPE)-1.f);+ inv_variance = native_powr(native_sqrt(inv_variance / items_num) + (MEAN_TYPE)EPSILON, (MEAN_TYPE)-1.f);#elif defined EPS_INSIDE_SQRT- #define CALC_INVERSE_VARIANCE(sum_diff_sq) native_powr((sum_diff_sq) / ITEMS_NUM + (MEAN_TYPE)EPSILON, (MEAN_TYPE)-0.5f)-#endif-#if SG_NUM != 1-DECLARE_WG_PACKED_REDUCE_ADD(reduce_inverse_variance, MEAN_TYPE, FSV, SG_NUM, CALC_INVERSE_VARIANCE)-#else-DECLARE_SG_PACKED_REDUCE_ADD(reduce_inverse_variance, MEAN_TYPE, FSV, CALC_INVERSE_VARIANCE)-#endif--REQD_SUB_GROUP_SIZE(SIMD)-__attribute__((reqd_work_group_size(LWS, 1, 1)))-KERNEL(mvn_mean_var_bsv32)(- const __global INPUT0_TYPE* input,- __global MEAN_TYPE* means-#if NORMALIZE_VARIANCE- , __global MEAN_TYPE* variances-#endif-) {- uint b = get_global_id(2);- uint f = get_global_id(1) * FSV;- uint flat_data_set_group = b * CEIL_DIV(OUTPUT_FEATURE_NUM, FSV) + get_global_id(1);-- const uint sgid = get_sub_group_id();- const uint sglid = get_sub_group_local_id();- const uint data_sets_offset = INPUT0_GET_INDEX(b, f, 0, 0);-- ACC_PACKED_TYPE partial_sum = FUNC_CALL(accumulate_sum_input)(input, data_sets_offset, get_local_id(0));-#if SG_NUM != 1- __local MEAN_TYPE slm_mean_acc[(SG_NUM - 1) * FSV];- MEAN_TYPE mean = FUNC_CALL(reduce_mean)(TO_MEAN_PACKED_TYPE(partial_sum), slm_mean_acc);-#else- MEAN_TYPE mean = FUNC_CALL(reduce_mean)(TO_MEAN_PACKED_TYPE(partial_sum));+ inv_variance = native_powr(inv_variance / items_num + (MEAN_TYPE)EPSILON, (MEAN_TYPE)-0.5f);#endif--#if NORMALIZE_VARIANCE- MEAN_PACKED_TYPE partial_dev = FUNC_CALL(accumulate_sum_sq_dev)(input, data_sets_offset, get_local_id(0), mean);- #if SG_NUM != 1- __local MEAN_TYPE slm_var_acc[(SG_NUM - 1) * FSV];- MEAN_TYPE inv_variance = FUNC_CALL(reduce_inverse_variance)(partial_dev, slm_var_acc);- #else- MEAN_TYPE inv_variance = FUNC_CALL(reduce_inverse_variance)(partial_dev);- #endif#endifif (sgid == 0 && (sglid < FSV || SIMD == FSV)) {- means[flat_data_set_group * FSV + sglid] = mean;- #if NORMALIZE_VARIANCE- variances[flat_data_set_group * FSV + sglid] = inv_variance;- #endif+ intermidiate_ivar[flat_data_set_group * FSV + sglid] = inv_variance;}}@@ -386,14 +349,22 @@ KERNEL(mvn_mean_var_bsv32)(#else // MVN_KERNEL_MAIN// Mean:-DECLARE_PACKED_ACCUMULATE(accumulate_sum_input, int, INPUT0_TYPE, FSV, INPUT_SLICE_PITCH, ITEMS_NUM, LWS, ACCUMULATE_SUM)-+#if IS_DYNAMIC+DECLARE_PACKED_ACCUMULATE_DYN(accumulate_sum_input, ACCUMULATOR_TYPE, INPUT0_TYPE, FSV, INPUT_SLICE_PITCH, LWS, ACCUMULATE_SUM)+#if SG_NUM != 1+DECLARE_WG_PACKED_REDUCE_ADD(reduce_mean, MEAN_TYPE, FSV, SG_NUM, REDUCE_NO_POST_OP)+#else+DECLARE_SG_PACKED_REDUCE_ADD(reduce_mean, MEAN_TYPE, FSV, REDUCE_NO_POST_OP)+#endif+#else+DECLARE_PACKED_ACCUMULATE(accumulate_sum_input, ACCUMULATOR_TYPE, INPUT0_TYPE, FSV, INPUT_SLICE_PITCH, ITEMS_NUM, LWS, ACCUMULATE_SUM)#define CALC_MEAN(sum) ((sum) / ITEMS_NUM)#if SG_NUM != 1DECLARE_WG_PACKED_REDUCE_ADD(reduce_mean, MEAN_TYPE, FSV, SG_NUM, CALC_MEAN)#elseDECLARE_SG_PACKED_REDUCE_ADD(reduce_mean, MEAN_TYPE, FSV, CALC_MEAN)#endif+#endif// Variance:#define EXTRA_ARGS_DECL_IMPL , MEAN_TYPE mean@@ -401,8 +372,15 @@ DECLARE_SG_PACKED_REDUCE_ADD(reduce_mean, MEAN_TYPE, FSV, CALC_MEAN)#define EXTRA_ARGS_DECL EXTRA_ARGS_DECL_IMPL#define EXTRA_ARGS EXTRA_ARGS_IMPL#define ACCUMULATE_SUM_SQ_DEV(curr, next, idx, mean) ACCUMULATE_SUM_SQ(curr, next - _sub_group_shuffle(mean, idx), idx)+#if IS_DYNAMIC+DECLARE_PACKED_ACCUMULATE_DYN_EARGS(accumulate_sum_sq_dev, MEAN_TYPE, INPUT0_TYPE, FSV, INPUT_SLICE_PITCH, LWS, ACCUMULATE_SUM_SQ_DEV, EXTRA_ARGS_DECL, EXTRA_ARGS)+#if SG_NUM != 1+DECLARE_WG_PACKED_REDUCE_ADD(reduce_inverse_variance, MEAN_TYPE, FSV, SG_NUM, REDUCE_NO_POST_OP)+#else+DECLARE_SG_PACKED_REDUCE_ADD(reduce_inverse_variance, MEAN_TYPE, FSV, REDUCE_NO_POST_OP)+#endif+#elseDECLARE_PACKED_ACCUMULATE_EARGS(accumulate_sum_sq_dev, MEAN_TYPE, INPUT0_TYPE, FSV, INPUT_SLICE_PITCH, ITEMS_NUM, LWS, ACCUMULATE_SUM_SQ_DEV, EXTRA_ARGS_DECL, EXTRA_ARGS)-#if defined EPS_OUTSIDE_SQRT#define CALC_INVERSE_VARIANCE(sum_diff_sq) native_powr(native_sqrt((sum_diff_sq) / ITEMS_NUM) + (MEAN_TYPE)EPSILON, (MEAN_TYPE)-1.f);#elif defined EPS_INSIDE_SQRT@@ -413,14 +391,21 @@ DECLARE_WG_PACKED_REDUCE_ADD(reduce_inverse_variance, MEAN_TYPE, FSV, SG_NUM, CA#elseDECLARE_SG_PACKED_REDUCE_ADD(reduce_inverse_variance, MEAN_TYPE, FSV, CALC_INVERSE_VARIANCE)#endif+#endif+#if TYPE_SIZE(INPUT0_TYPE) == 1#define INPUT_PACKED_BLOCK_READ(ptr) BLOCK_READN(INPUT0_TYPE, FSV, ptr, 0)--#define OUTPUT_PAD_IN_ITEMS (OUTPUT_PAD_BEFORE_SIZE_X != 0 || OUTPUT_PAD_AFTER_SIZE_X != 0 || OUTPUT_PAD_BEFORE_SIZE_Y != 0)+#else+// sub_group_block_read supports max 8 elements for ushort/uint types, so split into two 8-wide reads+#define INPUT_PACKED_BLOCK_READ(ptr) ((INPUT_PACKED_TYPE)(BLOCK_READN(INPUT0_TYPE, 8, ptr, 0), BLOCK_READN(INPUT0_TYPE, 8, ptr, 8 * SIMD)))+#endifREQD_SUB_GROUP_SIZE(SIMD)+#if !IS_DYNAMIC__attribute__((reqd_work_group_size(LWS, 1, 1)))+#endifKERNEL(mvn_final)(+ OPTIONAL_SHAPE_INFO_ARGconst __global INPUT0_TYPE* input,__global OUTPUT_TYPE* restrict output#if HAS_FUSED_OPS_DECLS@@ -432,14 +417,25 @@ KERNEL(mvn_final)(#if PRECALC_VARIANCE, const __global MEAN_TYPE* variances#endif+#if IS_DYNAMIC+ , uint items_num+#endif) {uint b = get_global_id(2);uint f = get_global_id(1) * FSV;uint flat_data_set_group = b * CEIL_DIV(OUTPUT_FEATURE_NUM, FSV) + get_global_id(1);-#if GWS != LWS+#if IS_DYNAMIC+ // In dynamic mode the JIT constant GWS may be a compile-time placeholder+ // that differs from the actual dispatch global work-size set at runtime.+ // Use get_global_size(0) to obtain the true runtime value.uint items_group = get_group_id(0);+ const uint effective_gws = get_global_size(0);+#elif GWS != LWS+ uint items_group = get_group_id(0);+ const uint effective_gws = GWS;#elseuint items_group = 0;+ const uint effective_gws = GWS;#endifconst uint sgid = get_sub_group_id() + items_group * SG_NUM;const uint sglid = get_sub_group_local_id();@@ -454,32 +450,50 @@ KERNEL(mvn_final)(#if PRECALC_MEANMEAN_TYPE mean = means[flat_data_set_group * FSV + sglid];#else- INT_PACKED_TYPE partial_sum = FUNC_CALL(accumulate_sum_input)(input, data_sets_offset, get_local_id(0));+#if IS_DYNAMIC+ ACC_PACKED_TYPE partial_sum = FUNC_CALL(accumulate_sum_input)(input, data_sets_offset, get_local_id(0), items_num);+#else+ ACC_PACKED_TYPE partial_sum = FUNC_CALL(accumulate_sum_input)(input, data_sets_offset, get_local_id(0));+#endif# if SG_NUM != 1__local MEAN_TYPE slm_mean_acc[(SG_NUM - 1) * FSV];MEAN_TYPE mean = FUNC_CALL(reduce_mean)(TO_MEAN_PACKED_TYPE(partial_sum), slm_mean_acc);# elseMEAN_TYPE mean = FUNC_CALL(reduce_mean)(TO_MEAN_PACKED_TYPE(partial_sum));# endif+#if IS_DYNAMIC+ mean = mean / items_num;+#endif#endif#if NORMALIZE_VARIANCE# if PRECALC_VARIANCEMEAN_TYPE inv_variance = variances[flat_data_set_group * FSV + sglid];# else+#if IS_DYNAMIC+ MEAN_PACKED_TYPE partial_dev = FUNC_CALL(accumulate_sum_sq_dev)(input, data_sets_offset, get_local_id(0), items_num, mean);+#elseMEAN_PACKED_TYPE partial_dev = FUNC_CALL(accumulate_sum_sq_dev)(input, data_sets_offset, get_local_id(0), mean);+#endif# if SG_NUM != 1__local MEAN_TYPE slm_var_acc[(SG_NUM - 1) * FSV];MEAN_TYPE inv_variance = FUNC_CALL(reduce_inverse_variance)(partial_dev, slm_var_acc);# elseMEAN_TYPE inv_variance = FUNC_CALL(reduce_inverse_variance)(partial_dev);# endif+#if IS_DYNAMIC+#if defined EPS_OUTSIDE_SQRT+ inv_variance = native_powr(native_sqrt(inv_variance / items_num) + (MEAN_TYPE)EPSILON, (MEAN_TYPE)-1.f);+#elif defined EPS_INSIDE_SQRT+ inv_variance = native_powr(inv_variance / items_num + (MEAN_TYPE)EPSILON, (MEAN_TYPE)-0.5f);+#endif+#endif# endif#elseMEAN_TYPE inv_variance = 1;#endif-#if OUTPUT_IS_FP+#if OUTPUT_IS_FP && (INPUT_SLICE_PITCH == FSV)input_offset = data_sets_offset + sgid * SIMD * FSV;uint output_spatial_base = sgid * SIMD;#if OUTPUT_DIMS == 5@@ -490,7 +504,7 @@ KERNEL(mvn_final)(// For fused ops to align with non-fp pathconst uint set_idx = sglid;- for (uint spatial_idx = 0; spatial_idx < ITEMS_NUM / GWS; ++spatial_idx) {+ for (uint spatial_idx = 0; spatial_idx < ITEMS_NUM / effective_gws; ++spatial_idx) {INPUT_PACKED_TYPE in_pack = INPUT_PACKED_BLOCK_READ(input + input_offset);unroll_for(uint si = 0; si < SIMD; ++si) {@@ -519,13 +533,13 @@ KERNEL(mvn_final)(DT_OUTPUT_BLOCK_WRITE(output, output_offset, result);#endif}- input_offset += GWS * FSV;- output_offset += GWS * FSV;- output_spatial_base += GWS;+ input_offset += effective_gws * FSV;+ output_offset += effective_gws * FSV;+ output_spatial_base += effective_gws;}// [constexpr] Number of leftovers after full local work-group iterations.- const uint lws_uniform_leftovers = ITEMS_NUM % GWS;+ const uint lws_uniform_leftovers = ITEMS_NUM % effective_gws;// [constexpr] Number of sub-groups that can process leftovers loading SIMD items.const uint lws_uniform_leftovers_full_simds = lws_uniform_leftovers / SIMD;// [constexpr] Number of leftovers after full sub-group processing.@@ -624,17 +638,18 @@ KERNEL(mvn_final)(#endif}}-#else // => !OUTPUT_IS_FP- input_offset = data_sets_offset + sgid * SIMD * FSV;+#else // => !OUTPUT_IS_FP || INPUT_SLICE_PITCH != FSV+ // Per-spatial-position path: works for both int types and cross-layout (e.g. fsv32 in, fsv16 out)+ input_offset = data_sets_offset + sgid * SIMD * INPUT_SLICE_PITCH;#if OUTPUT_DIMS == 5- uint output_offset = OUTPUT_GET_INDEX(b, f, 0, 0, 0) + sgid * SIMD * FSV;+ uint output_offset = OUTPUT_GET_INDEX(b, f, 0, 0, 0) + sgid * SIMD * OUTPUT_SLICE_PITCH;#else // OUTPUT_DIMS == 4- uint output_offset = OUTPUT_GET_INDEX(b, f, 0, 0) + sgid * SIMD * FSV;+ uint output_offset = OUTPUT_GET_INDEX(b, f, 0, 0) + sgid * SIMD * OUTPUT_SLICE_PITCH;#endifuint output_spatial = sgid * SIMD + sglid;- for (uint spatial_idx = 0; spatial_idx < ITEMS_NUM / GWS; ++spatial_idx) {- INPUT_PACKED_TYPE in_pack = ((const __global INPUT_PACKED_TYPE*)(input + input_offset))[sglid];+ for (uint spatial_idx = 0; spatial_idx < ITEMS_NUM / effective_gws; ++spatial_idx) {+ INPUT_PACKED_TYPE in_pack = ((const __global INPUT_PACKED_TYPE*)(input + input_offset))[sglid * ISP_STRIDE];OUTPUT_PACKED_TYPE result;unroll_for(uint set_idx = 0; set_idx < FSV; ++set_idx) {@@ -647,7 +662,7 @@ KERNEL(mvn_final)(# endif}#if !OUTPUT_PAD_IN_ITEMS- ((__global OUTPUT_PACKED_TYPE*)(output + output_offset))[sglid] = result;+ ((__global OUTPUT_PACKED_TYPE*)(output + output_offset))[sglid * OSP_STRIDE] = result;#else# if OUTPUT_DIMS == 5uint z = output_spatial / (OUTPUT_SIZE_X * OUTPUT_SIZE_Y);@@ -662,13 +677,13 @@ KERNEL(mvn_final)(((__global OUTPUT_PACKED_TYPE*)(output + output_offset))[0] = result;#endif- input_offset += GWS * FSV;- output_offset += GWS * FSV;- output_spatial += GWS;+ input_offset += effective_gws * INPUT_SLICE_PITCH;+ output_offset += effective_gws * OUTPUT_SLICE_PITCH;+ output_spatial += effective_gws;}// [constexpr] Number of leftovers after full local work-group iterations.- const uint lws_uniform_leftovers = ITEMS_NUM % GWS;+ const uint lws_uniform_leftovers = ITEMS_NUM % effective_gws;// [constexpr] Number of sub-groups that can process leftovers loading SIMD items.const uint lws_uniform_leftovers_full_simds = lws_uniform_leftovers / SIMD;// [constexpr] Number of leftovers after full sub-group processing.@@ -676,7 +691,7 @@ KERNEL(mvn_final)(if (lws_uniform_leftovers_full_simds > 0 && sgid < lws_uniform_leftovers_full_simds) {// Process leftovers that can use full sub-group.- INPUT_PACKED_TYPE in_pack = ((const __global INPUT_PACKED_TYPE*)(input + input_offset))[sglid];+ INPUT_PACKED_TYPE in_pack = ((const __global INPUT_PACKED_TYPE*)(input + input_offset))[sglid * ISP_STRIDE];OUTPUT_PACKED_TYPE result;unroll_for(uint set_idx = 0; set_idx < FSV; ++set_idx) {@@ -689,7 +704,7 @@ KERNEL(mvn_final)(# endif}#if !OUTPUT_PAD_IN_ITEMS- ((__global OUTPUT_PACKED_TYPE*)(output + output_offset))[sglid] = result;+ ((__global OUTPUT_PACKED_TYPE*)(output + output_offset))[sglid * OSP_STRIDE] = result;#else# if OUTPUT_DIMS == 5uint z = output_spatial / (OUTPUT_SIZE_X * OUTPUT_SIZE_Y);@@ -706,7 +721,7 @@ KERNEL(mvn_final)(} else if (lws_uniform_leftovers > 0 && sg_uniform_leftovers > 0 && sgid == lws_uniform_leftovers_full_simds) {// TODO: May be worth to consider the data here as across sub-group// Rest of leftovers, still use whole sub-group, but change addresses to not load extra data.- INPUT_PACKED_TYPE in_pack = ((const __global INPUT_PACKED_TYPE*)(input + input_offset))[sglid % sg_uniform_leftovers];+ INPUT_PACKED_TYPE in_pack = ((const __global INPUT_PACKED_TYPE*)(input + input_offset))[(sglid % sg_uniform_leftovers) * ISP_STRIDE];OUTPUT_PACKED_TYPE result;unroll_for(uint set_idx = 0; set_idx < FSV; ++set_idx) {@@ -720,7 +735,7 @@ KERNEL(mvn_final)(}if (sglid < sg_uniform_leftovers) {#if !OUTPUT_PAD_IN_ITEMS- ((__global OUTPUT_PACKED_TYPE*)(output + output_offset))[sglid] = result;+ ((__global OUTPUT_PACKED_TYPE*)(output + output_offset))[sglid * OSP_STRIDE] = result;#else# if OUTPUT_DIMS == 5uint z = output_spatial / (OUTPUT_SIZE_X * OUTPUT_SIZE_Y);@@ -744,7 +759,10 @@ KERNEL(mvn_final)(#undef FSV#undef INPUT_SLICE_PITCH+#undef OUTPUT_SLICE_PITCH#undef SG_NUM+#undef ISP_STRIDE+#undef OSP_STRIDE#undef INPUT_TYPE2#undef INPUT_TYPE4diff --git a/src/plugins/intel_gpu/src/kernel_selector/cl_kernels/mvn_gpu_b_fs_yx_fsv16_imad_accumulate.cl b/src/plugins/intel_gpu/src/kernel_selector/cl_kernels/mvn_gpu_b_fs_yx_fsv16_accumulate.clsimilarity index 60%rename from src/plugins/intel_gpu/src/kernel_selector/cl_kernels/mvn_gpu_b_fs_yx_fsv16_imad_accumulate.clrename to src/plugins/intel_gpu/src/kernel_selector/cl_kernels/mvn_gpu_b_fs_yx_fsv16_accumulate.clindex 1fd6720de0a..d4a941daf72 100644--- a/src/plugins/intel_gpu/src/kernel_selector/cl_kernels/mvn_gpu_b_fs_yx_fsv16_imad_accumulate.cl+++ b/src/plugins/intel_gpu/src/kernel_selector/cl_kernels/mvn_gpu_b_fs_yx_fsv16_accumulate.cl@@ -94,3 +94,49 @@ inline MAKE_VECTOR_TYPE(AccT, SliceSize) FUNC(Name)(const __global InputT* input#define DECLARE_PACKED_ACCUMULATE(Name, AccT, InputT, SliceSize, SlicePitch, Items, Workers, AccOp) \DECLARE_PACKED_ACCUMULATE_EARGS(Name, AccT, InputT, SliceSize, SlicePitch, Items, Workers, AccOp, , )++// ==============================================================================================================================+// Dynamic variants — Items is a function parameter (uint) instead of a compile-time constant.+// Used in IS_DYNAMIC mode where spatial dimensions are not known at OpenCL compile time.+// ==============================================================================================================================++#define DECLARE_PACKED_ACCUMULATE_DYN_EARGS(Name, AccT, InputT, SliceSize, SlicePitch, Workers, AccOp, ExtraArgsDecl, ExtraArgs) \+inline MAKE_VECTOR_TYPE(AccT, SliceSize) FUNC(Name)(const __global InputT* input, \+ uint offset, \+ uint worker_id, \+ uint items_count \+ ExtraArgsDecl) { \+ typedef MAKE_VECTOR_TYPE(InputT, SliceSize) packed_in_t; \+ typedef MAKE_VECTOR_TYPE(AccT, SliceSize) packed_acc_t; \+ \+ packed_acc_t acc = 0; /* Accumulation variable */ \+ \+ uint input_offset = offset + worker_id * (SlicePitch); /* Current input offset */ \+ \+ for (uint spatial_idx = 0; spatial_idx < items_count / (Workers); ++spatial_idx) { \+ packed_in_t in_pack = ((const __global packed_in_t*)(input + input_offset))[0]; \+ \+ input_offset += (Workers) * (SlicePitch); \+ \+ __attribute__((opencl_unroll_hint)) \+ for (uint set_idx = 0; set_idx < (SliceSize); ++set_idx) { \+ acc[set_idx] = AccOp(acc[set_idx], in_pack[set_idx], set_idx ExtraArgs); \+ } \+ } \+ \+ const uint leftovers = items_count % (Workers); \+ \+ if (leftovers > 0 && worker_id < leftovers) { \+ packed_in_t in_pack = ((const __global packed_in_t*)(input + input_offset))[0]; \+ \+ __attribute__((opencl_unroll_hint)) \+ for (uint set_idx = 0; set_idx < (SliceSize); ++set_idx) { \+ acc[set_idx] = AccOp(acc[set_idx], in_pack[set_idx], set_idx ExtraArgs); \+ } \+ } \+ \+ return acc; \+}++#define DECLARE_PACKED_ACCUMULATE_DYN(Name, AccT, InputT, SliceSize, SlicePitch, Workers, AccOp) \+ DECLARE_PACKED_ACCUMULATE_DYN_EARGS(Name, AccT, InputT, SliceSize, SlicePitch, Workers, AccOp, , )diff --git a/src/plugins/intel_gpu/src/kernel_selector/cl_kernels/mvn_gpu_b_fs_yx_fsv16_imad_reduce.cl b/src/plugins/intel_gpu/src/kernel_selector/cl_kernels/mvn_gpu_b_fs_yx_fsv16_reduce.clsimilarity index 100%rename from src/plugins/intel_gpu/src/kernel_selector/cl_kernels/mvn_gpu_b_fs_yx_fsv16_imad_reduce.clrename to src/plugins/intel_gpu/src/kernel_selector/cl_kernels/mvn_gpu_b_fs_yx_fsv16_reduce.cldiff --git a/src/plugins/intel_gpu/src/kernel_selector/cl_kernels/reorder_data_bfyx_to_blocked_format.cl b/src/plugins/intel_gpu/src/kernel_selector/cl_kernels/reorder_data_bfyx_to_blocked_format.clindex 504fd373836..0c89254ecad 100644--- a/src/plugins/intel_gpu/src/kernel_selector/cl_kernels/reorder_data_bfyx_to_blocked_format.cl+++ b/src/plugins/intel_gpu/src/kernel_selector/cl_kernels/reorder_data_bfyx_to_blocked_format.cl@@ -51,6 +51,7 @@}KERNEL (reorder_data_bfyx_to_blocked_format)(+ OPTIONAL_SHAPE_INFO_ARGconst __global INPUT0_TYPE* input,__global OUTPUT_TYPE* output)diff --git a/src/plugins/intel_gpu/src/kernel_selector/cl_kernels/reorder_data_fsv.cl b/src/plugins/intel_gpu/src/kernel_selector/cl_kernels/reorder_data_fsv.clnew file mode 100644index 00000000000..e405dccd4a6--- /dev/null+++ b/src/plugins/intel_gpu/src/kernel_selector/cl_kernels/reorder_data_fsv.cl@@ -0,0 +1,110 @@+// Copyright (C) 2018-2026 Intel Corporation+// SPDX-License-Identifier: Apache-2.0+//+// Reorder kernel for single-blocked fsv format conversions.+// Converts between b_fs_{yx,zyx}_fsv{4,8,16,32} formats with different fsv sizes.+// Both input and output are blocked only on the feature dimension.++#include "include/batch_headers/fetch_data.cl"++#ifdef FSV_VECTORIZED+ #define INPUT_VEC_TYPE MAKE_VECTOR_TYPE(INPUT0_TYPE, VEC_SIZE)+ #define OUTPUT_VEC_TYPE MAKE_VECTOR_TYPE(OUTPUT_TYPE, VEC_SIZE)+ #define CONVERT_OUT_VEC CAT(convert_, OUTPUT_VEC_TYPE)+ #define VLOAD_VEC CAT(vload, VEC_SIZE)+ #define VSTORE_VEC CAT(vstore, VEC_SIZE)+#endif++KERNEL (reorder_data_fsv)(+ OPTIONAL_SHAPE_INFO_ARG+ const __global INPUT0_TYPE* input,+ __global OUTPUT_TYPE* output)+{+ const uint x = (uint)get_global_id(0);+ const uint yz = (uint)get_global_id(1);+ const uint b_fs = (uint)get_global_id(2);++ const uint fs_out = b_fs % OUT_FEATURE_SLICE_NUM;+ const uint b = b_fs / OUT_FEATURE_SLICE_NUM;++#ifdef INPUT0_DIMS_5+ const uint z = yz % INPUT0_SIZE_Z;+ const uint y = yz / INPUT0_SIZE_Z;+#else+ const uint y = yz;+ const uint z = 0;+#endif++ const uint f_base = fs_out * OUT_FSV;++ const uint in_x_pitch = IN_FSV;+ const uint in_y_pitch = in_x_pitch * INPUT0_SIZE_X;+#ifdef INPUT0_DIMS_5+ const uint in_z_pitch = in_y_pitch * INPUT0_SIZE_Y;+ const uint in_fs_pitch = in_z_pitch * INPUT0_SIZE_Z;+#else+ const uint in_fs_pitch = in_y_pitch * INPUT0_SIZE_Y;+#endif+ const uint in_b_pitch = in_fs_pitch * IN_FEATURE_SLICE_NUM;++ const uint out_x_pitch = OUT_FSV;+ const uint out_y_pitch = out_x_pitch * OUTPUT_SIZE_X;+#ifdef INPUT0_DIMS_5+ const uint out_z_pitch = out_y_pitch * OUTPUT_SIZE_Y;+ const uint out_fs_pitch = out_z_pitch * OUTPUT_SIZE_Z;+#else+ const uint out_fs_pitch = out_y_pitch * OUTPUT_SIZE_Y;+#endif+ const uint out_b_pitch = out_fs_pitch * OUT_FEATURE_SLICE_NUM;++#ifdef INPUT0_DIMS_5+ const uint out_offset_base = b * out_b_pitch + fs_out * out_fs_pitch + z * out_z_pitch + y * out_y_pitch + x * OUT_FSV;+ const uint in_spatial_base = b * in_b_pitch + z * in_z_pitch + y * in_y_pitch + x * IN_FSV;+#else+ const uint out_offset_base = b * out_b_pitch + fs_out * out_fs_pitch + y * out_y_pitch + x * OUT_FSV;+ const uint in_spatial_base = b * in_b_pitch + y * in_y_pitch + x * IN_FSV;+#endif++#ifdef FSV_VECTORIZED+ // Vectorized path: read/write VEC_SIZE elements at a time.+ // RATIO = max(IN_FSV, OUT_FSV) / min(IN_FSV, OUT_FSV)+ #if (OUT_FSV > IN_FSV)+ // Upscale: e.g. fsv16 -> fsv32. Read RATIO input slices into one output slice.+ unroll_for (uint r = 0; r < RATIO; ++r) {+ const uint fs_in = fs_out * RATIO + r;+ const uint f_chunk = f_base + r * VEC_SIZE;+ if (f_chunk < INPUT0_FEATURE_NUM) {+ INPUT_VEC_TYPE v = VLOAD_VEC(0, input + in_spatial_base + fs_in * in_fs_pitch);+ VSTORE_VEC(CONVERT_OUT_VEC(v), 0, output + out_offset_base + r * VEC_SIZE);+ } else {+ OUTPUT_VEC_TYPE zero = (OUTPUT_VEC_TYPE)(0);+ VSTORE_VEC(zero, 0, output + out_offset_base + r * VEC_SIZE);+ }+ }+ #else+ // Downscale: e.g. fsv32 -> fsv16. Read one chunk from a larger input slice.+ const uint fs_in = fs_out / RATIO;+ const uint sub = fs_out % RATIO;+ if (f_base < INPUT0_FEATURE_NUM) {+ INPUT_VEC_TYPE v = VLOAD_VEC(0, input + in_spatial_base + fs_in * in_fs_pitch + sub * VEC_SIZE);+ VSTORE_VEC(CONVERT_OUT_VEC(v), 0, output + out_offset_base);+ } else {+ OUTPUT_VEC_TYPE zero = (OUTPUT_VEC_TYPE)(0);+ VSTORE_VEC(zero, 0, output + out_offset_base);+ }+ #endif+#else+ // Scalar fallback for small fsv sizes (fsv4, fsv8) or non-power-of-2 ratios.+ for (uint i = 0; i < OUT_FSV; ++i) {+ const uint f = f_base + i;+ if (f < INPUT0_FEATURE_NUM) {+ const uint fs_in = f / IN_FSV;+ const uint fsv_in = f % IN_FSV;+ const uint in_offset = in_spatial_base + fs_in * in_fs_pitch + fsv_in;+ output[out_offset_base + i] = ACTIVATION(TO_OUTPUT_TYPE(input[in_offset]), ACTIVATION_PARAMS);+ } else {+ output[out_offset_base + i] = TO_OUTPUT_TYPE(0);+ }+ }+#endif+}diff --git a/src/plugins/intel_gpu/src/kernel_selector/jitter.cpp b/src/plugins/intel_gpu/src/kernel_selector/jitter.cppindex 9344d805717..24eef9a6d79 100644--- a/src/plugins/intel_gpu/src/kernel_selector/jitter.cpp+++ b/src/plugins/intel_gpu/src/kernel_selector/jitter.cpp@@ -369,7 +369,7 @@ JitDefinitions DataTensorJitConstant::GetDefinitions() const {_tensor.GetLayout() == DataLayout::bfzyx || _tensor.GetLayout() == DataLayout::bfwzyx ||_tensor.GetLayout() == DataLayout::bfuwzyx || _tensor.GetLayout() == DataLayout::bfvuwzyx ||_tensor.GetLayout() == DataLayout::b_fs_yx_fsv16 || _tensor.GetLayout() == DataLayout::b_fs_yx_fsv32 ||- _tensor.GetLayout() == DataLayout::b_fs_zyx_fsv16) {+ _tensor.GetLayout() == DataLayout::b_fs_zyx_fsv16 || _tensor.GetLayout() == DataLayout::b_fs_zyx_fsv32) {definitions.push_back({_name + "_X_PITCH", "1"});definitions.push_back({_name + "_Y_PITCH", dims_padded.x()});definitions.push_back({_name + "_Z_PITCH", toVectorMulString({dims_padded.x(), dims_padded.y()})});diff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/concatenation/concatenation_kernel_simple_ref.cpp b/src/plugins/intel_gpu/src/kernel_selector/kernels/concatenation/concatenation_kernel_simple_ref.cppindex d4781f41ec8..8c9caf798f9 100644--- a/src/plugins/intel_gpu/src/kernel_selector/kernels/concatenation/concatenation_kernel_simple_ref.cpp+++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/concatenation/concatenation_kernel_simple_ref.cpp@@ -36,6 +36,8 @@ ParamsKey ConcatenationKernel_simple_Ref::GetSupportedKey() const {k.EnableOutputLayout(DataLayout::bfwzyx);k.EnableInputLayout(DataLayout::b_fs_zyx_fsv16);k.EnableOutputLayout(DataLayout::b_fs_zyx_fsv16);+ k.EnableInputLayout(DataLayout::b_fs_zyx_fsv32);+ k.EnableOutputLayout(DataLayout::b_fs_zyx_fsv32);k.EnableInputLayout(DataLayout::bs_fs_zyx_bsv16_fsv16);k.EnableOutputLayout(DataLayout::bs_fs_zyx_bsv16_fsv16);k.EnableInputLayout(DataLayout::bs_fs_yx_bsv16_fsv16);@@ -68,8 +70,10 @@ bool ConcatenationKernel_simple_Ref::Validate(const Params& p) const {auto same_layout = params.inputs[0].GetLayout();for (const auto& lt : params.inputs) {auto cur_layout = lt.GetLayout();- if ((cur_layout == DataLayout::bfzyx || cur_layout == DataLayout::b_fs_zyx_fsv16 || cur_layout == DataLayout::bs_fs_zyx_bsv16_fsv16) &&- (same_layout == DataLayout::bfzyx || same_layout == DataLayout::b_fs_zyx_fsv16 || same_layout == DataLayout::bs_fs_zyx_bsv16_fsv16+ if ((cur_layout == DataLayout::bfzyx || cur_layout == DataLayout::b_fs_zyx_fsv16 ||+ cur_layout == DataLayout::b_fs_zyx_fsv32 || cur_layout == DataLayout::bs_fs_zyx_bsv16_fsv16) &&+ (same_layout == DataLayout::bfzyx || same_layout == DataLayout::b_fs_zyx_fsv16 ||+ same_layout == DataLayout::b_fs_zyx_fsv32 || same_layout == DataLayout::bs_fs_zyx_bsv16_fsv16|| same_layout == DataLayout::bs_fs_yx_bsv32_fsv32)) {continue;} else if (cur_layout != same_layout) {diff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/mvn/mvn_kernel_b_fs_yx_fsv16.cpp b/src/plugins/intel_gpu/src/kernel_selector/kernels/mvn/mvn_kernel_b_fs_yx_fsv16.cppnew file mode 100644index 00000000000..507bc167c7f--- /dev/null+++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/mvn/mvn_kernel_b_fs_yx_fsv16.cpp@@ -0,0 +1,713 @@+// Copyright (C) 2018-2026 Intel Corporation+// SPDX-License-Identifier: Apache-2.0+//++#include "mvn_kernel_b_fs_yx_fsv16.hpp"+#include "common_tools.h"++#include <string>+#include <algorithm>+#include <iostream>++namespace kernel_selector {++static constexpr size_t simd = 16;+static constexpr size_t fsv = 16;+static constexpr size_t pref_work_groups = 16;++ParamsKey MVNKernel_b_fs_yx_fsv16::GetSupportedKey() const {+ ParamsKey k;++ k.EnableInputDataType(Datatype::F16);+ k.EnableInputDataType(Datatype::F32);+ k.EnableInputDataType(Datatype::INT8);+ k.EnableInputDataType(Datatype::UINT8);++ k.EnableOutputDataType(Datatype::F16);+ k.EnableOutputDataType(Datatype::F32);+ k.EnableOutputDataType(Datatype::INT8);+ k.EnableOutputDataType(Datatype::UINT8);++ k.EnableInputLayout(DataLayout::b_fs_yx_fsv16);+ k.EnableOutputLayout(DataLayout::b_fs_yx_fsv16);+ k.EnableInputLayout(DataLayout::b_fs_zyx_fsv16);+ k.EnableOutputLayout(DataLayout::b_fs_zyx_fsv16);+ k.EnableInputLayout(DataLayout::b_fs_yx_fsv32);+ k.EnableOutputLayout(DataLayout::b_fs_yx_fsv32);+ k.EnableInputLayout(DataLayout::b_fs_zyx_fsv32);+ k.EnableOutputLayout(DataLayout::b_fs_zyx_fsv32);+ k.EnableTensorOffset();+ k.EnableTensorPitches();+ k.EnableDifferentTypes();+ k.EnableBatching();+ // TODO Add support for across channels+ // k.EnableMVNMode(MVNMode::ACROSS_CHANNELS);+ k.EnableMVNMode(MVNMode::WITHIN_CHANNELS);+ k.EnableMVNNormalizeVariance();+ k.EnableDynamicShapesSupport();++ return k;+}++DeviceFeaturesKey MVNKernel_b_fs_yx_fsv16::get_required_device_features_key(const Params& params) const {+ auto k = get_common_subgroups_device_features_key(params);+ k.requires_subgroup_shuffle();+ k.requires_subgroup_reduce();++ return k;+}++bool MVNKernel_b_fs_yx_fsv16::Validate(const Params& p) const {+ if (!Parent::Validate(p))+ DO_NOT_USE_THIS_KERNEL(p.layerID);++ auto params = static_cast<const mvn_params&>(p);++ // TODO Add support for input padding via iterating over y (parallel or in kernel).+ // Skip padding check for dynamic tensors (padding not known at compile time).+ if (!params.has_dynamic_tensors()) {+ if (params.inputs[0].X().pad.Total() != 0 || params.inputs[0].Y().pad.Total() != 0 ||+ params.inputs[0].Z().pad.Total() != 0)+ DO_NOT_USE_THIS_KERNEL(p.layerID);+ }++ return true;+}++MVNKernelBase::DispatchData MVNKernel_b_fs_yx_fsv16::SetDefault(const mvn_params& params) const {+ auto dispatchData = Parent::SetDefault(params);++ auto max_wg = params.engineInfo.maxWorkGroupSize;+ auto slm_per_sg = fsv * 4;+ auto max_slm = params.engineInfo.maxLocalMemSize;+ auto max_sgs = max_slm / slm_per_sg;+ auto max_lws = std::min(max_wg, max_sgs * simd);++ if (params.has_dynamic_tensors()) {+ // Fixed LWS for shape-agnostic compilation (basic single-workgroup mode).+ // LWS is baked into reqd_work_group_size; GWS[1]/[2] updated at runtime.+ auto lws = std::max(max_lws / simd, (size_t)1) * simd;+ dispatchData.gws[0] = lws;+ dispatchData.gws[1] = 1;+ dispatchData.gws[2] = 1;+ dispatchData.lws[0] = lws;+ dispatchData.lws[1] = 1;+ dispatchData.lws[2] = 1;+ } else {+ auto items_num = params.outputs[0].X().v * params.outputs[0].Y().v * params.outputs[0].Z().v;+ auto lws = std::max(std::min(items_num, max_lws) / simd, (size_t)1) * simd;+ dispatchData.gws[0] = lws;+ dispatchData.gws[1] = CeilDiv(params.outputs[0].Feature().v, fsv);+ dispatchData.gws[2] = params.outputs[0].Batch().v;+ dispatchData.lws[0] = lws;+ dispatchData.lws[1] = 1;+ dispatchData.lws[2] = 1;+ }++ dispatchData.itemsNum = 1;++ return dispatchData;+}++Datatype MVNKernel_b_fs_yx_fsv16::GetAccumulatorType(const mvn_params& params) const {+ const auto& input_dt = params.inputs[0].GetDType();++ switch (input_dt) {+ case Datatype::F32:+ case Datatype::F16:+ return Datatype::F32;+ case Datatype::INT8:+ case Datatype::UINT8:+ return Datatype::INT32;+ default: return Datatype::F32;+ }+}++JitConstants MVNKernel_b_fs_yx_fsv16::GetJitConstants(const mvn_params& params, DispatchData dispatchData) const {+ auto jits = Parent::GetJitConstants(params, dispatchData);++ auto activation_dt = GetActivationType(params);+ jits.Merge(MakeTypeJitConstants(activation_dt, "ACTIVATION"));+ jits.Merge(MakeTypeJitConstants(activation_dt, "MEAN"));+ jits.Merge(MakeTypeJitConstants(GetAccumulatorType(params), "ACCUMULATOR"));+ jits.AddConstant(MakeJitConstant("SIMD", simd));+ jits.AddConstant(MakeJitConstant("LWS", dispatchData.lws[0]));+ jits.AddConstant(MakeJitConstant("GWS", dispatchData.gws[0]));+ jits.AddConstant(MakeJitConstant("ITEM_GROUPS", dispatchData.itemsNum));+ auto input_layout = params.inputs[0].GetLayout();+ size_t input_slice_pitch = (input_layout == DataLayout::b_fs_yx_fsv32 ||+ input_layout == DataLayout::b_fs_zyx_fsv32) ? 32 : 16;+ jits.AddConstant(MakeJitConstant("INPUT_SLICE_PITCH", input_slice_pitch));+ auto output_layout = params.outputs[0].GetLayout();+ size_t output_slice_pitch = (output_layout == DataLayout::b_fs_yx_fsv32 ||+ output_layout == DataLayout::b_fs_zyx_fsv32) ? 32 : 16;+ jits.AddConstant(MakeJitConstant("OUTPUT_SLICE_PITCH", output_slice_pitch));+ if (params.has_dynamic_tensors()) {+ // For dynamic shapes, ITEMS_NUM is passed as a scalar kernel argument+ // because inline accumulate functions can't access shape_info buffer.+ jits.AddConstant(MakeJitConstant("ITEMS_NUM", "items_num"));+ } else {+ // Define ITEMS_NUM via JIT so the batch-compilation #undef system+ // cleans it up between kernels sharing the same CL source file.+ jits.AddConstant(MakeJitConstant("ITEMS_NUM",+ params.outputs[0].X().v * params.outputs[0].Y().v * params.outputs[0].Z().v));+ }+ if (!params.fused_ops.empty()) {+ std::vector<std::string> idx_order;++ if (params.inputs[0].GetDims().size() <= 4) {+ idx_order = {"b",+ "(f + set_idx)",+ "(output_spatial / OUTPUT_SIZE_X)",+ "(output_spatial % OUTPUT_SIZE_X)"};+ } else if (params.inputs[0].GetDims().size() == 5) {+ idx_order = {"b",+ "(f + set_idx)",+ "(output_spatial / (OUTPUT_SIZE_X * OUTPUT_SIZE_Y))",+ "((output_spatial / OUTPUT_SIZE_X) % OUTPUT_SIZE_Y)",+ "(output_spatial % OUTPUT_SIZE_X)"};+ }++ auto conf = FusedOpsConfiguration("", idx_order, "normalized", activation_dt);+ if (params.has_dynamic_tensors()) {+ conf.SetBoundaryCheck(FusedOpsConfiguration::BoundaryCheck::ENABLED);+ }+ jits.Merge(MakeFusedOpsJitConstants(params, {conf}));+ }+ return jits;+}++MVNKernel_b_fs_yx_fsv16::MultiDispatchData MVNKernel_b_fs_yx_fsv16::SetDefaultForMulti(+ const mvn_params& params) const {+ MultiDispatchData dispatchData;++ auto max_wg = params.engineInfo.maxWorkGroupSize;+ auto slm_per_sg = fsv * 4;+ auto max_slm = params.engineInfo.maxLocalMemSize;+ auto max_sgs = max_slm / slm_per_sg;+ auto max_lws = std::min(max_wg, max_sgs * simd);++ size_t lws;+ if (params.has_dynamic_tensors()) {+ // Use hardware-max LWS for dynamic (data size unknown at compile time)+ lws = std::max(max_lws / simd, (size_t)1) * simd;+ } else {+ auto items_num = params.outputs[0].X().v * params.outputs[0].Y().v * params.outputs[0].Z().v;+ lws = std::max(std::min(items_num, max_lws) / simd, (size_t)1) * simd;+ }++ // TODO Check if larger number of work-groups does not provide benefit+ size_t item_groups = pref_work_groups;+ dispatchData.item_groups = item_groups;++ size_t stage1_lws = lws;++ dispatchData.stage_1.gws[0] = stage1_lws * item_groups;+ dispatchData.stage_1.gws[1] = params.has_dynamic_tensors() ? 1 : CeilDiv(params.outputs[0].Feature().v, fsv);+ dispatchData.stage_1.gws[2] = params.has_dynamic_tensors() ? 1 : params.outputs[0].Batch().v;++ dispatchData.stage_1.lws[0] = stage1_lws;+ dispatchData.stage_1.lws[1] = 1;+ dispatchData.stage_1.lws[2] = 1;++ dispatchData.stage_1.itemsNum = item_groups;++ size_t stage2_lws = std::max(std::min(item_groups, max_lws) / simd, (size_t)1) * simd;++ dispatchData.stage_2.gws[0] = stage2_lws;+ dispatchData.stage_2.gws[1] = params.has_dynamic_tensors() ? 1 : CeilDiv(params.outputs[0].Feature().v, fsv);+ dispatchData.stage_2.gws[2] = params.has_dynamic_tensors() ? 1 : params.outputs[0].Batch().v;++ dispatchData.stage_2.lws[0] = stage2_lws;+ dispatchData.stage_2.lws[1] = 1;+ dispatchData.stage_2.lws[2] = 1;++ dispatchData.stage_2.itemsNum = item_groups;++ if (params.has_dynamic_tensors()) {+ dispatchData.stage_final.gws[0] = simd; // Placeholder, updated at runtime+ dispatchData.stage_final.gws[1] = 1;+ dispatchData.stage_final.gws[2] = 1;+ } else {+ auto items_num = params.outputs[0].X().v * params.outputs[0].Y().v * params.outputs[0].Z().v;+ dispatchData.stage_final.gws[0] = std::max(items_num / simd, (size_t)1) * simd;+ dispatchData.stage_final.gws[1] = CeilDiv(params.outputs[0].Feature().v, fsv);+ dispatchData.stage_final.gws[2] = params.outputs[0].Batch().v;+ }++ dispatchData.stage_final.lws[0] = simd;+ dispatchData.stage_final.lws[1] = 1;+ dispatchData.stage_final.lws[2] = 1;++ dispatchData.stage_final.itemsNum = 1;++ return dispatchData;+}++KernelsData MVNKernel_b_fs_yx_fsv16::GetMultiStageKernelsData(const mvn_params& params) const {+ if (!Validate(params))+ return {};++ constexpr size_t intermidiate_bytes = 4;+ const mvn_params& orgParams = static_cast<const mvn_params&>(params);++ auto dispatchData = SetDefaultForMulti(orgParams);++ size_t kernels_num = params.mvnNormalizeVariance ? 5 : 3;+ KernelData kd = KernelData::Default<mvn_params>(params, kernels_num);++ auto finalKernelName = GetKernelName(orgParams);+ size_t entry_part_id = 0;+ {+ // Mean first stage+ auto cldnn_jit = GetJitConstants(orgParams, dispatchData.stage_1);+ cldnn_jit.AddConstant(MakeJitConstant("MVN_KERNEL_MEAN_1", 1));+ auto entry_point = GetEntryPoint(finalKernelName, orgParams.layerID, params, entry_part_id++);+ auto jit = CreateJit(finalKernelName, cldnn_jit, entry_point);+ auto& kernel = kd.kernels[0];+ FillCLKernelData(kernel,+ dispatchData.stage_1,+ params.engineInfo,+ finalKernelName,+ jit,+ entry_point,+ "",+ false,+ false,+ 0,+ 0);+ kernel.params.arguments.clear(); // Clear original output argument+ kernel.params.arguments.push_back({ArgumentDescriptor::Types::INPUT, 0});+ kernel.params.arguments.push_back({ArgumentDescriptor::Types::INTERNAL_BUFFER, 0});+ kd.internalBuffers.push_back(params.outputs[0].Batch().v * Align(params.outputs[0].Feature().v, fsv) *+ dispatchData.item_groups * intermidiate_bytes);+ }+ {+ // Mean second stage+ auto cldnn_jit = GetJitConstants(orgParams, dispatchData.stage_2);+ cldnn_jit.AddConstant(MakeJitConstant("MVN_KERNEL_MEAN_2", 1));+ auto entry_point = GetEntryPoint(finalKernelName, orgParams.layerID, params, entry_part_id++);+ auto jit = CreateJit(finalKernelName, cldnn_jit, entry_point);+ auto& kernel = kd.kernels[1];+ FillCLKernelData(kernel,+ dispatchData.stage_2,+ params.engineInfo,+ finalKernelName,+ jit,+ entry_point,+ "",+ false,+ false,+ 0,+ 0);+ kernel.params.arguments.clear(); // Clear original output argument+ kernel.params.arguments.push_back({ArgumentDescriptor::Types::INTERNAL_BUFFER, 0});+ kernel.params.arguments.push_back({ArgumentDescriptor::Types::INTERNAL_BUFFER, 1});+ kd.internalBuffers.push_back(params.outputs[0].Batch().v * Align(params.outputs[0].Feature().v, fsv) *+ intermidiate_bytes);+ }+ if (params.mvnNormalizeVariance) {+ // Variance first stage+ auto cldnn_jit = GetJitConstants(orgParams, dispatchData.stage_1);+ cldnn_jit.AddConstant(MakeJitConstant("MVN_KERNEL_VAR_1", 1));+ auto entry_point = GetEntryPoint(finalKernelName, orgParams.layerID, params, entry_part_id++);+ auto jit = CreateJit(finalKernelName, cldnn_jit, entry_point);+ auto& kernel = kd.kernels[2];+ FillCLKernelData(kernel,+ dispatchData.stage_1,+ params.engineInfo,+ finalKernelName,+ jit,+ entry_point,+ "",+ false,+ false,+ 0,+ 0);+ kernel.params.arguments.clear(); // Clear original output argument+ kernel.params.arguments.push_back({ArgumentDescriptor::Types::INPUT, 0});+ kernel.params.arguments.push_back({ArgumentDescriptor::Types::INTERNAL_BUFFER, 1});+ kernel.params.arguments.push_back({ArgumentDescriptor::Types::INTERNAL_BUFFER, 0});+ }+ if (params.mvnNormalizeVariance) {+ // Variance second stage+ auto cldnn_jit = GetJitConstants(orgParams, dispatchData.stage_2);+ cldnn_jit.AddConstant(MakeJitConstant("MVN_KERNEL_VAR_2", 1));+ auto entry_point = GetEntryPoint(finalKernelName, orgParams.layerID, params, entry_part_id++);+ auto jit = CreateJit(finalKernelName, cldnn_jit, entry_point);+ auto& kernel = kd.kernels[3];+ FillCLKernelData(kernel,+ dispatchData.stage_2,+ params.engineInfo,+ finalKernelName,+ jit,+ entry_point,+ "",+ false,+ false,+ 0,+ 0);+ kernel.params.arguments.clear(); // Clear original output argument+ kernel.params.arguments.push_back({ArgumentDescriptor::Types::INTERNAL_BUFFER, 0});+ kernel.params.arguments.push_back({ArgumentDescriptor::Types::INTERNAL_BUFFER, 2});+ kd.internalBuffers.push_back(params.outputs[0].Batch().v * Align(params.outputs[0].Feature().v, fsv) *+ intermidiate_bytes);+ }+ { // Final+ auto cldnn_jit = GetJitConstants(orgParams, dispatchData.stage_final);+ cldnn_jit.AddConstant(MakeJitConstant("MVN_KERNEL_MAIN", 1));+ cldnn_jit.AddConstant(MakeJitConstant("PRECALC_MEAN", 1));+ cldnn_jit.AddConstant(MakeJitConstant("PRECALC_VARIANCE", params.mvnNormalizeVariance));+ auto entry_point = GetEntryPoint(finalKernelName, orgParams.layerID, params, entry_part_id);+ auto jit = CreateJit(finalKernelName, cldnn_jit, entry_point);+ auto& kernel = kd.kernels[kernels_num - 1];+ FillCLKernelData(kernel,+ dispatchData.stage_final,+ params.engineInfo,+ finalKernelName,+ jit,+ entry_point,+ "",+ false,+ false,+ 1,+ GetFusedPrimitiveInputsCount(params));+ kernel.params.arguments.push_back({ArgumentDescriptor::Types::INTERNAL_BUFFER, 1});+ if (params.mvnNormalizeVariance) {+ kernel.params.arguments.push_back({ArgumentDescriptor::Types::INTERNAL_BUFFER, 2});+ }+ }+ kd.internalBufferDataType = Datatype::F32;++ GetUpdateDispatchDataFunc(kd);++ return {kd};+}++KernelsData MVNKernel_b_fs_yx_fsv16::GetDynamicMultiStageKernelsData(const mvn_params& params) const {+ if (!Validate(params))+ return {};++ const mvn_params& orgParams = static_cast<const mvn_params&>(params);+ bool has_variance = params.mvnNormalizeVariance;+ size_t multi_stage_kernels = has_variance ? 5 : 3;+ size_t total_kernels = 1 + multi_stage_kernels; // kernel[0]=basic + multi-stage++ KernelData kd = KernelData::Default<mvn_params>(params, total_kernels);+ auto finalKernelName = GetKernelName(orgParams);+ size_t entry_part_id = 0;++ // Helper to add items_num scalar argument to a kernel+ auto add_items_num_scalar = [](clKernelData& kernel) {+ ScalarDescriptor items_num;+ items_num.t = ScalarDescriptor::Types::UINT32;+ items_num.v.u32 = 1; // placeholder; updated at runtime+ kernel.params.scalars.push_back(items_num);+ kernel.params.arguments.push_back({ArgumentDescriptor::Types::SCALAR, 0});+ };++ // ---- Kernel[0]: Basic mode (single-kernel mean+var+normalize) ----+ {+ auto dispatchData = SetDefault(orgParams);+ auto cldnn_jit = GetJitConstants(orgParams, dispatchData);+ auto entry_point = GetEntryPoint(finalKernelName, orgParams.layerID, params, entry_part_id++);+ auto jit = CreateJit(finalKernelName, cldnn_jit, entry_point);+ auto& kernel = kd.kernels[0];+ FillCLKernelData(kernel,+ dispatchData,+ params.engineInfo,+ finalKernelName,+ jit,+ entry_point,+ "",+ false,+ false,+ 1,+ GetFusedPrimitiveInputsCount(params),+ 1,+ orgParams.is_shape_agnostic);+ add_items_num_scalar(kernel);+ }++ // ---- Multi-stage kernels [1..N] ----+ auto dispatchData = SetDefaultForMulti(orgParams);++ // Kernel[1]: Mean first stage+ {+ auto cldnn_jit = GetJitConstants(orgParams, dispatchData.stage_1);+ cldnn_jit.AddConstant(MakeJitConstant("MVN_KERNEL_MEAN_1", 1));+ auto entry_point = GetEntryPoint(finalKernelName, orgParams.layerID, params, entry_part_id++);+ auto jit = CreateJit(finalKernelName, cldnn_jit, entry_point);+ auto& kernel = kd.kernels[1];+ FillCLKernelData(kernel,+ dispatchData.stage_1,+ params.engineInfo,+ finalKernelName,+ jit,+ entry_point,+ "",+ false,+ false,+ 0,+ 0);+ kernel.params.arguments.clear();+ kernel.params.arguments.push_back({ArgumentDescriptor::Types::SHAPE_INFO, 0});+ kernel.params.arguments.push_back({ArgumentDescriptor::Types::INPUT, 0});+ kernel.params.arguments.push_back({ArgumentDescriptor::Types::INTERNAL_BUFFER, 0});+ add_items_num_scalar(kernel);+ }++ // Kernel[2]: Mean second stage+ {+ auto cldnn_jit = GetJitConstants(orgParams, dispatchData.stage_2);+ cldnn_jit.AddConstant(MakeJitConstant("MVN_KERNEL_MEAN_2", 1));+ auto entry_point = GetEntryPoint(finalKernelName, orgParams.layerID, params, entry_part_id++);+ auto jit = CreateJit(finalKernelName, cldnn_jit, entry_point);+ auto& kernel = kd.kernels[2];+ FillCLKernelData(kernel,+ dispatchData.stage_2,+ params.engineInfo,+ finalKernelName,+ jit,+ entry_point,+ "",+ false,+ false,+ 0,+ 0);+ kernel.params.arguments.clear();+ kernel.params.arguments.push_back({ArgumentDescriptor::Types::SHAPE_INFO, 0});+ kernel.params.arguments.push_back({ArgumentDescriptor::Types::INTERNAL_BUFFER, 0});+ kernel.params.arguments.push_back({ArgumentDescriptor::Types::INTERNAL_BUFFER, 1});+ add_items_num_scalar(kernel);+ }++ if (has_variance) {+ // Kernel[3]: Variance first stage+ {+ auto cldnn_jit = GetJitConstants(orgParams, dispatchData.stage_1);+ cldnn_jit.AddConstant(MakeJitConstant("MVN_KERNEL_VAR_1", 1));+ auto entry_point = GetEntryPoint(finalKernelName, orgParams.layerID, params, entry_part_id++);+ auto jit = CreateJit(finalKernelName, cldnn_jit, entry_point);+ auto& kernel = kd.kernels[3];+ FillCLKernelData(kernel,+ dispatchData.stage_1,+ params.engineInfo,+ finalKernelName,+ jit,+ entry_point,+ "",+ false,+ false,+ 0,+ 0);+ kernel.params.arguments.clear();+ kernel.params.arguments.push_back({ArgumentDescriptor::Types::SHAPE_INFO, 0});+ kernel.params.arguments.push_back({ArgumentDescriptor::Types::INPUT, 0});+ kernel.params.arguments.push_back({ArgumentDescriptor::Types::INTERNAL_BUFFER, 1});+ kernel.params.arguments.push_back({ArgumentDescriptor::Types::INTERNAL_BUFFER, 0});+ add_items_num_scalar(kernel);+ }++ // Kernel[4]: Variance second stage+ {+ auto cldnn_jit = GetJitConstants(orgParams, dispatchData.stage_2);+ cldnn_jit.AddConstant(MakeJitConstant("MVN_KERNEL_VAR_2", 1));+ auto entry_point = GetEntryPoint(finalKernelName, orgParams.layerID, params, entry_part_id++);+ auto jit = CreateJit(finalKernelName, cldnn_jit, entry_point);+ auto& kernel = kd.kernels[4];+ FillCLKernelData(kernel,+ dispatchData.stage_2,+ params.engineInfo,+ finalKernelName,+ jit,+ entry_point,+ "",+ false,+ false,+ 0,+ 0);+ kernel.params.arguments.clear();+ kernel.params.arguments.push_back({ArgumentDescriptor::Types::SHAPE_INFO, 0});+ kernel.params.arguments.push_back({ArgumentDescriptor::Types::INTERNAL_BUFFER, 0});+ kernel.params.arguments.push_back({ArgumentDescriptor::Types::INTERNAL_BUFFER, 2});+ add_items_num_scalar(kernel);+ }+ }++ // Final kernel (last index)+ {+ auto cldnn_jit = GetJitConstants(orgParams, dispatchData.stage_final);+ cldnn_jit.AddConstant(MakeJitConstant("MVN_KERNEL_MAIN", 1));+ cldnn_jit.AddConstant(MakeJitConstant("PRECALC_MEAN", 1));+ cldnn_jit.AddConstant(MakeJitConstant("PRECALC_VARIANCE", params.mvnNormalizeVariance));+ auto entry_point = GetEntryPoint(finalKernelName, orgParams.layerID, params, entry_part_id);+ auto jit = CreateJit(finalKernelName, cldnn_jit, entry_point);+ auto& kernel = kd.kernels[total_kernels - 1];+ FillCLKernelData(kernel,+ dispatchData.stage_final,+ params.engineInfo,+ finalKernelName,+ jit,+ entry_point,+ "",+ false,+ false,+ 1,+ GetFusedPrimitiveInputsCount(params),+ 1,+ orgParams.is_shape_agnostic);+ kernel.params.arguments.push_back({ArgumentDescriptor::Types::INTERNAL_BUFFER, 1});+ if (has_variance) {+ kernel.params.arguments.push_back({ArgumentDescriptor::Types::INTERNAL_BUFFER, 2});+ }+ add_items_num_scalar(kernel);+ }++ // Internal buffers with placeholder sizes (resized at runtime)+ kd.internalBuffers.push_back(InternalBuffer(1)); // buf0: partial sums+ kd.internalBuffers.push_back(InternalBuffer(1)); // buf1: mean values+ if (has_variance) {+ kd.internalBuffers.push_back(InternalBuffer(1)); // buf2: variance values+ }+ kd.internalBufferDataType = Datatype::F32;++ GetUpdateDispatchDataFunc(kd);++ return {kd};+}++void MVNKernel_b_fs_yx_fsv16::GetUpdateDispatchDataFunc(KernelData& kd) const {+ kd.update_dispatch_data_func = [](const Params& params, KernelData& kd) {+ const auto& prim_params = static_cast<const mvn_params&>(params);+ constexpr size_t local_fsv = 16;+ constexpr size_t local_simd = 16;+ constexpr size_t local_pref_work_groups = 16;+ constexpr size_t intermediate_bytes = 4;++ auto items_num = prim_params.outputs[0].X().v+ * prim_params.outputs[0].Y().v+ * prim_params.outputs[0].Z().v;+ auto batch = prim_params.outputs[0].Batch().v;+ auto feature = prim_params.outputs[0].Feature().v;++ // Update items_num scalar in all kernels that have it+ ScalarDescriptor items_num_scalar;+ items_num_scalar.t = ScalarDescriptor::Types::UINT32;+ items_num_scalar.v.u32 = static_cast<uint32_t>(items_num);+ for (size_t i = 0; i < kd.kernels.size(); ++i) {+ if (!kd.kernels[i].params.scalars.empty()) {+ kd.kernels[i].params.scalars[0] = items_num_scalar;+ }+ }++ if (kd.kernels.size() == 1) {+ // Basic mode only (single kernel)+ kd.kernels[0].params.workGroups.global[1] = CeilDiv(feature, local_fsv);+ kd.kernels[0].params.workGroups.global[2] = batch;+ kd.kernels[0].skip_execution = KernelData::SkipKernelExecution(prim_params);+ } else {+ // Dynamic multi-stage: kernel[0]=basic, kernel[1..]=multi-stage+ size_t num_kernels = kd.kernels.size();+ bool has_variance = num_kernels > 4; // 6 = basic + 5 stages++ auto max_wg = prim_params.engineInfo.maxWorkGroupSize;+ auto slm_per_sg = local_fsv * 4;+ auto max_slm = prim_params.engineInfo.maxLocalMemSize;+ auto max_sgs = max_slm / slm_per_sg;+ auto max_lws = std::min(max_wg, max_sgs * local_simd);++ // Runtime decision: use multi-stage when spatial size is large enough+ bool enough_slm = max_lws / local_simd * local_simd * slm_per_sg <= max_slm;+ bool enough_lws = max_lws / local_simd >= 1;+ bool enough_items = items_num >= max_lws / local_simd * local_simd * local_pref_work_groups;+ bool use_multi_stage = enough_slm && enough_lws && enough_items;++ // Skip execution flags+ kd.kernels[0].skip_execution = use_multi_stage || KernelData::SkipKernelExecution(prim_params);+ for (size_t i = 1; i < num_kernels; ++i) {+ kd.kernels[i].skip_execution = !use_multi_stage || KernelData::SkipKernelExecution(prim_params);+ }++ // Always update basic mode GWS (in case it gets selected)+ kd.kernels[0].params.workGroups.global[1] = CeilDiv(feature, local_fsv);+ kd.kernels[0].params.workGroups.global[2] = batch;++ if (use_multi_stage) {+ auto lws = std::max(std::min(items_num, max_lws) / local_simd, (size_t)1) * local_simd;+ size_t item_groups = local_pref_work_groups;++ // Stage 1 (mean_1): kernel[1]+ kd.kernels[1].params.workGroups.global = {lws * item_groups, CeilDiv(feature, local_fsv), batch};+ kd.kernels[1].params.workGroups.local[0] = lws;++ // Stage 2 (mean_2): kernel[2]+ auto stage2_lws = std::max(std::min(item_groups, max_lws) / local_simd, (size_t)1) * local_simd;+ kd.kernels[2].params.workGroups.global = {stage2_lws, CeilDiv(feature, local_fsv), batch};+ kd.kernels[2].params.workGroups.local[0] = stage2_lws;++ if (has_variance) {+ // var_1: kernel[3]+ kd.kernels[3].params.workGroups.global = {lws * item_groups, CeilDiv(feature, local_fsv), batch};+ kd.kernels[3].params.workGroups.local[0] = lws;++ // var_2: kernel[4]+ kd.kernels[4].params.workGroups.global = {stage2_lws, CeilDiv(feature, local_fsv), batch};+ kd.kernels[4].params.workGroups.local[0] = stage2_lws;++ // final: kernel[5]+ auto final_gws0 = std::max(items_num / local_simd, (size_t)1) * local_simd;+ kd.kernels[5].params.workGroups.global = {final_gws0, CeilDiv(feature, local_fsv), batch};+ } else {+ // final: kernel[3]+ auto final_gws0 = std::max(items_num / local_simd, (size_t)1) * local_simd;+ kd.kernels[3].params.workGroups.global = {final_gws0, CeilDiv(feature, local_fsv), batch};+ }++ // Resize internal buffers if needed+ size_t buf0_size = batch * Align(feature, local_fsv) * item_groups * intermediate_bytes;+ size_t buf1_size = batch * Align(feature, local_fsv) * intermediate_bytes;++ if (kd.internalBuffers.size() >= 2 &&+ (kd.internalBuffers[0].byte_count < buf0_size ||+ kd.internalBuffers[1].byte_count < buf1_size)) {+ kd.internalBuffers.clear();+ kd.internalBuffers.push_back(buf0_size);+ kd.internalBuffers.push_back(buf1_size);+ if (has_variance) {+ kd.internalBuffers.push_back(buf1_size);+ }+ }+ }+ }+ };+}++KernelsData MVNKernel_b_fs_yx_fsv16::GetKernelsData(const Params& params) const {+ const mvn_params& orgParams = static_cast<const mvn_params&>(params);++ // For dynamic shapes, compile both basic and multi-stage kernels;+ // the runtime update_dispatch_data_func selects the optimal path.+ if (orgParams.has_dynamic_tensors()) {+ return GetDynamicMultiStageKernelsData(orgParams);+ }++ auto max_slm = params.engineInfo.maxLocalMemSize;+ auto slm_per_sg = fsv * 4;+ auto max_lws = params.engineInfo.maxWorkGroupSize;+ auto items_num = orgParams.outputs[0].X().v * orgParams.outputs[0].Y().v * orgParams.outputs[0].Z().v;++ auto enough_slm = max_lws / simd * simd * slm_per_sg <= max_slm;+ auto enough_lws = max_lws / simd >= 1;+ auto enough_items = items_num >= max_lws / simd * simd * pref_work_groups;++ if (enough_slm && enough_lws && enough_items)+ return GetMultiStageKernelsData(orgParams);+ else+ return GetCommonKernelsData(params);+}++KernelsPriority MVNKernel_b_fs_yx_fsv16::GetKernelsPriority(const Params& /*params*/) const {+ return FORCE_PRIORITY_4;+}+} // namespace kernel_selectordiff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/mvn/mvn_kernel_b_fs_yx_fsv16_imad.hpp b/src/plugins/intel_gpu/src/kernel_selector/kernels/mvn/mvn_kernel_b_fs_yx_fsv16.hppsimilarity index 77%rename from src/plugins/intel_gpu/src/kernel_selector/kernels/mvn/mvn_kernel_b_fs_yx_fsv16_imad.hpprename to src/plugins/intel_gpu/src/kernel_selector/kernels/mvn/mvn_kernel_b_fs_yx_fsv16.hppindex 06282a0cc26..43b6f840fb6 100644--- a/src/plugins/intel_gpu/src/kernel_selector/kernels/mvn/mvn_kernel_b_fs_yx_fsv16_imad.hpp+++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/mvn/mvn_kernel_b_fs_yx_fsv16.hpp@@ -9,11 +9,11 @@#include <vector>namespace kernel_selector {-class MVNKernel_b_fs_yx_fsv16_imad : public MVNKernelBase {+class MVNKernel_b_fs_yx_fsv16 : public MVNKernelBase {public:using Parent = MVNKernelBase;- MVNKernel_b_fs_yx_fsv16_imad() : MVNKernelBase("mvn_gpu_b_fs_yx_fsv16_imad") {}- virtual ~MVNKernel_b_fs_yx_fsv16_imad() {}+ MVNKernel_b_fs_yx_fsv16() : MVNKernelBase("mvn_gpu_b_fs_yx_fsv16") {}+ virtual ~MVNKernel_b_fs_yx_fsv16() {}KernelsData GetKernelsData(const Params& params) const override;KernelsPriority GetKernelsPriority(const Params& params) const override;@@ -32,15 +32,18 @@ protected:bool Validate(const Params&) const override;DispatchData SetDefault(const mvn_params& params) const override;JitConstants GetJitConstants(const mvn_params& params, DispatchData dispatchData) const override;+ void GetUpdateDispatchDataFunc(KernelData& kd) const override;std::vector<FusedOpType> GetSupportedFusedOps() const override {return {FusedOpType::ACTIVATION,FusedOpType::QUANTIZE,- FusedOpType::ELTWISE+ FusedOpType::ELTWISE,+ FusedOpType::REORDER};}KernelsData GetMultiStageKernelsData(const mvn_params& params) const;+ KernelsData GetDynamicMultiStageKernelsData(const mvn_params& params) const;MultiDispatchData SetDefaultForMulti(const mvn_params& params) const;private:diff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/mvn/mvn_kernel_b_fs_yx_fsv16_imad.cpp b/src/plugins/intel_gpu/src/kernel_selector/kernels/mvn/mvn_kernel_b_fs_yx_fsv16_imad.cppdeleted file mode 100644index 043be2dccb4..00000000000--- a/src/plugins/intel_gpu/src/kernel_selector/kernels/mvn/mvn_kernel_b_fs_yx_fsv16_imad.cpp+++ /dev/null@@ -1,354 +0,0 @@-// Copyright (C) 2018-2026 Intel Corporation-// SPDX-License-Identifier: Apache-2.0-//--#include "mvn_kernel_b_fs_yx_fsv16_imad.hpp"-#include "common_tools.h"--#include <string>-#include <algorithm>-#include <iostream>--namespace kernel_selector {--static constexpr size_t simd = 16;-static constexpr size_t fsv = 16;-static constexpr size_t pref_work_groups = 16;--ParamsKey MVNKernel_b_fs_yx_fsv16_imad::GetSupportedKey() const {- ParamsKey k;-- k.EnableInputDataType(Datatype::INT8);- k.EnableInputDataType(Datatype::UINT8);-- k.EnableOutputDataType(Datatype::F16);- k.EnableOutputDataType(Datatype::F32);- k.EnableOutputDataType(Datatype::INT8);- k.EnableOutputDataType(Datatype::UINT8);-- k.EnableInputLayout(DataLayout::b_fs_yx_fsv16);- k.EnableOutputLayout(DataLayout::b_fs_yx_fsv16);- k.EnableInputLayout(DataLayout::b_fs_zyx_fsv16);- k.EnableOutputLayout(DataLayout::b_fs_zyx_fsv16);- k.EnableTensorOffset();- k.EnableTensorPitches();- k.EnableDifferentTypes();- k.EnableBatching();- // TODO Add support for across channels- // k.EnableMVNMode(MVNMode::ACROSS_CHANNELS);- k.EnableMVNMode(MVNMode::WITHIN_CHANNELS);- k.EnableMVNNormalizeVariance();-- return k;-}--DeviceFeaturesKey MVNKernel_b_fs_yx_fsv16_imad::get_required_device_features_key(const Params& params) const {- auto k = get_common_subgroups_device_features_key(params);- k.requires_subgroup_shuffle();- k.requires_subgroup_reduce();-- return k;-}--bool MVNKernel_b_fs_yx_fsv16_imad::Validate(const Params& p) const {- if (!Parent::Validate(p))- DO_NOT_USE_THIS_KERNEL(p.layerID);-- auto params = static_cast<const mvn_params&>(p);-- // TODO Add support for input padding via iterating over y (parallel or in kernel).- if (params.inputs[0].X().pad.Total() != 0 || params.inputs[0].Y().pad.Total() != 0 ||- params.inputs[0].Z().pad.Total() != 0)- DO_NOT_USE_THIS_KERNEL(p.layerID);-- return true;-}--MVNKernelBase::DispatchData MVNKernel_b_fs_yx_fsv16_imad::SetDefault(const mvn_params& params) const {- auto dispatchData = Parent::SetDefault(params);-- auto items_num = params.outputs[0].X().v * params.outputs[0].Y().v * params.outputs[0].Z().v;- auto max_wg = params.engineInfo.maxWorkGroupSize;- auto slm_per_sg = fsv * 4;- auto max_slm = params.engineInfo.maxLocalMemSize;- auto max_sgs = max_slm / slm_per_sg;-- auto max_lws = std::min(max_wg, max_sgs * simd);-- auto lws = std::max(std::min(items_num, max_lws) / simd, (size_t)1) * simd;-- dispatchData.gws[0] = lws;- dispatchData.gws[1] = CeilDiv(params.outputs[0].Feature().v, fsv);- dispatchData.gws[2] = params.outputs[0].Batch().v;-- dispatchData.lws[0] = lws;- dispatchData.lws[1] = 1;- dispatchData.lws[2] = 1;-- dispatchData.itemsNum = 1;-- return dispatchData;-}--Datatype MVNKernel_b_fs_yx_fsv16_imad::GetAccumulatorType(const mvn_params& params) const {- const auto& input_dt = params.inputs[0].GetDType();-- switch (input_dt) {- case Datatype::F32:- case Datatype::F16:- return Datatype::F32;- case Datatype::INT8:- case Datatype::UINT8:- return Datatype::INT32;- default: return Datatype::F32;- }-}--JitConstants MVNKernel_b_fs_yx_fsv16_imad::GetJitConstants(const mvn_params& params, DispatchData dispatchData) const {- auto jits = Parent::GetJitConstants(params, dispatchData);-- auto activation_dt = GetActivationType(params);- jits.Merge(MakeTypeJitConstants(activation_dt, "ACTIVATION"));- jits.Merge(MakeTypeJitConstants(activation_dt, "MEAN"));- jits.Merge(MakeTypeJitConstants(GetAccumulatorType(params), "ACCUMULATOR"));- jits.AddConstant(MakeJitConstant("SIMD", simd));- jits.AddConstant(MakeJitConstant("LWS", dispatchData.lws[0]));- jits.AddConstant(MakeJitConstant("GWS", dispatchData.gws[0]));- jits.AddConstant(MakeJitConstant("ITEM_GROUPS", dispatchData.itemsNum));- jits.AddConstant(MakeJitConstant("INPUT_SLICE_PITCH", 16));- if (!params.fused_ops.empty()) {- std::vector<std::string> idx_order;-- if (params.inputs[0].GetDims().size() <= 4) {- idx_order = {"b",- "(f + set_idx)",- "(output_spatial / OUTPUT_SIZE_X)",- "(output_spatial % OUTPUT_SIZE_X)"};- } else if (params.inputs[0].GetDims().size() == 5) {- idx_order = {"b",- "(f + set_idx)",- "(output_spatial / (OUTPUT_SIZE_X * OUTPUT_SIZE_Y))",- "((output_spatial / OUTPUT_SIZE_X) % OUTPUT_SIZE_Y)",- "(output_spatial % OUTPUT_SIZE_X)"};- }-- auto conf = FusedOpsConfiguration("", idx_order, "normalized", activation_dt);- jits.Merge(MakeFusedOpsJitConstants(params, {conf}));- }- return jits;-}--MVNKernel_b_fs_yx_fsv16_imad::MultiDispatchData MVNKernel_b_fs_yx_fsv16_imad::SetDefaultForMulti(- const mvn_params& params) const {- MultiDispatchData dispatchData;-- auto items_num = params.outputs[0].X().v * params.outputs[0].Y().v * params.outputs[0].Z().v;- auto max_wg = params.engineInfo.maxWorkGroupSize;- auto slm_per_sg = fsv * 4;- auto max_slm = params.engineInfo.maxLocalMemSize;- auto max_sgs = max_slm / slm_per_sg;-- auto max_lws = std::min(max_wg, max_sgs * simd);- auto lws = std::max(std::min(items_num, max_lws) / simd, (size_t)1) * simd;-- // TODO Check if larger number of work-groups does not provide benefit- size_t item_groups = pref_work_groups;- dispatchData.item_groups = item_groups;-- size_t stage1_lws = lws;-- dispatchData.stage_1.gws[0] = stage1_lws * item_groups;- dispatchData.stage_1.gws[1] = CeilDiv(params.outputs[0].Feature().v, fsv);- dispatchData.stage_1.gws[2] = params.outputs[0].Batch().v;-- dispatchData.stage_1.lws[0] = stage1_lws;- dispatchData.stage_1.lws[1] = 1;- dispatchData.stage_1.lws[2] = 1;-- dispatchData.stage_1.itemsNum = item_groups;-- size_t stage2_lws = std::max(std::min(item_groups, max_lws) / simd, (size_t)1) * simd;-- dispatchData.stage_2.gws[0] = stage2_lws;- dispatchData.stage_2.gws[1] = CeilDiv(params.outputs[0].Feature().v, fsv);- dispatchData.stage_2.gws[2] = params.outputs[0].Batch().v;-- dispatchData.stage_2.lws[0] = stage2_lws;- dispatchData.stage_2.lws[1] = 1;- dispatchData.stage_2.lws[2] = 1;-- dispatchData.stage_2.itemsNum = item_groups;-- dispatchData.stage_final.gws[0] = std::max(items_num / simd, (size_t)1) * simd;- dispatchData.stage_final.gws[1] = CeilDiv(params.outputs[0].Feature().v, fsv);- dispatchData.stage_final.gws[2] = params.outputs[0].Batch().v;-- dispatchData.stage_final.lws[0] = simd;- dispatchData.stage_final.lws[1] = 1;- dispatchData.stage_final.lws[2] = 1;-- dispatchData.stage_final.itemsNum = 1;-- return dispatchData;-}--KernelsData MVNKernel_b_fs_yx_fsv16_imad::GetMultiStageKernelsData(const mvn_params& params) const {- if (!Validate(params))- return {};-- constexpr size_t intermidiate_bytes = 4;- const mvn_params& orgParams = static_cast<const mvn_params&>(params);-- auto dispatchData = SetDefaultForMulti(orgParams);-- size_t kernels_num = params.mvnNormalizeVariance ? 5 : 3;- KernelData kd = KernelData::Default<mvn_params>(params, kernels_num);-- auto finalKernelName = GetKernelName(orgParams);- size_t entry_part_id = 0;- {- // Mean first stage- auto cldnn_jit = GetJitConstants(orgParams, dispatchData.stage_1);- cldnn_jit.AddConstant(MakeJitConstant("MVN_KERNEL_MEAN_1", 1));- auto entry_point = GetEntryPoint(finalKernelName, orgParams.layerID, params, entry_part_id++);- auto jit = CreateJit(finalKernelName, cldnn_jit, entry_point);- auto& kernel = kd.kernels[0];- FillCLKernelData(kernel,- dispatchData.stage_1,- params.engineInfo,- finalKernelName,- jit,- entry_point,- "",- false,- false,- 0,- 0);- kernel.params.arguments.clear(); // Clear original output argument- kernel.params.arguments.push_back({ArgumentDescriptor::Types::INPUT, 0});- kernel.params.arguments.push_back({ArgumentDescriptor::Types::INTERNAL_BUFFER, 0});- kd.internalBuffers.push_back(params.outputs[0].Batch().v * Align(params.outputs[0].Feature().v, fsv) *- dispatchData.item_groups * intermidiate_bytes);- }- {- // Mean second stage- auto cldnn_jit = GetJitConstants(orgParams, dispatchData.stage_2);- cldnn_jit.AddConstant(MakeJitConstant("MVN_KERNEL_MEAN_2", 1));- auto entry_point = GetEntryPoint(finalKernelName, orgParams.layerID, params, entry_part_id++);- auto jit = CreateJit(finalKernelName, cldnn_jit, entry_point);- auto& kernel = kd.kernels[1];- FillCLKernelData(kernel,- dispatchData.stage_2,- params.engineInfo,- finalKernelName,- jit,- entry_point,- "",- false,- false,- 0,- 0);- kernel.params.arguments.clear(); // Clear original output argument- kernel.params.arguments.push_back({ArgumentDescriptor::Types::INTERNAL_BUFFER, 0});- kernel.params.arguments.push_back({ArgumentDescriptor::Types::INTERNAL_BUFFER, 1});- kd.internalBuffers.push_back(params.outputs[0].Batch().v * Align(params.outputs[0].Feature().v, fsv) *- intermidiate_bytes);- }- if (params.mvnNormalizeVariance) {- // Variance first stage- auto cldnn_jit = GetJitConstants(orgParams, dispatchData.stage_1);- cldnn_jit.AddConstant(MakeJitConstant("MVN_KERNEL_VAR_1", 1));- auto entry_point = GetEntryPoint(finalKernelName, orgParams.layerID, params, entry_part_id++);- auto jit = CreateJit(finalKernelName, cldnn_jit, entry_point);- auto& kernel = kd.kernels[2];- FillCLKernelData(kernel,- dispatchData.stage_1,- params.engineInfo,- finalKernelName,- jit,- entry_point,- "",- false,- false,- 0,- 0);- kernel.params.arguments.clear(); // Clear original output argument- kernel.params.arguments.push_back({ArgumentDescriptor::Types::INPUT, 0});- kernel.params.arguments.push_back({ArgumentDescriptor::Types::INTERNAL_BUFFER, 1});- kernel.params.arguments.push_back({ArgumentDescriptor::Types::INTERNAL_BUFFER, 0});- }- if (params.mvnNormalizeVariance) {- // Variance second stage- auto cldnn_jit = GetJitConstants(orgParams, dispatchData.stage_2);- cldnn_jit.AddConstant(MakeJitConstant("MVN_KERNEL_VAR_2", 1));- auto entry_point = GetEntryPoint(finalKernelName, orgParams.layerID, params, entry_part_id++);- auto jit = CreateJit(finalKernelName, cldnn_jit, entry_point);- auto& kernel = kd.kernels[3];- FillCLKernelData(kernel,- dispatchData.stage_2,- params.engineInfo,- finalKernelName,- jit,- entry_point,- "",- false,- false,- 0,- 0);- kernel.params.arguments.clear(); // Clear original output argument- kernel.params.arguments.push_back({ArgumentDescriptor::Types::INTERNAL_BUFFER, 0});- kernel.params.arguments.push_back({ArgumentDescriptor::Types::INTERNAL_BUFFER, 2});- kd.internalBuffers.push_back(params.outputs[0].Batch().v * Align(params.outputs[0].Feature().v, fsv) *- intermidiate_bytes);- }- { // Final- auto cldnn_jit = GetJitConstants(orgParams, dispatchData.stage_final);- cldnn_jit.AddConstant(MakeJitConstant("MVN_KERNEL_MAIN", 1));- cldnn_jit.AddConstant(MakeJitConstant("PRECALC_MEAN", 1));- cldnn_jit.AddConstant(MakeJitConstant("PRECALC_VARIANCE", params.mvnNormalizeVariance));- auto entry_point = GetEntryPoint(finalKernelName, orgParams.layerID, params, entry_part_id);- auto jit = CreateJit(finalKernelName, cldnn_jit, entry_point);- auto& kernel = kd.kernels[kernels_num - 1];- FillCLKernelData(kernel,- dispatchData.stage_final,- params.engineInfo,- finalKernelName,- jit,- entry_point,- "",- false,- false,- 1,- GetFusedPrimitiveInputsCount(params));- kernel.params.arguments.push_back({ArgumentDescriptor::Types::INTERNAL_BUFFER, 1});- if (params.mvnNormalizeVariance) {- kernel.params.arguments.push_back({ArgumentDescriptor::Types::INTERNAL_BUFFER, 2});- }- }- kd.internalBufferDataType = Datatype::F32;-- return {kd};-}--KernelsData MVNKernel_b_fs_yx_fsv16_imad::GetKernelsData(const Params& params) const {- const mvn_params& orgParams = static_cast<const mvn_params&>(params);-- auto max_slm = params.engineInfo.maxLocalMemSize;- auto slm_per_sg = fsv * 4;- auto max_lws = params.engineInfo.maxWorkGroupSize;- auto items_num = orgParams.outputs[0].X().v * orgParams.outputs[0].Y().v * orgParams.outputs[0].Z().v;-- auto enough_slm = max_lws / simd * simd * slm_per_sg <= max_slm;- auto enough_lws = max_lws / simd >= 1;- auto enough_items = items_num >= max_lws / simd * simd * pref_work_groups;-- if (enough_slm && enough_lws && enough_items)- return GetMultiStageKernelsData(orgParams);- else- return GetCommonKernelsData(params);-}--KernelsPriority MVNKernel_b_fs_yx_fsv16_imad::GetKernelsPriority(const Params& /*params*/) const {- return FORCE_PRIORITY_4;-}-} // namespace kernel_selectordiff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/mvn/mvn_kernel_bs_fs_yx_bsv32.hpp b/src/plugins/intel_gpu/src/kernel_selector/kernels/mvn/mvn_kernel_bs_fs_yx_bsv32.hppindex 3b6d3c373fa..1bb499d3950 100644--- a/src/plugins/intel_gpu/src/kernel_selector/kernels/mvn/mvn_kernel_bs_fs_yx_bsv32.hpp+++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/mvn/mvn_kernel_bs_fs_yx_bsv32.hpp@@ -12,7 +12,7 @@ namespace kernel_selector {class MVNKernel_bs_fs_yx_bsv32 : public MVNKernelBase {public:using Parent = MVNKernelBase;- MVNKernel_bs_fs_yx_bsv32() : MVNKernelBase("mvn_gpu_b_fs_yx_fsv16_imad") {}+ MVNKernel_bs_fs_yx_bsv32() : MVNKernelBase("mvn_gpu_b_fs_yx_bsv32") {}virtual ~MVNKernel_bs_fs_yx_bsv32() {}KernelsData GetKernelsData(const Params& params) const override;diff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/mvn/mvn_kernel_selector.cpp b/src/plugins/intel_gpu/src/kernel_selector/kernels/mvn/mvn_kernel_selector.cppindex 10f02cfc4ed..d721ac695c5 100644--- a/src/plugins/intel_gpu/src/kernel_selector/kernels/mvn/mvn_kernel_selector.cpp+++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/mvn/mvn_kernel_selector.cpp@@ -5,14 +5,14 @@#include "mvn_kernel_selector.h"#include "mvn_kernel_ref.h"#include "mvn_kernel_bfyx_opt.h"-#include "mvn_kernel_b_fs_yx_fsv16_imad.hpp"+#include "mvn_kernel_b_fs_yx_fsv16.hpp"#include "mvn_kernel_bs_fs_yx_bsv32.hpp"namespace kernel_selector {mvn_kernel_selector::mvn_kernel_selector() {Attach<MVNKernelRef>();Attach<MVNKernelBfyxOpt>();- Attach<MVNKernel_b_fs_yx_fsv16_imad>();+ Attach<MVNKernel_b_fs_yx_fsv16>();Attach<MVNKernel_bs_fs_yx_bsv32>();}diff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/reorder/reorder_kernel_bfyx_to_blocked_format.cpp b/src/plugins/intel_gpu/src/kernel_selector/kernels/reorder/reorder_kernel_bfyx_to_blocked_format.cppindex 5b965cb67a4..1a400c6488e 100644--- a/src/plugins/intel_gpu/src/kernel_selector/kernels/reorder/reorder_kernel_bfyx_to_blocked_format.cpp+++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/reorder/reorder_kernel_bfyx_to_blocked_format.cpp@@ -40,6 +40,7 @@ ParamsKey ReorderKernel_bfyx_to_blocked_format::GetSupportedKey() const {k.EnableBatching();k.EnableTensorOffset();k.EnableTensorPitches();+ k.EnableDynamicShapesSupport();return k;}@@ -119,7 +120,9 @@ static inline size_t GetTileSize(const reorder_params& params) {return MIN_TILE_SIZE;}- if (params.inputs[0].Feature().v < DEFAULT_TILE_SIZE) {+ // For shape-agnostic (dynamic shapes), Feature count is unknown at compile time.+ // Use DEFAULT_TILE_SIZE; remainder path handles small features.+ if (!params.is_shape_agnostic && params.inputs[0].Feature().v < DEFAULT_TILE_SIZE) {return MIN_TILE_SIZE;}@@ -178,53 +181,93 @@ CommonDispatchData ReorderKernel_bfyx_to_blocked_format::SetDefault(const reordeJitConstants ReorderKernel_bfyx_to_blocked_format::GetJitConstants(const reorder_params& params) const {auto jit = ReorderKernelBase::GetJitConstants(params);- const size_t b = params.inputs[0].Batch().v;- const size_t f = params.inputs[0].Feature().v;- const size_t x = params.inputs[0].X().v;const size_t tile_size = GetTileSize(params);const size_t input_ndims = params.inputs[0].GetDims().size();const size_t fsv_alignment = GetFsvAlignment(params);- const auto& gws = GetGWS(params);- const auto& lws = GetBestLwsFromGws(params, gws, tile_size, tile_size);- const uint64_t total_lws = lws[0] * lws[1] * lws[2];-jit.AddConstant(MakeJitConstant("INPUT0_TILED_ORDER", GetTiledInputOrder(input_ndims)));- jit.AddConstant(MakeJitConstant("INPUT0_FEATURE_SLICE_NUM", CeilDiv(f, fsv_alignment)));jit.AddConstant(MakeJitConstant("TILE_SIZE", tile_size));jit.AddConstant(MakeJitConstant("FSV_ALIGNMENT", fsv_alignment));- jit.AddConstant(MakeJitConstant("TRANS_BUF_SIZE", tile_size * total_lws));if (params.outputs[0].GetLayout() == DataLayout::fs_b_yx_fsv32) {jit.AddConstant(MakeJitConstant("FS_B_YX_FSV", 1));}- if (params.outputs[0].GetLayout() == DataLayout::bs_fs_yx_bsv16_fsv16 ||+ const bool is_double_blocked = params.outputs[0].GetLayout() == DataLayout::bs_fs_yx_bsv16_fsv16 ||params.outputs[0].GetLayout() == DataLayout::bs_fs_yx_bsv16_fsv32 ||params.outputs[0].GetLayout() == DataLayout::bs_fs_zyx_bsv16_fsv16 ||params.outputs[0].GetLayout() == DataLayout::bs_fs_zyx_bsv16_fsv32 ||params.outputs[0].GetLayout() == DataLayout::bs_fs_zyx_bsv32_fsv16 ||- params.outputs[0].GetLayout() == DataLayout::bs_fs_zyx_bsv32_fsv32) {- const size_t bsv_alignment = GetBsvAlignment(params);- jit.AddConstant(MakeJitConstant("DOUBLE_BLOCKED_FORMAT", 1));- jit.AddConstant(MakeJitConstant("INPUT0_BATCH_SLICE_NUM", CeilDiv(b, bsv_alignment)));- jit.AddConstant(MakeJitConstant("BSV_ALIGNMENT", bsv_alignment));- }-- // whether F is tile_size-aligned- if (f % tile_size == 0) {- jit.AddConstant(MakeJitConstant("F_NO_REMAINDER_CONDITION", "(f < INPUT0_FEATURE_NUM)"));+ params.outputs[0].GetLayout() == DataLayout::bs_fs_zyx_bsv32_fsv32;++ if (params.is_shape_agnostic) {+ // Runtime expressions for shape-dependent constants+ jit.AddConstant(MakeJitConstant("INPUT0_FEATURE_SLICE_NUM",+ "((INPUT0_FEATURE_NUM + " + std::to_string(fsv_alignment) + " - 1) / " + std::to_string(fsv_alignment) + ")"));++ // TRANS_BUF_SIZE: use maximum possible LWS product to guarantee SLM is large enough at any runtime shape+ const size_t elem_size = params.outputs[0].ElementSize();+ const size_t max_local_mem_size = params.engineInfo.maxLocalMemSize;+ const size_t max_work_group_size = params.engineInfo.maxWorkGroupSize;+ size_t max_num_work_items = std::min(max_work_group_size, max_local_mem_size / (elem_size * tile_size * tile_size));+ jit.AddConstant(MakeJitConstant("TRANS_BUF_SIZE", tile_size * max_num_work_items));++ // F remainder: always emit both paths (remainder size unknown at compile time)+ std::string ts = std::to_string(tile_size);+ jit.AddConstant(MakeJitConstant("F_REMAINDER_SIZE", "(INPUT0_FEATURE_NUM % " + ts + ")"));+ jit.AddConstant(MakeJitConstant("F_REMAINDER_CONDITION",+ "(f >= (INPUT0_FEATURE_NUM - (INPUT0_FEATURE_NUM % " + ts + "))) && (f < INPUT0_FEATURE_NUM) && ((INPUT0_FEATURE_NUM % " + ts + ") != 0)"));+ jit.AddConstant(MakeJitConstant("F_NO_REMAINDER_CONDITION",+ "((f < INPUT0_FEATURE_NUM) && ((INPUT0_FEATURE_NUM % " + ts + ") == 0 || f < (INPUT0_FEATURE_NUM - (INPUT0_FEATURE_NUM % " + ts + "))))"));++ // X remainder: always emit both paths+ jit.AddConstant(MakeJitConstant("X_REMAINDER_SIZE", "(INPUT0_SIZE_X % " + ts + ")"));+ jit.AddConstant(MakeJitConstant("X_REMAINDER_CONDITION",+ "(x >= (INPUT0_SIZE_X - (INPUT0_SIZE_X % " + ts + "))) && (x < INPUT0_SIZE_X) && ((INPUT0_SIZE_X % " + ts + ") != 0)"));+ jit.AddConstant(MakeJitConstant("X_NO_REMAINDER_CONDITION",+ "((x < INPUT0_SIZE_X) && ((INPUT0_SIZE_X % " + ts + ") == 0 || x < (INPUT0_SIZE_X - (INPUT0_SIZE_X % " + ts + "))))"));++ if (is_double_blocked) {+ const size_t bsv_alignment = GetBsvAlignment(params);+ jit.AddConstant(MakeJitConstant("DOUBLE_BLOCKED_FORMAT", 1));+ jit.AddConstant(MakeJitConstant("INPUT0_BATCH_SLICE_NUM",+ "((INPUT0_BATCH_NUM + " + std::to_string(bsv_alignment) + " - 1) / " + std::to_string(bsv_alignment) + ")"));+ jit.AddConstant(MakeJitConstant("BSV_ALIGNMENT", bsv_alignment));+ }} else {- jit.AddConstant(MakeJitConstant("F_REMAINDER_SIZE", f % tile_size));- jit.AddConstant(MakeJitConstant("F_REMAINDER_CONDITION", "(f >= (INPUT0_FEATURE_NUM - F_REMAINDER_SIZE)) && (f < INPUT0_FEATURE_NUM)"));- jit.AddConstant(MakeJitConstant("F_NO_REMAINDER_CONDITION", "(f < (INPUT0_FEATURE_NUM - F_REMAINDER_SIZE))"));- }+ const size_t b = params.inputs[0].Batch().v;+ const size_t f = params.inputs[0].Feature().v;+ const size_t x = params.inputs[0].X().v;++ jit.AddConstant(MakeJitConstant("INPUT0_FEATURE_SLICE_NUM", CeilDiv(f, fsv_alignment)));++ const auto& gws = GetGWS(params);+ const auto& lws = GetBestLwsFromGws(params, gws, tile_size, tile_size);+ const uint64_t total_lws = lws[0] * lws[1] * lws[2];+ jit.AddConstant(MakeJitConstant("TRANS_BUF_SIZE", tile_size * total_lws));++ if (is_double_blocked) {+ const size_t bsv_alignment = GetBsvAlignment(params);+ jit.AddConstant(MakeJitConstant("DOUBLE_BLOCKED_FORMAT", 1));+ jit.AddConstant(MakeJitConstant("INPUT0_BATCH_SLICE_NUM", CeilDiv(b, bsv_alignment)));+ jit.AddConstant(MakeJitConstant("BSV_ALIGNMENT", bsv_alignment));+ }- // whether x is tile_size-aligned- if (x % tile_size != 0) {- jit.AddConstant(MakeJitConstant("X_REMAINDER_SIZE", x % tile_size));- jit.AddConstant(MakeJitConstant("X_REMAINDER_CONDITION", "(x >= (INPUT0_SIZE_X - X_REMAINDER_SIZE)) && (x < INPUT0_SIZE_X)"));- jit.AddConstant(MakeJitConstant("X_NO_REMAINDER_CONDITION", "(x < (INPUT0_SIZE_X - X_REMAINDER_SIZE))"));+ // whether F is tile_size-aligned+ if (f % tile_size == 0) {+ jit.AddConstant(MakeJitConstant("F_NO_REMAINDER_CONDITION", "(f < INPUT0_FEATURE_NUM)"));+ } else {+ jit.AddConstant(MakeJitConstant("F_REMAINDER_SIZE", f % tile_size));+ jit.AddConstant(MakeJitConstant("F_REMAINDER_CONDITION", "(f >= (INPUT0_FEATURE_NUM - F_REMAINDER_SIZE)) && (f < INPUT0_FEATURE_NUM)"));+ jit.AddConstant(MakeJitConstant("F_NO_REMAINDER_CONDITION", "(f < (INPUT0_FEATURE_NUM - F_REMAINDER_SIZE))"));+ }++ // whether x is tile_size-aligned+ if (x % tile_size != 0) {+ jit.AddConstant(MakeJitConstant("X_REMAINDER_SIZE", x % tile_size));+ jit.AddConstant(MakeJitConstant("X_REMAINDER_CONDITION", "(x >= (INPUT0_SIZE_X - X_REMAINDER_SIZE)) && (x < INPUT0_SIZE_X)"));+ jit.AddConstant(MakeJitConstant("X_NO_REMAINDER_CONDITION", "(x < (INPUT0_SIZE_X - X_REMAINDER_SIZE))"));+ }}return jit;@@ -275,6 +318,12 @@ bool ReorderKernel_bfyx_to_blocked_format::Validate(const Params& p) const {KernelsPriority ReorderKernel_bfyx_to_blocked_format::GetKernelsPriority(const Params& p) const {const reorder_params& params = static_cast<const reorder_params&>(p);++ // For dynamic shapes, skip shape-dependent heuristics+ if (params.is_shape_agnostic) {+ return FORCE_PRIORITY_5;+ }+const auto& input = params.inputs[0];const auto& output = params.outputs[0];diff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/reorder/reorder_kernel_fsv.cpp b/src/plugins/intel_gpu/src/kernel_selector/kernels/reorder/reorder_kernel_fsv.cppnew file mode 100644index 00000000000..c16bf0fa5cd--- /dev/null+++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/reorder/reorder_kernel_fsv.cpp@@ -0,0 +1,183 @@+// Copyright (C) 2018-2026 Intel Corporation+// SPDX-License-Identifier: Apache-2.0+//++#include "reorder_kernel_fsv.h"+#include "kernel_selector_utils.h"+#include <string>++namespace kernel_selector {++static size_t GetFsv(DataLayout layout) {+ switch (layout) {+ case DataLayout::b_fs_yx_fsv4:+ case DataLayout::b_fs_zyx_fsv4:+ return 4;+ case DataLayout::b_fs_yx_fsv8:+ case DataLayout::b_fs_zyx_fsv8:+ return 8;+ case DataLayout::b_fs_yx_fsv16:+ case DataLayout::b_fs_zyx_fsv16:+ return 16;+ case DataLayout::b_fs_yx_fsv32:+ case DataLayout::b_fs_zyx_fsv32:+ return 32;+ default:+ return 0;+ }+}++static bool IsSingleBlockedFsv(DataLayout layout) {+ return GetFsv(layout) != 0;+}++ParamsKey ReorderKernel_fsv::GetSupportedKey() const {+ ParamsKey k;++ k.EnableAllInputDataType();+ k.EnableAllOutputDataType();++ k.EnableInputLayout(DataLayout::b_fs_yx_fsv4);+ k.EnableInputLayout(DataLayout::b_fs_yx_fsv8);+ k.EnableInputLayout(DataLayout::b_fs_yx_fsv16);+ k.EnableInputLayout(DataLayout::b_fs_yx_fsv32);+ k.EnableInputLayout(DataLayout::b_fs_zyx_fsv4);+ k.EnableInputLayout(DataLayout::b_fs_zyx_fsv8);+ k.EnableInputLayout(DataLayout::b_fs_zyx_fsv16);+ k.EnableInputLayout(DataLayout::b_fs_zyx_fsv32);++ k.EnableOutputLayout(DataLayout::b_fs_yx_fsv4);+ k.EnableOutputLayout(DataLayout::b_fs_yx_fsv8);+ k.EnableOutputLayout(DataLayout::b_fs_yx_fsv16);+ k.EnableOutputLayout(DataLayout::b_fs_yx_fsv32);+ k.EnableOutputLayout(DataLayout::b_fs_zyx_fsv4);+ k.EnableOutputLayout(DataLayout::b_fs_zyx_fsv8);+ k.EnableOutputLayout(DataLayout::b_fs_zyx_fsv16);+ k.EnableOutputLayout(DataLayout::b_fs_zyx_fsv32);++ k.EnableDifferentTypes();+ k.EnableBatching();+ k.EnableTensorOffset();+ k.EnableTensorPitches();+ k.EnableDynamicShapesSupport();++ return k;+}++bool ReorderKernel_fsv::Validate(const Params& p) const {+ if (!ReorderKernelBase::Validate(p)) {+ DO_NOT_USE_THIS_KERNEL(p.layerID);+ }++ const reorder_params& params = static_cast<const reorder_params&>(p);+ const auto& input = params.inputs[0];+ const auto& output = params.outputs[0];++ if (!IsSingleBlockedFsv(input.GetLayout()) || !IsSingleBlockedFsv(output.GetLayout())) {+ DO_NOT_USE_THIS_KERNEL(p.layerID);+ }++ if (input.GetDims().size() != output.GetDims().size()) {+ DO_NOT_USE_THIS_KERNEL(p.layerID);+ }++ size_t in_fsv = GetFsv(input.GetLayout());+ size_t out_fsv = GetFsv(output.GetLayout());+ if (in_fsv == out_fsv) {+ DO_NOT_USE_THIS_KERNEL(p.layerID);+ }++ // Padding not supported+ if (input.X().pad.before != 0 || input.X().pad.after != 0 ||+ input.Y().pad.before != 0 || input.Y().pad.after != 0 ||+ input.Z().pad.before != 0 || input.Z().pad.after != 0 ||+ input.Feature().pad.before != 0 || input.Feature().pad.after != 0 ||+ input.Batch().pad.before != 0 || input.Batch().pad.after != 0) {+ DO_NOT_USE_THIS_KERNEL(p.layerID);+ }++ if (output.X().pad.before != 0 || output.X().pad.after != 0 ||+ output.Y().pad.before != 0 || output.Y().pad.after != 0 ||+ output.Z().pad.before != 0 || output.Z().pad.after != 0 ||+ output.Feature().pad.before != 0 || output.Feature().pad.after != 0 ||+ output.Batch().pad.before != 0 || output.Batch().pad.after != 0) {+ DO_NOT_USE_THIS_KERNEL(p.layerID);+ }++ return true;+}++CommonDispatchData ReorderKernel_fsv::SetDefault(const reorder_params& params) const {+ CommonDispatchData dispatchData;++ const auto& input = params.inputs[0];+ const size_t out_fsv = GetFsv(params.outputs[0].GetLayout());++ // GWS[0] = x+ // GWS[1] = y * z+ // GWS[2] = b * fs_out (feature slices in output blocking)+ size_t x = input.X().v;+ size_t y = input.Y().v;+ size_t z = input.Z().v;+ size_t b = input.Batch().v;+ size_t f = input.Feature().v;++ dispatchData.gws = { x, y * z, b * CeilDiv(f, out_fsv) };+ dispatchData.lws = GetOptimalLocalWorkGroupSizes(dispatchData.gws, params.engineInfo);++ return dispatchData;+}++JitConstants ReorderKernel_fsv::GetJitConstants(const reorder_params& params) const {+ auto jit = ReorderKernelBase::GetJitConstants(params);++ const size_t in_fsv = GetFsv(params.inputs[0].GetLayout());+ const size_t out_fsv = GetFsv(params.outputs[0].GetLayout());+ const size_t ndims = params.inputs[0].GetDims().size();++ jit.AddConstant(MakeJitConstant("IN_FSV", in_fsv));+ jit.AddConstant(MakeJitConstant("OUT_FSV", out_fsv));++ if (ndims == 5) {+ jit.AddConstant(MakeJitConstant("INPUT0_DIMS_5", 1));+ }++ // Vectorized path: when both fsv sizes are >= 16 and one is a multiple of the other+ // Threshold of 16 is chosen so vload16/vstore16 intrinsics map to a single+ // SIMD16 transaction. fsv4/fsv8 layouts fall back to the scalar loop in the .cl+ // because a smaller vector width would not amortize the added jit branches.+ const size_t min_fsv = std::min(in_fsv, out_fsv);+ const size_t max_fsv = std::max(in_fsv, out_fsv);+ if (min_fsv >= 16 && max_fsv % min_fsv == 0) {+ jit.AddConstant(MakeJitConstant("FSV_VECTORIZED", 1));+ jit.AddConstant(MakeJitConstant("VEC_SIZE", min_fsv));+ jit.AddConstant(MakeJitConstant("RATIO", max_fsv / min_fsv));+ }++ if (params.is_shape_agnostic) {+ jit.AddConstant(MakeJitConstant("IN_FEATURE_SLICE_NUM",+ "((INPUT0_FEATURE_NUM + " + std::to_string(in_fsv) + " - 1) / " + std::to_string(in_fsv) + ")"));+ jit.AddConstant(MakeJitConstant("OUT_FEATURE_SLICE_NUM",+ "((INPUT0_FEATURE_NUM + " + std::to_string(out_fsv) + " - 1) / " + std::to_string(out_fsv) + ")"));+ } else {+ const size_t f = params.inputs[0].Feature().v;+ jit.AddConstant(MakeJitConstant("IN_FEATURE_SLICE_NUM", CeilDiv(f, in_fsv)));+ jit.AddConstant(MakeJitConstant("OUT_FEATURE_SLICE_NUM", CeilDiv(f, out_fsv)));+ }++ return jit;+}++KernelsData ReorderKernel_fsv::GetKernelsData(const Params& params) const {+ assert(params.GetType() == KernelType::REORDER);++ const reorder_params& orgParams = static_cast<const reorder_params&>(params);++ return GetCommonKernelsData(orgParams);+}++KernelsPriority ReorderKernel_fsv::GetKernelsPriority(const Params& p) const {+ return FORCE_PRIORITY_4;+}++} // namespace kernel_selectordiff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/reorder/reorder_kernel_fsv.h b/src/plugins/intel_gpu/src/kernel_selector/kernels/reorder/reorder_kernel_fsv.hnew file mode 100644index 00000000000..66f4b137ddf--- /dev/null+++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/reorder/reorder_kernel_fsv.h@@ -0,0 +1,22 @@+// Copyright (C) 2018-2026 Intel Corporation+// SPDX-License-Identifier: Apache-2.0+//++#pragma once++#include "reorder_kernel_base.h"++namespace kernel_selector {+class ReorderKernel_fsv : public ReorderKernelBase {+public:+ ReorderKernel_fsv() : ReorderKernelBase("reorder_data_fsv") {}++ bool Validate(const Params& p) const override;+ KernelsData GetKernelsData(const Params& params) const override;+ KernelsPriority GetKernelsPriority(const Params& params) const override;+ ParamsKey GetSupportedKey() const override;+protected:+ JitConstants GetJitConstants(const reorder_params& params) const override;+ CommonDispatchData SetDefault(const reorder_params& params) const override;+};+} // namespace kernel_selectordiff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/reorder/reorder_kernel_selector.cpp b/src/plugins/intel_gpu/src/kernel_selector/kernels/reorder/reorder_kernel_selector.cppindex 3e2185027be..bffa3e97f0d 100644--- a/src/plugins/intel_gpu/src/kernel_selector/kernels/reorder/reorder_kernel_selector.cpp+++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/reorder/reorder_kernel_selector.cpp@@ -12,6 +12,7 @@#include "reorder_kernel_fs_b_yx_fsv32_to_bfyx.h"#include "reorder_kernel_bfyx_to_blocked_format.h"#include "reorder_kernel_b_fs_yx_fsv16_fsv32_to_bfyx.h"+#include "reorder_kernel_fsv.h"namespace kernel_selector {@@ -25,6 +26,7 @@ reorder_kernel_selector::reorder_kernel_selector() {Attach<ReorderKernel_fs_b_yx_fsv32_to_bfyx>();Attach<ReorderKernel_bfyx_to_blocked_format>();Attach<ReorderKernel_b_fs_yx_fsv16_fsv32_to_bfyx>();+ Attach<ReorderKernel_fsv>();}KernelsData reorder_kernel_selector::GetBestKernels(const Params& params) const {diff --git a/src/plugins/intel_gpu/tests/unit/dynamic_execution/deconv_quantize_kernel_test.cpp b/src/plugins/intel_gpu/tests/unit/dynamic_execution/deconv_quantize_kernel_test.cppnew file mode 100644index 00000000000..226475b621d--- /dev/null+++ b/src/plugins/intel_gpu/tests/unit/dynamic_execution/deconv_quantize_kernel_test.cpp@@ -0,0 +1,114 @@+// Copyright (C) 2018-2026 Intel Corporation+// SPDX-License-Identifier: Apache-2.0+//+// Dynamic shape kernel selection regression test.+//+// Checks: after execute(), get_impl()->get_kernel_name() must NOT contain+// "ocl:ref" for the deconv primitive on oneDNN-capable HW (DG2+).+//+// Why: Dynamic 5D deconv + quantize(u8, scale_shift_opt=true) causes oneDNN+// to receive f16→u8 output, which its backward-data path cannot handle+// with an optimized kernel. Without the fix, it falls back to ocl:ref+// (~30x slower than jit:ir).+//+// Note: Skipped on non-immad HW where oneDNN deconv path is not used.++#include "test_utils.h"++#include <intel_gpu/primitives/input_layout.hpp>+#include <intel_gpu/primitives/deconvolution.hpp>+#include <intel_gpu/primitives/quantize.hpp>+#include <intel_gpu/primitives/reorder.hpp>+#include <intel_gpu/primitives/data.hpp>++#include "primitive_inst.h"++#include <algorithm>+#include <string>++using namespace cldnn;+using namespace ::tests;+using namespace testing;++namespace {++// Helper: check if the engine supports oneDNN (immad).+// The ocl:ref regression only occurs on oneDNN-capable HW (e.g. DG2).+bool engine_supports_immad(const engine& eng) {+ return eng.get_device_info().supports_immad;+}++TEST(dynamic_deconv_quantize_kernel, no_ocl_ref_on_onednn_5d) {+ // Skip when oneDNN is not available — the bug only affects oneDNN path.+ auto& engine = get_test_engine();+ if (!engine_supports_immad(engine)) {+ GTEST_SKIP() << "oneDNN not supported on this device; skipping ocl:ref regression test";+ }++ // 5D dynamic input: [1, 320, ?, ?, ?]+ auto input_layout_dynamic = layout{ov::PartialShape{1, 320, -1, -1, -1}, data_types::f16, format::bfzyx};++ // Weights: deconv 320->320, kernel 3x3x3+ const int ic = 320, oc = 320;+ layout weight_layout{ov::PartialShape{ic, oc, 3, 3, 3}, data_types::f16, format::bfzyx};+ auto weights_mem = engine.allocate_memory(weight_layout);+ // Zero-fill is fine — we test kernel selection, not accuracy.+ set_values(weights_mem, std::vector<ov::float16>(weight_layout.count(), ov::float16(0.01f)));++ // Quantize parameters: input_low=0, input_high=1, output_low=0, output_high=255+ // This makes scale_shift_opt=true with out_dt=u8 — the exact pattern that triggers ocl:ref.+ auto in_lo_mem = engine.allocate_memory(layout{ov::PartialShape{1}, data_types::f32, format::bfyx});+ auto in_hi_mem = engine.allocate_memory(layout{ov::PartialShape{1}, data_types::f32, format::bfyx});+ auto out_lo_mem = engine.allocate_memory(layout{ov::PartialShape{1}, data_types::f32, format::bfyx});+ auto out_hi_mem = engine.allocate_memory(layout{ov::PartialShape{1}, data_types::f32, format::bfyx});+ set_values<float>(in_lo_mem, {0.0f});+ set_values<float>(in_hi_mem, {1.0f});+ set_values<float>(out_lo_mem, {0.0f});+ set_values<float>(out_hi_mem, {255.0f});++ topology topo;+ topo.add(input_layout("input", input_layout_dynamic));+ topo.add(data("weights", weights_mem));+ topo.add(data("in_lo", in_lo_mem));+ topo.add(data("in_hi", in_hi_mem));+ topo.add(data("out_lo", out_lo_mem));+ topo.add(data("out_hi", out_hi_mem));+ topo.add(deconvolution("deconv", input_info("input"), "weights",+ ov::Strides{2, 2, 2},+ ov::CoordinateDiff{0, 0, 0},+ ov::Strides{1, 1, 1}));+ topo.add(quantize("quant", input_info("deconv"),+ input_info("in_lo"), input_info("in_hi"),+ input_info("out_lo"), input_info("out_hi"),+ 256, data_types::u8));+ topo.add(reorder("output", input_info("quant"), format::bfzyx, data_types::f32));++ ExecutionConfig config = get_test_default_config(engine);+ config.set_property(ov::intel_gpu::optimize_data(true));+ config.set_property(ov::intel_gpu::allow_new_shape_infer(true));++ network net(engine, topo, config);++ // Allocate concrete input: [1, 320, 10, 10, 18]+ layout input_actual{ov::PartialShape{1, 320, 10, 10, 18}, data_types::f16, format::bfzyx};+ auto input_mem = engine.allocate_memory(input_actual);+ set_values(input_mem, std::vector<ov::float16>(input_actual.count(), ov::float16(0.5f)));++ net.set_input_data("input", input_mem);+ auto outputs = net.execute();++ // After execute(), the dynamic impl is selected and we can inspect it.+ auto deconv_inst = net.get_primitive("deconv");+ ASSERT_NE(deconv_inst, nullptr) << "deconv primitive instance not found";+ auto* impl = deconv_inst->get_impl();+ ASSERT_NE(impl, nullptr) << "deconv has no implementation after execute";++ auto kernel_name = impl->get_kernel_name();++ // The fix ensures deconv selects jit:ir (fast) instead of ocl:ref (slow, 30x+ regression).+ EXPECT_TRUE(kernel_name.find("jit:ir") != std::string::npos)+ << "Regression: deconv did not select jit:ir kernel. "+ << "kernel_name=" << kernel_name;+}++} // namespacediff --git a/src/plugins/intel_gpu/tests/unit/fusions/deconvolution_fusion_test.cpp b/src/plugins/intel_gpu/tests/unit/fusions/deconvolution_fusion_test.cppindex 477033b2174..3cb8fd9a0fd 100644--- a/src/plugins/intel_gpu/tests/unit/fusions/deconvolution_fusion_test.cpp+++ b/src/plugins/intel_gpu/tests/unit/fusions/deconvolution_fusion_test.cpp@@ -826,23 +826,23 @@ TEST_P(deconv_scale_actv_quant_u8_eltw_scale_actv_quant_i8, basic) {}INSTANTIATE_TEST_SUITE_P(fusings_gpu, deconv_scale_actv_quant_u8_eltw_scale_actv_quant_i8, ::testing::ValuesIn(std::vector<deconv_test_params>{- deconv_test_params{ CASE_DECONV_FP32_1, 2, 2, 9 },- deconv_test_params{ CASE_DECONV_FP32_2, 2, 2, 9 },+ deconv_test_params{ CASE_DECONV_FP32_1, 2, 4, 9 },+ deconv_test_params{ CASE_DECONV_FP32_2, 2, 4, 9 },// deconv_test_params{ CASE_DECONV_FP32_3, 2, 9 },- deconv_test_params{ CASE_DECONV_FP32_4, 2, 2, 9 },- deconv_test_params{ CASE_DECONV_FP32_5, 2, 2, 9 },- deconv_test_params{ CASE_DECONV_FP32_6, 2, 2, 9 },- deconv_test_params{ CASE_DECONV_FP32_7, 2, 2, 9 },- deconv_test_params{ CASE_DECONV_FP32_8, 2, 2, 9 },-- deconv_test_params{ CASE_DECONV_FP16_1, 2, 2, 9 },- deconv_test_params{ CASE_DECONV_FP16_2, 2, 2, 9 },- deconv_test_params{ CASE_DECONV_FP16_3, 2, 2, 9 },- deconv_test_params{ CASE_DECONV_FP16_4, 2, 2, 9 },- deconv_test_params{ CASE_DECONV_FP16_5, 2, 2, 9 },- deconv_test_params{ CASE_DECONV_FP16_6, 2, 2, 9 },- deconv_test_params{ CASE_DECONV_FP16_7, 2, 2, 9 },- deconv_test_params{ CASE_DECONV_FP16_8, 2, 2, 9 },+ deconv_test_params{ CASE_DECONV_FP32_4, 2, 4, 9 },+ deconv_test_params{ CASE_DECONV_FP32_5, 2, 4, 9 },+ deconv_test_params{ CASE_DECONV_FP32_6, 2, 4, 9 },+ deconv_test_params{ CASE_DECONV_FP32_7, 2, 4, 9 },+ deconv_test_params{ CASE_DECONV_FP32_8, 2, 4, 9 },++ deconv_test_params{ CASE_DECONV_FP16_1, 2, 4, 9 },+ deconv_test_params{ CASE_DECONV_FP16_2, 2, 4, 9 },+ deconv_test_params{ CASE_DECONV_FP16_3, 2, 4, 9 },+ deconv_test_params{ CASE_DECONV_FP16_4, 2, 4, 9 },+ deconv_test_params{ CASE_DECONV_FP16_5, 2, 4, 9 },+ deconv_test_params{ CASE_DECONV_FP16_6, 2, 4, 9 },+ deconv_test_params{ CASE_DECONV_FP16_7, 2, 4, 9 },+ deconv_test_params{ CASE_DECONV_FP16_8, 2, 4, 9 },deconv_test_params{ CASE_DECONV_U8S8_1, 2, 2, 9 },deconv_test_params{ CASE_DECONV_U8S8_2, 2, 2, 9 },@@ -862,25 +862,25 @@ INSTANTIATE_TEST_SUITE_P(fusings_gpu, deconv_scale_actv_quant_u8_eltw_scale_actvdeconv_test_params{ CASE_DECONV_S8S8_7, 2, 2, 9 },deconv_test_params{ CASE_DECONV_S8S8_8, 2, 2, 9 },- deconv_test_params{ CASE_DECONV_FP32_3D_1, 2, 2, 9 },+ deconv_test_params{ CASE_DECONV_FP32_3D_1, 2, 4, 9 },// deconv_test_params{ CASE_DECONV_FP32_3D_2, 2, 9 },// Commented out due to sporadic CI failures// deconv_test_params{ CASE_DECONV_FP32_3D_3, 2, 9 },- deconv_test_params{ CASE_DECONV_FP32_3D_4, 2, 2, 9 },- deconv_test_params{ CASE_DECONV_FP32_3D_5, 2, 2, 9 },- deconv_test_params{ CASE_DECONV_FP32_3D_6, 2, 2, 9 },+ deconv_test_params{ CASE_DECONV_FP32_3D_4, 2, 4, 9 },+ deconv_test_params{ CASE_DECONV_FP32_3D_5, 2, 4, 9 },+ deconv_test_params{ CASE_DECONV_FP32_3D_6, 2, 4, 9 },// deconv_test_params{ CASE_DECONV_FP32_3D_7, 2, 9 },- deconv_test_params{ CASE_DECONV_FP32_3D_8, 2, 2, 9 },+ deconv_test_params{ CASE_DECONV_FP32_3D_8, 2, 4, 9 },// deconv_test_params{ CASE_DECONV_FP32_3D_9, 6, 9 },- deconv_test_params{ CASE_DECONV_FP16_3D_1, 2, 2, 9 },- deconv_test_params{ CASE_DECONV_FP16_3D_2, 2, 2, 9 },- deconv_test_params{ CASE_DECONV_FP16_3D_3, 2, 2, 9 },- deconv_test_params{ CASE_DECONV_FP16_3D_4, 2, 2, 9 },- deconv_test_params{ CASE_DECONV_FP16_3D_5, 2, 2, 9 },- deconv_test_params{ CASE_DECONV_FP16_3D_6, 2, 2, 9 },- deconv_test_params{ CASE_DECONV_FP16_3D_7, 2, 2, 9 },- deconv_test_params{ CASE_DECONV_FP16_3D_8, 2, 2, 9 },+ deconv_test_params{ CASE_DECONV_FP16_3D_1, 2, 4, 9 },+ deconv_test_params{ CASE_DECONV_FP16_3D_2, 2, 4, 9 },+ deconv_test_params{ CASE_DECONV_FP16_3D_3, 2, 4, 9 },+ deconv_test_params{ CASE_DECONV_FP16_3D_4, 2, 4, 9 },+ deconv_test_params{ CASE_DECONV_FP16_3D_5, 2, 4, 9 },+ deconv_test_params{ CASE_DECONV_FP16_3D_6, 2, 4, 9 },+ deconv_test_params{ CASE_DECONV_FP16_3D_7, 2, 4, 9 },+ deconv_test_params{ CASE_DECONV_FP16_3D_8, 2, 4, 9 },// deconv_test_params{ CASE_DECONV_FP16_3D_9, 6, 9 },deconv_test_params{ CASE_DECONV_U8S8_3D_1, 2, 2, 9 },@@ -937,14 +937,14 @@ TEST_P(deconv_scale_activation_quantize_i8_eltwise_quantize_u8, basic) {}INSTANTIATE_TEST_SUITE_P(fusings_gpu, deconv_scale_activation_quantize_i8_eltwise_quantize_u8, ::testing::ValuesIn(std::vector<deconv_eltw_test_params>{- deconv_eltw_test_params{ CASE_DECONV_ELTW_FP32_1, 2, 2, 7 },- deconv_eltw_test_params{ CASE_DECONV_ELTW_FP32_2, 2, 2, 7 },- deconv_eltw_test_params{ CASE_DECONV_ELTW_FP32_3, 2, 2, 7 },- deconv_eltw_test_params{ CASE_DECONV_ELTW_FP32_4, 2, 2, 7 },- deconv_eltw_test_params{ CASE_DECONV_ELTW_FP32_5, 2, 2, 7 },- deconv_eltw_test_params{ CASE_DECONV_ELTW_FP32_6, 2, 2, 7 },- deconv_eltw_test_params{ CASE_DECONV_ELTW_FP32_7, 2, 2, 7 },- deconv_eltw_test_params{ CASE_DECONV_ELTW_FP32_8, 2, 2, 7 },+ deconv_eltw_test_params{ CASE_DECONV_ELTW_FP32_1, 2, 4, 7 },+ deconv_eltw_test_params{ CASE_DECONV_ELTW_FP32_2, 2, 4, 7 },+ deconv_eltw_test_params{ CASE_DECONV_ELTW_FP32_3, 2, 4, 7 },+ deconv_eltw_test_params{ CASE_DECONV_ELTW_FP32_4, 2, 4, 7 },+ deconv_eltw_test_params{ CASE_DECONV_ELTW_FP32_5, 2, 4, 7 },+ deconv_eltw_test_params{ CASE_DECONV_ELTW_FP32_6, 2, 4, 7 },+ deconv_eltw_test_params{ CASE_DECONV_ELTW_FP32_7, 2, 4, 7 },+ deconv_eltw_test_params{ CASE_DECONV_ELTW_FP32_8, 2, 4, 7 },deconv_eltw_test_params{ CASE_DECONV_ELTW_i8_1, 2, 2, 7 },deconv_eltw_test_params{ CASE_DECONV_ELTW_i8_2, 2, 2, 7 },@@ -987,3 +987,83 @@ INSTANTIATE_TEST_SUITE_P(fusings_gpu, deconv_activation_eltwise_diff_sizes, ::tedeconv_eltw_test_params{ CASE_DECONV_ELTW_i8_4, 2, 2, 4 },deconv_eltw_test_params{ CASE_DECONV_ELTW_i8_5, 2, 2, 4 },}));++/* ----------------------------------------------------------------------------------------------------- */+/* -------- Prevent quantize fusion into oneDNN deconv for float->int8 narrowing ----------------------- */+/* ----------------------------------------------------------------------------------------------------- */++// Checks: executed primitive count after fusion pass (static shape).+// - On OCL path : quantize fuses into deconv → expected_fused = 2 (deconv+reorder)+// - On oneDNN path: quantize must NOT fuse → expected_fused = 3 (deconv+quant+reorder)+// - Without any fusion → expected_not_fused = 3+// Why: oneDNN deconv uses conv backward-data internally, which cannot produce int8+// output (f16→u8). Fusing quantize forces u8 output → oneDNN falls back to ocl:ref.+class deconv_quantize_u8_onednn_prevent_fuse : public DeconvolutionFusingTest {};+TEST_P(deconv_quantize_u8_onednn_prevent_fuse, basic) {+ auto p = GetParam();+ create_topologies(+ input_layout("input", get_input_layout(p)),+ data("weights", get_mem(get_weights_layout(p))),+ data("in_lo", get_mem(get_per_channel_layout(p), min_random, 0)),+ data("in_hi", get_mem(get_per_channel_layout(p), 1, max_random)),+ data("out_lo", get_mem(get_single_element_layout(p), 0)),+ data("out_hi", get_mem(get_single_element_layout(p), 255)),+ deconvolution("deconv", input_info("input"), { "weights" }, p.groups, p.stride, p.pad),+ quantize("quant", input_info("deconv"), input_info("in_lo"), input_info("in_hi"),+ input_info("out_lo"), input_info("out_hi"), 256, data_types::u8),+ reorder("out", input_info("quant"), p.default_format, data_types::f32)+ );++ tolerance = 1.f;+ execute(p);+}++INSTANTIATE_TEST_SUITE_P(fusings_gpu, deconv_quantize_u8_onednn_prevent_fuse, ::testing::ValuesIn(std::vector<deconv_test_params>{+ // On oneDNN, quantize should NOT fuse (float->int8 narrowing is blocked).+ // expected_fused=2 (OCL: fused), expected_fused_onednn=3 (oneDNN: NOT fused), expected_not_fused=3+ // 2D cases+ deconv_test_params{ CASE_DECONV_FP16_2, 2, 3, 3 },+ deconv_test_params{ CASE_DECONV_FP16_5, 2, 3, 3 },+ deconv_test_params{ CASE_DECONV_FP16_6, 2, 3, 3 },+ // 3D cases (b_fs_zyx_fsv16, stride=2)+ deconv_test_params{ CASE_DECONV_FP16_3D_2, 2, 3, 3 },+ deconv_test_params{ CASE_DECONV_FP16_3D_5, 2, 3, 3 },+ deconv_test_params{ CASE_DECONV_FP16_3D_6, 2, 3, 3 },+}));++// Checks: executed primitive count — positive counter-test (static shape).+// - On both OCL and oneDNN: quantize fuses → expected_fused = 2 (deconv+reorder)+// - Without fusion → expected_not_fused = 3+// Why: int8→u8 narrowing IS supported by oneDNN deconv, so fusion is correct.+// Ensures the FIX_B guard does not over-block valid int8-to-int8 fusion.+class deconv_i8_quantize_u8_still_fuses : public DeconvolutionFusingTest {};+TEST_P(deconv_i8_quantize_u8_still_fuses, basic) {+ auto p = GetParam();+ create_topologies(+ input_layout("input", get_input_layout(p)),+ data("weights", get_mem(get_weights_layout(p))),+ data("in_lo", get_mem(get_per_channel_layout(p), min_random, 0)),+ data("in_hi", get_mem(get_per_channel_layout(p), 1, max_random)),+ data("out_lo", get_mem(get_single_element_layout(p), 0)),+ data("out_hi", get_mem(get_single_element_layout(p), 255)),+ deconvolution("deconv", input_info("input"), { "weights" }, p.groups, p.stride, p.pad),+ quantize("quant", input_info("deconv"), input_info("in_lo"), input_info("in_hi"),+ input_info("out_lo"), input_info("out_hi"), 256, data_types::u8),+ reorder("out", input_info("quant"), p.default_format, data_types::f32)+ );++ tolerance = 1.f;+ execute(p);+}++INSTANTIATE_TEST_SUITE_P(fusings_gpu, deconv_i8_quantize_u8_still_fuses, ::testing::ValuesIn(std::vector<deconv_test_params>{+ // int8 input → u8 output via quantize should still fuse on both OCL and oneDNN.+ // expected_fused=2, expected_fused_onednn=2, expected_not_fused=3+ deconv_test_params{ CASE_DECONV_U8S8_2, 2, 2, 3 },+ deconv_test_params{ CASE_DECONV_U8S8_5, 2, 2, 3 },+ deconv_test_params{ CASE_DECONV_S8S8_2, 2, 2, 3 },+ deconv_test_params{ CASE_DECONV_S8S8_5, 2, 2, 3 },+ // 3D+ deconv_test_params{ CASE_DECONV_U8S8_3D_2, 2, 2, 3 },+ deconv_test_params{ CASE_DECONV_S8S8_3D_2, 2, 2, 3 },+}));diff --git a/src/plugins/intel_gpu/tests/unit/fusions/mvn_fusion_test.cpp b/src/plugins/intel_gpu/tests/unit/fusions/mvn_fusion_test.cppindex 5ad9204ecdc..74f00e1710a 100644--- a/src/plugins/intel_gpu/tests/unit/fusions/mvn_fusion_test.cpp+++ b/src/plugins/intel_gpu/tests/unit/fusions/mvn_fusion_test.cpp@@ -99,6 +99,14 @@ public:#define CASE_MVN_3D_U8_4 { 2, 16, 8, 8, 8 }, { 1, 1, 1, 1, 1 }, data_types::u8, format::bfzyx, {2, 3, 4}, true, data_types::f32, format::bfzyx#define CASE_MVN_3D_U8_5 { 2, 16, 1, 8, 8 }, { 1, 1, 8, 1, 1 }, data_types::u8, format::bfzyx, {2, 3, 4}, true, data_types::f32, format::bfzyx+// F16 with blocked formats (fsv16/fsv32) - covers new float support in mvn_gpu_b_fs_yx_fsv16 kernel+#define CASE_MVN_F16_FSV16_1 { 1, 16, 8, 8 }, { 1, 16, 8, 8 }, data_types::f16, format::b_fs_yx_fsv16, {2, 3}, true, data_types::f16, format::bfyx+#define CASE_MVN_F16_FSV16_2 { 2, 32, 8, 8 }, { 2, 32, 8, 8 }, data_types::f16, format::b_fs_yx_fsv16, {1, 2, 3}, true, data_types::f16, format::bfyx+#define CASE_MVN_F16_FSV32_1 { 1, 32, 8, 8 }, { 1, 32, 8, 8 }, data_types::f16, format::b_fs_yx_fsv32, {2, 3}, true, data_types::f16, format::bfyx+#define CASE_MVN_F16_FSV32_2 { 2, 32, 8, 8 }, { 2, 32, 8, 8 }, data_types::f16, format::b_fs_yx_fsv32, {1, 2, 3}, true, data_types::f16, format::bfyx+#define CASE_MVN_3D_F16_FSV16_1 { 1, 16, 8, 8, 8 }, { 1, 16, 8, 8, 8 }, data_types::f16, format::b_fs_zyx_fsv16, {2, 3, 4}, true, data_types::f16, format::bfzyx+#define CASE_MVN_3D_F16_FSV32_1 { 1, 32, 8, 8, 8 }, { 1, 32, 8, 8, 8 }, data_types::f16, format::b_fs_zyx_fsv32, {2, 3, 4}, true, data_types::f16, format::bfzyx+class mvn_activation : public MVNFusingTest {};TEST_P(mvn_activation, basic) {auto p = GetParam();@@ -135,6 +143,12 @@ INSTANTIATE_TEST_SUITE_P(fusings_gpu, mvn_activation, ::testing::ValuesIn(std::vmvn_test_params{ CASE_MVN_U8_4, 2, 3, 3 },mvn_test_params{ CASE_MVN_3D_U8_1, 2, 3, 3 },mvn_test_params{ CASE_MVN_3D_U8_2, 2, 3, 3 },+ mvn_test_params{ CASE_MVN_F16_FSV16_1, 2, 3, 3 },+ mvn_test_params{ CASE_MVN_F16_FSV16_2, 2, 3, 3 },+ mvn_test_params{ CASE_MVN_F16_FSV32_1, 2, 3, 3 },+ mvn_test_params{ CASE_MVN_F16_FSV32_2, 2, 3, 3 },+ mvn_test_params{ CASE_MVN_3D_F16_FSV16_1, 2, 3, 3 },+ mvn_test_params{ CASE_MVN_3D_F16_FSV32_1, 2, 3, 3 },}));class mvn_scale_quantize_i8 : public MVNFusingTest {};@@ -299,4 +313,6 @@ INSTANTIATE_TEST_SUITE_P(fusings_gpu, mvn_eltwise_f16, ::testing::ValuesIn(std::mvn_test_params{ CASE_MVN_I8_8, 3, 3, 3 },mvn_test_params{ CASE_MVN_U8_2, 2, 2, 3 },mvn_test_params{ CASE_MVN_F16_1, 2, 2, 3},+ mvn_test_params{ CASE_MVN_F16_FSV16_1, 2, 2, 3},+ mvn_test_params{ CASE_MVN_F16_FSV32_1, 2, 2, 3},}));diff --git a/src/plugins/intel_gpu/tests/unit/passes/remove_redundant_reorders_tests.cpp b/src/plugins/intel_gpu/tests/unit/passes/remove_redundant_reorders_tests.cppindex 421715a3263..da1dc7e5ead 100644--- a/src/plugins/intel_gpu/tests/unit/passes/remove_redundant_reorders_tests.cpp+++ b/src/plugins/intel_gpu/tests/unit/passes/remove_redundant_reorders_tests.cpp@@ -310,6 +310,39 @@ TEST(remove_redundant_reorders, fuse_reorder_to_prev_mvn_dyn) {ASSERT_EQ(mvn_layout.data_type, data_types::f16);}+TEST(remove_redundant_reorders, fuse_reorder_to_prev_mvn_cross_layout) {+ // Topology: input(bfyx) -> reorder(b_fs_yx_fsv16) -> MVN -> reorder(b_fs_yx_fsv32) -> activation+ // Expectation: MVN supports cross-layout fusing between fsv16 and fsv32,+ // so the reorder after MVN should be fused (MVN outputs fsv32 directly).+ auto& engine = get_test_engine();+ auto input = engine.allocate_memory({ data_types::f16, format::bfyx, { 1, 32, 8, 8 } });++ topology topology;+ topology.add(input_layout("input", input->get_layout()));+ topology.add(reorder("reorder_to_fsv16", input_info("input"),+ { data_types::f16, format::b_fs_yx_fsv16, { 1, 32, 8, 8 } }));+ topology.add(mvn("mvn", input_info("reorder_to_fsv16"), true, 1e-10f, false, { 2, 3 }));+ topology.add(reorder("reorder_to_fsv32", input_info("mvn"),+ { data_types::f16, format::b_fs_yx_fsv32, { 1, 32, 8, 8 } }));+ topology.add(activation("act", input_info("reorder_to_fsv32"), activation_func::relu));++ ExecutionConfig config = get_test_default_config(engine);+ config.set_property(ov::intel_gpu::optimize_data(true));+ network network(engine, topology, config);+ network.set_input_data("input", input);++ EXPECT_NO_THROW(network.execute());++ auto prog = network.get_program();+ ASSERT_NE(prog, nullptr);++ // The reorder_to_fsv32 should be fused into MVN (MVN outputs fsv32 directly)+ ASSERT_FALSE(has_node(*prog, "reorder_to_fsv32"));+ auto& mvn_node = prog->get_node("mvn");+ auto mvn_layout = mvn_node.get_output_layout();+ ASSERT_EQ(mvn_layout.format.value, format::b_fs_yx_fsv32);+}+TEST(remove_redundant_reorders, fuse_reorder_to_prev_concat_dyn) {auto& engine = get_test_engine();auto in_layout1 = layout{ov::PartialShape{ ov::Dimension::dynamic(), 32, ov::Dimension::dynamic(), 80 }, data_types::f16, format::bfyx};diff --git a/src/plugins/intel_gpu/tests/unit/test_cases/mvn_gpu_test.cpp b/src/plugins/intel_gpu/tests/unit/test_cases/mvn_gpu_test.cppindex 6b55c9f0c59..f394be4ae0b 100644--- a/src/plugins/intel_gpu/tests/unit/test_cases/mvn_gpu_test.cpp+++ b/src/plugins/intel_gpu/tests/unit/test_cases/mvn_gpu_test.cpp@@ -799,14 +799,6 @@ struct mvn_random_test_bsv32 : ::testing::TestWithParam<mvn_basic_test_params> {fill_data(mem, input_data);}- size_t get_x_pitch(layout& layout) {- auto tensor_x0 = tensor(batch(0), feature(0), spatial(0, 0, 0, 0));- auto tensor_x1 = tensor(batch(0), feature(0), spatial(1, 0, 0, 0));- auto x0 = layout.get_linear_offset(tensor_x0);- auto x1 = layout.get_linear_offset(tensor_x1);- return (x1 - x0);- }-template <typename T>void compare_outputs(const cldnn::memory::ptr out_ref, const cldnn::memory::ptr out_opt) {auto output_lay = out_ref->get_layout();@@ -816,22 +808,37 @@ struct mvn_random_test_bsv32 : ::testing::TestWithParam<mvn_basic_test_params> {size_t f = output_lay.feature();size_t x = output_lay.spatial(0);size_t y = output_lay.spatial(1);+ size_t z = output_lay.spatial(2);cldnn::mem_lock<T> ref_ptr(out_ref, get_test_stream());cldnn::mem_lock<T> opt_ptr(out_opt, get_test_stream());- auto ref_x_pitch = get_x_pitch(output_lay);- auto opt_x_pitch = get_x_pitch(opt_output_lay);+ float tolerance = (output_lay.data_type == data_types::f16) ? 5.e-2f : 1.e-2f;+ size_t err_count = 0;for (size_t bi = 0; bi < b; ++bi) {for (size_t fi = 0; fi < f; ++fi) {- for (size_t yi = 0; yi < y; ++yi) {- auto ref_out_coords = tensor(batch(bi), feature(fi), spatial(0, yi, 0, 0));- auto ref_out_offset = output_lay.get_linear_offset(ref_out_coords);- auto opt_out_offset = opt_output_lay.get_linear_offset(ref_out_coords);- for (size_t xi = 0; xi < x; ++xi) {- auto ref_out_val = ref_ptr[ref_out_offset + xi * ref_x_pitch];- auto opt_out_val = opt_ptr[opt_out_offset + xi * opt_x_pitch];- ASSERT_NEAR(static_cast<float>(opt_out_val), static_cast<float>(ref_out_val), 1.e-1f);+ for (size_t zi = 0; zi < z; ++zi) {+ for (size_t yi = 0; yi < y; ++yi) {+ for (size_t xi = 0; xi < x; ++xi) {+ auto coords = tensor(batch(bi), feature(fi), spatial(xi, yi, zi, 0));+ auto ref_out_offset = output_lay.get_linear_offset(coords);+ auto opt_out_offset = opt_output_lay.get_linear_offset(coords);+ auto ref_out_val = ref_ptr[ref_out_offset];+ auto opt_out_val = opt_ptr[opt_out_offset];+ float diff = std::abs(static_cast<float>(opt_out_val) - static_cast<float>(ref_out_val));+ if (diff > tolerance && err_count < 5) {+ std::cerr << "MISMATCH at b=" << bi << " f=" << fi << " z=" << zi+ << " y=" << yi << " x=" << xi+ << " ref=" << static_cast<float>(ref_out_val)+ << " opt=" << static_cast<float>(opt_out_val)+ << " diff=" << diff+ << " ref_off=" << ref_out_offset+ << " opt_off=" << opt_out_offset+ << std::endl;+ err_count++;+ }+ ASSERT_NEAR(static_cast<float>(opt_out_val), static_cast<float>(ref_out_val), tolerance);+ }}}}@@ -842,13 +849,15 @@ struct mvn_random_test_bsv32 : ::testing::TestWithParam<mvn_basic_test_params> {auto& size = params.input_size;auto& output_pad = params.output_pad;auto& engine = get_test_engine();- auto input = engine.allocate_memory({params.input_type, format::bfyx, params.input_size});+ bool is_5d = size.spatial[2] > 1;+ auto ref_fmt = is_5d ? format::bfzyx : format::bfyx;+ auto input = engine.allocate_memory({params.input_type, ref_fmt, params.input_size});switch (params.input_type) {case data_types::f32:fill_random_data<float>(input, -127, 127);break;case data_types::f16:- fill_random_data<ov::float16>(input, -127, 127, 1);+ fill_random_data<ov::float16>(input, -10, 10, 1);break;case data_types::i8:fill_random_data<int8_t>(input, -127, 127, 1);@@ -860,7 +869,9 @@ struct mvn_random_test_bsv32 : ::testing::TestWithParam<mvn_basic_test_params> {break;}- auto axes = params.across_channels ? std::vector<int64_t>{1, 2, 3} : std::vector<int64_t>{2, 3};+ auto axes = params.across_channels+ ? (is_5d ? std::vector<int64_t>{1, 2, 3, 4} : std::vector<int64_t>{1, 2, 3})+ : (is_5d ? std::vector<int64_t>{2, 3, 4} : std::vector<int64_t>{2, 3});topology topo;topo.add(input_layout("input", input->get_layout()));auto prim = mvn("mvn", input_info("input"), params.normalize_variance, 1e-10f, false, axes);@@ -868,7 +879,7 @@ struct mvn_random_test_bsv32 : ::testing::TestWithParam<mvn_basic_test_params> {topo.add(prim);ExecutionConfig config = get_test_default_config(engine);config.set_property(ov::intel_gpu::custom_outputs(std::vector<std::string>{"mvn"}));- config.set_property(ov::intel_gpu::force_implementations(ov::intel_gpu::ImplForcingMap{ {"mvn", {format::type::bfyx, "mvn_gpu_bfyx_opt"}} }));+ config.set_property(ov::intel_gpu::force_implementations(ov::intel_gpu::ImplForcingMap{ {"mvn", {ref_fmt, "mvn_gpu_bfyx_opt"}} }));cldnn::network::ptr net = get_network(engine, topo, config, get_test_stream_ptr(), is_caching_test);@@ -885,7 +896,11 @@ struct mvn_random_test_bsv32 : ::testing::TestWithParam<mvn_basic_test_params> {topo_opt.add(prim_opt);ExecutionConfig config_opt = get_test_default_config(engine);config_opt.set_property(ov::intel_gpu::custom_outputs(std::vector<std::string>{"mvn_opt", "input_to_target_layout"}));- config_opt.set_property(ov::intel_gpu::force_implementations(ov::intel_gpu::ImplForcingMap{ {"mvn_opt", {params.input_format, "mvn_gpu_b_fs_yx_fsv16_imad"}} }));+ const auto opt_kernel = (params.input_format == format::bs_fs_yx_bsv32_fsv16 ||+ params.input_format == format::bs_fs_yx_bsv32_fsv32)+ ? "mvn_gpu_b_fs_yx_bsv32"+ : "mvn_gpu_b_fs_yx_fsv16";+ config_opt.set_property(ov::intel_gpu::force_implementations(ov::intel_gpu::ImplForcingMap{ {"mvn_opt", {params.input_format, opt_kernel}} }));cldnn::network::ptr net_opt = get_network(engine, topo_opt, config_opt, get_test_stream_ptr(), is_caching_test);@@ -931,6 +946,22 @@ struct mvn_test_case_generator_bsv32 : std::vector<mvn_basic_test_params> {push_back(mvn_basic_test_params{fmt, in_dt, {32, 32, 10, 10}, false, false, false, padding()});return *this;}++ mvn_test_case_generator_bsv32& fsv_tests(format::type fmt, data_types in_dt) {+ push_back(mvn_basic_test_params{fmt, in_dt, {2, 32, 17, 13}, false, false, false, padding()});+ push_back(mvn_basic_test_params{fmt, in_dt, {2, 32, 17, 13}, true, false, false, padding()});+ push_back(mvn_basic_test_params{fmt, in_dt, {2, 32, 17, 13}, false, true, false, padding()});+ push_back(mvn_basic_test_params{fmt, in_dt, {2, 32, 17, 13}, true, true, false, padding()});+ return *this;+ }++ mvn_test_case_generator_bsv32& fsv_zyx_tests(format::type fmt, data_types in_dt) {+ push_back(mvn_basic_test_params{fmt, in_dt, {2, 32, 5, 13, 7}, false, false, false, padding()});+ push_back(mvn_basic_test_params{fmt, in_dt, {2, 32, 5, 13, 7}, true, false, false, padding()});+ push_back(mvn_basic_test_params{fmt, in_dt, {2, 32, 5, 13, 7}, false, true, false, padding()});+ push_back(mvn_basic_test_params{fmt, in_dt, {2, 32, 5, 13, 7}, true, true, false, padding()});+ return *this;+ }};INSTANTIATE_TEST_SUITE_P(mvn_bsv32_fsv32,@@ -949,6 +980,55 @@ INSTANTIATE_TEST_SUITE_P(mvn_fsv16,testing::ValuesIn(mvn_test_case_generator_bsv32().bsv32_tests(format::b_fs_yx_fsv16, data_types::i8)));+// 4D fsv16 with float types (new: covers F16/F32 + mvn_gpu_b_fs_yx_fsv16 kernel path)+INSTANTIATE_TEST_SUITE_P(mvn_fsv16_f16,+ mvn_random_test_bsv32,+ testing::ValuesIn(mvn_test_case_generator_bsv32()+ .fsv_tests(format::b_fs_yx_fsv16, data_types::f16)));++INSTANTIATE_TEST_SUITE_P(mvn_fsv16_f32,+ mvn_random_test_bsv32,+ testing::ValuesIn(mvn_test_case_generator_bsv32()+ .fsv_tests(format::b_fs_yx_fsv16, data_types::f32)));++// 4D fsv32 (new: covers INPUT_SLICE_PITCH=32 kernel path)+INSTANTIATE_TEST_SUITE_P(mvn_fsv32_f16,+ mvn_random_test_bsv32,+ testing::ValuesIn(mvn_test_case_generator_bsv32()+ .fsv_tests(format::b_fs_yx_fsv32, data_types::f16)));++INSTANTIATE_TEST_SUITE_P(mvn_fsv32_f32,+ mvn_random_test_bsv32,+ testing::ValuesIn(mvn_test_case_generator_bsv32()+ .fsv_tests(format::b_fs_yx_fsv32, data_types::f32)));++INSTANTIATE_TEST_SUITE_P(mvn_fsv32_i8,+ mvn_random_test_bsv32,+ testing::ValuesIn(mvn_test_case_generator_bsv32()+ .fsv_tests(format::b_fs_yx_fsv32, data_types::i8)));++// 5D zyx fsv16 (new: covers b_fs_zyx_fsv16 kernel path with float types)+INSTANTIATE_TEST_SUITE_P(mvn_zyx_fsv16_f16,+ mvn_random_test_bsv32,+ testing::ValuesIn(mvn_test_case_generator_bsv32()+ .fsv_zyx_tests(format::b_fs_zyx_fsv16, data_types::f16)));++INSTANTIATE_TEST_SUITE_P(mvn_zyx_fsv16_f32,+ mvn_random_test_bsv32,+ testing::ValuesIn(mvn_test_case_generator_bsv32()+ .fsv_zyx_tests(format::b_fs_zyx_fsv16, data_types::f32)));++// 5D zyx fsv32 (new: covers b_fs_zyx_fsv32 + INPUT_SLICE_PITCH=32 kernel path)+INSTANTIATE_TEST_SUITE_P(mvn_zyx_fsv32_f16,+ mvn_random_test_bsv32,+ testing::ValuesIn(mvn_test_case_generator_bsv32()+ .fsv_zyx_tests(format::b_fs_zyx_fsv32, data_types::f16)));++INSTANTIATE_TEST_SUITE_P(mvn_zyx_fsv32_f32,+ mvn_random_test_bsv32,+ testing::ValuesIn(mvn_test_case_generator_bsv32()+ .fsv_zyx_tests(format::b_fs_zyx_fsv32, data_types::f32)));+TEST(mvn_gpu_test, mvn_test_across_channels_outside_sqrt_bfyx_cached) {test_mvn_test_across_channels_outside_sqrt_bfyx<float>(true);}diff --git a/src/plugins/intel_gpu/tests/unit/test_cases/reorder_gpu_test.cpp b/src/plugins/intel_gpu/tests/unit/test_cases/reorder_gpu_test.cppindex 3b76944f51c..eb05ee003a8 100644--- a/src/plugins/intel_gpu/tests/unit/test_cases/reorder_gpu_test.cpp+++ b/src/plugins/intel_gpu/tests/unit/test_cases/reorder_gpu_test.cpp@@ -269,6 +269,172 @@ TEST(reorder_gpu_optimization, compare_with_ref__bfyx_to_blocked_format_differencompare_bfyx2blocked_with_ref("reorder_data_bfyx_to_blocked_format", data_types::i64, data_types::f32, format::bfyx, format::b_fs_yx_fsv16, 3, 32 + 4, 16 + 7, 2, 0, 0, false);}+static void compare_bfyx2blocked_with_ref_dynamic(const std::string& kernel_name,+ const data_types input_data_type, const data_types output_data_type,+ cldnn::format input_format, cldnn::format output_format,+ int32_t b_in, int32_t f_in, int32_t x_in, int32_t y_in, int32_t z_in, int32_t w_in) {+ auto& engine = get_test_engine();+ if (engine.get_device_info().supports_immad) {+ return;+ }++ tensor ts;+ if (input_format.dimension() == 4) {+ ts = { b_in, f_in, x_in, y_in };+ } else if (input_format.dimension() == 5) {+ ts = { b_in, f_in, x_in, y_in, z_in };+ } else {+ ts = { b_in, f_in, x_in, y_in, z_in, w_in };+ }++ auto input = engine.allocate_memory({ input_data_type, input_format, ts });+ layout output_layout(output_data_type, output_format, ts);++ {+ auto stream = std::shared_ptr<cldnn::stream>(engine.create_stream(get_test_default_config(engine)));+ if (input_data_type == data_types::i8 || input_data_type == data_types::u8) {+ mem_lock<uint8_t> input_ptr{input, *stream};+ unsigned char i = 1;+ for (auto it = input_ptr.begin(); it != input_ptr.end(); ++it) {+ *it = (i++);+ if (i > 100) { i = 1; }+ }+ } else if (input_data_type == data_types::f16) {+ mem_lock<ov::float16> input_ptr{input, *stream};+ ov::float16 i = ov::float16(1.0f);+ for (auto it = input_ptr.begin(); it != input_ptr.end(); ++it) {+ *it = i;+ i = ov::float16(static_cast<float>(i) + 1.0f);+ }+ } else {+ mem_lock<float> input_ptr{input, *stream};+ float i = 1.f;+ for (auto it = input_ptr.begin(); it != input_ptr.end(); ++it) {+ *it = (i);+ i += 1.f;+ }+ }+ }++ // Reference: static shape with reorder_data (ref kernel)+ topology topo_ref(+ input_layout("input", input->get_layout()),+ reorder("reorder", input_info("input"), output_layout));++ ExecutionConfig config_ref = get_test_default_config(engine);+ ov::intel_gpu::ImplementationDesc reorder_ref = { output_format, "reorder_data" };+ config_ref.set_property(ov::intel_gpu::force_implementations(ov::intel_gpu::ImplForcingMap{ {"reorder", reorder_ref} }));++ cldnn::network network_ref(engine, topo_ref, config_ref);+ network_ref.set_input_data("input", input);+ auto outputs_ref = network_ref.execute();++ // Dynamic: shape-agnostic with optimized kernel+ layout in_dynamic_layout{ov::PartialShape::dynamic(input_format.dimension()), input_data_type, input_format};++ topology topo_dyn(+ input_layout("input", in_dynamic_layout),+ reorder("reorder", input_info("input"), output_format, output_data_type));++ ExecutionConfig config_dyn = get_test_default_config(engine);+ ov::intel_gpu::ImplementationDesc reorder_opt = { output_format, kernel_name };+ config_dyn.set_property(ov::intel_gpu::force_implementations(ov::intel_gpu::ImplForcingMap{ {"reorder", reorder_opt} }));+ config_dyn.set_property(ov::intel_gpu::allow_new_shape_infer(true));++ cldnn::network network_dyn(engine, topo_dyn, config_dyn);++ network_dyn.set_input_data("input", input);+ auto outputs_dyn = network_dyn.execute();++ auto reorder_inst = network_dyn.get_primitive("reorder");+ auto reorder_impl = reorder_inst->get_impl();+ ASSERT_TRUE(reorder_impl != nullptr);+ ASSERT_NE(reorder_impl->get_kernel_name().find(kernel_name), std::string::npos);++ // Compare ref vs dynamic+ if (output_data_type == data_types::i8)+ compare_result<int8_t>(outputs_ref, outputs_dyn);+ else if (output_data_type == data_types::u8)+ compare_result<uint8_t>(outputs_ref, outputs_dyn);+ else if (output_data_type == data_types::i32)+ compare_result<int32_t>(outputs_ref, outputs_dyn);+ else if (output_data_type == data_types::i64)+ compare_result<int64_t>(outputs_ref, outputs_dyn);+ else if (output_data_type == data_types::f16)+ compare_result<int16_t>(outputs_ref, outputs_dyn);+ else if (output_data_type == data_types::f32)+ compare_result<float>(outputs_ref, outputs_dyn);+}++TEST(reorder_gpu_optimization, dynamic_bfyx_to_blocked_f32) {+ // bfzyx -> b_fs_zyx_fsv32 (nnUNet pattern)+ compare_bfyx2blocked_with_ref_dynamic("reorder_data_bfyx_to_blocked_format", data_types::f32, data_types::f32, format::bfzyx, format::b_fs_zyx_fsv32, 1, 320, 8, 8, 8, 0);+ compare_bfyx2blocked_with_ref_dynamic("reorder_data_bfyx_to_blocked_format", data_types::f32, data_types::f32, format::bfzyx, format::b_fs_zyx_fsv32, 2, 64, 16, 16, 4, 0);+ // Remainder shapes: F%tile!=0, X%tile!=0+ compare_bfyx2blocked_with_ref_dynamic("reorder_data_bfyx_to_blocked_format", data_types::f32, data_types::f32, format::bfzyx, format::b_fs_zyx_fsv32, 1, 37, 13, 8, 4, 0);+ compare_bfyx2blocked_with_ref_dynamic("reorder_data_bfyx_to_blocked_format", data_types::f32, data_types::f32, format::bfyx, format::b_fs_yx_fsv32, 2, 37, 13, 4, 0, 0);+ // Multiple blocked output layouts+ compare_bfyx2blocked_with_ref_dynamic("reorder_data_bfyx_to_blocked_format", data_types::f32, data_types::f32, format::bfyx, format::b_fs_yx_fsv16, 2, 48, 16, 4, 0, 0);+ compare_bfyx2blocked_with_ref_dynamic("reorder_data_bfyx_to_blocked_format", data_types::f32, data_types::f32, format::bfzyx, format::b_fs_zyx_fsv16, 1, 64, 8, 8, 4, 0);+ // b_fs_yx_fsv4+ compare_bfyx2blocked_with_ref_dynamic("reorder_data_bfyx_to_blocked_format", data_types::f32, data_types::f32, format::bfyx, format::b_fs_yx_fsv4, 4, 32, 16, 4, 0, 0);+}++TEST(reorder_gpu_optimization, dynamic_bfyx_to_blocked_f16) {+ compare_bfyx2blocked_with_ref_dynamic("reorder_data_bfyx_to_blocked_format", data_types::f16, data_types::f16, format::bfzyx, format::b_fs_zyx_fsv32, 1, 320, 8, 8, 8, 0);+ compare_bfyx2blocked_with_ref_dynamic("reorder_data_bfyx_to_blocked_format", data_types::f16, data_types::f16, format::bfyx, format::b_fs_yx_fsv16, 2, 37, 13, 4, 0, 0);+}++TEST(reorder_gpu_optimization, dynamic_bfyx_to_blocked_u8) {+ // nnUNet actual pattern: u8:bfzyx -> u8:b_fs_zyx_fsv32+ compare_bfyx2blocked_with_ref_dynamic("reorder_data_bfyx_to_blocked_format", data_types::u8, data_types::u8, format::bfzyx, format::b_fs_zyx_fsv32, 1, 320, 8, 8, 8, 0);+ // u8 with remainder+ compare_bfyx2blocked_with_ref_dynamic("reorder_data_bfyx_to_blocked_format", data_types::u8, data_types::u8, format::bfyx, format::b_fs_yx_fsv16, 2, 37, 13, 4, 0, 0);+}++TEST(reorder_gpu_optimization, dynamic_bfyx_to_double_blocked) {+ // bs_fs_yx_bsv16_fsv16 (double-blocked)+ compare_bfyx2blocked_with_ref_dynamic("reorder_data_bfyx_to_blocked_format", data_types::f32, data_types::f32, format::bfyx, format::bs_fs_yx_bsv16_fsv16, 32, 48, 8, 4, 0, 0);+ // bs_fs_yx_bsv16_fsv16 with remainder+ compare_bfyx2blocked_with_ref_dynamic("reorder_data_bfyx_to_blocked_format", data_types::f32, data_types::f32, format::bfyx, format::bs_fs_yx_bsv16_fsv16, 34, 37, 13, 4, 0, 0);+ // bs_fs_zyx_bsv16_fsv32 (5D double-blocked)+ compare_bfyx2blocked_with_ref_dynamic("reorder_data_bfyx_to_blocked_format", data_types::f32, data_types::f32, format::bfzyx, format::bs_fs_zyx_bsv16_fsv32, 32, 48, 8, 4, 4, 0);+}++TEST(reorder_gpu_optimization, dynamic_fsv_reorder_f32) {+ // fsv16 -> fsv32 (nnUNet bottleneck pattern: b_fs_zyx_fsv16 -> b_fs_zyx_fsv32)+ compare_bfyx2blocked_with_ref_dynamic("reorder_data_fsv", data_types::f32, data_types::f32, format::b_fs_zyx_fsv16, format::b_fs_zyx_fsv32, 1, 32, 8, 8, 8, 0);+ compare_bfyx2blocked_with_ref_dynamic("reorder_data_fsv", data_types::f32, data_types::f32, format::b_fs_zyx_fsv16, format::b_fs_zyx_fsv32, 2, 64, 16, 16, 4, 0);+ // Remainder: F not aligned to output fsv+ compare_bfyx2blocked_with_ref_dynamic("reorder_data_fsv", data_types::f32, data_types::f32, format::b_fs_zyx_fsv16, format::b_fs_zyx_fsv32, 1, 48, 8, 8, 4, 0);+ // 4D: fsv16 -> fsv32+ compare_bfyx2blocked_with_ref_dynamic("reorder_data_fsv", data_types::f32, data_types::f32, format::b_fs_yx_fsv16, format::b_fs_yx_fsv32, 2, 64, 16, 8, 0, 0);+ // fsv32 -> fsv16 (reverse direction)+ compare_bfyx2blocked_with_ref_dynamic("reorder_data_fsv", data_types::f32, data_types::f32, format::b_fs_zyx_fsv32, format::b_fs_zyx_fsv16, 1, 64, 8, 8, 4, 0);+ compare_bfyx2blocked_with_ref_dynamic("reorder_data_fsv", data_types::f32, data_types::f32, format::b_fs_yx_fsv32, format::b_fs_yx_fsv16, 2, 48, 16, 8, 0, 0);+}++TEST(reorder_gpu_optimization, dynamic_fsv_reorder_u8) {+ // u8: nnUNet actual bottleneck pattern+ compare_bfyx2blocked_with_ref_dynamic("reorder_data_fsv", data_types::u8, data_types::u8, format::b_fs_zyx_fsv16, format::b_fs_zyx_fsv32, 1, 32, 8, 8, 8, 0);+ // u8 with feature remainder+ compare_bfyx2blocked_with_ref_dynamic("reorder_data_fsv", data_types::u8, data_types::u8, format::b_fs_zyx_fsv16, format::b_fs_zyx_fsv32, 1, 48, 8, 8, 4, 0);+ // u8 reverse+ compare_bfyx2blocked_with_ref_dynamic("reorder_data_fsv", data_types::u8, data_types::u8, format::b_fs_zyx_fsv32, format::b_fs_zyx_fsv16, 1, 64, 8, 8, 4, 0);+}++TEST(reorder_gpu_optimization, dynamic_fsv_reorder_f16) {+ compare_bfyx2blocked_with_ref_dynamic("reorder_data_fsv", data_types::f16, data_types::f16, format::b_fs_zyx_fsv16, format::b_fs_zyx_fsv32, 1, 32, 8, 8, 8, 0);+ compare_bfyx2blocked_with_ref_dynamic("reorder_data_fsv", data_types::f16, data_types::f16, format::b_fs_yx_fsv32, format::b_fs_yx_fsv16, 2, 64, 16, 8, 0, 0);+}++TEST(reorder_gpu_optimization, dynamic_fsv_reorder_cross_type) {+ // Cross-type: u8 -> f32 with format change+ compare_bfyx2blocked_with_ref_dynamic("reorder_data_fsv", data_types::u8, data_types::f32, format::b_fs_zyx_fsv16, format::b_fs_zyx_fsv32, 1, 32, 8, 8, 4, 0);+ // Cross-type: f16 -> f32 with format change+ compare_bfyx2blocked_with_ref_dynamic("reorder_data_fsv", data_types::f16, data_types::f32, format::b_fs_yx_fsv32, format::b_fs_yx_fsv16, 2, 48, 16, 8, 0, 0);+}+TEST(reorder_gpu_optimization, bfyx_to_fsv16_without_f_remainder) {auto& engine = get_test_engine();const int32_t b_in = 1;