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] Enable segment_max-16 (#34037)
Wilson Seokaebbbdb73d7b
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.hppindex df7c393e020..f2506131adc 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@@ -285,6 +285,7 @@ REGISTER_FACTORY(v16, SparseFillEmptyRows);REGISTER_FACTORY(v16, AvgPool);REGISTER_FACTORY(v16, OneHot);REGISTER_FACTORY(v16, Identity);+REGISTER_FACTORY(v16, SegmentMax);// --------------------------- Supported internal ops --------------------------- //REGISTER_FACTORY(internal, NonMaxSuppressionIEInternal);diff --git a/src/plugins/intel_gpu/include/intel_gpu/primitives/segment_max.hpp b/src/plugins/intel_gpu/include/intel_gpu/primitives/segment_max.hppnew file mode 100644index 00000000000..249cf3e8068--- /dev/null+++ b/src/plugins/intel_gpu/include/intel_gpu/primitives/segment_max.hpp@@ -0,0 +1,78 @@+// Copyright (C) 2018-2026 Intel Corporation+// SPDX-License-Identifier: Apache-2.0+//++#pragma once+#include "primitive.hpp"+#include "intel_gpu/graph/serialization/utils.hpp"+#include "openvino/op/util/attr_types.hpp"++namespace cldnn {++/// @brief SegmentMax computes the maximum values along segments of a tensor.+/// @details+/// Given a data tensor and a 1-D segment_ids tensor, produces an output tensor+/// where each segment contains the elementwise maximum of the corresponding+/// data rows.+struct segment_max : public primitive_base<segment_max> {+ CLDNN_DECLARE_PRIMITIVE(segment_max)++ segment_max() : primitive_base("", {}) {}++ /// @brief Constructs segment_max primitive.+ /// @param id This primitive id.+ /// @param data Data input.+ /// @param segment_ids Segment indices input (1-D, non-decreasing).+ /// @param fill_mode Fill mode for empty segments.+ segment_max(const primitive_id& id,+ const input_info& data,+ const input_info& segment_ids,+ ov::op::FillMode fill_mode)+ : primitive_base(id, {data, segment_ids}),+ fill_mode(fill_mode) {}++ /// @brief Fill mode for empty segments.+ ov::op::FillMode fill_mode = ov::op::FillMode::ZERO;++ /// @brief Max segment_id value for compile-time shape inference (when constant). -1 = not set.+ int64_t max_segment_id = -1;++ /// @brief Stored num_segments value for compile-time shape inference (when constant). -1 = not set.+ int64_t num_segments_val = -1;++ size_t hash() const override {+ size_t seed = primitive::hash();+ seed = hash_combine(seed, static_cast<int>(fill_mode));+ seed = hash_combine(seed, max_segment_id);+ seed = hash_combine(seed, num_segments_val);+ return seed;+ }++ bool operator==(const primitive& rhs) const override {+ if (!compare_common_params(rhs))+ return false;++ auto rhs_casted = downcast<const segment_max>(rhs);++ return fill_mode == rhs_casted.fill_mode &&+ max_segment_id == rhs_casted.max_segment_id &&+ num_segments_val == rhs_casted.num_segments_val;+ }++ void save(BinaryOutputBuffer& ob) const override {+ primitive_base<segment_max>::save(ob);+ ob << static_cast<int>(fill_mode);+ ob << max_segment_id;+ ob << num_segments_val;+ }++ void load(BinaryInputBuffer& ib) override {+ primitive_base<segment_max>::load(ib);+ int fm = 0;+ ib >> fm;+ fill_mode = static_cast<ov::op::FillMode>(fm);+ ib >> max_segment_id;+ ib >> num_segments_val;+ }+};+} // namespace cldnndiff --git a/src/plugins/intel_gpu/src/graph/impls/ocl_v2/segment_max.cpp b/src/plugins/intel_gpu/src/graph/impls/ocl_v2/segment_max.cppnew file mode 100644index 00000000000..e3e341f0952--- /dev/null+++ b/src/plugins/intel_gpu/src/graph/impls/ocl_v2/segment_max.cpp@@ -0,0 +1,126 @@+// Copyright (C) 2018-2026 Intel Corporation+// SPDX-License-Identifier: Apache-2.0+//++#include "segment_max.hpp"++#include "common_utils/jitter.hpp"+#include "intel_gpu/primitives/segment_max.hpp"+#include "primitive_inst.h"+#include "primitive_ocl_base.hpp"+#include "segment_max_inst.h"+#include "utils/kernel_generator.hpp"++namespace ov::intel_gpu::ocl {++namespace {++enum KernelsTypes {+ REF = 0,+ OPT,+};++class SegmentMaxRef : public KernelGenerator {+public:+ SegmentMaxRef() : KernelGenerator("segment_max_ref") {}++protected:+ [[nodiscard]] JitConstants get_jit_constants(const RuntimeParams& params) const override {+ auto jit = KernelGenerator::get_jit_constants(params);+ const auto& desc = params.typed_desc<segment_max>();++ jit.add(make_jit_constant("FILL_MODE", static_cast<int>(desc->fill_mode)));++ if (desc->fill_mode == ov::op::FillMode::ZERO) {+ jit.add(make_jit_constant("EMPTY_SEGMENT_VALUE", "0"));+ } else {+ jit.add(make_jit_constant("EMPTY_SEGMENT_VALUE", "OUTPUT_VAL_MIN"));+ }++ return jit;+ }++ [[nodiscard]] DispatchDataFunc get_dispatch_data_func() const override {+ return DispatchDataFunc{[](const RuntimeParams& params, KernelData& kd, ImplRuntimeParams* rt_params) {+ auto& wgs = kd.params.workGroups;+ const auto& out_l = params.get_output_layout(0);++ size_t output_size = out_l.is_dynamic() ? 1 : out_l.count();+ wgs.global = {output_size, 1, 1};+ wgs.local = ov::intel_gpu::get_optimal_lws(wgs.global, params.get_device_info());+ }};+ }+};++class SegmentMaxOpt : public KernelGenerator {+public:+ SegmentMaxOpt() : KernelGenerator("segment_max_opt") {}++protected:+ [[nodiscard]] JitConstants get_jit_constants(const RuntimeParams& params) const override {+ auto jit = KernelGenerator::get_jit_constants(params);+ const auto& desc = params.typed_desc<segment_max>();++ jit.add(make_jit_constant("FILL_MODE", static_cast<int>(desc->fill_mode)));++ if (desc->fill_mode == ov::op::FillMode::ZERO) {+ jit.add(make_jit_constant("EMPTY_SEGMENT_VALUE", "0"));+ } else {+ jit.add(make_jit_constant("EMPTY_SEGMENT_VALUE", "OUTPUT_VAL_MIN"));+ }++ return jit;+ }++ [[nodiscard]] DispatchDataFunc get_dispatch_data_func() const override {+ return DispatchDataFunc{[](const RuntimeParams& params, KernelData& kd, ImplRuntimeParams* rt_params) {+ auto& wgs = kd.params.workGroups;+ const auto& out_l = params.get_output_layout(0);++ if (out_l.is_dynamic()) {+ wgs.global = {1, 1, 1};+ } else {+ size_t inner_dim = static_cast<size_t>(out_l.feature()) * out_l.spatial(2) * out_l.spatial(1) * out_l.spatial(0);+ size_t num_segments = static_cast<size_t>(out_l.batch());+ wgs.global = {inner_dim, num_segments, 1};+ }+ wgs.local = ov::intel_gpu::get_optimal_lws(wgs.global, params.get_device_info());+ }};+ }+};++class SegmentMaxImpl : public PrimitiveImplOCL {+public:+ DECLARE_OBJECT_TYPE_SERIALIZATION(ov::intel_gpu::ocl::SegmentMaxImpl)++ Stage::Ptr ref_stage = make_stage<SegmentMaxRef>();+ Stage::Ptr opt_stage = make_stage<SegmentMaxOpt>();++ SegmentMaxImpl() : PrimitiveImplOCL(SegmentMax::get_type_info_static()) {}+ SegmentMaxImpl(const program_node& node, const RuntimeParams& params) : SegmentMaxImpl() {+ add_stage(ref_stage, params);+ add_stage(opt_stage, params);+ }++ [[nodiscard]] std::unique_ptr<primitive_impl> clone() const override {+ return make_deep_copy<SegmentMaxImpl>(this);+ }++ std::vector<size_t> get_stages_execution_order(const cldnn::primitive_inst& instance) const override {+ // Always prefer the optimized kernel (binary search) since segment_ids+ // is required to be sorted (non-decreasing) by the SegmentMax-16 spec.+ return {KernelsTypes::OPT};+ }+};++} // namespace++std::unique_ptr<primitive_impl> SegmentMax::create_impl(const program_node& node, const RuntimeParams& params) const {+ assert(node.is_type<segment_max>());+ return std::make_unique<SegmentMaxImpl>(node, params);+}++} // namespace ov::intel_gpu::ocl++BIND_BINARY_BUFFER_WITH_TYPE(cldnn::segment_max)+BIND_BINARY_BUFFER_WITH_TYPE(ov::intel_gpu::ocl::SegmentMaxImpl)diff --git a/src/plugins/intel_gpu/src/graph/impls/ocl_v2/segment_max.hpp b/src/plugins/intel_gpu/src/graph/impls/ocl_v2/segment_max.hppnew file mode 100644index 00000000000..74a5c878624--- /dev/null+++ b/src/plugins/intel_gpu/src/graph/impls/ocl_v2/segment_max.hpp@@ -0,0 +1,54 @@+// Copyright (C) 2018-2026 Intel Corporation+// SPDX-License-Identifier: Apache-2.0+//++#pragma once++#include "program_node.h"+#include "registry/implementation_manager.hpp"++using namespace cldnn; // TODO: Remove once namespaces are aligned+namespace ov::intel_gpu::ocl {++struct SegmentMax : public ImplementationManager {+ OV_GPU_PRIMITIVE_IMPL("ocl::segment_max")+ explicit SegmentMax(shape_types shape_type, ValidateFunc vf = nullptr) : ImplementationManager(impl_types::ocl, shape_type, std::move(vf)) {}++ [[nodiscard]] std::unique_ptr<primitive_impl> create_impl(const program_node& node, const RuntimeParams& params) const override;++ [[nodiscard]] bool validate_impl(const program_node& node) const override {+ static constexpr std::array supported_data_types = {+ ov::element::f32,+ ov::element::f16,+ ov::element::i8,+ ov::element::u8,+ ov::element::i32,+ ov::element::i64,+ };++ static constexpr std::array supported_segment_ids_types = {+ ov::element::i32,+ ov::element::i64,+ };++ const auto& in0_layout = node.get_input_layout(0); // data+ const auto& in1_layout = node.get_input_layout(1); // segment_ids+ const auto& out_layout = node.get_output_layout(0);++ if (!one_of(in0_layout.data_type, supported_data_types) || !one_of(out_layout.data_type, supported_data_types)) {+ return false;+ }++ if (!one_of(in1_layout.data_type, supported_segment_ids_types)) {+ return false;+ }++ if (node.has_fused_primitives()) {+ return false;+ }++ return true;+ }+};++} // namespace ov::intel_gpu::ocldiff --git a/src/plugins/intel_gpu/src/graph/impls/ocl_v2/segment_max_opt.cl b/src/plugins/intel_gpu/src/graph/impls/ocl_v2/segment_max_opt.clnew file mode 100644index 00000000000..928e5960776--- /dev/null+++ b/src/plugins/intel_gpu/src/graph/impls/ocl_v2/segment_max_opt.cl@@ -0,0 +1,95 @@+// Copyright (C) 2018-2026 Intel Corporation+// SPDX-License-Identifier: Apache-2.0+//++#include "include/batch_headers/fetch_data.cl"++// SegmentMax optimized kernel.+//+// Leverages the SegmentMax-16 specification requirement that segment_ids is+// sorted (non-decreasing) to use binary search for finding segment boundaries.+// This reduces the per-output-element complexity from O(num_rows) to+// O(log(num_rows) + segment_size).+//+// Work distribution:+// get_global_id(0) = inner dimension index j (coalesced memory access)+// get_global_id(1) = segment index+//+// Inputs:+// data – [num_rows x inner_dim_size] flattened+// segment_ids – [num_rows] sorted non-decreasing+// Output:+// output – [num_segments x inner_dim_size]++// Binary search: find first index in [lo, hi) where segment_ids[index] >= target.+inline int FUNC(lower_bound)(+ const __global INPUT1_TYPE* restrict segment_ids,+ int lo, int hi, INPUT1_TYPE target)+{+ while (lo < hi) {+ int mid = lo + ((hi - lo) >> 1);+ if (segment_ids[mid] < target)+ lo = mid + 1;+ else+ hi = mid;+ }+ return lo;+}++// Binary search: find first index in [lo, hi) where segment_ids[index] > target.+inline int FUNC(upper_bound)(+ const __global INPUT1_TYPE* restrict segment_ids,+ int lo, int hi, INPUT1_TYPE target)+{+ while (lo < hi) {+ int mid = lo + ((hi - lo) >> 1);+ if (segment_ids[mid] <= target)+ lo = mid + 1;+ else+ hi = mid;+ }+ return lo;+}++KERNEL(segment_max_opt)(+ OPTIONAL_SHAPE_INFO_ARG+ const __global INPUT0_TYPE* restrict data,+ const __global INPUT1_TYPE* restrict segment_ids,+ __global OUTPUT_TYPE* restrict output)+{+ const int j = get_global_id(0); // inner dimension index (coalesced access)+ const int seg = get_global_id(1); // segment index++ const int num_segments = OUTPUT_BATCH_NUM;+ const int inner_dim_size = OUTPUT_FEATURE_NUM * OUTPUT_SIZE_Z * OUTPUT_SIZE_Y * OUTPUT_SIZE_X;+ const int num_rows = INPUT0_BATCH_NUM;++ if (j >= inner_dim_size || seg >= num_segments)+ return;++ // Binary search for the half-open range [start, end) of rows belonging+ // to this segment. O(log num_rows) instead of O(num_rows).+ const int start = FUNC_CALL(lower_bound)(segment_ids, 0, num_rows, (INPUT1_TYPE)seg);+ const int end = FUNC_CALL(upper_bound)(segment_ids, start, num_rows, (INPUT1_TYPE)seg);++ const int out_idx = seg * inner_dim_size + j;++ if (start >= end) {+ // Empty segment — fill with the appropriate sentinel.+ output[out_idx] = EMPTY_SEGMENT_VALUE;+ return;+ }++ // Reduce over the segment rows.+ // First element is unconditionally assigned, avoiding a branch in the loop.+ OUTPUT_TYPE max_val = (OUTPUT_TYPE)data[start * inner_dim_size + j];++ for (int i = start + 1; i < end; ++i) {+ const INPUT0_TYPE v = data[i * inner_dim_size + j];+ if (v > max_val) {+ max_val = (OUTPUT_TYPE)v;+ }+ }++ output[out_idx] = max_val;+}diff --git a/src/plugins/intel_gpu/src/graph/impls/ocl_v2/segment_max_ref.cl b/src/plugins/intel_gpu/src/graph/impls/ocl_v2/segment_max_ref.clnew file mode 100644index 00000000000..2d5c095ed74--- /dev/null+++ b/src/plugins/intel_gpu/src/graph/impls/ocl_v2/segment_max_ref.cl@@ -0,0 +1,59 @@+// Copyright (C) 2018-2026 Intel Corporation+// SPDX-License-Identifier: Apache-2.0+//++#include "include/batch_headers/fetch_data.cl"++// SegmentMax reference kernel.+//+// For each output element (segment_id, j) where j is an index in the inner+// dimension, scans all data rows that belong to the segment and computes the+// maximum value.+//+// Inputs:+// data – [num_rows x inner_dim_size] flattened+// segment_ids – [num_rows]+// Output:+// output – [num_segments x inner_dim_size]++KERNEL(segment_max_ref)(+ OPTIONAL_SHAPE_INFO_ARG+ const __global INPUT0_TYPE* restrict data,+ const __global INPUT1_TYPE* restrict segment_ids,+ __global OUTPUT_TYPE* restrict output)+{+ const int gid = get_global_id(0);++ // Total number of output elements = num_segments * inner_dim_size+ const int num_segments = OUTPUT_BATCH_NUM;+ const int inner_dim_size = OUTPUT_FEATURE_NUM * OUTPUT_SIZE_Z * OUTPUT_SIZE_Y * OUTPUT_SIZE_X;+ const int total_output = num_segments * inner_dim_size;++ if (gid >= total_output)+ return;++ const int seg = gid / inner_dim_size;+ const int j = gid % inner_dim_size;++ // num_rows is the first dimension of the data tensor+ const int num_rows = INPUT0_BATCH_NUM;++ OUTPUT_TYPE max_val = EMPTY_SEGMENT_VALUE;+ int found = 0;++ for (int i = 0; i < num_rows; ++i) {+ if ((INPUT1_TYPE)segment_ids[i] == (INPUT1_TYPE)seg) {+ INPUT0_TYPE v = data[i * inner_dim_size + j];+ if (!found || v > max_val) {+ max_val = (OUTPUT_TYPE)v;+ }+ found = 1;+ }+ }++ if (!found) {+ max_val = EMPTY_SEGMENT_VALUE;+ }++ output[gid] = max_val;+}diff --git a/src/plugins/intel_gpu/src/graph/include/segment_max_inst.h b/src/plugins/intel_gpu/src/graph/include/segment_max_inst.hnew file mode 100644index 00000000000..537a9686732--- /dev/null+++ b/src/plugins/intel_gpu/src/graph/include/segment_max_inst.h@@ -0,0 +1,46 @@+// Copyright (C) 2018-2026 Intel Corporation+// SPDX-License-Identifier: Apache-2.0+//+#pragma once++#include <intel_gpu/primitives/segment_max.hpp>++#include "primitive_inst.h"++namespace cldnn {++template <>+struct typed_program_node<segment_max> : public typed_program_node_base<segment_max> {+ using parent = typed_program_node_base<segment_max>;+ typed_program_node(const std::shared_ptr<segment_max> prim, program& prog) : parent(prim, prog) {}++public:+ using parent::parent;++ program_node& input(size_t idx = 0) const {+ return get_dependency(idx);+ }+ std::vector<size_t> get_shape_infer_dependencies() const override {+ return {};+ }+};++using segment_max_node = typed_program_node<segment_max>;++template <>+class typed_primitive_inst<segment_max> : public typed_primitive_inst_base<segment_max> {+ using parent = typed_primitive_inst_base<segment_max>;+ using parent::parent;++public:+ typed_primitive_inst(network& network, segment_max_node const& desc);+ template <typename ShapeType>+ static std::vector<layout> calc_output_layouts(segment_max_node const& node,+ kernel_impl_params const& impl_param);+ static layout calc_output_layout(segment_max_node const& node, kernel_impl_params const& impl_param);+ static std::string to_string(segment_max_node const& node);+};++using segment_max_inst = typed_primitive_inst<segment_max>;++} // namespace cldnndiff --git a/src/plugins/intel_gpu/src/graph/registry/registry.hpp b/src/plugins/intel_gpu/src/graph/registry/registry.hppindex 0bdbca846c3..f3c6d8a19d2 100644--- a/src/plugins/intel_gpu/src/graph/registry/registry.hpp+++ b/src/plugins/intel_gpu/src/graph/registry/registry.hpp@@ -236,6 +236,7 @@ REGISTER_DEFAULT_IMPLS(eye, OCL_S);REGISTER_DEFAULT_IMPLS(unique_count, OCL_S, OCL_D);REGISTER_DEFAULT_IMPLS(unique_gather, OCL_S, OCL_D);REGISTER_DEFAULT_IMPLS(search_sorted, OCL_S, OCL_D);+REGISTER_IMPLS(segment_max);REGISTER_DEFAULT_IMPLS(STFT, OCL_S, OCL_D);REGISTER_DEFAULT_IMPLS(ISTFT, OCL_S, OCL_D);REGISTER_DEFAULT_IMPLS(sparse_fill_empty_rows, OCL_S, OCL_D);diff --git a/src/plugins/intel_gpu/src/graph/registry/segment_max_impls.cpp b/src/plugins/intel_gpu/src/graph/registry/segment_max_impls.cppnew file mode 100644index 00000000000..a2b1b0ee956--- /dev/null+++ b/src/plugins/intel_gpu/src/graph/registry/segment_max_impls.cpp@@ -0,0 +1,25 @@+// Copyright (C) 2018-2026 Intel Corporation+// SPDX-License-Identifier: Apache-2.0+//++#include "intel_gpu/primitives/segment_max.hpp"+#include "primitive_inst.h"+#include "registry.hpp"++#if OV_GPU_WITH_OCL+# include "impls/ocl_v2/segment_max.hpp"+#endif++namespace ov {+namespace intel_gpu {++using namespace cldnn;++const std::vector<std::shared_ptr<cldnn::ImplementationManager>>& Registry<segment_max>::get_implementations() {+ static const std::vector<std::shared_ptr<ImplementationManager>> impls = {OV_GPU_CREATE_INSTANCE_OCL(ocl::SegmentMax, shape_types::any)};++ return impls;+}++} // namespace intel_gpu+} // namespace ovdiff --git a/src/plugins/intel_gpu/src/graph/segment_max.cpp b/src/plugins/intel_gpu/src/graph/segment_max.cppnew file mode 100644index 00000000000..f88af157e34--- /dev/null+++ b/src/plugins/intel_gpu/src/graph/segment_max.cpp@@ -0,0 +1,60 @@+// Copyright (C) 2018-2026 Intel Corporation+// SPDX-License-Identifier: Apache-2.0+//++#include <json_object.h>+#include <segment_max_inst.h>++#include <sstream>++#include "openvino/core/enum_names.hpp"+#include "primitive_type_base.h"++namespace cldnn {+GPU_DEFINE_PRIMITIVE_TYPE_ID(segment_max)++segment_max_inst::typed_primitive_inst(network& network, segment_max_node const& node) : parent(network, node) {}++layout segment_max_inst::calc_output_layout(segment_max_node const& node, kernel_impl_params const& impl_param) {+ return calc_output_layouts<ov::PartialShape>(node, impl_param)[0];+}++template <typename ShapeType>+std::vector<layout> segment_max_inst::calc_output_layouts(segment_max_node const& node,+ kernel_impl_params const& impl_param) {+ auto primitive = impl_param.typed_desc<segment_max>();++ auto input0_layout = impl_param.get_input_layout(0);++ const data_types output_type = impl_param.desc->output_data_types[0].value_or(input0_layout.data_type);++ // GPU-internal layouts are padded to 4D/5D (bfyx/bfzyx). The core+ // SegmentMax shape_infer expects logical OV shapes and will reject the+ // padded segment_ids (e.g. [1,6,1,1] instead of [6]). Compute the output+ // shape directly: output_shape = [num_segments] + data_shape[1:]+ auto output_pshape = input0_layout.get<ShapeType>();++ if (primitive->num_segments_val >= 0) {+ output_pshape[0] = primitive->num_segments_val;+ } else if (primitive->max_segment_id >= 0) {+ output_pshape[0] = primitive->max_segment_id + 1;+ } else {+ output_pshape[0] = ov::Dimension::dynamic();+ }++ return {layout{output_pshape, output_type, input0_layout.format}};+}++std::string segment_max_inst::to_string(segment_max_node const& node) {+ auto node_info = node.desc_to_json();+ json_composite segment_max_info;+ segment_max_info.add("data id", node.input(0).id());+ segment_max_info.add("segment_ids id", node.input(1).id());+ segment_max_info.add("fill_mode", static_cast<int>(node.get_primitive()->fill_mode));+ node_info->add("segment_max info", segment_max_info);+ std::stringstream primitive_description;+ node_info->dump(primitive_description);+ return primitive_description.str();+}++} // namespace cldnndiff --git a/src/plugins/intel_gpu/src/kernel_selector/common_types.h b/src/plugins/intel_gpu/src/kernel_selector/common_types.hindex 9d0c6bc694b..bfe46927111 100644--- a/src/plugins/intel_gpu/src/kernel_selector/common_types.h+++ b/src/plugins/intel_gpu/src/kernel_selector/common_types.h@@ -106,6 +106,7 @@ enum class KernelType {ROPE,DYNAMIC_QUANTIZE,SEARCH_SORTED,+ SEGMENT_MAX,STFT,ISTFT,COL2IM,diff --git a/src/plugins/intel_gpu/src/plugin/ops/segment_max.cpp b/src/plugins/intel_gpu/src/plugin/ops/segment_max.cppnew file mode 100644index 00000000000..af64d05121a--- /dev/null+++ b/src/plugins/intel_gpu/src/plugin/ops/segment_max.cpp@@ -0,0 +1,61 @@+// Copyright (C) 2018-2026 Intel Corporation+// SPDX-License-Identifier: Apache-2.0+//++#include "openvino/op/segment_max.hpp"+#include "openvino/op/constant.hpp"+#include "openvino/core/validation_util.hpp"++#include "intel_gpu/plugin/common_utils.hpp"+#include "intel_gpu/plugin/program_builder.hpp"+#include "intel_gpu/primitives/segment_max.hpp"++namespace ov::intel_gpu {++static void CreateSegmentMaxOp(ProgramBuilder& p, const std::shared_ptr<ov::op::v16::SegmentMax>& op) {+ validate_inputs_count(op, {2, 3});+ auto inputs = p.GetInputInfo(op);++ auto prim = cldnn::segment_max(layer_type_name_ID(op),+ inputs[0], // data+ inputs[1], // segment_ids+ op->get_fill_mode());++ // Store max(segment_ids) for compile-time shape inference.+ // Use get_constant_from_source to handle cases where the constant is+ // wrapped by Convert/Reshape/etc.+ auto seg_const = ov::util::get_constant_from_source(op->input_value(1));++ // When num_segments is not provided (2-input form), segment_ids must be a Constant+ // so that the primitive can infer the output shape based on max(segment_ids) + 1.+ if (op->get_input_size() == 2) {+ OPENVINO_ASSERT(seg_const,+ "[GPU] SegmentMax: segment_ids input must be a Constant when num_segments "+ "is not provided. Non-constant segment_ids in 2-input form is not supported.");+ }++ if (seg_const) {+ // segment_ids is required to be sorted (non-decreasing), so back() == max.+ auto seg_ids = seg_const->cast_vector<int64_t>();+ if (!seg_ids.empty()) {+ prim.max_segment_id = seg_ids.back();+ }+ }++ // Store num_segments constant data for compile-time shape inference.+ // Note: The current primitive/kernel only supports num_segments as a compile-time constant.+ // A non-constant num_segments tensor is not wired as a primitive input.+ if (op->get_input_size() > 2) {+ auto ns_const = ov::util::get_constant_from_source(op->input_value(2));+ OPENVINO_ASSERT(ns_const, "[GPU] SegmentMax: num_segments input must be a Constant. "+ "Non-constant num_segments is not yet supported.");+ prim.num_segments_val = ns_const->cast_vector<int64_t>()[0];+ }++ prim.output_data_types = get_output_data_types(op);+ p.add_primitive(*op, prim);+}++REGISTER_FACTORY_IMPL(v16, SegmentMax);++} // namespace ov::intel_gpudiff --git a/src/plugins/intel_gpu/tests/functional/shared_tests_instances/single_layer_tests/segment_max.cpp b/src/plugins/intel_gpu/tests/functional/shared_tests_instances/single_layer_tests/segment_max.cppnew file mode 100644index 00000000000..d55e4af80ea--- /dev/null+++ b/src/plugins/intel_gpu/tests/functional/shared_tests_instances/single_layer_tests/segment_max.cpp@@ -0,0 +1,130 @@+// Copyright (C) 2018-2026 Intel Corporation+// SPDX-License-Identifier: Apache-2.0+//++#include "single_op_tests/segment_max.hpp"+#include "openvino/runtime/properties.hpp"++#include <algorithm>+#include <sstream>++namespace ov {+namespace test {+namespace {++// Workaround: core_configuration() in core_config.cpp sets inference_precision via+// core->set_property(DEVICE_GPU, f32), but this global property does not propagate+// to dGPU (GPU.1) when --device_suffix=1 is used. As a result, f32 SegmentMax models+// are silently compiled with f16 precision on dGPU, causing LOWEST fill values+// (-FLT_MAX) to be truncated to -HALF_MAX (-65504) and comparison failures.+// To work around this, explicitly pass inference_precision=f32 in the per-model+// configuration for f32 test cases.+class SegmentMaxLayerGPUTest : public SegmentMaxLayerTest {+ void SetUp() override {+ SegmentMaxLayerTest::SetUp();+ const auto& [segmentMaxParams, inputPrecision, targetDevice] = this->GetParam();+ if (inputPrecision == ov::element::f32) {+ configuration.insert({ov::hint::inference_precision(ov::element::f32)});+ }+ }+};++TEST_P(SegmentMaxLayerGPUTest, Inference) {+ run();+}++// 10 params × 3 precisions = 30 tests+// Coverage: Rank 1-4, ZERO/LOWEST, contiguous/gap, padding/truncation, single-element+const std::vector<SegmentMaxSpecificParams> segmentMaxParams = {+ // Rank-1: contiguous segments, ZERO+ {InputShape{{}, {{6}}}, {0, 0, 1, 1, 2, 2}, -1, ov::op::FillMode::ZERO},+ // Rank-1: discontinuous gap (segs 1,2 empty), LOWEST+ {InputShape{{}, {{4}}}, {0, 0, 3, 3}, -1, ov::op::FillMode::LOWEST},+ // Rank-1: large gaps + num_segments padding (7 > max+1=6), ZERO+ {InputShape{{}, {{6}}}, {0, 0, 0, 3, 5, 5}, 7, ov::op::FillMode::ZERO},+ // Rank-1: single element+ {InputShape{{}, {{1}}}, {0}, -1, ov::op::FillMode::ZERO},+ // Rank-1: num_segments truncation (2 < max+1=4), ZERO+ {InputShape{{}, {{5}}}, {0, 0, 2, 3, 3}, 2, ov::op::FillMode::ZERO},+ // Rank-2: gap (segment 1 empty), LOWEST+ {InputShape{{}, {{3, 4}}}, {0, 2, 2}, -1, ov::op::FillMode::LOWEST},+ // Rank-2: per-element segments + num_segments padding, LOWEST+ {InputShape{{}, {{4, 2}}}, {0, 1, 2, 3}, 6, ov::op::FillMode::LOWEST},+ // Rank-3: contiguous segments, LOWEST+ {InputShape{{}, {{4, 2, 3}}}, {0, 0, 1, 1}, 2, ov::op::FillMode::LOWEST},+ // Rank-4: gap (segments 1,2 empty), ZERO+ {InputShape{{}, {{3, 2, 2, 3}}}, {0, 3, 3}, -1, ov::op::FillMode::ZERO},+ // Rank-4: per-element segments + num_segments padding, LOWEST+ {InputShape{{}, {{3, 2, 2, 2}}}, {0, 1, 2}, 6, ov::op::FillMode::LOWEST},+};++const auto precisions = testing::Values(ElementType::f32, ElementType::f16, ElementType::i32);+const auto targetDevice = testing::Values(ov::test::utils::DEVICE_GPU);++INSTANTIATE_TEST_SUITE_P(smoke_SegmentMax,+ SegmentMaxLayerGPUTest,+ ::testing::Combine(::testing::ValuesIn(segmentMaxParams),+ precisions,+ targetDevice),+ SegmentMaxLayerTest::getTestCaseName);++// ---------------------------------------------------------------------------+// Large-data profiling tests.+// These are NOT part of smoke tests — run them with --gtest_filter=*perf_SegmentMax*+// to measure opt vs ref kernel device time on dGPU with meaningful workloads.+// ---------------------------------------------------------------------------++// Helper: generate sorted segment_ids for N rows spread across S segments.+static std::vector<int64_t> makeSortedSegIds(int num_rows, int num_segments) {+ std::vector<int64_t> ids(num_rows);+ for (int i = 0; i < num_rows; ++i)+ ids[i] = static_cast<int64_t>(i) * num_segments / num_rows;+ return ids;+}++// Custom naming that summarises segment_ids (count+segments) instead of+// dumping every element — avoids gtest stack overflow on huge vectors.+static std::string perfTestCaseName(const testing::TestParamInfo<SegmentMaxLayerTestParams>& obj) {+ const auto& [segmentMaxParams, inputPrecision, targetDevice] = obj.param;+ const auto& [dataInputShape, segmentIdsValues, numSegments, fillMode] = segmentMaxParams;++ int64_t maxSeg = segmentIdsValues.empty() ? 0 : *std::max_element(segmentIdsValues.begin(), segmentIdsValues.end());++ std::ostringstream result;+ result << inputPrecision << "_IS=";+ result << ov::test::utils::partialShape2str({dataInputShape.first}) << "_";+ result << "TS=(";+ for (const auto& ts : dataInputShape.second)+ result << ov::test::utils::vec2str(ts) << "_";+ result << ")_";+ result << "rows=" << segmentIdsValues.size() << "_";+ result << "segs=" << (maxSeg + 1) << "_";+ result << "numSeg=" << numSegments << "_";+ result << "fillMode=" << static_cast<int>(fillMode) << "_";+ result << "dev=" << targetDevice;+ return result.str();+}++const std::vector<SegmentMaxSpecificParams> segmentMaxPerfParams = {+ // 1K rows × 64 inner, 100 segments → ref O(1K) per output, opt O(log1K + ~10)+ {InputShape{{}, {{1024, 64}}}, makeSortedSegIds(1024, 100), -1, ov::op::FillMode::LOWEST},+ // 10K rows × 128 inner, 500 segments+ {InputShape{{}, {{10000, 128}}}, makeSortedSegIds(10000, 500), -1, ov::op::FillMode::LOWEST},+ // 100K rows × 64 inner, 1000 segments → ref scans 100K per output (huge)+ {InputShape{{}, {{100000, 64}}}, makeSortedSegIds(100000, 1000), -1, ov::op::FillMode::LOWEST},+ // 100K rows × 1 inner (scalar reduction), 2000 segments+ {InputShape{{}, {{100000}}}, makeSortedSegIds(100000, 2000), -1, ov::op::FillMode::ZERO},+ // 50K rows × 256 inner, 5000 segments — wide inner dim stresses memory bandwidth+ {InputShape{{}, {{50000, 256}}}, makeSortedSegIds(50000, 5000), -1, ov::op::FillMode::LOWEST},+};++INSTANTIATE_TEST_SUITE_P(perf_SegmentMax,+ SegmentMaxLayerGPUTest,+ ::testing::Combine(::testing::ValuesIn(segmentMaxPerfParams),+ testing::Values(ElementType::f32),+ targetDevice),+ perfTestCaseName);++} // namespace+} // namespace test+} // namespace ovdiff --git a/src/plugins/intel_gpu/tests/unit/test_cases/segment_max_gpu_test.cpp b/src/plugins/intel_gpu/tests/unit/test_cases/segment_max_gpu_test.cppnew file mode 100644index 00000000000..dafa2814f08--- /dev/null+++ b/src/plugins/intel_gpu/tests/unit/test_cases/segment_max_gpu_test.cpp@@ -0,0 +1,450 @@+// Copyright (C) 2018-2026 Intel Corporation+// SPDX-License-Identifier: Apache-2.0+//+// Unit tests for the SegmentMax cldnn primitive.+// Test cases are based on the SegmentMax-16 specification:+// https://docs.openvino.ai/nightly/documentation/openvino-ir-format/operation-sets/operation-specs/arithmetic/segment-max-16.html++#include <limits>++#include <intel_gpu/primitives/data.hpp>+#include <intel_gpu/primitives/input_layout.hpp>+#include <intel_gpu/primitives/reorder.hpp>+#include <intel_gpu/primitives/segment_max.hpp>++#include "test_utils.h"+#include "segment_max_inst.h"++namespace {++using namespace cldnn;+using namespace ::tests;++constexpr float REL_EPS = 2e-3f;+constexpr float ABS_EPS = 1e-5f;++namespace helpers {++template <typename T>+memory::ptr AllocateTensor(ov::PartialShape shape, const std::vector<T>& data) {+ const layout lo = {shape, ov::element::from<T>(), cldnn::format::bfyx};+ EXPECT_EQ(lo.get_linear_size(), data.size());+ memory::ptr tensor = get_test_engine().allocate_memory(lo);+ set_values<T>(tensor, data);+ return tensor;+}++template <typename T>+void CompareTypedBuffers(const memory::ptr& output, const std::vector<T>& expected, cldnn::stream& stream) {+ mem_lock<T> output_ptr(output, stream);+ ASSERT_EQ(output_ptr.size(), expected.size());+ for (size_t i = 0; i < expected.size(); ++i) {+ if constexpr (std::is_floating_point_v<T>) {+ ASSERT_TRUE(are_equal(expected[i], output_ptr[i], REL_EPS, ABS_EPS))+ << "at index " << i << " expected=" << expected[i] << " actual=" << output_ptr[i];+ } else {+ ASSERT_EQ(expected[i], output_ptr[i])+ << "at index " << i << " expected=" << expected[i] << " actual=" << output_ptr[i];+ }+ }+}++} // namespace helpers++// ============================================================================+// Test fixture for f32 data with i32 segment_ids (parameterized)+// ============================================================================++struct SegmentMaxTestParams {+ ov::PartialShape data_shape;+ std::vector<float> data_values;+ std::vector<int32_t> segment_ids;+ ov::op::FillMode fill_mode; // FillMode::ZERO or FillMode::LOWEST+ int64_t num_segments; // -1 = not set (infer from segment_ids)+ std::vector<float> expected_output;+ ov::PartialShape expected_output_shape;+ std::string test_name;+};++class SegmentMaxGpuTest : public ::testing::TestWithParam<SegmentMaxTestParams> {+public:+ static std::string getTestCaseName(const testing::TestParamInfo<SegmentMaxTestParams>& obj) {+ return obj.param.test_name;+ }++ void Execute(const SegmentMaxTestParams& p) {+ auto stream = get_test_stream_ptr(get_test_default_config(engine_));++ auto data_mem = helpers::AllocateTensor<float>(p.data_shape, p.data_values);+ auto seg_mem = helpers::AllocateTensor<int32_t>(+ ov::PartialShape{static_cast<int64_t>(p.segment_ids.size())}, p.segment_ids);++ topology topology;++ auto data_dynamic_layout = layout{ov::PartialShape::dynamic(p.data_shape.rank().get_length()),+ data_types::f32, format::bfyx};+ auto seg_dynamic_layout = layout{ov::PartialShape::dynamic(1), data_types::i32, format::bfyx};++ topology.add(input_layout("data", data_dynamic_layout));+ topology.add(input_layout("segment_ids", seg_dynamic_layout));++ auto prim = segment_max("segment_max", input_info("data"), input_info("segment_ids"), p.fill_mode);+ if (!p.segment_ids.empty()) {+ prim.max_segment_id = static_cast<int64_t>(p.segment_ids.back());+ }+ if (p.num_segments >= 0) {+ prim.num_segments_val = p.num_segments;+ }+ topology.add(prim);++ topology.add(reorder("output", input_info("segment_max"), format::bfyx, data_types::f32));++ ExecutionConfig config = get_test_default_config(engine_);+ config.set_property(ov::intel_gpu::allow_new_shape_infer(true));++ cldnn::network::ptr network = get_network(engine_, topology, config, stream, false);+ network->set_input_data("data", data_mem);+ network->set_input_data("segment_ids", seg_mem);++ auto inst = network->get_primitive("segment_max");+ auto impl = inst->get_impl();+ ASSERT_TRUE(impl != nullptr);+ ASSERT_TRUE(impl->is_dynamic());++ auto outputs = network->execute();+ auto output_mem = outputs.at("output").get_memory();++ auto out_layout = output_mem->get_layout();+ ASSERT_EQ(out_layout.get_partial_shape(), p.expected_output_shape);++ helpers::CompareTypedBuffers<float>(output_mem, p.expected_output, *stream);+ }++private:+ engine& engine_ = get_test_engine();+};++// ----------- Test cases (f32 data, i32 segment_ids) -----------++std::vector<SegmentMaxTestParams> generateSegmentMaxTestParams() {+ std::vector<SegmentMaxTestParams> params;++ // --- Basic functionality ---++ // 1D basic: 3 segments, no empty segments+ params.push_back({+ ov::PartialShape{6},+ {1.0f, 5.0f, 3.0f, 2.0f, 8.0f, 4.0f},+ {0, 0, 1, 2, 2, 2},+ ov::op::FillMode::ZERO, -1, // fill_mode=ZERO, num_segments=infer+ {5.0f, 3.0f, 8.0f},+ ov::PartialShape{3},+ "basic_1d_3seg"+ });++ // Single element per segment+ params.push_back({+ ov::PartialShape{3},+ {100.0f, 200.0f, 300.0f},+ {0, 1, 2},+ ov::op::FillMode::ZERO, -1,+ {100.0f, 200.0f, 300.0f},+ ov::PartialShape{3},+ "single_elem_per_seg"+ });++ // All elements in one segment+ params.push_back({+ ov::PartialShape{5},+ {3.0f, 1.0f, 4.0f, 1.0f, 5.0f},+ {0, 0, 0, 0, 0},+ ov::op::FillMode::ZERO, -1,+ {5.0f},+ ov::PartialShape{1},+ "all_one_segment"+ });++ // 1D with negative values+ params.push_back({+ ov::PartialShape{5},+ {-3.0f, -1.0f, -5.0f, -2.0f, -4.0f},+ {0, 0, 1, 1, 1},+ ov::op::FillMode::ZERO, -1,+ {-1.0f, -2.0f},+ ov::PartialShape{2},+ "negative_values"+ });++ // --- Empty segment handling ---++ // 1D with empty segment (fill_mode = ZERO)+ params.push_back({+ ov::PartialShape{4},+ {10.0f, 20.0f, 30.0f, 40.0f},+ {0, 0, 2, 2}, // segment 1 is empty+ ov::op::FillMode::ZERO, -1,+ {20.0f, 0.0f, 40.0f},+ ov::PartialShape{3},+ "empty_seg_zero_fill"+ });++ // 1D with empty segment (fill_mode = LOWEST)+ params.push_back({+ ov::PartialShape{4},+ {10.0f, 20.0f, 30.0f, 40.0f},+ {0, 0, 2, 2}, // segment 1 is empty+ ov::op::FillMode::LOWEST, -1,+ {20.0f, std::numeric_limits<float>::lowest(), 40.0f},+ ov::PartialShape{3},+ "empty_seg_lowest_fill"+ });++ // --- 2D data ---++ // 2D basic: data=[4,3], segment_ids=[4], 2 segments+ params.push_back({+ ov::PartialShape{4, 3},+ {1.0f, 2.0f, 3.0f,+ 4.0f, 5.0f, 6.0f,+ 7.0f, 8.0f, 9.0f,+ 10.0f, 11.0f, 12.0f},+ {0, 0, 1, 1},+ ov::op::FillMode::ZERO, -1,+ {4.0f, 5.0f, 6.0f,+ 10.0f, 11.0f, 12.0f},+ ov::PartialShape{2, 3},+ "basic_2d"+ });++ // 2D with empty segment (fill_mode = ZERO)+ params.push_back({+ ov::PartialShape{3, 2},+ {1.0f, 2.0f,+ 3.0f, 4.0f,+ 5.0f, 6.0f},+ {0, 2, 2}, // segment 1 is empty+ ov::op::FillMode::ZERO, -1,+ {1.0f, 2.0f,+ 0.0f, 0.0f,+ 5.0f, 6.0f},+ ov::PartialShape{3, 2},+ "2d_empty_seg_zero"+ });++ // 2D with empty segment (fill_mode = LOWEST) — Spec Example 3+ params.push_back({+ ov::PartialShape{3, 4},+ {1.0f, 2.0f, 3.0f, 4.0f,+ 5.0f, 6.0f, 7.0f, 8.0f,+ 9.0f, 10.0f, 11.0f, 12.0f},+ {0, 1, 1}, // 2 segments, no empty+ ov::op::FillMode::LOWEST, -1,+ {1.0f, 2.0f, 3.0f, 4.0f, // segment 0: row 0+ 9.0f, 10.0f, 11.0f, 12.0f}, // segment 1: max(row 1, row 2)+ ov::PartialShape{2, 4},+ "2d_lowest_fill"+ });++ // --- num_segments tests (Spec Examples 1 & 2) ---++ // num_segments < max(segment_ids) + 1 (truncation) — Spec Example 1+ // segment_ids = [0, 0, 2, 3, 3] defines segments 0..3, but num_segments=2 truncates to [0, 1]+ params.push_back({+ ov::PartialShape{5},+ {1.0f, 5.0f, 3.0f, 2.0f, 8.0f},+ {0, 0, 2, 3, 3},+ ov::op::FillMode::ZERO, 2, // num_segments=2 < 4+ {5.0f, 0.0f}, // seg 0: max(1,5)=5, seg 1: empty=0+ ov::PartialShape{2},+ "num_segments_truncation"+ });++ // num_segments > max(segment_ids) + 1 (padding) — Spec Example 2+ // segment_ids = [0, 0, 2, 3, 3] defines segments 0..3, num_segments=8 pads with empty segments+ params.push_back({+ ov::PartialShape{5},+ {1.0f, 5.0f, 3.0f, 2.0f, 8.0f},+ {0, 0, 2, 3, 3},+ ov::op::FillMode::ZERO, 8, // num_segments=8 > 4+ {5.0f, 0.0f, 3.0f, 8.0f, 0.0f, 0.0f, 0.0f, 0.0f}, // seg 4-7 are empty (ZERO fill)+ ov::PartialShape{8},+ "num_segments_padding_zero"+ });++ // num_segments > max(segment_ids) + 1 with fill_mode = LOWEST+ params.push_back({+ ov::PartialShape{3},+ {10.0f, 20.0f, 30.0f},+ {0, 1, 1},+ ov::op::FillMode::LOWEST, 5, // num_segments=5, LOWEST fill+ {10.0f, 30.0f,+ std::numeric_limits<float>::lowest(),+ std::numeric_limits<float>::lowest(),+ std::numeric_limits<float>::lowest()},+ ov::PartialShape{5},+ "num_segments_padding_lowest"+ });++ // num_segments == max(segment_ids) + 1 (exact match, same as default)+ params.push_back({+ ov::PartialShape{4},+ {1.0f, 2.0f, 3.0f, 4.0f},+ {0, 1, 1, 2},+ ov::op::FillMode::ZERO, 3, // num_segments=3 == max(2)+1+ {1.0f, 3.0f, 4.0f},+ ov::PartialShape{3},+ "num_segments_exact"+ });++ // 2D + num_segments padding+ params.push_back({+ ov::PartialShape{3, 2},+ {1.0f, 2.0f,+ 3.0f, 4.0f,+ 5.0f, 6.0f},+ {0, 0, 1},+ ov::op::FillMode::ZERO, 4, // num_segments=4, with padding+ {3.0f, 4.0f, // seg 0: max(row 0, row 1)+ 5.0f, 6.0f, // seg 1: row 2+ 0.0f, 0.0f, // seg 2: empty (ZERO)+ 0.0f, 0.0f}, // seg 3: empty (ZERO)+ ov::PartialShape{4, 2},+ "2d_num_segments_padding"+ });++ return params;+}++TEST_P(SegmentMaxGpuTest, ref_comp_f32) {+ const auto& testParams = GetParam();+ Execute(testParams);+}++INSTANTIATE_TEST_SUITE_P(+ SegmentMaxGpuTestSuite,+ SegmentMaxGpuTest,+ testing::ValuesIn(generateSegmentMaxTestParams()),+ SegmentMaxGpuTest::getTestCaseName+);++// ============================================================================+// Non-parameterized tests for i64 segment_ids and i32 data type+// ============================================================================++class SegmentMaxGpuTypeTest : public ::testing::Test {+protected:+ engine& engine_ = get_test_engine();+};++// Test with i64 segment_ids (spec allows i32 or i64 for T_IDX1)+TEST_F(SegmentMaxGpuTypeTest, i64_segment_ids) {+ auto stream = get_test_stream_ptr(get_test_default_config(engine_));++ std::vector<float> data_values = {1.0f, 5.0f, 3.0f, 2.0f, 8.0f, 4.0f};+ std::vector<int64_t> seg_ids = {0, 0, 1, 2, 2, 2};++ auto data_mem = helpers::AllocateTensor<float>(ov::PartialShape{6}, data_values);+ auto seg_mem = helpers::AllocateTensor<int64_t>(ov::PartialShape{6}, seg_ids);++ topology topology;+ topology.add(input_layout("data",+ layout{ov::PartialShape::dynamic(1), data_types::f32, format::bfyx}));+ topology.add(input_layout("segment_ids",+ layout{ov::PartialShape::dynamic(1), data_types::i64, format::bfyx}));++ auto prim = segment_max("segment_max", input_info("data"), input_info("segment_ids"), ov::op::FillMode::ZERO);+ prim.max_segment_id = 2;+ topology.add(prim);+ topology.add(reorder("output", input_info("segment_max"), format::bfyx, data_types::f32));++ ExecutionConfig config = get_test_default_config(engine_);+ config.set_property(ov::intel_gpu::allow_new_shape_infer(true));++ auto network = get_network(engine_, topology, config, stream, false);+ network->set_input_data("data", data_mem);+ network->set_input_data("segment_ids", seg_mem);++ auto outputs = network->execute();+ auto output_mem = outputs.at("output").get_memory();++ ASSERT_EQ(output_mem->get_layout().get_partial_shape(), ov::PartialShape{3});++ std::vector<float> expected = {5.0f, 3.0f, 8.0f};+ helpers::CompareTypedBuffers<float>(output_mem, expected, *stream);+}++// Test with i32 data type (spec: "any supported numerical data type")+TEST_F(SegmentMaxGpuTypeTest, i32_data) {+ auto stream = get_test_stream_ptr(get_test_default_config(engine_));++ std::vector<int32_t> data_values = {10, 50, 30, 20, 80, 40};+ std::vector<int32_t> seg_ids = {0, 0, 1, 2, 2, 2};++ auto data_mem = helpers::AllocateTensor<int32_t>(ov::PartialShape{6}, data_values);+ auto seg_mem = helpers::AllocateTensor<int32_t>(ov::PartialShape{6}, seg_ids);++ topology topology;+ topology.add(input_layout("data",+ layout{ov::PartialShape::dynamic(1), data_types::i32, format::bfyx}));+ topology.add(input_layout("segment_ids",+ layout{ov::PartialShape::dynamic(1), data_types::i32, format::bfyx}));++ auto prim = segment_max("segment_max", input_info("data"), input_info("segment_ids"), ov::op::FillMode::ZERO);+ prim.max_segment_id = 2;+ topology.add(prim);+ topology.add(reorder("output", input_info("segment_max"), format::bfyx, data_types::i32));++ ExecutionConfig config = get_test_default_config(engine_);+ config.set_property(ov::intel_gpu::allow_new_shape_infer(true));++ auto network = get_network(engine_, topology, config, stream, false);+ network->set_input_data("data", data_mem);+ network->set_input_data("segment_ids", seg_mem);++ auto outputs = network->execute();+ auto output_mem = outputs.at("output").get_memory();++ ASSERT_EQ(output_mem->get_layout().get_partial_shape(), ov::PartialShape{3});++ std::vector<int32_t> expected = {50, 30, 80};+ helpers::CompareTypedBuffers<int32_t>(output_mem, expected, *stream);+}++// Test with i32 data type and fill_mode = LOWEST (empty segment)+TEST_F(SegmentMaxGpuTypeTest, i32_data_lowest_fill) {+ auto stream = get_test_stream_ptr(get_test_default_config(engine_));++ std::vector<int32_t> data_values = {10, 20, 30, 40};+ std::vector<int32_t> seg_ids = {0, 0, 2, 2}; // segment 1 is empty++ auto data_mem = helpers::AllocateTensor<int32_t>(ov::PartialShape{4}, data_values);+ auto seg_mem = helpers::AllocateTensor<int32_t>(ov::PartialShape{4}, seg_ids);++ topology topology;+ topology.add(input_layout("data",+ layout{ov::PartialShape::dynamic(1), data_types::i32, format::bfyx}));+ topology.add(input_layout("segment_ids",+ layout{ov::PartialShape::dynamic(1), data_types::i32, format::bfyx}));++ auto prim = segment_max("segment_max", input_info("data"), input_info("segment_ids"), ov::op::FillMode::LOWEST);+ prim.max_segment_id = 2;+ topology.add(prim);+ topology.add(reorder("output", input_info("segment_max"), format::bfyx, data_types::i32));++ ExecutionConfig config = get_test_default_config(engine_);+ config.set_property(ov::intel_gpu::allow_new_shape_infer(true));++ auto network = get_network(engine_, topology, config, stream, false);+ network->set_input_data("data", data_mem);+ network->set_input_data("segment_ids", seg_mem);++ auto outputs = network->execute();+ auto output_mem = outputs.at("output").get_memory();++ ASSERT_EQ(output_mem->get_layout().get_partial_shape(), ov::PartialShape{3});++ std::vector<int32_t> expected = {20, std::numeric_limits<int32_t>::lowest(), 40};+ helpers::CompareTypedBuffers<int32_t>(output_mem, expected, *stream);+}++} // namespacediff --git a/src/tests/functional/plugin/shared/include/shared_test_classes/single_op/segment_max.hpp b/src/tests/functional/plugin/shared/include/shared_test_classes/single_op/segment_max.hppnew file mode 100644index 00000000000..15602ac92a1--- /dev/null+++ b/src/tests/functional/plugin/shared/include/shared_test_classes/single_op/segment_max.hpp@@ -0,0 +1,33 @@+// Copyright (C) 2018-2026 Intel Corporation+// SPDX-License-Identifier: Apache-2.0+//++#pragma once++#include "shared_test_classes/base/ov_subgraph.hpp"++namespace ov {+namespace test {++using SegmentMaxSpecificParams = std::tuple<InputShape, // data shape+ std::vector<int64_t>, // segment_ids values+ int64_t, // num_segments (-1 means no num_segments input)+ ov::op::FillMode>; // fill_mode++using SegmentMaxLayerTestParams = std::tuple<SegmentMaxSpecificParams,+ ElementType, // data precision+ std::string>; // target device++class SegmentMaxLayerTest : public testing::WithParamInterface<SegmentMaxLayerTestParams>,+ public ov::test::SubgraphBaseTest {+public:+ static std::string getTestCaseName(const testing::TestParamInfo<SegmentMaxLayerTestParams>& obj);+ static const std::vector<SegmentMaxSpecificParams> GenerateParams();++protected:+ void SetUp() override;+ void generate_inputs(const std::vector<ov::Shape>& targetInputStaticShapes) override;+};++} // namespace test+} // namespace ovdiff --git a/src/tests/functional/plugin/shared/include/single_op_tests/segment_max.hpp b/src/tests/functional/plugin/shared/include/single_op_tests/segment_max.hppnew file mode 100644index 00000000000..8cd0f0a6dc1--- /dev/null+++ b/src/tests/functional/plugin/shared/include/single_op_tests/segment_max.hpp@@ -0,0 +1,15 @@+// Copyright (C) 2018-2026 Intel Corporation+// SPDX-License-Identifier: Apache-2.0+//++#pragma once++#include "shared_test_classes/single_op/segment_max.hpp"++namespace ov {+namespace test {+TEST_P(SegmentMaxLayerTest, Inference) {+ run();+}+} // namespace test+} // namespace ovdiff --git a/src/tests/functional/plugin/shared/src/single_op/segment_max.cpp b/src/tests/functional/plugin/shared/src/single_op/segment_max.cppnew file mode 100644index 00000000000..05678acf36e--- /dev/null+++ b/src/tests/functional/plugin/shared/src/single_op/segment_max.cpp@@ -0,0 +1,120 @@+// Copyright (C) 2018-2026 Intel Corporation+// SPDX-License-Identifier: Apache-2.0+//++#include "shared_test_classes/single_op/segment_max.hpp"++#include "common_test_utils/ov_tensor_utils.hpp"+#include "shared_test_classes/base/ov_subgraph.hpp"+#include "openvino/op/segment_max.hpp"++namespace ov {+namespace test {++std::string SegmentMaxLayerTest::getTestCaseName(const testing::TestParamInfo<SegmentMaxLayerTestParams>& obj) {+ const auto& [segmentMaxParams, inputPrecision, targetDevice] = obj.param;+ const auto& [dataInputShape, segmentIdsValues, numSegments, fillMode] = segmentMaxParams;++ std::ostringstream result;+ result << inputPrecision << "_IS=";+ result << ov::test::utils::partialShape2str({dataInputShape.first}) << "_";+ result << "TS=";+ result << "(";+ for (const auto& targetShape : dataInputShape.second) {+ result << ov::test::utils::vec2str(targetShape) << "_";+ }+ result << ")_";+ result << "segIds=" << ov::test::utils::vec2str(segmentIdsValues) << "_";+ result << "numSeg=" << numSegments << "_";+ result << "fillMode=" << static_cast<int>(fillMode) << "_";+ result << "dev=" << targetDevice;+ return result.str();+}++void SegmentMaxLayerTest::generate_inputs(const std::vector<ov::Shape>& targetInputStaticShapes) {+ inputs.clear();+ const auto& funcInputs = function->inputs();+ const auto dataPrecision = funcInputs[0].get_element_type();++ ov::test::utils::InputGenerateData in_data;+ in_data.start_from = -10;+ in_data.range = 20;+ const auto dataTensor = ov::test::utils::create_and_fill_tensor(dataPrecision, targetInputStaticShapes[0], in_data);+ inputs.insert({funcInputs[0].get_node_shared_ptr(), dataTensor});+}++void SegmentMaxLayerTest::SetUp() {+ const auto& [segmentMaxParams, inputPrecision, _targetDevice] = this->GetParam();+ targetDevice = _targetDevice;++ const auto& [dataInputShape, segmentIdsValues, numSegments, fillMode] = segmentMaxParams;++ init_input_shapes({dataInputShape});++ auto dataParam = std::make_shared<ov::op::v0::Parameter>(inputPrecision, inputDynamicShapes[0]);+ ov::ParameterVector params{dataParam};++ // segment_ids is always a constant in these tests+ auto segmentIdsConst = std::make_shared<ov::op::v0::Constant>(+ ov::element::i64, ov::Shape{segmentIdsValues.size()}, segmentIdsValues);++ std::shared_ptr<ov::op::v16::SegmentMax> segmentMax;+ if (numSegments >= 0) {+ auto numSegmentsConst = std::make_shared<ov::op::v0::Constant>(+ ov::element::i32, ov::Shape{}, numSegments);+ segmentMax = std::make_shared<ov::op::v16::SegmentMax>(dataParam, segmentIdsConst, numSegmentsConst, fillMode);+ } else {+ segmentMax = std::make_shared<ov::op::v16::SegmentMax>(dataParam, segmentIdsConst, fillMode);+ }++ function = std::make_shared<ov::Model>(segmentMax->outputs(), params, "SegmentMax");+}++const std::vector<SegmentMaxSpecificParams> SegmentMaxLayerTest::GenerateParams() {+ const std::vector<SegmentMaxSpecificParams> params = {+ // 1D simple, FillMode::ZERO+ SegmentMaxSpecificParams{InputShape{{}, {{4}}},+ {0, 0, 2, 2},+ 3,+ ov::op::FillMode::ZERO},+ // 1D simple, FillMode::LOWEST+ SegmentMaxSpecificParams{InputShape{{}, {{4}}},+ {0, 0, 2, 2},+ 3,+ ov::op::FillMode::LOWEST},+ // 2D data+ SegmentMaxSpecificParams{InputShape{{}, {{4, 3}}},+ {0, 0, 1, 1},+ -1, // no num_segments+ ov::op::FillMode::ZERO},+ // 2D data with empty segments+ SegmentMaxSpecificParams{InputShape{{}, {{6, 4}}},+ {0, 0, 3, 3, 5, 5},+ 7,+ ov::op::FillMode::LOWEST},+ // Single element per segment+ SegmentMaxSpecificParams{InputShape{{}, {{4, 2}}},+ {0, 1, 2, 3},+ 4,+ ov::op::FillMode::ZERO},+ // All elements in one segment+ SegmentMaxSpecificParams{InputShape{{}, {{5}}},+ {0, 0, 0, 0, 0},+ -1,+ ov::op::FillMode::ZERO},+ // numSegments > max(segment_ids) + 1+ SegmentMaxSpecificParams{InputShape{{}, {{4}}},+ {0, 1, 2, 3},+ 8,+ ov::op::FillMode::LOWEST},+ // 3D data+ SegmentMaxSpecificParams{InputShape{{}, {{4, 2, 3}}},+ {0, 0, 1, 1},+ 2,+ ov::op::FillMode::ZERO},+ };+ return params;+}++} // namespace test+} // namespace ov