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] fix timm models perf regression caused by IMAD partial-IFM weight-tail zeroing in inference hot path (#37981)
Xiong Yuane5167d1d35ab
diff --git a/src/plugins/intel_gpu/src/graph/primitive_inst.cpp b/src/plugins/intel_gpu/src/graph/primitive_inst.cppindex b3810e90206..ef405615c34 100644--- a/src/plugins/intel_gpu/src/graph/primitive_inst.cpp+++ b/src/plugins/intel_gpu/src/graph/primitive_inst.cpp@@ -72,6 +72,12 @@namespace cldnn {namespace {+bool requires_imad_isv4_padding_initialization(const layout& weights_layout) {+ return (weights_layout.format == format::os_is_yx_osv16_isv4 ||+ weights_layout.format == format::g_os_is_yx_osv16_isv4) &&+ weights_layout.feature() % 4 != 0;+}+template <typename T>bool is_optimized_output_user(const T user) {if (user->can_be_optimized()) {@@ -2863,15 +2869,17 @@ void primitive_inst::update_weights() {auto expected_layout = reorder_kernel_params->get_output_layout().clone_with_other_shape(original_layout.get_partial_shape());_impl_params->weights_layout = optional_layout(expected_layout);- if (_reordered_weights_cache.has(expected_layout) &&+ auto cached_weights_memory = _reordered_weights_cache.get(expected_layout);+ if (cached_weights_memory &&// WA: for custom format, we need to check traits to know what it really represents- (expected_layout.format != cldnn::format::custom ||- expected_layout.format.traits() == _reordered_weights_cache.get(expected_layout)->get_layout().format.traits())) {+ (expected_layout.format != cldnn::format::custom || expected_layout.format.traits() == cached_weights_memory->get_layout().format.traits()) &&+ (!requires_imad_isv4_padding_initialization(expected_layout) ||+ !engine.is_the_same_buffer(*cached_weights_memory, *original_weights_memory))) {GPU_DEBUG_PROFILED_STAGE_CACHE_HIT(true);GPU_DEBUG_TRACE_DETAIL << id() << ": reuse weights for " << expected_layout.to_short_string() << std::endl;return;}- if (original_layout.compatible(expected_layout)) {+ if (original_layout.compatible(expected_layout) && !requires_imad_isv4_padding_initialization(expected_layout)) {GPU_DEBUG_PROFILED_STAGE_CACHE_HIT(true);GPU_DEBUG_TRACE_DETAIL << id() << ": reinterpret original weights memory from " << original_layout.to_short_string() << " to "<< expected_layout.to_short_string() << std::endl;diff --git a/src/plugins/intel_gpu/src/kernel_selector/cl_kernels/convolution_gpu_imad.cl b/src/plugins/intel_gpu/src/kernel_selector/cl_kernels/convolution_gpu_imad.clindex 60524570fe8..7ebc24035a7 100644--- a/src/plugins/intel_gpu/src/kernel_selector/cl_kernels/convolution_gpu_imad.cl+++ b/src/plugins/intel_gpu/src/kernel_selector/cl_kernels/convolution_gpu_imad.cl@@ -222,7 +222,7 @@ KERNEL (fused_convolution_eltwise_gpu_imad)(uint valid_ifm_in_pack_input = (kd + 1) * PACK <= FILTER_IFM_NUM ? PACK : (FILTER_IFM_NUM % PACK);for (uint v = 0; v < valid_ifm_in_pack_input; v++) {int f_addr = ((feature_location + v) / FSV + INPUT0_PAD_BEFORE_FEATURE_NUM / FSV) * \- INPUT0_FEATURE_PITCH * FSV + (feature_location + v) % FSV;+ INPUT0_FEATURE_PITCH * FSV + (feature_location + v) % FSV;input_int8_arr[v] = conv_input[in_addr + f_addr];}for (uint v = valid_ifm_in_pack_input; v < PACK; v++) {@@ -239,7 +239,7 @@ KERNEL (fused_convolution_eltwise_gpu_imad)(#endifin[reg] = *(__global PACKED_TYPE*)(conv_input + in_addr);in_addr += (INPUT0_SIZE_X + IWPAD) * 16;- #endif+ #endif#else#ifdef BLOCK_LOAD_INPUTSin[reg] = AS_PACKED_TYPE(_sub_group_block_read((const __global uint*) &conv_input[in_addr]));@@ -270,17 +270,6 @@ KERNEL (fused_convolution_eltwise_gpu_imad)(}#endif- #if FILTER_IFM_NUM % PACK != 0- if ((kd + 1) * PACK >= ALIGN(FILTER_IFM_NUM, PACK)) {- for (int pf = 0; pf < NUM_FILTERS; pf++) {- FILTER_TYPE* w_p = (FILTER_TYPE*)&w[pf];- unroll_for (uint in_f = FILTER_IFM_NUM % PACK; in_f < PACK; in_f++) {- w_p[in_f] = 0;- }- }- }- #endif-int wi = 0;// This loop is temporarily not unrolled because the unroll causes TeamCity hangs.//__attribute__((opencl_unroll_hint(FILTER_SIZE_Y)))diff --git a/src/plugins/intel_gpu/src/kernel_selector/cl_kernels/reorder_weights.cl b/src/plugins/intel_gpu/src/kernel_selector/cl_kernels/reorder_weights.clindex 0df298afd1a..25636b1488f 100644--- a/src/plugins/intel_gpu/src/kernel_selector/cl_kernels/reorder_weights.cl+++ b/src/plugins/intel_gpu/src/kernel_selector/cl_kernels/reorder_weights.cl@@ -302,6 +302,8 @@ inline uint FUNC(get_input_index)(uint g, uint o, uint i, uint z, uint y, uint xreturn GET_FILTER_OS_IS_YX_ISA8_OSV16_ISV4_INDEX(INPUT0, o, i, y, x);#elif defined INPUT0_LAYOUT_OS_IS_ZYX_ISA8_OSV16_ISV4return GET_FILTER_OS_IS_ZYX_ISA8_OSV16_ISV4_INDEX(INPUT0, o, i, z, y, x);+#elif defined INPUT0_LAYOUT_OS_IS_YX_OSV16_ISV4+ return GET_FILTER_OS_IS_YX_OSV16_ISV4_INDEX(INPUT0, o, i, y, x);#elif defined INPUT0_LAYOUT_OS_IS_YX_ISV16_OSV16return GET_FILTER_OS_IS_YX_ISV_OSV_INDEX(INPUT0, o, i, y, x, 16, 16);#elif defined INPUT0_LAYOUT_OIYX_O16@@ -356,6 +358,8 @@ inline uint FUNC(get_input_index)(uint g, uint o, uint i, uint z, uint y, uint xreturn GET_FILTER_GS_OI_YXS_GSV16_YXSV4_INDEX(INPUT0, g, o, i, y, x);#elif defined INPUT0_LAYOUT_GS_OI_YXS_GSV32_YXSV4return GET_FILTER_GS_OI_YXS_GSV32_YXSV4_INDEX(INPUT0, g, o, i, y, x);+#elif defined INPUT0_LAYOUT_G_OS_IS_YX_OSV16_ISV4+ return GET_FILTER_G_OS_IS_YX_OSV16_ISV4_INDEX(INPUT0, g, o, i, y, x);#elif defined INPUT0_LAYOUT_G_OS_ZYX_IS_OSV16_ISV4return GET_FILTER_G_OS_ZYX_IS_OSV16_ISV4_INDEX(INPUT0, g, o, i, z, y, x);#elif defined INPUT0_LAYOUT_G_OS_ZYX_IS_OSV16_ISV16@@ -563,6 +567,18 @@ KERNEL (reorder_weights)(const __global INPUT0_TYPE* input, __global OUTPUT_TYPEconst unsigned z = (zyx / OUTPUT_SIZE_X) / OUTPUT_SIZE_Y;#endif+#if !REORDER_ROTATE+ uint output_idx = FUNC_CALL(get_output_index)(g, o, i, z, y, x);+#else+ uint output_idx = FUNC_CALL(get_output_index)(g, o, i, OUTPUT_SIZE_Z - z - 1, OUTPUT_SIZE_Y - y - 1, OUTPUT_SIZE_X - x - 1);+#endif+#if IMAD_ISV4_PADDING+ if (i >= OUTPUT_IFM_NUM) {+ output[output_idx] = (OUTPUT_TYPE)0;+ return;+ }+#endif+#if OUTPUT_GROUPS_NUM > 1 // Add grouped macro instead this checkuint8 ir = RESHAPE_WEIGHT_DIMS_WITH_GROUPS(OUTPUT, INPUT0, g, o, i, 0, z, y, x);#else@@ -570,11 +586,6 @@ KERNEL (reorder_weights)(const __global INPUT0_TYPE* input, __global OUTPUT_TYPE#endifuint input_idx = FUNC_CALL(get_input_index)(ir.s0,ir.s1,ir.s2,ir.s4,ir.s5,ir.s6);-#if !REORDER_ROTATE- uint output_idx = FUNC_CALL(get_output_index)(g, o, i, z, y, x);-#else- uint output_idx = FUNC_CALL(get_output_index)(g, o, i, OUTPUT_SIZE_Z - z - 1, OUTPUT_SIZE_Y - y - 1, OUTPUT_SIZE_X - x - 1);-#endif#ifdef BF16_INPUToutput[output_idx] = TO_OUTPUT_TYPE(_convert_as_bfloat16_float(input[input_idx]));#elsediff --git a/src/plugins/intel_gpu/src/kernel_selector/kernel_selector_utils.cpp b/src/plugins/intel_gpu/src/kernel_selector/kernel_selector_utils.cppindex 72a7176ab96..9e596a51ebe 100644--- a/src/plugins/intel_gpu/src/kernel_selector/kernel_selector_utils.cpp+++ b/src/plugins/intel_gpu/src/kernel_selector/kernel_selector_utils.cpp@@ -59,6 +59,12 @@ static WeightsFormatSupportType CheckWeights(const weight_bias_params& newParams(reqLayouts != WeightsLayout::oi || tensor.GetLayout() != WeightsLayout::oiyx);}+ if (!reorderNeeded &&+ (reqLayouts == WeightsLayout::os_is_yx_osv16_isv4 || reqLayouts == WeightsLayout::g_os_is_yx_osv16_isv4) &&+ tensor.IFM().v % 4 != 0) {+ reorderNeeded = true;+ }+return reorderNeeded ? REORDER_NEEDED : SUPPORTED;}diff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/reorder/reorder_weights_kernel.cpp b/src/plugins/intel_gpu/src/kernel_selector/kernels/reorder/reorder_weights_kernel.cppindex 21224da908f..e78cd7ca55c 100644--- a/src/plugins/intel_gpu/src/kernel_selector/kernels/reorder/reorder_weights_kernel.cpp+++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/reorder/reorder_weights_kernel.cpp@@ -11,10 +11,12 @@ ParamsKey ReorderWeightsKernel::GetSupportedKey() const {ParamsKey k;k.EnableInputWeightsType(WeightsType::BF16);k.EnableInputWeightsType(WeightsType::INT8);+ k.EnableInputWeightsType(WeightsType::UINT8);k.EnableInputWeightsType(WeightsType::F16);k.EnableInputWeightsType(WeightsType::F32);k.EnableInputWeightsType(WeightsType::INT32);k.EnableOutputWeightsType(WeightsType::INT8);+ k.EnableOutputWeightsType(WeightsType::UINT8);k.EnableOutputWeightsType(WeightsType::F16);k.EnableOutputWeightsType(WeightsType::F32);k.EnableOutputWeightsType(WeightsType::INT32);@@ -32,14 +34,34 @@ KernelsData ReorderWeightsKernel::GetKernelsData(const Params& params) const {return GetCommonKernelsData(orgParams);}+bool ReorderWeightsKernel::NeedsImadIsv4Padding(const reorder_weights_params& params) const {+ const auto output_layout = params.output.GetLayout();+ return (output_layout == WeightsLayout::os_is_yx_osv16_isv4 || output_layout == WeightsLayout::g_os_is_yx_osv16_isv4) &&+ params.output.IFM().v % 4 != 0;+}+JitConstants ReorderWeightsKernel::GetJitConstants(const reorder_weights_params& params) const {auto jit = ReorderKernelBase::GetJitConstants(params);if ( params.input.GetDType() == WeightsType::BF16 ) {jit.AddConstant(MakeJitConstant("BF16_INPUT", true));}++ jit.AddConstant(MakeJitConstant("IMAD_ISV4_PADDING", NeedsImadIsv4Padding(params)));+return jit;}+ReorderWeightsKernel::DispatchData ReorderWeightsKernel::SetDefault(const reorder_weights_params& params) const {+ auto dispatch_data = ReorderKernelBase::SetDefault(params);++ if (NeedsImadIsv4Padding(params)) {+ dispatch_data.gws[1] = Align(params.output.IFM().v, size_t{4});+ dispatch_data.lws = GetOptimalLocalWorkGroupSizes(dispatch_data.gws, params.engineInfo);+ }++ return dispatch_data;+}+KernelsPriority ReorderWeightsKernel::GetKernelsPriority(const Params& /*params*/) const {return DONT_USE_IF_HAVE_SOMETHING_ELSE;}diff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/reorder/reorder_weights_kernel.h b/src/plugins/intel_gpu/src/kernel_selector/kernels/reorder/reorder_weights_kernel.hindex 041fae98a06..365e71cbbce 100644--- a/src/plugins/intel_gpu/src/kernel_selector/kernels/reorder/reorder_weights_kernel.h+++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/reorder/reorder_weights_kernel.h@@ -12,8 +12,12 @@ public:ReorderWeightsKernel() : ReorderKernelBase("reorder_weights") {}~ReorderWeightsKernel() override = default;JitConstants GetJitConstants(const reorder_weights_params& params) const override;+ DispatchData SetDefault(const reorder_weights_params& params) const override;KernelsData GetKernelsData(const Params& params) const override;KernelsPriority GetKernelsPriority(const Params& params) const override;ParamsKey GetSupportedKey() const override;++private:+ bool NeedsImadIsv4Padding(const reorder_weights_params& params) const;};} // namespace kernel_selectordiff --git a/src/plugins/intel_gpu/tests/unit/test_cases/convolution_gpu_test.cpp b/src/plugins/intel_gpu/tests/unit/test_cases/convolution_gpu_test.cppindex 38ff4e3e594..b309779b5cd 100644--- a/src/plugins/intel_gpu/tests/unit/test_cases/convolution_gpu_test.cpp+++ b/src/plugins/intel_gpu/tests/unit/test_cases/convolution_gpu_test.cpp@@ -27,6 +27,7 @@#include <tuple>#include "convolution_inst.h"+#include "primitive_inst_test_helper.h"#ifdef ENABLE_ONEDNN_FOR_GPU#include "graph/impls/onednn/utils.hpp"#include "graph/impls/onednn/primitive_onednn_base.h"@@ -4828,6 +4829,114 @@ TEST(convolution_int8_fw_gpu, quantized_convolution_u8s8f32_asymmetric_activatio}}+TEST(convolution_int8_fw_gpu, dynamic_same_layout_weights_initialize_imad_isv4_padding) {+ auto& engine = get_test_engine();++ const auto input_layout_dynamic = layout{ov::PartialShape{1, 5, -1, -1}, data_types::i8, format::b_fs_yx_fsv16};+ const auto input_layout_static = layout{ov::PartialShape{1, 5, 8, 8}, data_types::i8, format::b_fs_yx_fsv16};+ const auto weights_layout = layout{data_types::i8,+ format::os_is_yx_osv16_isv4,+ tensor(batch(16), feature(5), spatial(3, 3))};++ auto input = engine.allocate_memory(input_layout_static);+ set_values(input, std::vector<int8_t>(input_layout_static.get_linear_size(), 0));++ auto weights = engine.allocate_memory(weights_layout);+ set_values(weights, std::vector<int8_t>(weights_layout.get_linear_size(), 42));++ topology topology(input_layout("input", input_layout_dynamic),+ data("weights", weights),+ convolution("conv", input_info("input"), "weights", no_bias, 1, {1, 1}, {1, 1}, {1, 1}, {1, 1}, false));++ ExecutionConfig config = get_test_default_config(engine);+ config.set_property(ov::intel_gpu::allow_new_shape_infer(true));+ const ov::intel_gpu::ImplementationDesc conv_impl = {+ format::b_fs_yx_fsv16, "convolution_gpu_imad", impl_types::ocl};+ config.set_property(ov::intel_gpu::force_implementations(ov::intel_gpu::ImplForcingMap{{"conv", conv_impl}}));++ network network(engine, topology, config);+ network.set_input_data("input", input);+ network.execute();++ auto conv_inst = std::dynamic_pointer_cast<convolution_inst>(network.get_primitive("conv"));+ ASSERT_NE(conv_inst, nullptr);+ auto reordered_weights = conv_inst->weights_memory();+ ASSERT_FALSE(engine.is_the_same_buffer(*weights, *reordered_weights));++ cldnn::mem_lock<int8_t, mem_lock_type::read> reordered_weights_ptr(reordered_weights, get_test_stream());+ for (size_t output_feature = 0; output_feature < 16; ++output_feature) {+ for (size_t input_feature = 5; input_feature < 8; ++input_feature) {+ for (size_t y = 0; y < 3; ++y) {+ for (size_t x = 0; x < 3; ++x) {+ const size_t offset = input_feature % 4 ++ output_feature * 4 ++ x * 16 * 4 ++ y * 16 * 4 * 3 ++ input_feature / 4 * 16 * 4 * 3 * 3;+ ASSERT_EQ(reordered_weights_ptr[offset], 0)+ << "at output_feature=" << output_feature << " input_feature=" << input_feature+ << " y=" << y << " x=" << x;+ }+ }+ }+ }+}++TEST(convolution_int8_fw_gpu, dynamic_implementation_switch_does_not_reuse_unsanitized_imad_weights) {+ auto& engine = get_test_engine();++ const auto input_layout_dynamic = layout{ov::PartialShape{1, 5, -1, -1}, data_types::i8, format::b_fs_yx_fsv16};+ const auto input_layout_static = layout{ov::PartialShape{1, 5, 8, 8}, data_types::i8, format::b_fs_yx_fsv16};+ const auto weights_layout = layout{data_types::i8,+ format::os_is_yx_osv16_isv4,+ tensor(batch(16), feature(5), spatial(3, 3))};++ auto input = engine.allocate_memory(input_layout_static);+ set_values(input, std::vector<int8_t>(input_layout_static.get_linear_size(), 0));++ auto weights = engine.allocate_memory(weights_layout);+ set_values(weights, std::vector<int8_t>(weights_layout.get_linear_size(), 42));++ topology test_topology(input_layout("input", input_layout_dynamic),+ data("weights", weights),+ convolution("conv", input_info("input"), "weights", no_bias, 1, {1, 1}, {1, 1}, {1, 1}, {1, 1}, false));++ ExecutionConfig config = get_test_default_config(engine);+ config.set_property(ov::intel_gpu::allow_new_shape_infer(true));+ const ov::intel_gpu::ImplementationDesc conv_impl = {format::b_fs_yx_fsv16, "convolution_gpu_imad", impl_types::ocl};+ config.set_property(ov::intel_gpu::force_implementations(ov::intel_gpu::ImplForcingMap{{"conv", conv_impl}}));++ network network(engine, test_topology, config);+ network.set_input_data("input", input);+ network.execute();++ auto conv_inst = std::dynamic_pointer_cast<convolution_inst>(network.get_primitive("conv"));+ ASSERT_NE(conv_inst, nullptr);++ // Simulate a previous implementation without a weights reorder. It caches the original preformatted buffer,+ // which must not be reused after switching to the IMAD implementation.+ PrimitiveInstTestHelper::cache_original_weights(conv_inst);+ PrimitiveInstTestHelper::update_weights(conv_inst);+ auto switched_weights = conv_inst->weights_memory();+ ASSERT_FALSE(engine.is_the_same_buffer(*weights, *switched_weights));++ cldnn::mem_lock<int8_t, mem_lock_type::read> switched_weights_ptr(switched_weights, get_test_stream());+ for (size_t output_feature = 0; output_feature < 16; ++output_feature) {+ for (size_t input_feature = 5; input_feature < 8; ++input_feature) {+ for (size_t y = 0; y < 3; ++y) {+ for (size_t x = 0; x < 3; ++x) {+ const size_t offset = input_feature % 4 ++ output_feature * 4 ++ x * 16 * 4 ++ y * 16 * 4 * 3 ++ input_feature / 4 * 16 * 4 * 3 * 3;+ ASSERT_EQ(switched_weights_ptr[offset], 0);+ }+ }+ }+ }+}+TEST(convolution_int8_fw_gpu, quantized_convolution_u8s8f32_asymmetric_activations_per_channel_3ic_with_sub) {auto& engine = get_test_engine();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 763b0e52200..f39d2a07824 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@@ -3257,6 +3257,107 @@ TEST(reorder_weights_gpu_i32, reorder_weights)}}+template <typename T>+static void check_imad_isv4_weight_padding(data_types data_type,+ format input_format,+ format output_format,+ const tensor& weights_size,+ size_t groups,+ size_t output_features,+ size_t input_features) {+ auto& engine = get_test_engine();++ layout input_weights_layout(data_type, input_format, weights_size);+ layout output_weights_layout(data_type, output_format, weights_size);+ auto weights_reorder_params = std::make_shared<WeightsReorderParams>(input_weights_layout, output_weights_layout, false, groups > 1);++ std::vector<T> input_values(input_weights_layout.get_linear_size());+ for (size_t i = 0; i < input_values.size(); ++i) {+ input_values[i] = static_cast<T>(i % 127 + 1);+ }++ auto input = engine.allocate_memory(input_weights_layout);+ set_values(input, input_values);++ topology test_topology {+ input_layout("input", input_weights_layout),+ reorder("reorder", input_info("input"), weights_reorder_params)+ };++ ExecutionConfig config = get_test_default_config(engine);+ ov::intel_gpu::ImplementationDesc wr_impl_desc = { output_format, "reorder_weights", impl_types::ocl };+ config.set_property(ov::intel_gpu::force_implementations(ov::intel_gpu::ImplForcingMap{ {"reorder", wr_impl_desc} }));++ network network(engine, test_topology, config);+ network.set_input_data("input", input);++ auto output = engine.allocate_memory(output_weights_layout);+ std::vector<T> sentinel_values(output_weights_layout.get_linear_size(), static_cast<T>(42));+ set_values(output, sentinel_values);+ network.set_output_memory("reorder", output);++ auto outputs = network.execute();+ ASSERT_EQ(outputs.size(), size_t(1));+ ASSERT_EQ(outputs.begin()->first, "reorder");+ ASSERT_TRUE(engine.is_the_same_buffer(*output, *outputs.begin()->second.get_memory()));+ cldnn::mem_lock<T, mem_lock_type::read> output_ptr(output, get_test_stream());++ ASSERT_NE(groups, size_t(0));+ ASSERT_EQ(output_features % groups, size_t(0));+ ASSERT_EQ(input_features % groups, size_t(0));+ const size_t output_features_per_group = output_features / groups;+ const size_t input_features_per_group = input_features / groups;+ const size_t filter_y = static_cast<size_t>(weights_size.spatial[1]);+ const size_t filter_x = static_cast<size_t>(weights_size.spatial[0]);+ const auto get_os_is_yx_osv16_isv4_offset = [=](size_t g, size_t o, size_t i, size_t y, size_t x) {+ const size_t isv = i % 4;+ const size_t osv = o % 16;+ const size_t input_slice = i / 4;+ const size_t output_slice = o / 16;+ const size_t x_pitch = 16 * 4;+ const size_t y_pitch = x_pitch * filter_x;+ const size_t input_slice_pitch = y_pitch * filter_y;+ const size_t output_slice_pitch = input_slice_pitch * align_to(input_features_per_group, size_t{4}) / 4;+ const size_t group_pitch = output_slice_pitch * align_to(output_features_per_group, size_t{16}) / 16;++ return isv ++ osv * 4 ++ x * x_pitch ++ y * y_pitch ++ input_slice * input_slice_pitch ++ output_slice * output_slice_pitch ++ g * group_pitch;+ };++ for (size_t g = 0; g < groups; ++g) {+ for (size_t o = 0; o < output_features_per_group; ++o) {+ for (size_t i = input_features_per_group; i < align_to(input_features_per_group, size_t{4}); ++i) {+ for (size_t y = 0; y < filter_y; ++y) {+ for (size_t x = 0; x < filter_x; ++x) {+ ASSERT_LT(get_os_is_yx_osv16_isv4_offset(g, o, i, y, x), output_ptr.size());+ ASSERT_EQ(output_ptr[get_os_is_yx_osv16_isv4_offset(g, o, i, y, x)], 0)+ << "at g=" << g << " o=" << o << " i=" << i << " y=" << y << " x=" << x;+ }+ }+ }+ }+ }+}++TEST(reorder_weights_gpu_i8, reorder_weights_imad_isv4_padding) {+ check_imad_isv4_weight_padding<int8_t>(data_types::i8, format::oiyx, format::os_is_yx_osv16_isv4, tensor(batch(16), feature(5), spatial(3, 3)), 1, 16, 5);+ check_imad_isv4_weight_padding<int8_t>(data_types::i8, format::goiyx, format::g_os_is_yx_osv16_isv4, tensor(group(16), batch(1), feature(5), spatial(3, 3)), 16, 16, 80);+ check_imad_isv4_weight_padding<int8_t>(data_types::i8, format::os_is_yx_osv16_isv4, format::os_is_yx_osv16_isv4, tensor(batch(16), feature(5), spatial(3, 3)), 1, 16, 5);+ check_imad_isv4_weight_padding<int8_t>(data_types::i8, format::g_os_is_yx_osv16_isv4, format::g_os_is_yx_osv16_isv4, tensor(group(16), batch(1), feature(5), spatial(3, 3)), 16, 16, 80);+}++TEST(reorder_weights_gpu_u8, reorder_weights_imad_isv4_padding) {+ check_imad_isv4_weight_padding<uint8_t>(data_types::u8, format::oiyx, format::os_is_yx_osv16_isv4, tensor(batch(16), feature(5), spatial(3, 3)), 1, 16, 5);+ check_imad_isv4_weight_padding<uint8_t>(data_types::u8, format::goiyx, format::g_os_is_yx_osv16_isv4, tensor(group(16), batch(1), feature(5), spatial(3, 3)), 16, 16, 80);+ check_imad_isv4_weight_padding<uint8_t>(data_types::u8, format::os_is_yx_osv16_isv4, format::os_is_yx_osv16_isv4, tensor(batch(16), feature(5), spatial(3, 3)), 1, 16, 5);+ check_imad_isv4_weight_padding<uint8_t>(data_types::u8, format::g_os_is_yx_osv16_isv4, format::g_os_is_yx_osv16_isv4, tensor(group(16), batch(1), feature(5), spatial(3, 3)), 16, 16, 80);+}+TEST(reorder_weights_gpu_i32, reorder_weights_in_dynamic_convolution){// This test is to check if weights_reorder shape stay same as convolution shapediff --git a/src/plugins/intel_gpu/tests/unit/test_utils/primitive_inst_test_helper.h b/src/plugins/intel_gpu/tests/unit/test_utils/primitive_inst_test_helper.hindex 93c11c03c92..5049a66d01d 100644--- a/src/plugins/intel_gpu/tests/unit/test_utils/primitive_inst_test_helper.h+++ b/src/plugins/intel_gpu/tests/unit/test_utils/primitive_inst_test_helper.h@@ -23,5 +23,13 @@ public:static bool need_reset_output_memory(const std::shared_ptr<primitive_inst>& inst) {return inst->need_reset_output_memory();}+ static void update_weights(const std::shared_ptr<primitive_inst>& inst) {+ inst->update_weights();+ }+ static void cache_original_weights(const std::shared_ptr<primitive_inst>& inst) {+ const auto weights_idx = inst->get_node().get_primitive()->input.size();+ const auto original_weights = inst->dep_memory_ptr(weights_idx);+ inst->_reordered_weights_cache.add(original_weights->get_layout(), original_weights);+ }};} // namespace cldnn