Skip to content

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

[GPU] Fuse DupUp3D shortcut pattern to reduce Qwen-Image 2.1 VAE decoder memory usage (#38555)

Andrew Kwangwoong Parka54783c84e9d
diff --git a/src/plugins/intel_gpu/include/intel_gpu/op/grouped_depth_to_space.hpp b/src/plugins/intel_gpu/include/intel_gpu/op/grouped_depth_to_space.hpp
new file mode 100644
index 00000000000..6ad22dc1b05
--- /dev/null
+++ b/src/plugins/intel_gpu/include/intel_gpu/op/grouped_depth_to_space.hpp
@@ -0,0 +1,47 @@
+// Copyright (C) 2018-2026 Intel Corporation
+// SPDX-License-Identifier: Apache-2.0
+//
+
+#pragma once
+
+#include "openvino/op/op.hpp"
+
+namespace ov::intel_gpu::op {
+
+/// \brief Rearranges repeated channel groups of a 5D tensor into temporal and spatial dimensions.
+///
+/// The input has shape [N, C, T, H, W]. Channels are repeated as needed and interpreted as
+/// [output_channels, factor_t, factor_s, factor_s] before being moved into the T, H, and W dimensions.
+/// crop_begin_t elements are removed from the beginning of the expanded temporal dimension.
+class GroupedDepthToSpace : public ov::op::Op {
+public:
+ OPENVINO_OP("GroupedDepthToSpace", "ie_internal_opset");
+
+ GroupedDepthToSpace() = default;
+ GroupedDepthToSpace(const ov::Output<Node>& input, size_t factor_t, size_t factor_s, size_t output_channels, size_t crop_begin_t);
+
+ void validate_and_infer_types() override;
+ bool visit_attributes(ov::AttributeVisitor& visitor) override;
+ std::shared_ptr<Node> clone_with_new_inputs(const ov::OutputVector& new_args) const override;
+
+ size_t get_factor_t() const {
+ return m_factor_t;
+ }
+ size_t get_factor_s() const {
+ return m_factor_s;
+ }
+ size_t get_output_channels() const {
+ return m_output_channels;
+ }
+ size_t get_crop_begin_t() const {
+ return m_crop_begin_t;
+ }
+
+private:
+ size_t m_factor_t = 1;
+ size_t m_factor_s = 1;
+ size_t m_output_channels = 0;
+ size_t m_crop_begin_t = 0;
+};
+
+} // namespace ov::intel_gpu::op
diff --git a/src/plugins/intel_gpu/include/intel_gpu/plugin/primitives_list.hpp b/src/plugins/intel_gpu/include/intel_gpu/plugin/primitives_list.hpp
index 5e6cd613a43..7323fef1d42 100644
--- a/src/plugins/intel_gpu/include/intel_gpu/plugin/primitives_list.hpp
+++ b/src/plugins/intel_gpu/include/intel_gpu/plugin/primitives_list.hpp
@@ -21,6 +21,7 @@ REGISTER_FACTORY(v0, Cosh);
REGISTER_FACTORY(v0, CumSum);
REGISTER_FACTORY(v0, CTCGreedyDecoder);
REGISTER_FACTORY(v0, DepthToSpace);
+REGISTER_FACTORY(internal, GroupedDepthToSpace);
REGISTER_FACTORY(v0, DetectionOutput);
REGISTER_FACTORY(v0, Elu);
REGISTER_FACTORY(v0, Erf);
diff --git a/src/plugins/intel_gpu/include/intel_gpu/primitives/depth_to_space.hpp b/src/plugins/intel_gpu/include/intel_gpu/primitives/depth_to_space.hpp
index 9b70a34348f..d3f5e2cf282 100644
--- a/src/plugins/intel_gpu/include/intel_gpu/primitives/depth_to_space.hpp
+++ b/src/plugins/intel_gpu/include/intel_gpu/primitives/depth_to_space.hpp
@@ -12,7 +12,9 @@ enum class depth_to_space_mode : int32_t {
/// @brief the input depth is divided to [block_size, ..., block_size, new_depth].
blocks_first,
/// @brief the input depth is divided to [new_depth, block_size, ..., block_size]
- depth_first
+ depth_first,
+ /// @brief Grouped channel repetition followed by anisotropic depth-to-space.
+ grouped_depth_first
};
/// @brief
@@ -35,15 +37,36 @@ struct depth_to_space : public primitive_base<depth_to_space> {
, block_size(block_size)
, mode(mode) {}
+ depth_to_space(const primitive_id& id,
+ const input_info& input,
+ size_t factor_t,
+ size_t factor_s,
+ size_t output_channels,
+ size_t crop_begin_t)
+ : primitive_base(id, {input})
+ , mode(depth_to_space_mode::grouped_depth_first)
+ , factor_t(factor_t)
+ , factor_s(factor_s)
+ , output_channels(output_channels)
+ , crop_begin_t(crop_begin_t) {}
+
/// @brief Block size.
size_t block_size = 0;
/// @brief depth division mode
depth_to_space_mode mode = depth_to_space_mode::blocks_first;
+ size_t factor_t = 1;
+ size_t factor_s = 1;
+ size_t output_channels = 0;
+ size_t crop_begin_t = 0;
size_t hash() const override {
size_t seed = primitive::hash();
seed = hash_combine(seed, block_size);
seed = hash_combine(seed, mode);
+ seed = hash_combine(seed, factor_t);
+ seed = hash_combine(seed, factor_s);
+ seed = hash_combine(seed, output_channels);
+ seed = hash_combine(seed, crop_begin_t);
return seed;
}
@@ -54,20 +77,30 @@ struct depth_to_space : public primitive_base<depth_to_space> {
auto rhs_casted = downcast<const depth_to_space>(rhs);
- return block_size == rhs_casted.block_size &&
- mode == rhs_casted.mode;
+ return block_size == rhs_casted.block_size &&
+ mode == rhs_casted.mode &&
+ factor_t == rhs_casted.factor_t && factor_s == rhs_casted.factor_s &&
+ output_channels == rhs_casted.output_channels && crop_begin_t == rhs_casted.crop_begin_t;
}
void save(BinaryOutputBuffer& ob) const override {
primitive_base<depth_to_space>::save(ob);
ob << block_size;
ob << make_data(&mode, sizeof(depth_to_space_mode));
+ ob << factor_t;
+ ob << factor_s;
+ ob << output_channels;
+ ob << crop_begin_t;
}
void load(BinaryInputBuffer& ib) override {
primitive_base<depth_to_space>::load(ib);
ib >> block_size;
ib >> make_data(&mode, sizeof(depth_to_space_mode));
+ ib >> factor_t;
+ ib >> factor_s;
+ ib >> output_channels;
+ ib >> crop_begin_t;
}
};
} // namespace cldnn
diff --git a/src/plugins/intel_gpu/src/graph/depth_to_space.cpp b/src/plugins/intel_gpu/src/graph/depth_to_space.cpp
index 633d7cbc063..1275faed85c 100644
--- a/src/plugins/intel_gpu/src/graph/depth_to_space.cpp
+++ b/src/plugins/intel_gpu/src/graph/depth_to_space.cpp
@@ -21,6 +21,23 @@ layout depth_to_space_inst::calc_output_layout(depth_to_space_node const& node,
const size_t block_size = desc->block_size;
+ if (impl_param.has_fused_primitives()) {
+ input_layout.data_type = impl_param.get_output_element_type();
+ }
+
+ if (desc->mode == depth_to_space_mode::grouped_depth_first) {
+ const size_t factor = desc->factor_t * desc->factor_s * desc->factor_s;
+ if (format::spatial_num(input_layout.format) != 3 || desc->output_channels * factor % input_layout.feature() != 0) {
+ CLDNN_ERROR_MESSAGE(desc->id, "GroupedDepthToSpace requires a 5D input and divisible channel mapping");
+ }
+
+ const size_t z = input_layout.spatial(2) * desc->factor_t - desc->crop_begin_t;
+ const size_t y = input_layout.spatial(1) * desc->factor_s;
+ const size_t x = input_layout.spatial(0) * desc->factor_s;
+ auto out_size = tensor(TensorValue(input_layout.batch()), TensorValue(desc->output_channels), TensorValue(x), TensorValue(y), TensorValue(z));
+ return layout{input_layout.data_type, input_format, out_size};
+ }
+
if (input_layout.feature() % (block_size * block_size) != 0) {
CLDNN_ERROR_MESSAGE(
desc->id,
@@ -42,10 +59,6 @@ layout depth_to_space_inst::calc_output_layout(depth_to_space_node const& node,
out_size = tensor(TensorValue(input_layout.batch()), TensorValue(feature), TensorValue(x), TensorValue(y));
}
- if (impl_param.has_fused_primitives()) {
- input_layout.data_type = impl_param.get_output_element_type();
- }
-
return layout{input_layout.data_type, input_format, out_size};
}
@@ -56,6 +69,15 @@ std::vector<layout> depth_to_space_inst::calc_output_layouts(depth_to_space_node
auto output_type = desc->output_data_types[0].value_or(input_layout.data_type);
auto output_format = input_layout.format;
+ if (desc->mode == depth_to_space_mode::grouped_depth_first) {
+ auto output_shape = input_layout.get<ShapeType>();
+ output_shape[1] = desc->output_channels;
+ output_shape[2] = output_shape[2] * desc->factor_t - desc->crop_begin_t;
+ output_shape[3] = output_shape[3] * desc->factor_s;
+ output_shape[4] = output_shape[4] * desc->factor_s;
+ return {layout{output_shape, output_type, output_format}};
+ }
+
ov::op::v0::DepthToSpace op;
op.set_block_size(desc->block_size);
@@ -79,7 +101,16 @@ std::string depth_to_space_inst::to_string(depth_to_space_node const& node) {
json_composite depth_to_space_info;
depth_to_space_info.add("input id", input.id());
depth_to_space_info.add("block size", desc->block_size);
- depth_to_space_info.add("mode", desc->mode == depth_to_space_mode::blocks_first ? "blocks_first" : "depth_first");
+ const char* mode = desc->mode == depth_to_space_mode::blocks_first ? "blocks_first"
+ : desc->mode == depth_to_space_mode::depth_first ? "depth_first"
+ : "grouped_depth_first";
+ depth_to_space_info.add("mode", mode);
+ if (desc->mode == depth_to_space_mode::grouped_depth_first) {
+ depth_to_space_info.add("factor_t", desc->factor_t);
+ depth_to_space_info.add("factor_s", desc->factor_s);
+ depth_to_space_info.add("output_channels", desc->output_channels);
+ depth_to_space_info.add("crop_begin_t", desc->crop_begin_t);
+ }
node_info->add("depth_to_space info", depth_to_space_info);
node_info->dump(primitive_description);
diff --git a/src/plugins/intel_gpu/src/graph/impls/ocl/depth_to_space.cpp b/src/plugins/intel_gpu/src/graph/impls/ocl/depth_to_space.cpp
index cf91ef6eccb..f1ba86083f4 100644
--- a/src/plugins/intel_gpu/src/graph/impls/ocl/depth_to_space.cpp
+++ b/src/plugins/intel_gpu/src/graph/impls/ocl/depth_to_space.cpp
@@ -27,8 +27,13 @@ struct depth_to_space_impl : typed_primitive_impl_ocl<depth_to_space> {
auto params = get_default_params<kernel_selector::depth_to_space_params>(impl_param);
params.block_size = primitive->block_size;
- params.mode = primitive->mode == depth_to_space_mode::blocks_first ? kernel_selector::depth_to_space_mode::BLOCKS_FIRST
- : kernel_selector::depth_to_space_mode::DEPTH_FIRST;
+ params.mode = primitive->mode == depth_to_space_mode::blocks_first ? kernel_selector::depth_to_space_mode::BLOCKS_FIRST
+ : primitive->mode == depth_to_space_mode::depth_first ? kernel_selector::depth_to_space_mode::DEPTH_FIRST
+ : kernel_selector::depth_to_space_mode::GROUPED_DEPTH_FIRST;
+ params.factor_t = primitive->factor_t;
+ params.factor_s = primitive->factor_s;
+ params.output_channels = primitive->output_channels;
+ params.crop_begin_t = primitive->crop_begin_t;
return params;
}
};
diff --git a/src/plugins/intel_gpu/src/kernel_selector/cl_kernels/depth_to_space_ref.cl b/src/plugins/intel_gpu/src/kernel_selector/cl_kernels/depth_to_space_ref.cl
index 60f29471bf2..7d7c2312135 100644
--- a/src/plugins/intel_gpu/src/kernel_selector/cl_kernels/depth_to_space_ref.cl
+++ b/src/plugins/intel_gpu/src/kernel_selector/cl_kernels/depth_to_space_ref.cl
@@ -13,6 +13,23 @@ KERNEL(depth_to_space_ref)(const __global INPUT0_TYPE* input,
{
const uint batch = get_global_id(0);
const uint feature = get_global_id(1);
+#if GROUPED_DEPTH_FIRST
+ const uint z = (uint)get_global_id(2) / OUTPUT_SIZE_X / OUTPUT_SIZE_Y;
+ const uint y = ((uint)get_global_id(2) / OUTPUT_SIZE_X) % OUTPUT_SIZE_Y;
+ const uint x = (uint)get_global_id(2) % OUTPUT_SIZE_X;
+
+ const uint uncropped_z = z + CROP_BEGIN_T;
+ const uint input_z = uncropped_z / FACTOR_T;
+ const uint offset_z = uncropped_z % FACTOR_T;
+ const uint input_y = y / FACTOR_S;
+ const uint offset_y = y % FACTOR_S;
+ const uint input_x = x / FACTOR_S;
+ const uint offset_x = x % FACTOR_S;
+ const uint repeated_feature = (((feature * FACTOR_T + offset_z) * FACTOR_S + offset_y) * FACTOR_S + offset_x);
+ const uint input_feature = repeated_feature / CHANNEL_REPEATS;
+ const uint output_index = OUTPUT_GET_INDEX(batch, feature, z, y, x);
+ const uint input_index = INPUT0_GET_INDEX(batch, input_feature, input_z, input_y, input_x);
+#else
#if OUTPUT_DIMS == 5
const uint z = (uint)get_global_id(2) / OUTPUT_SIZE_X / OUTPUT_SIZE_Y;
const uint y = ((uint)get_global_id(2) / OUTPUT_SIZE_X) % OUTPUT_SIZE_Y;
@@ -50,6 +67,7 @@ KERNEL(depth_to_space_ref)(const __global INPUT0_TYPE* input,
#endif // BLOCKS_FIRST
const uint output_index = OUTPUT_GET_INDEX(batch, feature, y, x);
const uint input_index = INPUT0_GET_INDEX(batch, input_feature, input_y, input_x);
+#endif
#endif
INPUT0_TYPE in_val = input[input_index];
diff --git a/src/plugins/intel_gpu/src/kernel_selector/common_types.h b/src/plugins/intel_gpu/src/kernel_selector/common_types.h
index a6000222f70..ca3e3ad2046 100644
--- a/src/plugins/intel_gpu/src/kernel_selector/common_types.h
+++ b/src/plugins/intel_gpu/src/kernel_selector/common_types.h
@@ -396,6 +396,7 @@ enum class ConcatAxis {
enum class DepthToSpaceMode {
BLOCKS_FIRST,
DEPTH_FIRST,
+ GROUPED_DEPTH_FIRST,
};
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
diff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/depth_to_space/depth_to_space_kernel_base.cpp b/src/plugins/intel_gpu/src/kernel_selector/kernels/depth_to_space/depth_to_space_kernel_base.cpp
index 37c00c14fcc..6bfa6be36c3 100644
--- a/src/plugins/intel_gpu/src/kernel_selector/kernels/depth_to_space/depth_to_space_kernel_base.cpp
+++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/depth_to_space/depth_to_space_kernel_base.cpp
@@ -36,8 +36,15 @@ JitConstants DepthToSpaceKernelBase::GetJitConstants(const depth_to_space_params
jit.AddConstant(MakeJitConstant("BLOCK_SIZE", params.block_size));
if (params.mode == DepthToSpaceMode::BLOCKS_FIRST) {
jit.AddConstant(MakeJitConstant("BLOCKS_FIRST", 1));
- } else {
+ } else if (params.mode == DepthToSpaceMode::DEPTH_FIRST) {
jit.AddConstant(MakeJitConstant("DEPTH_FIRST", 1));
+ } else {
+ jit.AddConstant(MakeJitConstant("GROUPED_DEPTH_FIRST", 1));
+ jit.AddConstant(MakeJitConstant("FACTOR_T", params.factor_t));
+ jit.AddConstant(MakeJitConstant("FACTOR_S", params.factor_s));
+ jit.AddConstant(MakeJitConstant("CROP_BEGIN_T", params.crop_begin_t));
+ jit.AddConstant(
+ MakeJitConstant("CHANNEL_REPEATS", params.output_channels * params.factor_t * params.factor_s * params.factor_s / params.inputs[0].Feature().v));
}
return jit;
diff --git a/src/plugins/intel_gpu/src/kernel_selector/kernels/depth_to_space/depth_to_space_kernel_base.h b/src/plugins/intel_gpu/src/kernel_selector/kernels/depth_to_space/depth_to_space_kernel_base.h
index cc67819f77e..186eabf6576 100644
--- a/src/plugins/intel_gpu/src/kernel_selector/kernels/depth_to_space/depth_to_space_kernel_base.h
+++ b/src/plugins/intel_gpu/src/kernel_selector/kernels/depth_to_space/depth_to_space_kernel_base.h
@@ -15,8 +15,16 @@ struct depth_to_space_params : public base_params {
depth_to_space_params()
: base_params(KernelType::DEPTH_TO_SPACE)
, block_size(0)
+ , factor_t(1)
+ , factor_s(1)
+ , output_channels(0)
+ , crop_begin_t(0)
, mode(DepthToSpaceMode::DEPTH_FIRST) {}
size_t block_size;
+ size_t factor_t;
+ size_t factor_s;
+ size_t output_channels;
+ size_t crop_begin_t;
DepthToSpaceMode mode;
};
diff --git a/src/plugins/intel_gpu/src/plugin/ops/depth_to_space.cpp b/src/plugins/intel_gpu/src/plugin/ops/depth_to_space.cpp
index 02edc42cb57..55caa55870d 100644
--- a/src/plugins/intel_gpu/src/plugin/ops/depth_to_space.cpp
+++ b/src/plugins/intel_gpu/src/plugin/ops/depth_to_space.cpp
@@ -8,6 +8,11 @@
#include "openvino/op/depth_to_space.hpp"
#include "intel_gpu/primitives/depth_to_space.hpp"
+#include "intel_gpu/op/grouped_depth_to_space.hpp"
+
+namespace ov::op::internal {
+using GroupedDepthToSpace = ov::intel_gpu::op::GroupedDepthToSpace;
+}
namespace ov {
namespace intel_gpu {
@@ -41,5 +46,16 @@ static void CreateDepthToSpaceOp(ProgramBuilder& p, const std::shared_ptr<ov::op
REGISTER_FACTORY_IMPL(v0, DepthToSpace);
+static void CreateGroupedDepthToSpaceOp(ProgramBuilder& p, const std::shared_ptr<ov::op::internal::GroupedDepthToSpace>& op) {
+ validate_inputs_count(op, {1});
+ auto inputs = p.GetInputInfo(op);
+ auto prim =
+ cldnn::depth_to_space(layer_type_name_ID(op), inputs[0], op->get_factor_t(), op->get_factor_s(), op->get_output_channels(), op->get_crop_begin_t());
+ prim.output_data_types = get_output_data_types(op);
+ p.add_primitive(*op, prim);
+}
+
+REGISTER_FACTORY_IMPL(internal, GroupedDepthToSpace);
+
} // namespace intel_gpu
} // namespace ov
diff --git a/src/plugins/intel_gpu/src/plugin/transformations/fuse_grouped_depth_to_space.cpp b/src/plugins/intel_gpu/src/plugin/transformations/fuse_grouped_depth_to_space.cpp
new file mode 100644
index 00000000000..89aa1730ca5
--- /dev/null
+++ b/src/plugins/intel_gpu/src/plugin/transformations/fuse_grouped_depth_to_space.cpp
@@ -0,0 +1,223 @@
+// Copyright (C) 2018-2026 Intel Corporation
+// SPDX-License-Identifier: Apache-2.0
+//
+
+#include "fuse_grouped_depth_to_space.hpp"
+
+#include <limits>
+#include <optional>
+
+#include "intel_gpu/op/grouped_depth_to_space.hpp"
+#include "openvino/core/graph_util.hpp"
+#include "openvino/core/rt_info.hpp"
+#include "openvino/core/validation_util.hpp"
+#include "openvino/op/concat.hpp"
+#include "openvino/op/constant.hpp"
+#include "openvino/op/gather.hpp"
+#include "openvino/op/multiply.hpp"
+#include "openvino/op/range.hpp"
+#include "openvino/op/reshape.hpp"
+#include "openvino/op/slice.hpp"
+#include "openvino/op/tile.hpp"
+#include "openvino/op/transpose.hpp"
+#include "openvino/op/unsqueeze.hpp"
+#include "openvino/pass/pattern/op/wrap_type.hpp"
+#include "transformations/utils/utils.hpp"
+
+namespace ov::intel_gpu {
+namespace {
+
+std::optional<std::vector<int64_t>> get_i64_values(const ov::Output<ov::Node>& output) {
+ const auto constant = ov::util::get_constant_from_source(output);
+ if (!constant) {
+ return std::nullopt;
+ }
+ return constant->cast_vector<int64_t>();
+}
+
+bool has_values(const ov::Output<ov::Node>& output, const std::vector<int64_t>& expected) {
+ const auto values = get_i64_values(output);
+ return values && *values == expected;
+}
+
+bool has_static_shape_values(const ov::Output<ov::Node>& output, const ov::PartialShape& expected_shape) {
+ if (!expected_shape.is_static()) {
+ return false;
+ }
+
+ const auto shape = expected_shape.to_shape();
+ return has_values(output, std::vector<int64_t>(shape.begin(), shape.end()));
+}
+
+bool has_single_consumer(const std::shared_ptr<ov::Node>& node) {
+ return node->output(0).get_target_inputs().size() == 1;
+}
+
+bool multiply_uses_factor(const ov::Output<ov::Node>& output, int64_t factor) {
+ const auto multiply = ov::as_type_ptr<ov::op::v1::Multiply>(output.get_node_shared_ptr());
+ if (!multiply) {
+ return false;
+ }
+ return has_values(multiply->input_value(0), {factor}) || has_values(multiply->input_value(1), {factor});
+}
+
+bool validate_repeat_indices(const std::shared_ptr<ov::op::v8::Gather>& gather, int64_t input_channels, int64_t repeats, ov::NodeVector& matched_nodes) {
+ if (gather->get_batch_dims() != 0 || !has_values(gather->input_value(2), {1})) {
+ return false;
+ }
+
+ if (const auto indices = get_i64_values(gather->input_value(1))) {
+ if (indices->size() != static_cast<size_t>(input_channels * repeats)) {
+ return false;
+ }
+ for (size_t index = 0; index < indices->size(); ++index) {
+ if ((*indices)[index] != static_cast<int64_t>(index) / repeats) {
+ return false;
+ }
+ }
+ matched_nodes.push_back(gather->get_input_node_shared_ptr(1));
+ return true;
+ }
+
+ const auto indices_reshape = ov::as_type_ptr<ov::op::v1::Reshape>(gather->get_input_node_shared_ptr(1));
+ if (!indices_reshape || indices_reshape->get_special_zero() || !has_single_consumer(indices_reshape) ||
+ !has_values(indices_reshape->input_value(1), {-1})) {
+ return false;
+ }
+
+ const auto indices_transpose = ov::as_type_ptr<ov::op::v1::Transpose>(indices_reshape->get_input_node_shared_ptr(0));
+ if (!indices_transpose || !has_single_consumer(indices_transpose) || !has_values(indices_transpose->input_value(1), {1, 0})) {
+ return false;
+ }
+
+ const auto tile = ov::as_type_ptr<ov::op::v0::Tile>(indices_transpose->get_input_node_shared_ptr(0));
+ if (!tile || !has_single_consumer(tile) || !has_values(tile->input_value(1), {repeats, 1})) {
+ return false;
+ }
+
+ const auto unsqueeze = ov::as_type_ptr<ov::op::v0::Unsqueeze>(tile->get_input_node_shared_ptr(0));
+ if (!unsqueeze || !has_single_consumer(unsqueeze) || !has_values(unsqueeze->input_value(1), {0})) {
+ return false;
+ }
+
+ const auto range = ov::as_type_ptr<ov::op::v4::Range>(unsqueeze->get_input_node_shared_ptr(0));
+ if (!range || !has_single_consumer(range) || !has_values(range->input_value(0), {0}) || !has_values(range->input_value(1), {input_channels}) ||
+ !has_values(range->input_value(2), {1})) {
+ return false;
+ }
+
+ matched_nodes.insert(matched_nodes.end(), {range, unsqueeze, tile, indices_transpose, indices_reshape});
+ return true;
+}
+
+bool validate_reshape_shapes(const std::shared_ptr<ov::op::v1::Reshape>& factor_reshape,
+ const std::shared_ptr<ov::op::v1::Reshape>& output_reshape,
+ int64_t input_time,
+ int64_t output_channels,
+ int64_t factor_t,
+ int64_t factor_s) {
+ if (has_static_shape_values(factor_reshape->input_value(1), factor_reshape->get_output_partial_shape(0)) &&
+ has_static_shape_values(output_reshape->input_value(1), output_reshape->get_output_partial_shape(0))) {
+ return true;
+ }
+
+ const auto factor_shape = ov::as_type_ptr<ov::op::v0::Concat>(factor_reshape->get_input_node_shared_ptr(1));
+ if (!factor_shape || factor_shape->get_axis() != 0 || factor_shape->get_input_size() != 7 || !has_values(factor_shape->input_value(1), {output_channels}) ||
+ !has_values(factor_shape->input_value(2), {factor_t}) || !has_values(factor_shape->input_value(3), {factor_s}) ||
+ !has_values(factor_shape->input_value(4), {factor_s}) || !has_values(factor_shape->input_value(5), {input_time})) {
+ return false;
+ }
+
+ const auto output_shape = ov::as_type_ptr<ov::op::v0::Concat>(output_reshape->get_input_node_shared_ptr(1));
+ return output_shape && output_shape->get_axis() == 0 && output_shape->get_input_size() == 5 &&
+ has_values(output_shape->input_value(1), {output_channels}) && has_values(output_shape->input_value(2), {input_time * factor_t}) &&
+ multiply_uses_factor(output_shape->input_value(3), factor_s) && multiply_uses_factor(output_shape->input_value(4), factor_s);
+}
+
+} // namespace
+
+FuseGroupedDepthToSpace::FuseGroupedDepthToSpace() {
+ using namespace ov::pass::pattern;
+
+ auto input_m = any_input(type_matches_any({ov::element::f16, ov::element::f32, ov::element::u8, ov::element::i8}));
+ auto gather_m = wrap_type<ov::op::v8::Gather>({input_m, any_input(), wrap_type<ov::op::v0::Constant>()}, consumers_count(1));
+ auto factor_reshape_m = wrap_type<ov::op::v1::Reshape>({gather_m, any_input()}, consumers_count(1));
+ auto transpose_m = wrap_type<ov::op::v1::Transpose>({factor_reshape_m, wrap_type<ov::op::v0::Constant>()}, consumers_count(1));
+ auto output_reshape_m = wrap_type<ov::op::v1::Reshape>({transpose_m, any_input()});
+
+ ov::matcher_pass_callback callback = [OV_CAPTURE_CPY_AND_THIS](Matcher& m) {
+ const auto& pattern_map = m.get_pattern_value_map();
+ const auto input = pattern_map.at(input_m);
+ const auto gather = ov::as_type_ptr<ov::op::v8::Gather>(pattern_map.at(gather_m).get_node_shared_ptr());
+ const auto factor_reshape = ov::as_type_ptr<ov::op::v1::Reshape>(pattern_map.at(factor_reshape_m).get_node_shared_ptr());
+ const auto transpose = ov::as_type_ptr<ov::op::v1::Transpose>(pattern_map.at(transpose_m).get_node_shared_ptr());
+ const auto output_reshape = ov::as_type_ptr<ov::op::v1::Reshape>(pattern_map.at(output_reshape_m).get_node_shared_ptr());
+
+ if (transformation_callback(output_reshape) || output_reshape->get_users().size() != 1 ||
+ !has_values(transpose->input_value(1), {0, 1, 5, 2, 6, 3, 7, 4})) {
+ return false;
+ }
+
+ const auto input_shape = input.get_partial_shape();
+ const auto factor_shape = factor_reshape->get_output_partial_shape(0);
+ if (input_shape.rank() != 5 || factor_shape.rank() != 8 || !input_shape[1].is_static() || !input_shape[2].is_static() || !factor_shape[1].is_static() ||
+ !factor_shape[2].is_static() || !factor_shape[3].is_static() || !factor_shape[4].is_static() || factor_shape[3] != factor_shape[4] ||
+ factor_shape[5] != input_shape[2] || factor_shape[6] != input_shape[3] || factor_shape[7] != input_shape[4]) {
+ return false;
+ }
+
+ const int64_t input_channels = input_shape[1].get_length();
+ const int64_t input_time = input_shape[2].get_length();
+ const int64_t output_channels = factor_shape[1].get_length();
+ const int64_t factor_t = factor_shape[2].get_length();
+ const int64_t factor_s = factor_shape[3].get_length();
+ const int64_t factor = factor_t * factor_s * factor_s;
+ if (input_channels <= 0 || output_channels <= 0 || factor_t <= 0 || factor_s <= 0 || (output_channels * factor) % input_channels != 0) {
+ return false;
+ }
+ const int64_t repeats = output_channels * factor / input_channels;
+
+ const auto gather_shape = gather->get_output_partial_shape(0);
+ if (gather_shape.rank() != 5 || !gather_shape[1].is_static() || gather_shape[1].get_length() != input_channels * repeats ||
+ !validate_reshape_shapes(factor_reshape, output_reshape, input_time, output_channels, factor_t, factor_s)) {
+ return false;
+ }
+
+ ov::NodeVector matched_nodes = {gather, factor_reshape, transpose, output_reshape};
+ if (!validate_repeat_indices(gather, input_channels, repeats, matched_nodes)) {
+ return false;
+ }
+
+ size_t crop_begin_t = 0;
+ std::shared_ptr<ov::Node> root = output_reshape;
+ const auto output_user = output_reshape->get_users().front();
+ if (const auto slice = ov::as_type_ptr<ov::op::v8::Slice>(output_user)) {
+ if (!has_values(slice->input_value(1), {factor_t - 1}) || !has_values(slice->input_value(2), {std::numeric_limits<int64_t>::max()}) ||
+ !has_values(slice->input_value(3), {1}) || !has_values(slice->input_value(4), {2})) {
+ return false;
+ }
+ crop_begin_t = static_cast<size_t>(factor_t - 1);
+ root = slice;
+ matched_nodes.push_back(slice);
+ }
+
+ auto grouped = std::make_shared<ov::intel_gpu::op::GroupedDepthToSpace>(input,
+ static_cast<size_t>(factor_t),
+ static_cast<size_t>(factor_s),
+ static_cast<size_t>(output_channels),
+ crop_begin_t);
+ if (!grouped->get_output_partial_shape(0).compatible(root->get_output_partial_shape(0))) {
+ return false;
+ }
+
+ grouped->set_friendly_name(root->get_friendly_name());
+ ov::copy_runtime_info(matched_nodes, grouped);
+ ov::replace_node(root, grouped);
+ return true;
+ };
+
+ auto m = std::make_shared<Matcher>(output_reshape_m, "FuseGroupedDepthToSpace");
+ register_matcher(m, callback);
+}
+
+} // namespace ov::intel_gpu
diff --git a/src/plugins/intel_gpu/src/plugin/transformations/fuse_grouped_depth_to_space.hpp b/src/plugins/intel_gpu/src/plugin/transformations/fuse_grouped_depth_to_space.hpp
new file mode 100644
index 00000000000..0b35170b7d6
--- /dev/null
+++ b/src/plugins/intel_gpu/src/plugin/transformations/fuse_grouped_depth_to_space.hpp
@@ -0,0 +1,46 @@
+// Copyright (C) 2018-2026 Intel Corporation
+// SPDX-License-Identifier: Apache-2.0
+//
+
+#pragma once
+
+#include "openvino/pass/graph_rewrite.hpp"
+
+namespace ov::intel_gpu {
+
+/// Fuses grouped channel repetition followed by anisotropic depth-to-space.
+/// The repeat indices may be produced by the subgraph shown below or by its constant-folded equivalent.
+///
+/// Before:
+/// ┌───────┐ ┌───────────┐ ┌──────┐ ┌───────────┐ ┌─────────┐
+/// │ Range ├───►│ Unsqueeze ├───►│ Tile ├───►│ Transpose ├───►│ Reshape │
+/// └───────┘ └───────────┘ └──────┘ └───────────┘ └────┬────┘
+/// │ indices
+/// ┌───────┐ ┌────▼───┐ ┌─────────┐
+/// │ Input ├─────────────────────────────────────────────────►│ Gather ├───►│ Reshape │
+/// └───────┘ └────────┘ └────┬────┘
+/// │
+/// ┌─────▼─────┐
+/// │ Transpose │
+/// └─────┬─────┘
+/// │
+/// ┌────▼────┐
+/// │ Reshape │
+/// └────┬────┘
+/// │
+/// ┌────▼────┐
+/// │ [Slice] │
+/// └─────────┘
+/// After:
+/// ┌───────┐ ┌─────────────────────┐
+/// │ Input ├───►│ GroupedDepthToSpace │
+/// └───────┘ └─────────────────────┘
+///
+/// Slice is optional and removes the leading expanded temporal elements.
+class FuseGroupedDepthToSpace : public ov::pass::MatcherPass {
+public:
+ OPENVINO_MATCHER_PASS_RTTI("FuseGroupedDepthToSpace");
+ FuseGroupedDepthToSpace();
+};
+
+} // namespace ov::intel_gpu
diff --git a/src/plugins/intel_gpu/src/plugin/transformations/op/grouped_depth_to_space.cpp b/src/plugins/intel_gpu/src/plugin/transformations/op/grouped_depth_to_space.cpp
new file mode 100644
index 00000000000..7a391b1a4f5
--- /dev/null
+++ b/src/plugins/intel_gpu/src/plugin/transformations/op/grouped_depth_to_space.cpp
@@ -0,0 +1,59 @@
+// Copyright (C) 2018-2026 Intel Corporation
+// SPDX-License-Identifier: Apache-2.0
+//
+
+#include "intel_gpu/op/grouped_depth_to_space.hpp"
+
+namespace ov::intel_gpu::op {
+
+GroupedDepthToSpace::GroupedDepthToSpace(const ov::Output<Node>& input, size_t factor_t, size_t factor_s, size_t output_channels, size_t crop_begin_t)
+ : Op({input}),
+ m_factor_t(factor_t),
+ m_factor_s(factor_s),
+ m_output_channels(output_channels),
+ m_crop_begin_t(crop_begin_t) {
+ constructor_validate_and_infer_types();
+}
+
+void GroupedDepthToSpace::validate_and_infer_types() {
+ NODE_VALIDATION_CHECK(this, m_factor_t > 0, "factor_t must be greater than zero");
+ NODE_VALIDATION_CHECK(this, m_factor_s > 0, "factor_s must be greater than zero");
+ NODE_VALIDATION_CHECK(this, m_output_channels > 0, "output_channels must be greater than zero");
+ NODE_VALIDATION_CHECK(this, m_crop_begin_t < m_factor_t, "crop_begin_t must be less than factor_t");
+
+ auto output_shape = get_input_partial_shape(0);
+ if (output_shape.rank().is_static()) {
+ NODE_VALIDATION_CHECK(this, output_shape.rank().get_length() == 5, "input rank must be 5");
+
+ const auto input_channels = output_shape[1];
+ const size_t factor = m_factor_t * m_factor_s * m_factor_s;
+ if (input_channels.is_static()) {
+ NODE_VALIDATION_CHECK(this, input_channels.get_length() > 0, "input channels must be greater than zero");
+ NODE_VALIDATION_CHECK(this,
+ (m_output_channels * factor) % input_channels.get_length() == 0,
+ "output_channels * factor_t * factor_s^2 must be divisible by input channels");
+ }
+
+ output_shape[1] = ov::Dimension(static_cast<int64_t>(m_output_channels));
+ output_shape[2] = output_shape[2] * static_cast<int64_t>(m_factor_t) - static_cast<int64_t>(m_crop_begin_t);
+ output_shape[3] = output_shape[3] * static_cast<int64_t>(m_factor_s);
+ output_shape[4] = output_shape[4] * static_cast<int64_t>(m_factor_s);
+ }
+
+ set_output_type(0, get_input_element_type(0), output_shape);
+}
+
+bool GroupedDepthToSpace::visit_attributes(ov::AttributeVisitor& visitor) {
+ visitor.on_attribute("factor_t", m_factor_t);
+ visitor.on_attribute("factor_s", m_factor_s);
+ visitor.on_attribute("output_channels", m_output_channels);
+ visitor.on_attribute("crop_begin_t", m_crop_begin_t);
+ return true;
+}
+
+std::shared_ptr<ov::Node> GroupedDepthToSpace::clone_with_new_inputs(const ov::OutputVector& new_args) const {
+ check_new_args_count(this, new_args);
+ return std::make_shared<GroupedDepthToSpace>(new_args.at(0), m_factor_t, m_factor_s, m_output_channels, m_crop_begin_t);
+}
+
+} // namespace ov::intel_gpu::op
diff --git a/src/plugins/intel_gpu/src/plugin/transformations_pipeline.cpp b/src/plugins/intel_gpu/src/plugin/transformations_pipeline.cpp
index a070c3da65e..df0282fea1c 100644
--- a/src/plugins/intel_gpu/src/plugin/transformations_pipeline.cpp
+++ b/src/plugins/intel_gpu/src/plugin/transformations_pipeline.cpp
@@ -103,6 +103,7 @@
#include "plugin/transformations/fold_activation_transpose.hpp"
#include "plugin/transformations/fuse_gated_mlp.hpp"
#include "plugin/transformations/fuse_atan2_decomposed.hpp"
+#include "plugin/transformations/fuse_grouped_depth_to_space.hpp"
#include "plugin/transformations/fuse_moe_router.hpp"
#include "plugin/transformations/fuse_moe_router_scale.hpp"
#include "plugin/transformations/group_query_attention_decomposition.hpp"
@@ -848,6 +849,7 @@ void TransformationsPipeline::apply(std::shared_ptr<ov::Model> func) {
// Fuse dynamic padding before CommonOptimizations decomposes its shape arithmetic.
manager.register_pass<ov::intel_gpu::DynamicSamePaddingFusion>();
+ manager.register_pass<ov::intel_gpu::FuseGroupedDepthToSpace>();
manager.register_pass<ov::pass::CommonOptimizations>();
pass_config->disable<ov::pass::GroupQueryAttentionDecomposition>();
manager.register_pass<ov::intel_gpu::GroupQueryAttentionDecomposition>();
diff --git a/src/plugins/intel_gpu/tests/unit/shape_infer/depth_to_space_si_test.cpp b/src/plugins/intel_gpu/tests/unit/shape_infer/depth_to_space_si_test.cpp
index da41aae37b3..3b2ad35e13f 100644
--- a/src/plugins/intel_gpu/tests/unit/shape_infer/depth_to_space_si_test.cpp
+++ b/src/plugins/intel_gpu/tests/unit/shape_infer/depth_to_space_si_test.cpp
@@ -7,6 +7,7 @@
#include <intel_gpu/primitives/input_layout.hpp>
#include <intel_gpu/primitives/depth_to_space.hpp>
#include <intel_gpu/primitives/data.hpp>
+#include <intel_gpu/primitives/reorder.hpp>
#include "depth_to_space_inst.h"
@@ -47,6 +48,29 @@ TEST_P(depth_to_space_test, shape_infer) {
ASSERT_EQ(res[0], p.expected_layout);
}
+TEST(depth_to_space_test, grouped_fused_output_type) {
+ auto& engine = get_test_engine();
+
+ const auto input_layout_desc = layout{ov::PartialShape{1, 4, 1, 1, 1}, data_types::f32, format::bfzyx};
+ const auto output_shape = ov::PartialShape{1, 2, 1, 2, 2};
+ auto input_layout_prim = std::make_shared<input_layout>("input", input_layout_desc);
+ auto depth_to_space_prim = std::make_shared<depth_to_space>("depth_to_space", input_info("input"), 2, 2, 2, 1);
+ auto reorder_prim = std::make_shared<reorder>("reorder", input_info("depth_to_space"), format::bfzyx, data_types::i8);
+
+ cldnn::program prog(engine);
+ auto& input_layout_node = prog.get_or_create(input_layout_prim);
+ auto& depth_to_space_node = prog.get_or_create(depth_to_space_prim);
+ program_wrapper::add_connection(prog, input_layout_node, depth_to_space_node);
+
+ auto impl_params = depth_to_space_node.get_kernel_impl_params();
+ fused_primitive_desc fused_reorder(reorder_prim);
+ fused_reorder.output_layout = layout{output_shape, data_types::i8, format::bfzyx};
+ impl_params->fused_desc = {fused_reorder};
+
+ const auto result = depth_to_space_inst::calc_output_layout(depth_to_space_node, *impl_params);
+ EXPECT_EQ(result, (layout{output_shape, data_types::i8, format::bfzyx}));
+}
+
INSTANTIATE_TEST_SUITE_P(smoke, depth_to_space_test,
testing::ValuesIn(std::vector<depth_to_space_test_params>{
{
diff --git a/src/plugins/intel_gpu/tests/unit/sources.cmake b/src/plugins/intel_gpu/tests/unit/sources.cmake
index bcbe6109b25..70f2a9e478c 100644
--- a/src/plugins/intel_gpu/tests/unit/sources.cmake
+++ b/src/plugins/intel_gpu/tests/unit/sources.cmake
@@ -328,6 +328,7 @@ set(GPU_UNIT_TESTS_SRCS
${CMAKE_CURRENT_LIST_DIR}/transformations/fold_activation_transpose_test.cpp
${CMAKE_CURRENT_LIST_DIR}/transformations/fold_rms_transposes_test.cpp
${CMAKE_CURRENT_LIST_DIR}/transformations/fuse_atan2_decomposed_test.cpp
+ ${CMAKE_CURRENT_LIST_DIR}/transformations/fuse_grouped_depth_to_space_test.cpp
${CMAKE_CURRENT_LIST_DIR}/transformations/fuse_moe_router_scale_test.cpp
${CMAKE_CURRENT_LIST_DIR}/transformations/fuse_moe_router_test.cpp
${CMAKE_CURRENT_LIST_DIR}/transformations/fuse_moe_shared_expert_test.cpp
@@ -414,6 +415,8 @@ set(GPU_UNIT_TESTS_TRANSFORMATIONS_SRCS
${CMAKE_HOME_DIRECTORY}/src/plugins/intel_gpu/src/plugin/transformations/fold_rms_transposes.hpp
${CMAKE_HOME_DIRECTORY}/src/plugins/intel_gpu/src/plugin/transformations/fuse_atan2_decomposed.cpp
${CMAKE_HOME_DIRECTORY}/src/plugins/intel_gpu/src/plugin/transformations/fuse_atan2_decomposed.hpp
+ ${CMAKE_HOME_DIRECTORY}/src/plugins/intel_gpu/src/plugin/transformations/fuse_grouped_depth_to_space.cpp
+ ${CMAKE_HOME_DIRECTORY}/src/plugins/intel_gpu/src/plugin/transformations/fuse_grouped_depth_to_space.hpp
${CMAKE_HOME_DIRECTORY}/src/plugins/intel_gpu/src/plugin/transformations/fuse_gated_mlp.cpp
${CMAKE_HOME_DIRECTORY}/src/plugins/intel_gpu/src/plugin/transformations/fuse_gated_mlp.hpp
${CMAKE_HOME_DIRECTORY}/src/plugins/intel_gpu/src/plugin/transformations/fuse_moe_router.cpp
@@ -475,6 +478,7 @@ set(GPU_UNIT_TESTS_TRANSFORMATIONS_SRCS
${CMAKE_HOME_DIRECTORY}/src/plugins/intel_gpu/src/plugin/transformations/op/gated_mlp.cpp
${CMAKE_HOME_DIRECTORY}/src/plugins/intel_gpu/src/plugin/transformations/op/gemm.cpp
${CMAKE_HOME_DIRECTORY}/src/plugins/intel_gpu/src/plugin/transformations/op/indirect_gemm.cpp
+ ${CMAKE_HOME_DIRECTORY}/src/plugins/intel_gpu/src/plugin/transformations/op/grouped_depth_to_space.cpp
${CMAKE_HOME_DIRECTORY}/src/plugins/intel_gpu/src/plugin/transformations/op/indirect_sdpa.cpp
${CMAKE_HOME_DIRECTORY}/src/plugins/intel_gpu/src/plugin/transformations/op/kv_cache.cpp
${CMAKE_HOME_DIRECTORY}/src/plugins/intel_gpu/src/plugin/transformations/op/lora_subgraph_fused.cpp
diff --git a/src/plugins/intel_gpu/tests/unit/test_cases/depth_to_space_gpu_test.cpp b/src/plugins/intel_gpu/tests/unit/test_cases/depth_to_space_gpu_test.cpp
index 85b44754610..ceedcdbd898 100644
--- a/src/plugins/intel_gpu/tests/unit/test_cases/depth_to_space_gpu_test.cpp
+++ b/src/plugins/intel_gpu/tests/unit/test_cases/depth_to_space_gpu_test.cpp
@@ -17,6 +17,54 @@
using namespace cldnn;
using namespace ::tests;
+TEST(depth_to_space_fp32_gpu, grouped_block2_with_temporal_crop) {
+ auto& engine = get_test_engine();
+ auto input = engine.allocate_memory({ data_types::f32, format::bfzyx, { 1, 4, 1, 1, 1 } });
+ set_values(input, { 0.f, 1.f, 2.f, 3.f });
+
+ topology topology;
+ topology.add(input_layout("input", input->get_layout()));
+ topology.add(
+ depth_to_space("grouped_depth_to_space", input_info("input"), 2, 2, 2, 1)
+ );
+
+ network network(engine, topology, get_test_default_config(engine));
+ network.set_input_data("input", input);
+
+ auto output = network.execute().at("grouped_depth_to_space").get_memory();
+ ASSERT_EQ(output->get_layout().get_shape(), ov::Shape({ 1, 2, 1, 2, 2 }));
+
+ cldnn::mem_lock<float, mem_lock_type::read> output_ptr(output, get_test_stream());
+ const std::vector<float> expected = { 1.f, 1.f, 1.f, 1.f, 3.f, 3.f, 3.f, 3.f };
+ for (size_t i = 0; i < expected.size(); ++i) {
+ ASSERT_FLOAT_EQ(expected[i], output_ptr[i]) << "i=" << i;
+ }
+}
+
+TEST(depth_to_space_fp32_gpu, grouped_block3_anisotropic_spatial_mapping) {
+ auto& engine = get_test_engine();
+ auto input = engine.allocate_memory({ data_types::f32, format::bfzyx, { 1, 4, 1, 1, 1 } });
+ set_values(input, { 0.f, 1.f, 2.f, 3.f });
+
+ topology topology;
+ topology.add(input_layout("input", input->get_layout()));
+ topology.add(
+ depth_to_space("grouped_depth_to_space", input_info("input"), 1, 2, 2, 0)
+ );
+
+ network network(engine, topology, get_test_default_config(engine));
+ network.set_input_data("input", input);
+
+ auto output = network.execute().at("grouped_depth_to_space").get_memory();
+ ASSERT_EQ(output->get_layout().get_shape(), ov::Shape({ 1, 2, 1, 2, 2 }));
+
+ cldnn::mem_lock<float, mem_lock_type::read> output_ptr(output, get_test_stream());
+ const std::vector<float> expected = { 0.f, 0.f, 1.f, 1.f, 2.f, 2.f, 3.f, 3.f };
+ for (size_t i = 0; i < expected.size(); ++i) {
+ ASSERT_FLOAT_EQ(expected[i], output_ptr[i]) << "i=" << i;
+ }
+}
+
TEST(depth_to_space_fp16_gpu, d1411_bs2) {
// Input : 1x4x1x1
// Block size : 2
diff --git a/src/plugins/intel_gpu/tests/unit/transformations/fuse_grouped_depth_to_space_test.cpp b/src/plugins/intel_gpu/tests/unit/transformations/fuse_grouped_depth_to_space_test.cpp
new file mode 100644
index 00000000000..ce7c7dcfcf7
--- /dev/null
+++ b/src/plugins/intel_gpu/tests/unit/transformations/fuse_grouped_depth_to_space_test.cpp
@@ -0,0 +1,127 @@
+// Copyright (C) 2018-2026 Intel Corporation
+// SPDX-License-Identifier: Apache-2.0
+//
+
+#include "plugin/transformations/fuse_grouped_depth_to_space.hpp"
+
+#include <gtest/gtest.h>
+
+#include <limits>
+#include <memory>
+#include <vector>
+
+#include "intel_gpu/op/grouped_depth_to_space.hpp"
+#include "openvino/core/model.hpp"
+#include "openvino/op/concat.hpp"
+#include "openvino/op/constant.hpp"
+#include "openvino/op/gather.hpp"
+#include "openvino/op/multiply.hpp"
+#include "openvino/op/parameter.hpp"
+#include "openvino/op/range.hpp"
+#include "openvino/op/reshape.hpp"
+#include "openvino/op/shape_of.hpp"
+#include "openvino/op/slice.hpp"
+#include "openvino/op/tile.hpp"
+#include "openvino/op/transpose.hpp"
+#include "openvino/op/unsqueeze.hpp"
+#include "openvino/pass/constant_folding.hpp"
+#include "openvino/pass/manager.hpp"
+
+namespace {
+
+std::shared_ptr<ov::op::v0::Constant> i64(const std::vector<int64_t>& values) {
+ return ov::op::v0::Constant::create(ov::element::i64, ov::Shape{values.size()}, values);
+}
+
+std::shared_ptr<ov::op::v0::Constant> i64_scalar(int64_t value) {
+ return ov::op::v0::Constant::create(ov::element::i64, ov::Shape{}, {value});
+}
+
+std::shared_ptr<ov::Model> make_dup_up_model(bool with_crop,
+ bool valid_transpose_order = true,
+ bool shape_derived_range_stop = false,
+ ov::element::Type input_type = ov::element::f16) {
+ auto input = std::make_shared<ov::op::v0::Parameter>(input_type, ov::Shape{1, 4, 2, 3, 5});
+
+ ov::Output<ov::Node> range_stop = i64_scalar(4);
+ if (shape_derived_range_stop) {
+ auto input_shape = std::make_shared<ov::op::v3::ShapeOf>(input, ov::element::i64);
+ range_stop = std::make_shared<ov::op::v8::Gather>(input_shape, i64_scalar(1), i64_scalar(0));
+ }
+ auto range = std::make_shared<ov::op::v4::Range>(i64_scalar(0), range_stop, i64_scalar(1), ov::element::i64);
+ auto unsqueeze = std::make_shared<ov::op::v0::Unsqueeze>(range, i64({0}));
+ auto tile = std::make_shared<ov::op::v0::Tile>(unsqueeze, i64({4, 1}));
+ auto indices_transpose = std::make_shared<ov::op::v1::Transpose>(tile, i64({1, 0}));
+ auto indices = std::make_shared<ov::op::v1::Reshape>(indices_transpose, i64({-1}), false);
+ auto gather = std::make_shared<ov::op::v8::Gather>(input, indices, i64({1}));
+
+ auto factor_shape = std::make_shared<ov::op::v0::Concat>(ov::OutputVector{i64({1}), i64({2}), i64({2}), i64({2}), i64({2}), i64({2}), i64({3, 5})}, 0);
+ auto factor_reshape = std::make_shared<ov::op::v1::Reshape>(gather, factor_shape, false);
+ const std::vector<int64_t> transpose_order =
+ valid_transpose_order ? std::vector<int64_t>{0, 1, 5, 2, 6, 3, 7, 4} : std::vector<int64_t>{0, 1, 5, 2, 6, 4, 7, 3};
+ auto transpose = std::make_shared<ov::op::v1::Transpose>(factor_reshape, i64(transpose_order));
+
+ auto output_height = std::make_shared<ov::op::v1::Multiply>(i64({3}), i64({2}));
+ auto output_width = std::make_shared<ov::op::v1::Multiply>(i64({5}), i64({2}));
+ auto output_shape = std::make_shared<ov::op::v0::Concat>(ov::OutputVector{i64({1}), i64({2}), i64({4}), output_height, output_width}, 0);
+ auto output_reshape = std::make_shared<ov::op::v1::Reshape>(transpose, output_shape, false);
+
+ ov::Output<ov::Node> output = output_reshape;
+ if (with_crop) {
+ output = std::make_shared<ov::op::v8::Slice>(output_reshape, i64({1}), i64({std::numeric_limits<int64_t>::max()}), i64({1}), i64({2}));
+ }
+ return std::make_shared<ov::Model>(ov::OutputVector{output}, ov::ParameterVector{input});
+}
+
+std::shared_ptr<ov::intel_gpu::op::GroupedDepthToSpace> run_fusion(const std::shared_ptr<ov::Model>& model, bool fold_constants = false) {
+ ov::pass::Manager manager;
+ if (fold_constants) {
+ manager.register_pass<ov::pass::ConstantFolding>();
+ }
+ manager.register_pass<ov::intel_gpu::FuseGroupedDepthToSpace>();
+ manager.run_passes(model);
+ return ov::as_type_ptr<ov::intel_gpu::op::GroupedDepthToSpace>(model->get_results().front()->get_input_node_shared_ptr(0));
+}
+
+TEST(FuseGroupedDepthToSpaceTest, FusesWithoutTemporalCrop) {
+ const auto grouped = run_fusion(make_dup_up_model(false));
+
+ ASSERT_NE(grouped, nullptr);
+ EXPECT_EQ(grouped->get_factor_t(), 2u);
+ EXPECT_EQ(grouped->get_factor_s(), 2u);
+ EXPECT_EQ(grouped->get_output_channels(), 2u);
+ EXPECT_EQ(grouped->get_crop_begin_t(), 0u);
+ EXPECT_EQ(grouped->get_output_shape(0), (ov::Shape{1, 2, 4, 6, 10}));
+}
+
+TEST(FuseGroupedDepthToSpaceTest, FusesTemporalCrop) {
+ const auto grouped = run_fusion(make_dup_up_model(true));
+
+ ASSERT_NE(grouped, nullptr);
+ EXPECT_EQ(grouped->get_crop_begin_t(), 1u);
+ EXPECT_EQ(grouped->get_output_shape(0), (ov::Shape{1, 2, 3, 6, 10}));
+}
+
+TEST(FuseGroupedDepthToSpaceTest, FusesShapeDerivedRangeStop) {
+ EXPECT_NE(run_fusion(make_dup_up_model(false, true, true)), nullptr);
+}
+
+TEST(FuseGroupedDepthToSpaceTest, FusesConstantFoldedInputs) {
+ EXPECT_NE(run_fusion(make_dup_up_model(false, true, true), true), nullptr);
+}
+
+TEST(FuseGroupedDepthToSpaceTest, RejectsDifferentTransposeOrder) {
+ EXPECT_EQ(run_fusion(make_dup_up_model(false, false)), nullptr);
+}
+
+TEST(FuseGroupedDepthToSpaceTest, RejectsUnsupportedInputType) {
+ EXPECT_EQ(run_fusion(make_dup_up_model(false, true, false, ov::element::bf16)), nullptr);
+}
+
+TEST(FuseGroupedDepthToSpaceTest, RejectsZeroInputChannels) {
+ auto input = std::make_shared<ov::op::v0::Parameter>(ov::element::f16, ov::Shape{1, 0, 2, 3, 5});
+
+ EXPECT_THROW(static_cast<void>(std::make_shared<ov::intel_gpu::op::GroupedDepthToSpace>(input, 2, 2, 2, 0)), ov::NodeValidationFailure);
+}
+
+} // namespace